Skip to content

Commit e173e1d

Browse files
authored
refactor: classnames (#5857)
* refactor: classnames * feat: classname wip * feat: clean classnames
1 parent 06364ab commit e173e1d

File tree

138 files changed

+1024
-743
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+1024
-743
lines changed

.changeset/funny-steaks-prove.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ultraviolet/themes": patch
3+
---
4+
5+
New function `cn` to generate clean classnames

.changeset/great-symbols-burn.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@ultraviolet/illustrations": patch
3+
"@ultraviolet/icons": patch
4+
"@ultraviolet/form": patch
5+
"@ultraviolet/plus": patch
6+
"@ultraviolet/ui": patch
7+
---
8+
9+
Use `cn` function to generate clean classnames
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
22
"compilerOptions": {
33
"target": "ES2017",
4-
"lib": ["dom", "dom.iterable", "esnext"],
4+
"lib": [
5+
"dom",
6+
"dom.iterable",
7+
"esnext"
8+
],
59
"allowJs": true,
610
"skipLibCheck": true,
711
"strict": true,
@@ -11,22 +15,27 @@
1115
"moduleResolution": "bundler",
1216
"resolveJsonModule": true,
1317
"isolatedModules": true,
14-
"jsx": "preserve",
18+
"jsx": "react-jsx",
1519
"incremental": true,
1620
"plugins": [
1721
{
1822
"name": "next"
1923
}
2024
],
2125
"paths": {
22-
"@/*": ["./*"]
26+
"@/*": [
27+
"./*"
28+
]
2329
}
2430
},
2531
"include": [
2632
"next-env.d.ts",
2733
"**/*.ts",
2834
"**/*.tsx",
2935
".next/types/**/*.ts",
36+
".next/dev/types/**/*.ts"
3037
],
31-
"exclude": ["node_modules"]
38+
"exclude": [
39+
"node_modules"
40+
]
3241
}

packages/form/src/components/DateInputField/__tests__/__snapshots__/index.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ exports[`dateInputField > should clear field 1`] = `
6161
</div>
6262
</div>
6363
<div
64-
class="uv_705z6f0 uv_9rlyg91 uv_w40vpo4 null"
64+
class="uv_705z6f0 uv_9rlyg91 uv_w40vpo4"
6565
id="_r_3k_"
6666
role="dialog"
6767
style="--uv_ozfz3c0: -5px; --uv_ozfz3c1: 0px; --uv_ozfz3c2: rotate(180deg); --uv_ozfz3c4: translate3d(0px, 4px, 0); --uv_ozfz3c5: 0ms; --uv_ozfz3c6: translate3d(0px, 4px, 0); --uv_ozfz3c7: 16.5rem; opacity: 1;"

packages/form/src/components/SelectInputField/__tests__/__snapshots__/index.test.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ exports[`selectInputField > should display right value on grouped options 1`] =
5757
</div>
5858
</div>
5959
<div
60-
class="uv_5kpm8k0 uv_w40vpo4 null"
60+
class="uv_5kpm8k0 uv_w40vpo4"
6161
id="_r_l_"
6262
role="dialog"
6363
style="--uv_ozfz3c0: -5px; --uv_ozfz3c1: 0px; --uv_ozfz3c2: rotate(180deg); --uv_ozfz3c4: translate3d(0px, 4px, 0); --uv_ozfz3c5: 0ms; --uv_ozfz3c6: translate3d(0px, 4px, 0); --uv_ozfz3c7: 100%; opacity: 1;"
@@ -81,7 +81,7 @@ exports[`selectInputField > should display right value on grouped options 1`] =
8181
class="uv_5kpm8k5"
8282
>
8383
<button
84-
class=" uv_5kpm8k3"
84+
class="uv_5kpm8k3"
8585
data-selectgroup="false"
8686
data-testid="group-0"
8787
role="group"
@@ -219,7 +219,7 @@ exports[`selectInputField > should display right value on grouped options 1`] =
219219
class="uv_5kpm8k5"
220220
>
221221
<button
222-
class=" uv_5kpm8k3"
222+
class="uv_5kpm8k3"
223223
data-selectgroup="false"
224224
data-testid="group-1"
225225
role="group"

packages/form/src/components/SelectableCardOptionGroupField/__tests__/__snapshots__/index.test.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ exports[`selectableCardOptionGroupField > should render correctly 1`] = `
118118
</div>
119119
<div
120120
aria-label="selectable-card-option"
121-
class="uv_12n1yvr4 uv_uf6pag0"
121+
class="uv_12n1yvr4 uv_uf6pag0"
122122
>
123123
<div
124124
aria-controls="_r_7_"
@@ -258,7 +258,7 @@ exports[`selectableCardOptionGroupField > should render correctly 1`] = `
258258
</div>
259259
<div
260260
aria-label="selectable-card-option"
261-
class="uv_12n1yvr4 uv_uf6pag0"
261+
class="uv_12n1yvr4 uv_uf6pag0"
262262
>
263263
<div
264264
aria-controls="_r_h_"
@@ -398,7 +398,7 @@ exports[`selectableCardOptionGroupField > should render correctly 1`] = `
398398
</div>
399399
<div
400400
aria-label="selectable-card-option"
401-
class="uv_12n1yvr4 uv_uf6pag0"
401+
class="uv_12n1yvr4 uv_uf6pag0"
402402
>
403403
<div
404404
aria-controls="_r_r_"

packages/form/src/components/UnitInputField/__tests__/__snapshots__/index.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ exports[`unitInputField > should handles onChange and selection 1`] = `
2828
</span>
2929
</div>
3030
<div
31-
class="uv_gwf0fle uv_gwf0fla uv_gwf0fl5 uv_x6hyh50 "
31+
class="uv_gwf0fle uv_gwf0fla uv_gwf0fl5 uv_x6hyh50"
3232
style="--uv_3mg8xe0: 1fr auto; --uv_3mg8xe1: 1fr auto; --uv_3mg8xe2: 1fr auto; --uv_3mg8xe3: 1fr auto; --uv_3mg8xe4: 1fr auto; --uv_3mg8xe5: 1fr auto;"
3333
>
3434
<div
@@ -131,7 +131,7 @@ exports[`unitInputField > should render correctly 1`] = `
131131
Test
132132
</label>
133133
<div
134-
class="uv_gwf0fle uv_gwf0fla uv_gwf0fl5 uv_x6hyh50 "
134+
class="uv_gwf0fle uv_gwf0fla uv_gwf0fl5 uv_x6hyh50"
135135
style="--uv_3mg8xe0: 1fr auto; --uv_3mg8xe1: 1fr auto; --uv_3mg8xe2: 1fr auto; --uv_3mg8xe3: 1fr auto; --uv_3mg8xe4: 1fr auto; --uv_3mg8xe5: 1fr auto;"
136136
>
137137
<div

packages/icons/src/components/CategoryIcon/Icon.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client'
22

3+
import { cn } from '@ultraviolet/themes'
34
import type { CSSProperties, ReactNode } from 'react'
45
import type { VARIANTS } from './style.css'
56
import { categoryIcon } from './style.css'
@@ -27,7 +28,7 @@ export const Icon = ({
2728

2829
return (
2930
<svg
30-
className={`${className ? `${className} ` : ''}${categoryIcon[computedVariant]}`}
31+
className={cn(className, categoryIcon[computedVariant])}
3132
height="20"
3233
style={style}
3334
viewBox="0 0 20 20"

packages/icons/src/components/Flags/Icon.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client'
22

3+
import { cn } from '@ultraviolet/themes'
34
import type { ReactNode } from 'react'
45
import type { SIZES } from './constant'
56
import { flag } from './style.css'
@@ -15,10 +16,7 @@ export type IconProps = {
1516
* Logo component is used to render a set of flags. Their style cannot be changed
1617
*/
1718
export const Icon = ({ size = 'medium', className, children }: IconProps) => (
18-
<svg
19-
className={`${className ? `${className} ` : ''}${flag[size]}`}
20-
viewBox="0 0 24 24"
21-
>
19+
<svg className={cn(className, flag[size])} viewBox="0 0 24 24">
2220
{children}
2321
</svg>
2422
)

packages/icons/src/components/Icon/Icon.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client'
22

3+
import { cn } from '@ultraviolet/themes'
34
import type { ReactNode, SVGProps } from 'react'
45
import { forwardRef } from 'react'
56
import type { PROMINENCES, SENTIMENTS, SIZES } from './constants'
@@ -47,7 +48,7 @@ export const Icon = forwardRef<SVGSVGElement, IconProps>(
4748
) => (
4849
<svg
4950
aria-label={ariaLabel}
50-
className={`${className ? `${className} ` : ''}${icon({ disabled, prominence, sentiment, size })}`}
51+
className={cn(className, icon({ disabled, prominence, sentiment, size }))}
5152
cursor={cursor}
5253
data-testid={dataTestId}
5354
ref={ref}

0 commit comments

Comments
 (0)