Skip to content

Commit ea19590

Browse files
refactor(eds-core-react): migrate Banner.Message and Chip label off TypographyNext (#4984)
Removes the TypographyNext wrapper from both components and moves typography directly into their CSS using --eds-typography-* tokens. Banner.Message now renders a plain <p> with font-family, font-size, and line-height set in banner.css. The old baseline="center" trimming was unintentional for a wrapping paragraph and has not been carried forward. Chip replaces TypographyNext and the data-font-family/data-font-size/ data-space-proportions attributes with explicit token overrides in chip.css, preserving squished spacing, md icon size, and md gap-horizontal so density responsiveness is fully retained. Closes #4835 Closes #4836
1 parent a6473d6 commit ea19590

4 files changed

Lines changed: 27 additions & 33 deletions

File tree

packages/eds-core-react/src/components/next/Banner/Banner.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { forwardRef } from 'react'
22
import { close } from '@equinor/eds-icons'
3-
import { TypographyNext } from '../../Typography'
43
import { Button } from '../Button'
54
import { Icon } from '../Icon'
65
import type {
@@ -27,19 +26,13 @@ const BannerIcon = forwardRef<HTMLSpanElement, BannerIconProps>(
2726
const BannerMessage = forwardRef<HTMLParagraphElement, BannerMessageProps>(
2827
function BannerMessage({ className, children, ...rest }, ref) {
2928
return (
30-
<TypographyNext
29+
<p
3130
ref={ref}
32-
as="p"
33-
family="ui"
34-
size="md"
35-
baseline="center"
36-
lineHeight="default"
37-
tracking="normal"
3831
className={['eds-banner__message', className].filter(Boolean).join(' ')}
3932
{...rest}
4033
>
4134
{children}
42-
</TypographyNext>
35+
</p>
4336
)
4437
},
4538
)

packages/eds-core-react/src/components/next/Banner/banner.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,18 @@
3636

3737
.eds-banner__message {
3838
flex: 1;
39+
3940
min-width: 0;
4041
margin: 0;
42+
43+
font-family: var(--eds-typography-ui-body-font-family);
44+
font-size: var(--eds-typography-ui-body-md-font-size);
45+
line-height: var(--eds-typography-ui-body-md-line-height-default);
4146
color: var(--eds-color-text-strong);
47+
48+
@supports (text-box: trim-both cap alphabetic) {
49+
text-box: trim-both cap alphabetic;
50+
}
4251
}
4352

4453
.eds-banner__actions {

packages/eds-core-react/src/components/next/Chip/Chip.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
} from '@equinor/eds-icons'
88
import type { ChipProps } from './Chip.types'
99
import { Icon } from '../Icon'
10-
import { TypographyNext } from '../../Typography'
1110

1211
export const Chip = forwardRef<HTMLButtonElement, ChipProps>(function Chip(
1312
{
@@ -51,10 +50,7 @@ export const Chip = forwardRef<HTMLButtonElement, ChipProps>(function Chip(
5150
className={classes}
5251
data-variant={variant}
5352
data-color-appearance={tone}
54-
data-font-family="ui"
55-
data-font-size="md"
5653
data-selectable-space="sm"
57-
data-space-proportions="squished"
5854
data-selected={selected || undefined}
5955
aria-pressed={toggleable ? selected : undefined}
6056
aria-expanded={dropdown ? selected : undefined}
@@ -65,16 +61,7 @@ export const Chip = forwardRef<HTMLButtonElement, ChipProps>(function Chip(
6561
{selected && !dropdown && !deletable && (
6662
<Icon data={check} aria-hidden className="icon" />
6763
)}
68-
<TypographyNext
69-
as="span"
70-
className="label"
71-
family="ui"
72-
size="md"
73-
lineHeight="squished"
74-
baseline="center"
75-
>
76-
{children}
77-
</TypographyNext>
64+
<span className="label">{children}</span>
7865
{deletable && <Icon data={close} title="Remove" className="icon" />}
7966
{!deletable && dropdown && (
8067
<Icon

packages/eds-core-react/src/components/next/Chip/chip.css

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
@layer eds-components {
22
.eds-chip {
3+
/* Replaces data-space-proportions="squished" — squished vertical spacing for sm selectable space */
4+
--eds-spacing-proportions-sm-vertical: var(
5+
--eds-spacing-inset-sm-vertical-squished
6+
);
7+
8+
/* Replaces data-font-size="md" — sets icon size and gap tokens for md context */
9+
--eds-typography-icon-size: var(--eds-sizing-icon-md);
10+
--eds-typography-gap-horizontal: var(--eds-spacing-icon-md-gap-horizontal);
11+
312
/* Typography metrics — same compensation pattern as Button */
13+
--_label-font-size: var(--eds-typography-ui-body-md-font-size);
414
--_label-line-height: var(--eds-typography-ui-body-md-line-height-squished);
515
--_label-height: round(1cap, 4px); /* Figma has a cap-rounded value but it is not exposed as a CSS token; 1cap gives the same result (Inter metrics + 4px grid) */
16+
--_font-family: var(--eds-typography-ui-body-font-family);
617
--_padding-block: var(--eds-selectable-space-vertical);
18+
719
/*
820
* Reduce block padding by half the line-height overflow so the visual
921
* height equals (padding × 2 + cap-height) instead of (padding × 2 + line-height).
@@ -28,7 +40,9 @@
2840
border: none;
2941
border-radius: var(--eds-spacing-border-radius-pill, 100vmax);
3042

31-
font: inherit;
43+
font-family: var(--_font-family);
44+
font-size: var(--_label-font-size);
45+
line-height: var(--_label-line-height);
3246
color: inherit;
3347

3448
transition:
@@ -105,15 +119,6 @@
105119
}
106120
}
107121

108-
/*
109-
* Outside @layer to override typography.css [data-font-family] { display: block }.
110-
* data-font-family/data-font-size on the chip container establishes the typography
111-
* context for gap and icon sizing tokens.
112-
*/
113-
.eds-chip {
114-
display: inline-flex;
115-
}
116-
117122
/*
118123
* Label needs inline-flex to center custom icons with text.
119124
* text-box: normal disables baseline trimming — chip handles sizing via

0 commit comments

Comments
 (0)