Skip to content

Commit 7cf029d

Browse files
joshblacklukasoppermannfrancinelucca
authored
feat: add support for size to Blankslate (#5899)
Co-authored-by: Lukas Oppermann <[email protected]> Co-authored-by: Marie Lucca <[email protected]>
1 parent fc43b48 commit 7cf029d

File tree

97 files changed

+330
-161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+330
-161
lines changed

.changeset/famous-eagles-think.md

Lines changed: 5 additions & 0 deletions

.changeset/purple-numbers-leave.md

Lines changed: 5 additions & 0 deletions

e2e/components/Blankslate.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {test, expect} from '@playwright/test'
22
import {visit} from '../test-helpers/storybook'
33
import {themes} from '../test-helpers/themes'
44
import {viewports} from '../test-helpers/viewports'
5+
import {matrix, serialize} from '../test-helpers/matrix'
56

67
const stories: Array<{title: string; id: string; viewports?: Array<keyof typeof viewports>}> = [
78
{
@@ -41,6 +42,12 @@ const stories: Array<{title: string; id: string; viewports?: Array<keyof typeof
4142
},
4243
]
4344

45+
const scenarios = matrix({
46+
size: ['small', 'medium', 'large'],
47+
spacious: [true, false],
48+
border: [true, false],
49+
})
50+
4451
test.describe('Blankslate', () => {
4552
for (const story of stories) {
4653
test.describe(story.title, () => {
@@ -78,4 +85,20 @@ test.describe('Blankslate', () => {
7885
}
7986
})
8087
}
88+
89+
for (const scenario of scenarios) {
90+
const id = serialize(scenario)
91+
92+
test.describe(id, () => {
93+
test('default @vrt', async ({page}) => {
94+
await visit(page, {
95+
id: 'experimental-components-blankslate--playground',
96+
args: scenario,
97+
})
98+
99+
// Default state
100+
expect(await page.screenshot()).toMatchSnapshot(`Blankslate.${id}.png`)
101+
})
102+
})
103+
}
81104
})

packages/react/src/Blankslate/Blankslate.docs.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@
5151
"type": "string",
5252
"description": "Class name(s) for custom styling.",
5353
"defaultValue": ""
54+
},
55+
{
56+
"name": "size",
57+
"type": "'small' | 'medium' | 'large'",
58+
"description": "The size of the componeont",
59+
"defaultValue": "'medium'"
5460
}
5561
],
5662
"subcomponents": [

packages/react/src/Blankslate/Blankslate.features.stories.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const WithBorder = () => (
8787
)
8888

8989
export const Narrow = () => (
90-
<Blankslate narrow>
90+
<Blankslate border narrow>
9191
<Blankslate.Visual>
9292
<BookIcon size="medium" />
9393
</Blankslate.Visual>
@@ -105,3 +105,27 @@ export const Spacious = () => (
105105
<Blankslate.Description>Use it to provide information when no dynamic content exists.</Blankslate.Description>
106106
</Blankslate>
107107
)
108+
109+
export const SizeSmall = () => (
110+
<Blankslate border size="small">
111+
<Blankslate.Visual>
112+
<BookIcon size="medium" />
113+
</Blankslate.Visual>
114+
<Blankslate.Heading>Blankslate heading</Blankslate.Heading>
115+
<Blankslate.Description>Use it to provide information when no dynamic content exists.</Blankslate.Description>
116+
<Blankslate.PrimaryAction href="#">Primary action</Blankslate.PrimaryAction>
117+
<Blankslate.SecondaryAction href="#">Secondary action</Blankslate.SecondaryAction>
118+
</Blankslate>
119+
)
120+
121+
export const SizeLarge = () => (
122+
<Blankslate size="large">
123+
<Blankslate.Visual>
124+
<BookIcon size="medium" />
125+
</Blankslate.Visual>
126+
<Blankslate.Heading>Blankslate heading</Blankslate.Heading>
127+
<Blankslate.Description>Use it to provide information when no dynamic content exists.</Blankslate.Description>
128+
<Blankslate.PrimaryAction href="#">Primary action</Blankslate.PrimaryAction>
129+
<Blankslate.SecondaryAction href="#">Secondary action</Blankslate.SecondaryAction>
130+
</Blankslate>
131+
)
Lines changed: 55 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,73 @@
11
import {Blankslate} from '../Blankslate'
22
import figma from '@figma/code-connect'
33

4+
const props = {
5+
leadingVisual: figma.nestedProps('_BlankslateVisual', {
6+
item: figma.children('leadingVisual'),
7+
}),
8+
size: figma.enum('size', {
9+
small: 'small',
10+
medium: 'medium',
11+
large: 'large',
12+
}),
13+
spacious: figma.boolean('spacious'),
14+
border: figma.boolean('border'),
15+
heading: figma.textContent('Text: Heading'),
16+
description: figma.textContent('Text: Description'),
17+
PrimaryAction: figma.children('_BlankSlate.PrimaryAction'),
18+
SecondaryActionText: figma.boolean('SecondaryAction?', {
19+
true: figma.textContent('Secondary action link'),
20+
false: undefined,
21+
}),
22+
}
23+
424
figma.connect(Blankslate, 'https://www.figma.com/design/GCvY3Qv8czRgZgvl1dG6lp/Primer-Web?node-id=4398-2383&m=dev', {
5-
props: {
6-
leadingVisual: figma.nestedProps('_BlankslateVisual', {
7-
item: figma.children('leadingVisual'),
8-
}),
9-
narrow: figma.boolean('narrow?'),
10-
spacious: figma.boolean('spacious?'),
11-
border: figma.boolean('border?'),
12-
heading: figma.textContent('Text: Heading'),
13-
description: figma.textContent('Text: Description'),
14-
},
15-
variant: {primaryAction: 'false', secondaryAction: 'false'},
16-
example: ({leadingVisual, border, spacious, narrow, description, heading}) => (
17-
<Blankslate border={border} spacious={spacious} narrow={narrow}>
25+
props,
26+
variant: {'SecondaryAction?': 'true'},
27+
example: ({leadingVisual, border, spacious, size, description, heading, SecondaryActionText, PrimaryAction}) => (
28+
<Blankslate border={border} spacious={spacious} size={size}>
1829
<Blankslate.Visual>{leadingVisual.item}</Blankslate.Visual>
1930
<Blankslate.Heading>{heading}</Blankslate.Heading>
2031
<Blankslate.Description>{description}</Blankslate.Description>
32+
<Blankslate.SecondaryAction href="">{SecondaryActionText}</Blankslate.SecondaryAction>
33+
{PrimaryAction}
2134
</Blankslate>
2235
),
2336
})
2437
figma.connect(Blankslate, 'https://www.figma.com/design/GCvY3Qv8czRgZgvl1dG6lp/Primer-Web?node-id=4398-2383&m=dev', {
25-
props: {
26-
leadingVisual: figma.nestedProps('_BlankslateVisual', {
27-
item: figma.children('leadingVisual'),
28-
}),
29-
narrow: figma.boolean('narrow?'),
30-
spacious: figma.boolean('spacious?'),
31-
border: figma.boolean('border?'),
32-
heading: figma.textContent('Text: Heading'),
33-
description: figma.textContent('Text: Description'),
34-
primaryAction: figma.nestedProps('Primary action', {
35-
text: figma.textContent('Button'),
36-
}),
37-
},
38-
variant: {primaryAction: 'true', secondaryAction: 'false'},
39-
example: ({leadingVisual, border, spacious, narrow, description, heading, primaryAction}) => (
40-
<Blankslate border={border} spacious={spacious} narrow={narrow}>
38+
props,
39+
variant: {'SecondaryAction?': 'false'},
40+
example: ({leadingVisual, border, spacious, size, description, heading, PrimaryAction}) => (
41+
<Blankslate border={border} spacious={spacious} size={size}>
4142
<Blankslate.Visual>{leadingVisual.item}</Blankslate.Visual>
4243
<Blankslate.Heading>{heading}</Blankslate.Heading>
4344
<Blankslate.Description>{description}</Blankslate.Description>
44-
<Blankslate.PrimaryAction href="">{primaryAction.text}</Blankslate.PrimaryAction>
45+
{PrimaryAction}
4546
</Blankslate>
4647
),
4748
})
48-
figma.connect(Blankslate, 'https://www.figma.com/design/GCvY3Qv8czRgZgvl1dG6lp/Primer-Web?node-id=4398-2383&m=dev', {
49-
props: {
50-
leadingVisual: figma.nestedProps('_BlankslateVisual', {
51-
item: figma.children('leadingVisual'),
52-
}),
53-
narrow: figma.boolean('narrow?'),
54-
spacious: figma.boolean('spacious?'),
55-
border: figma.boolean('border?'),
56-
heading: figma.textContent('Text: Heading'),
57-
description: figma.textContent('Text: Description'),
58-
primaryAction: figma.nestedProps('Primary action', {
59-
text: figma.textContent('Button'),
60-
}),
61-
secondaryAction: figma.textContent('Secondary action link'),
62-
},
63-
variant: {primaryAction: 'true', secondaryAction: 'true'},
64-
example: ({leadingVisual, border, spacious, narrow, description, heading, primaryAction, secondaryAction}) => (
65-
<Blankslate border={border} spacious={spacious} narrow={narrow}>
66-
<Blankslate.Visual>{leadingVisual.item}</Blankslate.Visual>
67-
<Blankslate.Heading>{heading}</Blankslate.Heading>
68-
<Blankslate.Description>{description}</Blankslate.Description>
69-
<Blankslate.PrimaryAction href="">{primaryAction.text}</Blankslate.PrimaryAction>
70-
<Blankslate.SecondaryAction href="">{secondaryAction}</Blankslate.SecondaryAction>
71-
</Blankslate>
72-
),
73-
})
74-
figma.connect(Blankslate, 'https://www.figma.com/design/GCvY3Qv8czRgZgvl1dG6lp/Primer-Web?node-id=4398-2383&m=dev', {
75-
props: {
76-
leadingVisual: figma.nestedProps('_BlankslateVisual', {
77-
item: figma.children('leadingVisual'),
78-
}),
79-
narrow: figma.boolean('narrow?'),
80-
spacious: figma.boolean('spacious?'),
81-
border: figma.boolean('border?'),
82-
heading: figma.textContent('Text: Heading'),
83-
description: figma.textContent('Text: Description'),
84-
secondaryAction: figma.textContent('Secondary action link'),
49+
50+
figma.connect(
51+
Blankslate,
52+
'https://www.figma.com/design/GCvY3Qv8czRgZgvl1dG6lp/Primer-Web?node-id=40491-3841&t=5mMfBZbhHgyouYtk-4',
53+
{
54+
props: {
55+
PrimaryAction: figma.nestedProps('Primary action', {
56+
text: figma.textContent('Button'),
57+
icon: figma.children('icon'),
58+
variant: figma.enum('variant', {
59+
primary: 'primary',
60+
secondary: 'secondary',
61+
danger: 'danger',
62+
invisible: 'invisible',
63+
}),
64+
}),
65+
},
66+
example: ({PrimaryAction}) => (
67+
<Blankslate.PrimaryAction href="">
68+
{PrimaryAction.icon}
69+
{PrimaryAction.text}
70+
</Blankslate.PrimaryAction>
71+
),
8572
},
86-
variant: {primaryAction: 'false', secondaryAction: 'true'},
87-
example: ({leadingVisual, border, spacious, narrow, description, heading, secondaryAction}) => (
88-
<Blankslate border={border} spacious={spacious} narrow={narrow}>
89-
<Blankslate.Visual>{leadingVisual.item}</Blankslate.Visual>
90-
<Blankslate.Heading>{heading}</Blankslate.Heading>
91-
<Blankslate.Description>{description}</Blankslate.Description>
92-
<Blankslate.SecondaryAction href="">{secondaryAction}</Blankslate.SecondaryAction>
93-
</Blankslate>
94-
),
95-
})
73+
)

0 commit comments

Comments
 (0)