-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path.refresh_icon_story.sh
executable file
·63 lines (45 loc) · 1.38 KB
/
.refresh_icon_story.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# This script is used to refresh the icon storybook
# Get storybook code
# Go to the src directory
cd src
# Remove the old storybook
rm -rf ./stories/icons && mkdir ./stories/icons
# Get icons list
icons=$(awk 'BEGIN{ORS="\n"} {print $5}' ./icons/index.ts)
for icon in $icons
do
echo "Creating story for $icon"
# Create a new story for the icon
echo "import type { Meta, StoryObj } from '@storybook/react'
import { $icon } from '@/icons'
const meta: Meta<typeof $icon> = {
component: $icon,
}
export default meta
type Story = StoryObj<typeof $icon>
export const Default: Story = {}" > "./stories/icons/$icon.stories.tsx"
done
# Get sub directories
sub_dirs=$(cd ./icons &&ls -dF */ | tr -d '/')
echo "Sub directories: $sub_dirs"
for sub_dir in $sub_dirs
do
# Make a new directory for the sub directory
mkdir ./stories/icons/$sub_dir
# Get icons list
icons=$(awk 'BEGIN{ORS="\n"} {print $5}' ./icons/$sub_dir/index.ts)
for icon in $icons
do
echo "Creating story for $icon"
# Create a new story for the icon
echo "import type { Meta, StoryObj } from '@storybook/react'
import { $icon } from '@/icons/$sub_dir'
const meta: Meta<typeof $icon> = {
component: $icon,
}
export default meta
type Story = StoryObj<typeof $icon>
export const Default: Story = {}" > "./stories/icons/$sub_dir/$icon.stories.tsx"
done
done