Skip to content

Commit f1e7757

Browse files
authored
IBX-10151: [Storybook] Story to preview colors used in Design System
1 parent c4b748e commit f1e7757

File tree

7 files changed

+95
-5
lines changed

7 files changed

+95
-5
lines changed

packages/components/src/Accordion/Accordion.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const meta: Meta<typeof Accordion> = {
1010
parameters: {
1111
layout: 'padded',
1212
},
13-
tags: ['autodocs'],
13+
tags: ['autodocs', 'secondary'],
1414
argTypes: {
1515
initiallyExpanded: {
1616
control: 'boolean',

packages/components/src/Autosave/Autosave.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const meta: Meta<typeof Autosave> = {
77
parameters: {
88
layout: 'centered',
99
},
10-
tags: ['autodocs'],
10+
tags: ['autodocs', 'in-frequent'],
1111
argTypes: {
1212
isDarkMode: {
1313
control: 'boolean',

packages/components/src/Button/Button.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const meta: Meta<typeof Button> = {
1111
parameters: {
1212
layout: 'centered',
1313
},
14-
tags: ['autodocs'],
14+
tags: ['autodocs', 'foundation', 'buttons'],
1515
argTypes: {
1616
size: {
1717
control: 'select',

packages/components/src/Expander/Expander.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const meta: Meta<typeof Expander> = {
88
parameters: {
99
layout: 'centered',
1010
},
11-
tags: ['autodocs'],
11+
tags: ['autodocs', 'buttons'],
1212
argTypes: {
1313
hasIcon: {
1414
control: 'boolean',

packages/components/src/Icon/Icon.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const meta: Meta<typeof Icon> = {
88
parameters: {
99
layout: 'centered',
1010
},
11-
tags: ['autodocs'],
11+
tags: ['autodocs', 'foundation'],
1212
argTypes: {
1313
name: {
1414
control: 'text',

stories/Colors.stories.tsx

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import React, { useState } from 'react';
2+
3+
import type { Meta, StoryObj } from '@storybook/react';
4+
5+
import colors from '!!raw-loader!../packages/assets/src/scss/variables/_colors.scss';
6+
7+
const colorsList = colors
8+
.split('\n')
9+
.map((line: string) => {
10+
const [name, hex] = line.split(/:\s*|\s+/).map((item) => item.trim());
11+
12+
if (!name || !hex.startsWith('#')) {
13+
return undefined;
14+
}
15+
16+
return {
17+
name: name.replace('$color-', ''),
18+
hex,
19+
};
20+
})
21+
.filter((item) => item !== undefined);
22+
23+
// TODO: remove temporary styles when scss is available
24+
25+
const ColorsList = () => {
26+
const [searchValue, setSearchValue] = useState('');
27+
const iconsRows = colorsList
28+
.filter(({ name }) => searchValue === '' || name.includes(searchValue))
29+
.map(({ name, hex }) => {
30+
return (
31+
<tr className="ids-table__row" key={name}>
32+
<td className="ids-table__cell" style={{ padding: '10px' }}>
33+
{name}
34+
</td>
35+
<td className="ids-table__cell" style={{ padding: '10px' }}>
36+
{hex}
37+
</td>
38+
<td className="ids-table__cell" style={{ padding: 0 }}>
39+
<div
40+
style={{
41+
width: '40px',
42+
height: '40px',
43+
backgroundColor: hex,
44+
}}
45+
/>
46+
</td>
47+
</tr>
48+
);
49+
});
50+
51+
return (
52+
<div style={{ display: 'flex', justifyContent: 'center' }}>
53+
<div>
54+
<input
55+
className="ids-input ids-input--text"
56+
onChange={(event) => {
57+
setSearchValue(event.target.value);
58+
}}
59+
placeholder="Search colors..."
60+
style={{ marginBottom: '10px' }}
61+
type="text"
62+
/>
63+
<table border={1} className="ids-table">
64+
<tbody className="ids-table__body">{iconsRows}</tbody>
65+
</table>
66+
</div>
67+
</div>
68+
);
69+
};
70+
71+
const meta: Meta<typeof ColorsList> = {
72+
component: ColorsList,
73+
parameters: {
74+
layout: 'padded',
75+
},
76+
tags: [],
77+
};
78+
79+
export default meta;
80+
81+
type Story = StoryObj<typeof ColorsList>;
82+
83+
export const Default: Story = {
84+
name: 'Default',
85+
};

types/index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ declare module '../packages/assets/src/img/all-icons.json' {
77
const icons: string[];
88
export default icons;
99
};
10+
11+
declare module '!!raw-loader!../packages/assets/src/scss/variables/_colors.scss' {
12+
const value: string;
13+
export default value;
14+
};

0 commit comments

Comments
 (0)