Skip to content

Commit

Permalink
Ensure content is left aligned by default (#1624)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltaranto authored Oct 14, 2024
1 parent c4ebe9c commit f16ebd9
Show file tree
Hide file tree
Showing 19 changed files with 195 additions and 10 deletions.
14 changes: 12 additions & 2 deletions .changeset/gentle-apricots-attend.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@

---
updated:
- Alert
- Card
- Checkbox
- Dialog
- Drawer
- FieldLabel
- FieldMessage
- List
- Notice
- RadioItem
- Toggle
---

**List**: Ensure list item text is left aligned
Ensure content is left aligned by default

Applies left alignment to text within list items, to ensure consistent alignment even when inside centered layout containers.
Applies left alignment to content, to ensure consistent alignment even when inside centered layout containers.
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,18 @@ export const screenshots: ComponentScreenshot = {
</Alert>
),
},
{
label: 'Test: should be left aligned in a centered Stack',
Example: () => (
<Stack space="large" align="center">
<Alert tone="positive">
<Text>
Enim elit eu et culpa non esse voluptate labore in ea. Incididunt
irure aliquip cillum occaecat irure.
</Text>
</Alert>
</Stack>
),
},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const Alert = ({
overflow="hidden"
role="alert"
aria-live="polite"
textAlign="left"
{...buildDataAttributes({ data, validateRestProps: restProps })}
>
<Columns space="small">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import type { ComponentScreenshot } from 'site/types';
import { Box, Card } from '../';
import { Box, Card, Stack, Text } from '../';
import { Placeholder } from '../../playroom/components';

export const screenshots: ComponentScreenshot = {
Expand Down Expand Up @@ -98,5 +98,18 @@ export const screenshots: ComponentScreenshot = {
</Box>
),
},
{
label: 'Test: should be left aligned in a centered Stack',
Example: () => (
<Stack space="large" align="center">
<Card height="content">
<Text>
Enim elit eu et culpa non esse voluptate labore in ea. Incididunt
irure aliquip cillum occaecat irure.
</Text>
</Card>
</Stack>
),
},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const Card = ({
borderRadius={roundingForTheme}
boxShadow={!isLegacyTheme ? 'borderNeutralLight' : undefined}
height={height === 'full' ? height : undefined}
textAlign="left"
{...buildDataAttributes({ data, validateRestProps: restProps })}
>
{tone ? <Keyline tone={tone} borderRadius={roundingForTheme} /> : null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,5 +293,21 @@ export const screenshots: ComponentScreenshot = {
</Box>
),
},
{
label: 'Test: should be left aligned in a centered Stack',
Example: ({ id, handler }) => (
<Stack space="large" align="center">
<Checkbox
id={id}
checked={false}
onChange={handler}
label="Dolor cillum elit aliquip velit reprehenderit."
tone="critical"
message="Do ut pariatur anim aliquip duis mollit esse qui irure pariatur eu elit."
description="Nulla amet dolor sunt elit consequat proident eiusmod id. Do ut pariatur anim aliquip duis mollit esse qui irure pariatur eu elit."
/>
</Stack>
),
},
],
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { type ReactNode } from 'react';
import type { ComponentScreenshot } from 'site/types';
import { Inline, Stack, Box } from '../';
import { Inline, Stack, Box, Text } from '../';
import { Placeholder } from '../../playroom/components';
import { DialogContent } from './Dialog';
import * as styles from '../private/Modal/Modal.css';
Expand Down Expand Up @@ -219,5 +219,26 @@ export const screenshots: ComponentScreenshot = {
</DialogContent>
),
},
{
label: 'Test: should be left aligned in a centered Stack',
gutter: false,
Container,
Example: ({ id }) => (
<Stack space="large" align="center">
<DialogContent
id={id}
title="Default test"
onClose={() => {}}
width="medium"
scrollLock={false}
>
<Text>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Pellentesque sodales hendrerit nulla.
</Text>
</DialogContent>
</Stack>
),
},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { ComponentScreenshot } from 'site/types';
import { Box } from '../Box/Box';
import { Placeholder } from '../../playroom/components';
import { DrawerContent } from './Drawer';
import { Stack } from '../Stack/Stack';
import { Text } from '../Text/Text';
import * as styles from '../private/Modal/Modal.css';

export const DrawerPreview = ({ children }: { children: ReactNode }) => (
Expand Down Expand Up @@ -136,5 +138,26 @@ export const screenshots: ComponentScreenshot = {
</DrawerContent>
),
},
{
label: 'Test: should be left aligned in a centered Stack',
gutter: false,
Container,
Example: ({ id }) => (
<Stack space="large" align="center">
<DrawerContent
id={id}
title="Default test"
onClose={() => {}}
width="medium"
scrollLock={false}
>
<Text>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Pellentesque sodales hendrerit nulla.
</Text>
</DrawerContent>
</Stack>
),
},
],
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { type ReactNode } from 'react';
import type { ComponentScreenshot } from 'site/types';
import { FieldLabel, TextLink } from '../';
import { FieldLabel, Stack, TextLink } from '../';

const Container = ({ children }: { children: ReactNode }) => (
<div style={{ maxWidth: '300px' }}>{children}</div>
Expand Down Expand Up @@ -86,5 +86,21 @@ export const screenshots: ComponentScreenshot = {
/>
),
},
{
label: 'Test: should be left aligned in a centered Stack',
Container,
Example: () => (
<Stack space="large" align="center">
<FieldLabel
htmlFor={false}
label="Enim elit eu et culpa non esse voluptate labore in ea."
secondaryLabel="Secondary"
tertiaryLabel={<TextLink href="#">Tertiary</TextLink>}
description="Enim elit eu et culpa non esse voluptate labore in ea. Incididunt
irure aliquip cillum occaecat irure."
/>
</Stack>
),
},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const FieldLabel = ({
);

return (
<Stack space="small" data={data}>
<Stack space="small" align="left" data={data}>
{label ? (
<Box component="span" display="flex" justifyContent="spaceBetween">
{htmlFor === false ? (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import type { ComponentScreenshot } from 'site/types';
import { FieldMessage } from '../';
import { FieldMessage, Stack } from '../';

export const screenshots: ComponentScreenshot = {
screenshotWidths: [320],
Expand Down Expand Up @@ -54,5 +54,20 @@ export const screenshots: ComponentScreenshot = {
/>
),
},
{
label: 'Test: should be left aligned in a centered Stack',
Container: ({ children }) => (
<div style={{ maxWidth: '300px' }}>{children}</div>
),
Example: ({ id }) => (
<Stack space="large" align="center">
<FieldMessage
id={id}
tone="critical"
message="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque sodales hendrerit nulla."
/>
</Stack>
),
},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const FieldMessage = ({
id={id}
display="flex"
justifyContent="flexEnd"
textAlign="left"
{...buildDataAttributes({ data, validateRestProps: restProps })}
>
<Box flexGrow={1} userSelect={showMessage ? undefined : 'none'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,18 @@ export const screenshots: ComponentScreenshot = {
</Notice>
),
},
{
label: 'Test: should be left aligned in a centered Stack',
Example: () => (
<Stack space="large" align="center">
<Notice tone="positive">
<Text>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Pellentesque sodales hendrerit nulla.
</Text>
</Notice>
</Stack>
),
},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const Notice = ({
<Box
role="alert"
aria-live="polite"
textAlign="left"
{...buildDataAttributes({ data, validateRestProps: restProps })}
>
<DefaultTextPropsProvider tone={tone}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import type { ComponentScreenshot } from 'site/types';
import { Box, RadioGroup, RadioItem } from '../';
import { Box, RadioGroup, RadioItem, Stack } from '../';
import { Placeholder } from '../../playroom/components';
import { BackgroundContrastTest } from '../../utils/BackgroundContrastTest';
import { debugTouchableAttrForDataProp } from '../private/touchable/debugTouchable';
Expand Down Expand Up @@ -280,5 +280,31 @@ export const screenshots: ComponentScreenshot = {
</Box>
),
},
{
label: 'Test: should be left aligned in a centered Stack',
Example: ({ handler }) => (
<Stack space="large" align="center">
<RadioGroup
id="arialabelledbywithdesc"
value="2"
onChange={handler}
label="Dolor cillum elit aliquip velit reprehenderit."
tone="critical"
message="Do ut pariatur anim aliquip duis mollit esse qui irure pariatur eu elit."
description="Nulla amet dolor sunt elit consequat proident eiusmod id. Do ut pariatur anim aliquip duis mollit esse qui irure pariatur eu elit."
>
<RadioItem label="Veniam voluptate minim consectetur." value="1" />
<RadioItem
label="Ex magna amet quis esse Lorem commodo. Consequat aliquip commodo ipsum reprehenderit."
value="2"
/>
<RadioItem
label="Consequat tempor cupidatat pariatur ea eiusmod proident sit cupidatat magna duis."
value="3"
/>
</RadioGroup>
</Stack>
),
},
],
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import type { ComponentScreenshot } from 'site/types';
import { Toggle, Box, Tiles, Inline, Text } from '../';
import { Toggle, Box, Tiles, Inline, Text, Stack } from '../';
import { BackgroundContrastTest } from '../../utils/BackgroundContrastTest';
import { debugTouchableAttrForDataProp } from '../private/touchable/debugTouchable';

Expand Down Expand Up @@ -252,5 +252,18 @@ export const screenshots: ComponentScreenshot = {
</Box>
),
},
{
label: 'Test: should be left aligned in a centered Stack',
Example: ({ id, handler }) => (
<Stack space="large" align="center">
<Toggle
on={true}
label="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque sodales hendrerit nulla."
id={id}
onChange={handler}
/>
</Stack>
),
},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const Toggle = forwardRef<HTMLInputElement, ToggleProps>(
}
justifyContent={alignToEnd ? 'flexEnd' : undefined}
className={styles.root}
textAlign="left"
{...buildDataAttributes({ data, validateRestProps: restProps })}
>
<Box
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const InlineField = forwardRef<

return (
<Box position="relative">
<Box display="flex">
<Box display="flex" textAlign="left">
<StyledInput
{...restProps}
type={type}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export const ModalContent = ({
height="full"
display="flex"
alignItems="center"
textAlign="left"
justifyContent={justifyContent}
>
<Box
Expand Down

0 comments on commit f16ebd9

Please sign in to comment.