Skip to content

Commit

Permalink
Standardise icon slot spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltaranto committed Oct 23, 2024
1 parent 1422b36 commit 7799595
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 22 deletions.
23 changes: 23 additions & 0 deletions .changeset/bright-peas-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'braid-design-system': patch
---

---
updated:
- AccordionItem
- Button
- ButtonLink
- FieldMessage
- Heading
- List
- MenuItem
- MenuItemCheckbox
- Notice
- Rating
- Tab
- Text
---

Standardise icon slot spacing

Normalise the space between the `icon` slot and component content across the system.
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ export const ButtonText = ({
{icon && iconPosition === 'leading' ? (
<AvoidWidowIcon
iconPosition={iconPosition}
space="xsmall"
className={
shouldReducePaddingX || bleed
? null
Expand All @@ -401,7 +400,6 @@ export const ButtonText = ({
{!loading && icon && iconPosition === 'trailing' ? (
<AvoidWidowIcon
iconPosition={iconPosition}
space="xsmall"
className={
shouldReducePaddingX || bleed
? null
Expand Down
7 changes: 2 additions & 5 deletions packages/braid-design-system/src/lib/components/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
useDefaultTextProps,
} from '../private/defaultTextProps';
import { lineHeightContainer } from '../../css/lineHeightContainer.css';
import { iconSlotSpace } from '../private/iconSlotSpace';
import * as styles from './List.css';

function numberToAlpha(inputNumber: number) {
Expand Down Expand Up @@ -178,11 +179,7 @@ export const List = ({
})()}
</Box>
</Text>
<Box
minWidth={0}
width="full"
paddingLeft={size === 'xsmall' ? 'xsmall' : 'small'}
>
<Box minWidth={0} width="full" paddingLeft={iconSlotSpace}>
{listItem}
</Box>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { atoms } from '../../css/atoms/atoms';
import { iconSize } from '../../hooks/useIcon';
import * as styles from './useMenuItem.css';
import { MenuRendererContext } from '../MenuRenderer/MenuRendererContext';
import { iconSlotSpace } from '../private/iconSlotSpace';

const {
MENU_ITEM_UP,
Expand All @@ -35,7 +36,6 @@ const {
} = actionTypes;

const menuItemChildrenSize = 'standard';
const menuItemPaddingSize = 'small';

type MenuItemTone = 'critical' | undefined;

Expand Down Expand Up @@ -157,7 +157,7 @@ export function useMenuItem<MenuItemElement extends HTMLElement>({
atoms({
display: 'block',
width: 'full',
paddingX: menuItemPaddingSize,
paddingX: 'xsmall',
cursor: 'pointer',
textAlign: 'left',
outline: 'none',
Expand Down Expand Up @@ -220,7 +220,7 @@ function MenuItemChildren({
{leftSlot ? (
<Box
component="span"
paddingRight={menuItemPaddingSize}
paddingRight={iconSlotSpace}
flexShrink={0}
minWidth={0}
>
Expand All @@ -240,7 +240,7 @@ function MenuItemChildren({
{badge ? (
<Box
component="span"
paddingLeft={menuItemPaddingSize}
paddingLeft={iconSlotSpace}
flexShrink={0}
minWidth={0}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Box } from '../Box/Box';
import { IconTick } from '../icons/IconTick/IconTick';
import type { MenuItemProps } from '../MenuItem/MenuItem';
import { useMenuItem } from '../MenuItem/useMenuItem';
import { iconSlotSpace } from '../private/iconSlotSpace';

import * as styles from './MenuItemCheckbox.css';

Expand Down Expand Up @@ -43,7 +44,7 @@ export const MenuItemCheckbox = ({
boxShadow="borderField"
position="relative"
background={{ lightMode: 'surface' }}
marginRight="xsmall"
marginRight={iconSlotSpace}
flexShrink={0}
className={styles.checkboxSize}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { DefaultTextPropsProvider } from '../private/defaultTextProps';
import buildDataAttributes, {
type DataAttributeMap,
} from '../private/buildDataAttributes';
import { iconSlotSpace } from '../private/iconSlotSpace';

type Tone = 'promote' | 'info' | 'positive' | 'critical';

Expand Down Expand Up @@ -40,7 +41,7 @@ export const Notice = ({
{...buildDataAttributes({ data, validateRestProps: restProps })}
>
<DefaultTextPropsProvider tone={tone}>
<Columns space="xsmall">
<Columns space={iconSlotSpace}>
<Column width="content">
<Text>
<Icon />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,3 @@ export const darkModeStarColor = style(
export const starSpacing = style({
paddingRight: '1px',
});

export const textSpacing = style({
paddingLeft: '0.4em',
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { type TextProps, Text } from '../Text/Text';
import { IconStarSvg as IconStarEmptySvg } from '../icons/IconStar/IconStarSvg';
import { IconStarHalfSvg } from '../icons/IconStar/IconStarHalfSvg';
import { IconStarActiveSvg as IconStarFullSvg } from '../icons/IconStar/IconStarActiveSvg';
import { iconSlotSpace } from '../private/iconSlotSpace';
import * as styles from './Rating.css';

const getPercent = (rating: number, position: number) =>
Expand Down Expand Up @@ -127,7 +128,7 @@ export const Rating = ({
)}
</Box>
{variant !== 'starsOnly' && (
<Box component="span" className={styles.textSpacing} aria-hidden={true}>
<Box component="span" paddingLeft={iconSlotSpace} aria-hidden={true}>
{rating.toFixed(1)}
</Box>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import type { Space } from '../../../css/atoms/atoms';
import { type BoxProps, Box } from '../../Box/Box';
import { iconSlotSpace } from '../iconSlotSpace';

import * as styles from './AvoidWidowIcon.css';

Expand All @@ -12,13 +13,12 @@ interface Props extends Pick<BoxProps, 'children' | 'className'> {
export const AvoidWidowIcon = ({
children,
iconPosition,
space = 'xxsmall',
className,
}: Props) => (
<Box
component="span"
paddingRight={iconPosition === 'leading' ? space : undefined}
paddingLeft={iconPosition === 'trailing' ? space : undefined}
paddingRight={iconPosition === 'leading' ? iconSlotSpace : undefined}
paddingLeft={iconPosition === 'trailing' ? iconSlotSpace : undefined}
className={[styles.nowrap, className]}
aria-hidden
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { MaxLines } from '../MaxLines/MaxLines';
import type { UseIconProps } from '../../../hooks/useIcon';
import { alignToFlexAlign } from '../../../utils/align';
import { descenderCropFixForWebkitBox } from '../MaxLines/MaxLines.css';
import { iconSlotSpace } from '../iconSlotSpace';

export interface TypographyProps extends Pick<BoxProps, 'id' | 'component'> {
children?: ReactNode;
Expand Down Expand Up @@ -59,7 +60,7 @@ export const Typography = ({
<Box
component="span"
display="block"
paddingRight="xsmall"
paddingRight={iconSlotSpace}
flexGrow={0}
flexShrink={0}
minWidth={0}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const iconSlotSpace = 'xxsmall';

0 comments on commit 7799595

Please sign in to comment.