Skip to content

Commit e1e4f16

Browse files
committed
🎨 apply default text color in comp not in variants
1 parent 87c5662 commit e1e4f16

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

web/core/Typography/Typography.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/* eslint-disable @typescript-eslint/ban-ts-comment */
2-
import { forwardRef, ElementType, HTMLAttributes, AnchorHTMLAttributes } from 'react'
3-
import { TypographyGroups, TypographyVariants, quickVariants, variants } from './variants'
4-
import { OverridableComponent } from '@equinor/eds-utils'
2+
3+
import type { OverridableComponent } from '@equinor/eds-utils'
4+
import { type AnchorHTMLAttributes, type ElementType, forwardRef, type HTMLAttributes } from 'react'
55
import envisTwMerge from '../../twMerge'
6+
import { quickVariants, type TypographyGroups, type TypographyVariants, variants } from './variants'
67

78
const getElementType = (variant: string, link: boolean): ElementType => {
89
if (link) {
@@ -25,12 +26,12 @@ const getElementType = (variant: string, link: boolean): ElementType => {
2526

2627
const findTypography = (variantName: TypographyVariants, group?: TypographyGroups): string => {
2728
// For quick use when using paragraphs and headings we can skip group
28-
//@ts-ignore
29+
//@ts-expect-error
2930
if (!group && quickVariants[variantName]) {
30-
//@ts-ignore
31+
//@ts-expect-error
3132
return quickVariants[variantName] as string
3233
}
33-
//@ts-ignores
34+
//@ts-expect-errors
3435
return (variants[group] as unknown)[variantName] as string
3536
}
3637

@@ -79,7 +80,11 @@ export const Typography: OverridableComponent<TypographyProps, HTMLElement> = fo
7980
const TypographyTag = as ?? (`p` as React.ElementType)
8081

8182
return (
82-
<TypographyTag {...rest} ref={ref} className={envisTwMerge(typography, className)}>
83+
<TypographyTag
84+
{...rest}
85+
ref={ref}
86+
className={envisTwMerge('text-slate-80 dark:text-white-100', typography, className)}
87+
>
8388
{children}
8489
</TypographyTag>
8590
)

web/core/Typography/variants.ts

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
const variants = {
22
heading: {
3-
h1: 'text-slate-80 dark:text-white-100 text-3xl leading-earthy font-normal pb-11 my-0',
4-
h2: 'text-slate-80 dark:text-white-100 text-2xl leading-cloudy font-normal pb-8 my-0',
5-
h3: 'text-slate-80 dark:text-white-100 text-xl leading-inherit font-normal pb-0 my-0',
6-
h4: 'text-slate-80 dark:text-white-100 text-lg leading-inherit font-normal pb-0',
7-
h5: 'text-slate-80 dark:text-white-100 text-md leading-inherit font-normal pb-0',
8-
h6: 'text-slate-80 dark:text-white-100 text-base leading-inherit font-normal pb-0',
9-
h7: 'text-slate-80 dark:text-white-100 text-xs leading-earthy font-normal pb-0',
10-
xs: 'text-slate-80 dark:text-white-100 text-xs leading-earthy font-normal',
11-
sm: 'text-slate-80 dark:text-white-100 text-sm leading-inherit font-normal',
12-
base: 'text-slate-80 dark:text-white-100 text-base leading-inherit font-normal',
13-
md: 'text-slate-80 dark:text-white-100 text-md leading-inherit font-normal',
14-
lg: 'text-slate-80 dark:text-white-100 text-lg leading-inherit font-normal',
15-
xl: 'text-slate-80 dark:text-white-100 text-xl leading-inherit font-normal',
16-
'2xl': 'text-slate-80 dark:text-white-100 text-2xl leading-cloudy font-normal',
17-
'3xl': 'text-slate-80 dark:text-white-100 text-3xl leading-earthy font-normal',
18-
'4xl': 'text-slate-80 dark:text-white-100 text-4xl leading-cloudy font-normal',
19-
'5xl': 'text-slate-80 dark:text-white-100 text-5xl leading-cloudy font-normal',
20-
'8xl':
21-
'text-slate-80 dark:text-white-100 text-5xl lg:text-6xl 2xl:text-8xl leading-cloudy lg:leading-cloudy 2xl:leading-cloudy font-normal',
3+
h1: ' text-3xl leading-earthy font-normal pb-11 my-0',
4+
h2: ' text-2xl leading-cloudy font-normal pb-8 my-0',
5+
h3: ' text-xl leading-inherit font-normal pb-0 my-0',
6+
h4: ' text-lg leading-inherit font-normal pb-0',
7+
h5: ' text-md leading-inherit font-normal pb-0',
8+
h6: ' text-base leading-inherit font-normal pb-0',
9+
h7: ' text-xs leading-earthy font-normal pb-0',
10+
xs: ' text-xs leading-earthy font-normal',
11+
sm: ' text-sm leading-inherit font-normal',
12+
base: ' text-base leading-inherit font-normal',
13+
md: ' text-md leading-inherit font-normal',
14+
lg: ' text-lg leading-inherit font-normal',
15+
xl: ' text-xl leading-inherit font-normal',
16+
'2xl': ' text-2xl leading-cloudy font-normal',
17+
'3xl': ' text-3xl leading-earthy font-normal',
18+
'4xl': ' text-4xl leading-cloudy font-normal',
19+
'5xl': ' text-5xl leading-cloudy font-normal',
20+
'8xl': ' text-5xl lg:text-6xl 2xl:text-8xl leading-cloudy lg:leading-cloudy 2xl:leading-cloudy font-normal',
2221
},
2322
display: {
2423
h1_base: 'text-4xl leading-tight tracking-[var(--tracking-display)] pb-6 lg:pb-12',
@@ -31,8 +30,8 @@ const variants = {
3130
paragraph: {
3231
ingress: '',
3332
caption: '',
34-
overline: 'text-md text-slate-80 dark:text-white-100',
35-
body: 'text-base font-normal text-slate-80 dark:text-white-100',
33+
overline: 'text-md ',
34+
body: 'text-base font-normal ',
3635
},
3736
plain: {
3837
div: '',

0 commit comments

Comments
 (0)