Skip to content

Commit 13fbc18

Browse files
authored
feat(Text)!: remove deprecated props (#1873)
- remove `size` prop The `size` prop, being redundant, is now replaced by the more expressive `preset` prop, which contains all the semantic (tier-2) tokens by name. Each of the `size` values corresponds to a specific and existing `preset` value, listed in the following table: | `size` | `preset` | |--------|--------| | body | body-md | | xs | body-xs | | sm | body-sm | | md | Cell | | lg | body-lg | | caption-md | caption-md | | caption-lg | caption-lg | | overline | overline | | callout | body-sm | In usages of `size`, you can remove the prop. If there is no preset defined for the instance of `Text`, you can use the table above to replace the `size` prop and value with the equivalent preset. - remove `weight` prop Instead of specifying `weight` on any instance of `Text`, you can instead use utility classes or styles to add an override to `font-weight`. The `preset` values specify weight in addition to `font-size`, `line-height`, and other details so overrides like this should be rare. One example to apply this weight override is to use [`font-*`](https://tailwindcss.com/docs/font-weight#setting-the-font-weight) or use the relevant CSS properties to adjust the weight. - remove `variant` prop `variant` overlapped with the utility classes, and served as a namespaced subset of the actual color tokens, in some cases changing the name of the token in the API. We remove variant in favor of utility classes, similar to weight adjustments. For each `variant` value, the equivalent token to use can be found in the following table: | `variant` | equivalent EDS token | |--------|--------| | error | --eds-theme-color-text-utility-error | | neutral-subtle | --eds-theme-color-text-neutral-subtle | | neutral-medium | --eds-theme-color-text-neutral-default | | neutral-strong | --eds-theme-color-text-neutral-strong | | brand | --eds-theme-color-text-brand-default | | info | --eds-color-info-700 | | inherit | **this is the default behavior now** | | success | --eds-theme-color-text-utility-success | | warning | --eds-theme-color-text-utility-warning | | white | --eds-theme-color-text-neutral-default-inverse | [Use the following table](https://chanzuckerberg.github.io/edu-design-system/?path=/story/design-tokens-tier-2-usage-colors--text) to match design intent to code equivalent, referencing the table above. For example, if the code currently uses `variant="neutral-medium"`, convert by removing that, and adding `className="text-neutral-default"` or using `color: var(--eds-theme-color-text-neutral-default)` in a stylesheet. - remove partial definition of `fontSize` from default tailwind config The existing tailwind config is redundant, as it only partially overlaps the more expressive `preset` field on `Text`, and lacks the precision of the typography tokens. Along with cleaning up these settings, we also remove a mismatch between `Text` and `Heading` (which did not sync up with the associated `preset`s of either component). This restores the default values provided by tailwind. - update stories and examples - update component usages in compositions * repair WireframeDemo page * apply snapshot regressions on several components * update stacked cards table example * remove fontSize config from tailwind.config.ts
1 parent f1bf71e commit 13fbc18

37 files changed

+218
-393
lines changed

.storybook/pages/WireframeDemo/WireframeDemo.tsx

+12-12
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ const StudentTab = ({
152152
)}
153153
>
154154
<div className={clsx(styles['watch-page__avatar'], 'h-10 w-10')}>
155-
<Text size="sm">{studentName.slice(0, 1)}</Text>
155+
<Text preset="body-sm">{studentName.slice(0, 1)}</Text>
156156
</div>
157-
<Text className="!mt-2 truncate" size="xs">
157+
<Text className="!mt-2 truncate" preset="body-xs">
158158
{studentName}
159159
</Text>
160160
</div>
@@ -249,12 +249,12 @@ const WatchPage = ({ onLogout }: { onLogout: () => void }) => {
249249
<div
250250
className={clsx(styles['watch-page__avatar'], 'mr-2 h-9 w-9')}
251251
>
252-
<Text size="sm">M</Text>
252+
<Text preset="body-sm">M</Text>
253253
</div>
254254

255255
<div>
256-
<Text size="sm">Mikaela</Text>
257-
<Text size="xs">3d</Text>
256+
<Text preset="body-sm">Mikaela</Text>
257+
<Text preset="body-xs">3d</Text>
258258
</div>
259259
</div>
260260
<img
@@ -279,7 +279,7 @@ const WatchPage = ({ onLogout }: { onLogout: () => void }) => {
279279
<div className={styles['watch-page__response']}>
280280
<Label htmlFor={responseTextareaId} text="Respond to Mikaela" />
281281
<textarea
282-
className={clsx(styles['watch-page__textarea'], 'h-[9.25rem')}
282+
className={clsx(styles['watch-page__textarea'], 'h-[9.25rem]')}
283283
id={responseTextareaId}
284284
onChange={handleTextareaChange}
285285
placeholder="Type your response to Mikaela"
@@ -312,7 +312,7 @@ const WatchPage = ({ onLogout }: { onLogout: () => void }) => {
312312
'm-4 h-[6.25rem] w-[6.25rem]',
313313
)}
314314
>
315-
<Text size="lg">M</Text>
315+
<Text preset="body-lg">M</Text>
316316
</div>
317317
<Link className="mb-4">
318318
<Heading as="h2" preset="headline-sm">
@@ -330,22 +330,22 @@ const WatchPage = ({ onLogout }: { onLogout: () => void }) => {
330330
<thead>
331331
<tr>
332332
<th>
333-
<Text size="xs">Questions received</Text>
333+
<Text preset="body-xs">Questions received</Text>
334334
</th>
335335
<th>
336-
<Text size="xs">Reflections submitted</Text>
336+
<Text preset="body-xs">Reflections submitted</Text>
337337
</th>
338338
</tr>
339339
</thead>
340340
<tbody>
341341
<tr>
342342
<td>
343-
<Text className="text-center" size="lg">
343+
<Text className="text-center" preset="body-lg">
344344
10
345345
</Text>
346346
</td>
347347
<td>
348-
<Text className="text-center" size="lg">
348+
<Text className="text-center" preset="body-lg">
349349
8
350350
</Text>
351351
</td>
@@ -355,7 +355,7 @@ const WatchPage = ({ onLogout }: { onLogout: () => void }) => {
355355
</div>
356356

357357
<div className={styles['watch-page__teacher-notes-heading']}>
358-
<Text size="xs">Your personal notes</Text>
358+
<Text preset="body-xs">Your personal notes</Text>
359359
<Tooltip
360360
childNotInteractive
361361
text={

src/components/Accordion/Accordion.stories.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export const UsingComplexHeaders: Story = {
316316
<>
317317
<Accordion.Row>
318318
<Accordion.Button>
319-
<Text size="lg">
319+
<Text preset="body-lg">
320320
<Icon
321321
className="m-2"
322322
name="check-circle"
@@ -335,7 +335,7 @@ export const UsingComplexHeaders: Story = {
335335
</Accordion.Row>
336336
<Accordion.Row>
337337
<Accordion.Button>
338-
<Text size="lg">
338+
<Text preset="body-lg">
339339
<Icon
340340
className="m-2"
341341
name="check-circle"
@@ -373,7 +373,7 @@ export const UsingNumberIconInHeaders: Story = {
373373
<Accordion.Button>
374374
<div className="flex flex-wrap items-center gap-2">
375375
<NumberIcon aria-label="Step 1" number={1} />
376-
<Text size="lg">Step 1</Text>
376+
<Text preset="body-lg">Step 1</Text>
377377
</div>
378378
</Accordion.Button>
379379
<Accordion.Panel>
@@ -387,7 +387,7 @@ export const UsingNumberIconInHeaders: Story = {
387387
<Accordion.Button>
388388
<div className="items flex flex-wrap items-center gap-2">
389389
<NumberIcon aria-label="Step 2" number={2} />
390-
<Text size="lg">Step 2</Text>
390+
<Text preset="body-lg">Step 2</Text>
391391
</div>
392392
</Accordion.Button>
393393
<Accordion.Panel>

src/components/Accordion/__snapshots__/Accordion.test.tsx.snap

+4-4
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,7 @@ exports[`<Accordion /> UsingComplexHeaders story renders snapshot 1`] = `
16291629
class="heading heading--headline-md accordion-button__heading"
16301630
>
16311631
<p
1632-
class="text text--lg"
1632+
class="text text--body-lg"
16331633
>
16341634
<svg
16351635
aria-hidden="true"
@@ -1681,7 +1681,7 @@ exports[`<Accordion /> UsingComplexHeaders story renders snapshot 1`] = `
16811681
class="heading heading--headline-md accordion-button__heading"
16821682
>
16831683
<p
1684-
class="text text--lg"
1684+
class="text text--body-lg"
16851685
>
16861686
<svg
16871687
aria-hidden="true"
@@ -1754,7 +1754,7 @@ exports[`<Accordion /> UsingNumberIconInHeaders story renders snapshot 1`] = `
17541754
1
17551755
</span>
17561756
<p
1757-
class="text text--lg"
1757+
class="text text--body-lg"
17581758
>
17591759
Step 1
17601760
</p>
@@ -1803,7 +1803,7 @@ exports[`<Accordion /> UsingNumberIconInHeaders story renders snapshot 1`] = `
18031803
2
18041804
</span>
18051805
<p
1806-
class="text text--lg"
1806+
class="text text--body-lg"
18071807
>
18081808
Step 2
18091809
</p>

src/components/Card/Card.stories.tsx

+5-13
Original file line numberDiff line numberDiff line change
@@ -131,29 +131,21 @@ export const LoadingProfileCard: StoryObj<Args> = {
131131
{!isLoading && (
132132
<>
133133
<Avatar size="lg" user={{ fullName: 'Josephine Smith' }} />
134-
<Text
135-
className="mb-2 mt-2"
136-
variant="neutral-strong"
137-
weight="bold"
138-
>
134+
<Text className="mb-2 mt-2 text-neutral-strong">
139135
Example Job Title
140136
</Text>
141-
<Text
142-
className="mb-2 mt-2"
143-
variant="neutral-strong"
144-
weight="bold"
145-
>
137+
<Text className="mb-2 mt-2 text-neutral-strong">
146138
Example Company Name
147139
</Text>
148140
<Hr />
149-
<Text className="mb-2 mt-2" variant="neutral-medium">
141+
<Text className="mb-2 mt-2 text-neutral-default">
150142
Lorem ipsum dolor sit amet consectetur adipisicing elit.
151143
Mollitia dolorem doloribus laudantium magnam. Laboriosam!
152144
</Text>
153-
<Text className="mb-2 mt-2" variant="neutral-medium">
145+
<Text className="mb-2 mt-2 text-neutral-default">
154146
Lorem ipsum dolor sit amet consectetur adipisicing elit.
155147
</Text>
156-
<Text className="mb-2 mt-2" variant="neutral-medium">
148+
<Text className="mb-2 mt-2 text-neutral-default">
157149
Lorem ipsum dolor sit amet.
158150
</Text>
159151
</>

src/components/FieldNote/__snapshots__/FieldNote.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ exports[`<FieldNote /> WithText story renders snapshot 1`] = `
4444
class="max-w-xl"
4545
>
4646
<p
47-
class="text text--body mb-6"
47+
class="text text--body-md mb-6"
4848
>
4949
Here is a field note that involves:
5050
</p>

src/components/HorizontalStepper/HorizontalStepper.module.css

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
.horizontal-step__text {
9292
/* Hides text for smaller screen sizes. */
9393
display: none;
94+
font-weight: var(--eds-font-weight-bold);
95+
9496
@media all and (min-width: $eds-bp-md) {
9597
display: inline;
9698
/* Hides overflow text with ellipsis. */

src/components/HorizontalStepper/HorizontalStepper.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,7 @@ export const HorizontalStep = ({
192192
<Text
193193
as="span"
194194
className={styles['horizontal-step__text']}
195-
size="sm"
196-
variant="inherit"
197-
weight="bold"
195+
preset="body-sm"
198196
>
199197
{text}
200198
</Text>

0 commit comments

Comments
 (0)