Skip to content

Commit 9069372

Browse files
fix(eds-core-react): rename text-icon className to eds-typography-text-icon to prevent conflicts and support using typography component as link (#4233)
* chore(eds-core-react): remove old duplicate typography style that is not used * feat(eds-core-react): rename text-icon selector to eds-typography-text-icon so that the intend and scope is clearer * chore(eds-core-react): set the latest eds-tokens as peerDependency * feat(eds-core-react): support using Typography component as anchor fixes #4232
1 parent 26214af commit 9069372

10 files changed

Lines changed: 82 additions & 566 deletions

File tree

packages/eds-core-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"react": "^19",
9797
"react-dom": "^19",
9898
"styled-components": "^6",
99-
"@equinor/eds-tokens": "^2"
99+
"@equinor/eds-tokens": "^2.0.1"
100100
},
101101
"dependencies": {
102102
"@babel/runtime": "^7.28.4",

packages/eds-core-react/src/components/Typography/Typography.new.stories.tsx

Lines changed: 71 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,63 +107,71 @@ export const WithIcons: StoryFn = () => {
107107
baseline="grid"
108108
style={iconTextStyle}
109109
>
110-
<Icon name="save" className="text-icon" /> Extra small text with icon
110+
<Icon name="save" className="eds-typography-text-icon" /> Extra small
111+
text with icon
111112
</TypographyNext>
112113
<TypographyNext
113114
family="ui"
114115
size="sm"
115116
baseline="grid"
116117
style={iconTextStyle}
117118
>
118-
<Icon name="save" className="text-icon" /> Small text with icon
119+
<Icon name="save" className="eds-typography-text-icon" /> Small text
120+
with icon
119121
</TypographyNext>
120122
<TypographyNext
121123
family="ui"
122124
size="md"
123125
baseline="grid"
124126
style={iconTextStyle}
125127
>
126-
<Icon name="save" className="text-icon" /> Medium text with icon
128+
<Icon name="save" className="eds-typography-text-icon" /> Medium text
129+
with icon
127130
</TypographyNext>
128131
<TypographyNext
129132
family="ui"
130133
size="lg"
131134
baseline="grid"
132135
style={iconTextStyle}
133136
>
134-
<Icon name="save" className="text-icon" /> Large text with icon
137+
<Icon name="save" className="eds-typography-text-icon" /> Large text
138+
with icon
135139
</TypographyNext>
136140
<TypographyNext
137141
family="ui"
138142
size="xl"
139143
baseline="grid"
140144
style={iconTextStyle}
141145
>
142-
<Icon name="save" className="text-icon" /> Extra large text with icon
146+
<Icon name="save" className="eds-typography-text-icon" /> Extra large
147+
text with icon
143148
</TypographyNext>
144149
<TypographyNext
145150
family="ui"
146151
size="2xl"
147152
baseline="grid"
148153
style={iconTextStyle}
149154
>
150-
<Icon name="save" className="text-icon" /> 2XL heading text with icon
155+
<Icon name="save" className="eds-typography-text-icon" /> 2XL heading
156+
text with icon
151157
</TypographyNext>
152158
<TypographyNext
153159
family="ui"
154160
size="3xl"
155161
baseline="grid"
156162
style={iconTextStyle}
157163
>
158-
<Icon name="save" className="text-icon" /> 3XL heading text with icon
164+
<Icon name="save" className="eds-typography-text-icon" /> 3XL heading
165+
text with icon
159166
</TypographyNext>
160167
<TypographyNext
161168
family="ui"
162169
size="4xl"
163170
baseline="grid"
164171
style={iconTextStyle}
165172
>
166-
<Icon name="save" className="text-icon" /> 4XL heading text with icon
173+
<Icon name="save" className="eds-typography-text-icon" /> 4XL heading
174+
text with icon
167175
</TypographyNext>
168176
</div>
169177
)
@@ -173,7 +181,61 @@ WithIcons.parameters = {
173181
docs: {
174182
description: {
175183
story:
176-
"Icons can be used alongside TypographyNext by applying the `.text-icon` class. The icon will automatically adapt its size based on the typography component's font-size using CSS custom properties. The icon scales proportionally with the text size.",
184+
"Icons can be used alongside TypographyNext by applying the `.eds-typography-text-icon` class. The icon will automatically adapt its size based on the typography component's font-size using CSS custom properties. The icon scales proportionally with the text size.",
185+
},
186+
},
187+
}
188+
189+
export const AsLink: StoryFn = () => {
190+
return (
191+
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
192+
<TypographyNext
193+
as="a"
194+
href="https://eds.equinor.com"
195+
family="ui"
196+
size="md"
197+
baseline="grid"
198+
>
199+
Link to EDS documentation
200+
</TypographyNext>
201+
<TypographyNext
202+
as="a"
203+
href="https://eds.equinor.com"
204+
family="ui"
205+
size="lg"
206+
baseline="grid"
207+
>
208+
Large link text
209+
</TypographyNext>
210+
<TypographyNext
211+
as="a"
212+
href="https://eds.equinor.com"
213+
family="ui"
214+
size="sm"
215+
baseline="grid"
216+
>
217+
Small link text
218+
</TypographyNext>
219+
<TypographyNext
220+
as="a"
221+
href="https://eds.equinor.com"
222+
target="_blank"
223+
rel="noopener noreferrer"
224+
family="ui"
225+
size="md"
226+
baseline="grid"
227+
>
228+
External link (opens in new tab)
229+
</TypographyNext>
230+
</div>
231+
)
232+
}
233+
234+
AsLink.parameters = {
235+
docs: {
236+
description: {
237+
story:
238+
'TypographyNext can be used as a link by setting `as="a"` and providing an `href` prop. All standard anchor attributes are supported, such as `target` and `rel` for external links.',
177239
},
178240
},
179241
}

packages/eds-core-react/src/components/Typography/Typography.new.types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HTMLAttributes, ElementType } from 'react'
1+
import { HTMLAttributes, AnchorHTMLAttributes, ElementType } from 'react'
22
import {
33
FontFamily,
44
FontSize,
@@ -35,4 +35,4 @@ export type TypographyNextProps = {
3535
/** Semantic HTML element to render. Defaults to 'span' */
3636
as?: ElementType
3737
} & BaseTypographyProps &
38-
HTMLAttributes<HTMLElement>
38+
(HTMLAttributes<HTMLElement> | AnchorHTMLAttributes<HTMLAnchorElement>)

packages/eds-core-react/src/components/Typography/Typography.stories.shared.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export const IconTextRow = ({
316316
}) => (
317317
<ComparisonRowItem label={label}>
318318
<IconTextContainer className={`font-ui text-${size}`}>
319-
<Icon name={iconName} className="text-icon" />
319+
<Icon name={iconName} className="eds-typography-text-icon" />
320320
<span className="text-baseline-center">{text}</span>
321321
</IconTextContainer>
322322
</ComparisonRowItem>

0 commit comments

Comments
 (0)