Skip to content

Commit

Permalink
Merge 63c9e5a into 75cbb2a
Browse files Browse the repository at this point in the history
  • Loading branch information
langermank authored Aug 9, 2024
2 parents 75cbb2a + 63c9e5a commit 371a37d
Show file tree
Hide file tree
Showing 26 changed files with 299 additions and 56 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
194 changes: 141 additions & 53 deletions e2e/components/Text.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,146 @@ import {themes} from '../test-helpers/themes'

test.describe('Text', () => {
test.describe('Default', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-text--default',
globals: {
colorScheme: theme,
},
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`Text.Default.${theme}.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-text--default',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations()
})
})
}
})

test.describe('Playground', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-text--playground',
globals: {
colorScheme: theme,
},
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`Text.Playground.${theme}.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-text--playground',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations()
})
})
}
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-text--default',
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`Text.Default.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-text--default',
})
await expect(page).toHaveNoViolations()
})
})

test.describe('Small', () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-text-features--size-small',
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`Text.Small.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-text-features--size-small',
})
await expect(page).toHaveNoViolations()
})
})

test.describe('Medium', () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-text-features--size-medium',
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`Text.Medium.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-text-features--size-medium',
})
await expect(page).toHaveNoViolations()
})
})

test.describe('Large', () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-text-features--size-large',
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`Text.Large.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-text-features--size-large',
})
await expect(page).toHaveNoViolations()
})
})

test.describe('LightWeight', () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-text-features--light-weight',
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`Text.Light.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-text-features--light-weight',
})
await expect(page).toHaveNoViolations()
})
})

test.describe('NormalWeight', () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-text-features--normal-weight',
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`Text.Normal.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-text-features--normal-weight',
})
await expect(page).toHaveNoViolations()
})
})

test.describe('MediumWeight', () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-text-features--medium-weight',
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`Text.Medium.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-text-features--medium-weight',
})
await expect(page).toHaveNoViolations()
})
})

test.describe('SemiboldWeight', () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-text-features--semibold-weight',
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`Text.Semibold.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-text-features--semibold-weight',
})
await expect(page).toHaveNoViolations()
})
})
})
8 changes: 8 additions & 0 deletions packages/react/src/Text/Text.docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
{
"name": "sx",
"type": "SystemStyleObject"
},
{
"name": "size",
"type": "'large' | 'medium' | 'small'"
},
{
"name": "weight",
"type": "'light' | 'normal' | 'medium' | 'semibold'"
}
],
"subcomponents": []
Expand Down
44 changes: 43 additions & 1 deletion packages/react/src/Text/Text.features.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,49 @@ export const Polymorphism = () => (
)

export const StyledText = () => (
<Text as="p" sx={{color: 'fg.onEmphasis', bg: 'neutral.emphasis', p: 2}}>
<Text as="p" sx={{color: 'fg.onEmphasis', bg: 'neutral.emphasis', p: 2}} size="small">
Stylized text
</Text>
)

export const SizeSmall = () => (
<Text as="span" size="small">
Stylized text
</Text>
)

export const SizeMedium = () => (
<Text as="span" size="medium">
Stylized text
</Text>
)

export const SizeLarge = () => (
<Text as="span" size="large">
Stylized text
</Text>
)

export const LightWeight = () => (
<Text as="span" weight="light">
Stylized text
</Text>
)

export const NormalWeight = () => (
<Text as="span" weight="normal">
Stylized text
</Text>
)

export const MediumWeight = () => (
<Text as="span" weight="medium">
Stylized text
</Text>
)

export const SemiboldWeight = () => (
<Text as="span" weight="semibold">
Stylized text
</Text>
)
2 changes: 2 additions & 0 deletions packages/react/src/Text/Text.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export const Playground: StoryFn<typeof Text> = args => <Text {...args}>{args.te
Playground.args = {
text: 'Playground',
as: 'span',
size: 'medium',
weight: 'normal',
}

Playground.argTypes = {
Expand Down
45 changes: 43 additions & 2 deletions packages/react/src/Text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,52 @@ import type {SxProp} from '../sx'
import sx from '../sx'
import type {ComponentProps} from '../utils/types'

const Text = styled.span<SystemTypographyProps & SystemCommonProps & SxProp>`
type StyledTextProps = {
size?: 'large' | 'medium' | 'small'
weight?: 'light' | 'normal' | 'medium' | 'semibold'
} & SystemTypographyProps &
SystemCommonProps &
SxProp

const Text = styled.span.attrs<StyledTextProps>(({size, weight}) => ({
'data-size': size,
'data-weight': weight,
}))<StyledTextProps>`
${TYPOGRAPHY};
${COMMON};
&:where([data-size='small']) {
font-size: var(--text-body-size-small, 0.75rem);
line-height: var(--text-body-lineHeight-small, 1.6666);
}
&:where([data-size='medium']) {
font-size: var(--text-body-size-medium, 0.875rem);
line-height: var(--text-body-lineHeight-medium, 1.4285);
}
&:where([data-size='large']) {
font-size: var(--text-body-size-large, 1rem);
line-height: var(--text-body-lineHeight-large, 1.5);
}
&:where([data-weight='light']) {
font-weight: var(--base-text-weight-light, 300);
}
&:where([data-weight='normal']) {
font-weight: var(--base-text-weight-normal, 400);
}
&:where([data-weight='medium']) {
font-weight: var(--base-text-weight-medium, 500);
}
&:where([data-weight='semibold']) {
font-weight: var(--base-text-weight-semibold, 600);
}
${sx};
`

export type TextProps = ComponentProps<typeof Text>
export default Text
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,37 @@ exports[`TextInputWithTokens renders a truncated set of tokens 1`] = `
color: var(--fgColor-muted,var(--color-fg-muted,#656d76));
}
.c9:where([data-size='small']) {
font-size: var(--text-body-size-small,0.75rem);
line-height: var(--text-body-lineHeight-small,1.6666);
}
.c9:where([data-size='medium']) {
font-size: var(--text-body-size-medium,0.875rem);
line-height: var(--text-body-lineHeight-medium,1.4285);
}
.c9:where([data-size='large']) {
font-size: var(--text-body-size-large,1rem);
line-height: var(--text-body-lineHeight-large,1.5);
}
.c9:where([data-weight='light']) {
font-weight: var(--base-text-weight-light,300);
}
.c9:where([data-weight='normal']) {
font-weight: var(--base-text-weight-normal,400);
}
.c9:where([data-weight='medium']) {
font-weight: var(--base-text-weight-medium,500);
}
.c9:where([data-weight='semibold']) {
font-weight: var(--base-text-weight-semibold,600);
}
.c0 {
font-size: 14px;
line-height: 20px;
Expand Down
Loading

0 comments on commit 371a37d

Please sign in to comment.