Skip to content

Commit 916ed95

Browse files
authored
feat(Stack): Convert Stack to CSS modules behind feature flag (#5214)
* Convert Stack component to CSS modules * Adding className tests * Create gentle-doors-sell.md
1 parent 25ebfca commit 916ed95

File tree

5 files changed

+623
-229
lines changed

5 files changed

+623
-229
lines changed

.changeset/gentle-doors-sell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": patch
3+
---
4+
5+
Convert Stack to CSS modules behind feature flag
Lines changed: 323 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,323 @@
1+
.Stack {
2+
display: flex;
3+
flex-flow: column;
4+
align-items: stretch;
5+
align-content: flex-start;
6+
gap: var(--stack-gap, var(--stack-gap-normal));
7+
8+
&[data-padding='none'],
9+
&[data-padding-narrow='none'] {
10+
padding: 0;
11+
}
12+
13+
&[data-padding='condensed'],
14+
&[data-padding-narrow='condensed'] {
15+
/* stylelint-disable-next-line primer/spacing */
16+
padding: var(--stack-padding-condensed);
17+
}
18+
19+
&[data-padding='normal'],
20+
&[data-padding-narrow='normal'] {
21+
/* stylelint-disable-next-line primer/spacing */
22+
padding: var(--stack-padding-normal);
23+
}
24+
25+
&[data-padding='spacious'],
26+
&[data-padding-narrow='spacious'] {
27+
/* stylelint-disable-next-line primer/spacing */
28+
padding: var(--stack-padding-spacious);
29+
}
30+
31+
&[data-direction='horizontal'],
32+
&[data-direction-narrow='horizontal'] {
33+
flex-flow: row;
34+
}
35+
36+
&[data-direction='vertical'],
37+
&[data-direction-narrow='vertical'] {
38+
flex-flow: column;
39+
}
40+
41+
&[data-gap='none'],
42+
&[data-gap-narrow='none'] {
43+
--stack-gap: 0;
44+
}
45+
46+
&[data-gap='condensed'],
47+
&[data-gap-narrow='condensed'] {
48+
--stack-gap: var(--stack-gap-condensed);
49+
}
50+
51+
&[data-gap='normal'],
52+
&[data-gap-narrow='normal'] {
53+
--stack-gap: var(--stack-gap-normal);
54+
}
55+
56+
&[data-gap='spacious'],
57+
&[data-gap-narrow='spacious'] {
58+
--stack-gap: var(--stack-gap-spacious);
59+
}
60+
61+
&[data-align='start'],
62+
&[data-align-narrow='start'] {
63+
align-items: flex-start;
64+
}
65+
66+
&[data-align='center'],
67+
&[data-align-narrow='center'] {
68+
align-items: center;
69+
}
70+
71+
&[data-align='end'],
72+
&[data-align-narrow='end'] {
73+
align-items: flex-end;
74+
}
75+
76+
&[data-align='baseline'],
77+
&[data-align-narrow='baseline'] {
78+
align-items: baseline;
79+
}
80+
81+
&[data-justify='start'],
82+
&[data-justify-narrow='start'] {
83+
justify-content: flex-start;
84+
}
85+
86+
&[data-justify='center'],
87+
&[data-justify-narrow='center'] {
88+
justify-content: center;
89+
}
90+
91+
&[data-justify='end'],
92+
&[data-justify-narrow='end'] {
93+
justify-content: flex-end;
94+
}
95+
96+
&[data-justify='space-between'],
97+
&[data-justify-narrow='space-between'] {
98+
justify-content: space-between;
99+
}
100+
101+
&[data-justify='space-evenly'],
102+
&[data-justify-narrow='space-evenly'] {
103+
justify-content: space-evenly;
104+
}
105+
106+
&[data-wrap='wrap'],
107+
&[data-wrap-narrow='wrap'] {
108+
flex-wrap: wrap;
109+
}
110+
111+
&[data-wrap='nowrap'],
112+
&[data-wrap-narrow='nowrap'] {
113+
flex-wrap: nowrap;
114+
}
115+
116+
@media (--veiwportRange-regular) {
117+
&[data-padding-regular='none'] {
118+
padding: 0;
119+
}
120+
121+
&[data-padding-regular='condensed'] {
122+
/* stylelint-disable-next-line primer/spacing */
123+
padding: var(--stack-padding-condensed);
124+
}
125+
126+
&[data-padding-regular='normal'] {
127+
/* stylelint-disable-next-line primer/spacing */
128+
padding: var(--stack-padding-normal);
129+
}
130+
131+
&[data-padding-regular='spacious'] {
132+
/* stylelint-disable-next-line primer/spacing */
133+
padding: var(--stack-padding-spacious);
134+
}
135+
136+
&[data-direction-regular='horizontal'] {
137+
flex-flow: row;
138+
}
139+
140+
&[data-direction-regular='vertical'] {
141+
flex-flow: column;
142+
}
143+
144+
&[data-gap-regular='none'] {
145+
--stack-gap: 0;
146+
}
147+
148+
&[data-gap-regular='condensed'] {
149+
--stack-gap: var(--stack-gap-condensed);
150+
}
151+
152+
&[data-gap-regular='normal'] {
153+
--stack-gap: var(--stack-gap-normal);
154+
}
155+
156+
&[data-gap-regular='spacious'] {
157+
--stack-gap: var(--stack-gap-spacious);
158+
}
159+
160+
&[data-align-regular='start'] {
161+
align-items: flex-start;
162+
}
163+
164+
&[data-align-regular='center'] {
165+
align-items: center;
166+
}
167+
168+
&[data-align-regular='end'] {
169+
align-items: flex-end;
170+
}
171+
172+
&[data-align-regular='baseline'] {
173+
align-items: baseline;
174+
}
175+
176+
&[data-justify-regular='start'] {
177+
justify-content: flex-start;
178+
}
179+
180+
&[data-justify-regular='center'] {
181+
justify-content: center;
182+
}
183+
184+
&[data-justify-regular='end'] {
185+
justify-content: flex-end;
186+
}
187+
188+
&[data-justify-regular='space-between'] {
189+
justify-content: space-between;
190+
}
191+
192+
&[data-justify-regular='space-evenly'] {
193+
justify-content: space-evenly;
194+
}
195+
196+
&[data-wrap-regular='wrap'] {
197+
flex-wrap: wrap;
198+
}
199+
200+
&[data-wrap-regular='nowrap'] {
201+
flex-wrap: nowrap;
202+
}
203+
}
204+
205+
@media (--viewportRange-wide) {
206+
&[data-padding-wide='none'] {
207+
padding: 0;
208+
}
209+
210+
&[data-padding-wide='condensed'] {
211+
/* stylelint-disable-next-line primer/spacing */
212+
padding: var(--stack-padding-condensed);
213+
}
214+
215+
&[data-padding-wide='normal'] {
216+
/* stylelint-disable-next-line primer/spacing */
217+
padding: var(--stack-padding-normal);
218+
}
219+
220+
&[data-padding-wide='spacious'] {
221+
/* stylelint-disable-next-line primer/spacing */
222+
padding: var(--stack-padding-spacious);
223+
}
224+
225+
&[data-direction-wide='horizontal'] {
226+
flex-flow: row;
227+
}
228+
229+
&[data-direction-wide='vertical'] {
230+
flex-flow: column;
231+
}
232+
233+
&[data-gap-wide='none'] {
234+
--stack-gap: 0;
235+
}
236+
237+
&[data-gap-wide='condensed'] {
238+
--stack-gap: var(--stack-gap-condensed);
239+
}
240+
241+
&[data-gap-wide='normal'] {
242+
--stack-gap: var(--stack-gap-normal);
243+
}
244+
245+
&[data-gap-wide='spacious'] {
246+
--stack-gap: var(--stack-gap-spacious);
247+
}
248+
249+
&[data-align-wide='start'] {
250+
align-items: flex-start;
251+
}
252+
253+
&[data-align-wide='center'] {
254+
align-items: center;
255+
}
256+
257+
&[data-align-wide='end'] {
258+
align-items: flex-end;
259+
}
260+
261+
&[data-align-wide='baseline'] {
262+
align-items: baseline;
263+
}
264+
265+
&[data-justify-wide='start'] {
266+
justify-content: flex-start;
267+
}
268+
269+
&[data-justify-wide='center'] {
270+
justify-content: center;
271+
}
272+
273+
&[data-justify-wide='end'] {
274+
justify-content: flex-end;
275+
}
276+
277+
&[data-justify-wide='space-between'] {
278+
justify-content: space-between;
279+
}
280+
281+
&[data-justify-wide='space-evenly'] {
282+
justify-content: space-evenly;
283+
}
284+
285+
&[data-wrap-wide='wrap'] {
286+
flex-wrap: wrap;
287+
}
288+
289+
&[data-wrap-wide='nowrap'] {
290+
flex-wrap: nowrap;
291+
}
292+
}
293+
}
294+
295+
.StackItem {
296+
flex: 0 1 auto;
297+
min-inline-size: 0;
298+
299+
&[data-grow='true'],
300+
&[data-grow-narrow='true'] {
301+
flex-grow: 1;
302+
}
303+
304+
@media (--veiwportRange-regular) {
305+
&[data-grow-regular='true'] {
306+
flex-grow: 1;
307+
}
308+
309+
&[data-grow-regular='false'] {
310+
flex-grow: 0;
311+
}
312+
}
313+
314+
@media (--viewportRange-wide) {
315+
&[data-grow-wide='true'] {
316+
flex-grow: 1;
317+
}
318+
319+
&[data-grow-wide='false'] {
320+
flex-grow: 0;
321+
}
322+
}
323+
}

0 commit comments

Comments
 (0)