Skip to content

Commit 729ef8b

Browse files
committed
refactor(theme-generator): replace culori with @ant-design/colors
1 parent 0c32a09 commit 729ef8b

File tree

17 files changed

+150
-160
lines changed

17 files changed

+150
-160
lines changed

packages/storybook/.storybook/main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ const config: StorybookConfig = {
3434
`,
3535
staticDirs: [
3636
'../assets',
37-
{ from: '../../themes/dist', to: '/themes' },
3837
...getCodeEditorStaticDirs(__filename)
3938
],
4039
stories: [

packages/storybook/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
"start": "yarn generate:versions && storybook dev -p 6006 --no-open"
1212
},
1313
"dependencies": {
14+
"@ant-design/colors": "7.1.0",
1415
"@ark-ui/react": "5.25.1",
1516
"@ovhcloud/ods-react": "19.2.1",
1617
"@ovhcloud/ods-themes": "19.2.1",
1718
"classnames": "2.5.1",
18-
"culori": "4.0.2",
1919
"lz-string": "1.5.0",
2020
"prettier": "3.6.2",
2121
"react": "18.2.0",
@@ -30,7 +30,6 @@
3030
"@storybook/react": "8.6.12",
3131
"@storybook/react-vite": "8.6.12",
3232
"@storybook/types": "8.6.12",
33-
"@types/culori": "4.0.1",
3433
"custom-elements-manifest": "1.0.0",
3534
"node-fetch": "2.7.0",
3635
"prop-types": "15.8.1",

packages/storybook/src/components/themeGenerator/ThemeGeneratorColorPicker/ThemeGeneratorColorPicker.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@ const formatColorValue = (colorValue: any): string => {
2828
};
2929

3030
const parseColorWithRoundedAlpha = (colorString: string) => {
31-
const color = parseColor(colorString);
32-
const alpha = color.getChannelValue('alpha');
33-
const roundedAlpha = Math.round(alpha * 100) / 100;
34-
return color.withChannelValue('alpha', roundedAlpha);
31+
try {
32+
const color = parseColor(colorString.startsWith('var(') ? '#000000' : colorString);
33+
const alpha = color.getChannelValue('alpha');
34+
const roundedAlpha = Math.round(alpha * 100) / 100;
35+
return color.withChannelValue('alpha', roundedAlpha);
36+
} catch {
37+
return parseColor('#000000');
38+
}
3539
};
3640

3741
const ThemeGeneratorColorPicker = ({
@@ -85,8 +89,14 @@ const ThemeGeneratorColorPicker = ({
8589
{label}
8690
</ColorPicker.Label>
8791
)}
88-
8992
<ColorPicker.Control className={styles['theme-generator-color-picker__control']}>
93+
<ColorPicker.ChannelInput
94+
asChild
95+
channel="hex"
96+
onKeyDown={(e) => e.stopPropagation()}
97+
>
98+
<Input type="text" />
99+
</ColorPicker.ChannelInput>
90100
<ColorPicker.Trigger className={styles['theme-generator-color-picker__control__trigger']}>
91101
<ColorPicker.ValueSwatch className={styles['theme-generator-color-picker__control__trigger__swatch']} />
92102
</ColorPicker.Trigger>

packages/storybook/src/components/themeGenerator/ThemeGeneratorColorPicker/index.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/storybook/src/components/themeGenerator/ThemeGeneratorColorPicker/themeGeneratorColorPicker.module.css

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.theme-generator-color-picker {
22
display: flex;
3-
gap: 0.5rem;
3+
gap: 8px;
44
align-items: center;
55
justify-content: space-between;
66
width: 100%;
@@ -28,7 +28,7 @@
2828
}
2929

3030
.theme-generator-color-picker__control__trigger:disabled {
31-
opacity: 0.5;
31+
opacity: 1;
3232
cursor: not-allowed;
3333
}
3434

@@ -128,4 +128,3 @@
128128
gap: 8px;
129129
min-width: 200px;
130130
}
131-

packages/storybook/src/components/themeGenerator/ThemeGeneratorTreeView/ThemeGeneratorTreeView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Spinner, Text, TreeView, TreeViewNode, TreeViewNodes, SPINNER_SIZE, TEXT_PRESET } from '@ovhcloud/ods-react';
22
import React, { useMemo } from 'react';
33
import { categorizeCssVariables } from '../themeVariableUtils';
4-
import { ThemeGeneratorColorPicker } from '../ThemeGeneratorColorPicker';
4+
import { ThemeGeneratorColorPicker } from '../ThemeGeneratorColorPicker/ThemeGeneratorColorPicker';
55
import styles from './themeGeneratorTreeView.module.css';
66

77
interface TreeItem {

packages/storybook/src/components/themeGenerator/ThemeGeneratorTreeView/themeGeneratorTreeView.module.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
.theme-generator-tree-view__loading {
88
display: flex;
9-
align-items: center;
109
gap: 8px;
10+
align-items: center;
1111
margin: 16px;
1212
}
1313

1414
.theme-generator-tree-view__item {
1515
display: flex;
16-
gap: 0.5rem;
16+
gap: 8px;
1717
align-items: center;
1818
justify-content: space-between;
1919
width: 100%;

packages/storybook/src/components/themeGenerator/themeGenerator.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
}
5353

5454
.theme-generator__container__resize--vertical {
55-
margin: 2px 16px ;
55+
margin: 2px 16px;
5656
height: 4px;
5757
min-height: auto;
5858
}

packages/storybook/src/components/themeGenerator/themeGeneratorJSONModal/ThemeGeneratorJSONModal.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,3 @@ const ThemeGeneratorJSONModal = ({ open, variables, onClose, onReplace }: ThemeG
8282
};
8383

8484
export { ThemeGeneratorJSONModal };
85-
86-

packages/storybook/src/components/themeGenerator/themeGeneratorJSONModal/themeGeneratorJSONModal.module.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,3 @@
2525
.theme-generator-json-modal__error {
2626
color: var(--ods-color-critical-600);
2727
}
28-
29-

0 commit comments

Comments
 (0)