@apify/ui-library 1.97.2 → 1.98.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/action_link.stories.d.ts +50 -0
- package/dist/src/components/action_link.stories.d.ts.map +1 -0
- package/dist/src/components/action_link.stories.js +129 -0
- package/dist/src/components/action_link.stories.js.map +1 -0
- package/dist/src/components/actor_template_card.stories.d.ts +49 -0
- package/dist/src/components/actor_template_card.stories.d.ts.map +1 -0
- package/dist/src/components/actor_template_card.stories.js +154 -0
- package/dist/src/components/actor_template_card.stories.js.map +1 -0
- package/dist/src/components/banner.stories.d.ts +53 -0
- package/dist/src/components/banner.stories.d.ts.map +1 -0
- package/dist/src/components/banner.stories.js +132 -0
- package/dist/src/components/banner.stories.js.map +1 -0
- package/dist/src/components/blog_article.stories.d.ts +33 -0
- package/dist/src/components/blog_article.stories.d.ts.map +1 -0
- package/dist/src/components/blog_article.stories.js +92 -0
- package/dist/src/components/blog_article.stories.js.map +1 -0
- package/dist/src/components/chip.stories.d.ts +98 -0
- package/dist/src/components/chip.stories.d.ts.map +1 -0
- package/dist/src/components/chip.stories.js +251 -0
- package/dist/src/components/chip.stories.js.map +1 -0
- package/dist/src/components/code/code_block/code_block_with_tabs.d.ts +1 -1
- package/dist/src/components/code/code_block/code_block_with_tabs.d.ts.map +1 -1
- package/dist/src/components/code/code_block/code_block_with_tabs.stories.d.ts +23 -0
- package/dist/src/components/code/code_block/code_block_with_tabs.stories.d.ts.map +1 -0
- package/dist/src/components/code/code_block/code_block_with_tabs.stories.js +63 -0
- package/dist/src/components/code/code_block/code_block_with_tabs.stories.js.map +1 -0
- package/dist/src/components/code/inline_code/inline_code.stories.d.ts +16 -0
- package/dist/src/components/code/inline_code/inline_code.stories.d.ts.map +1 -0
- package/dist/src/components/code/inline_code/inline_code.stories.js +47 -0
- package/dist/src/components/code/inline_code/inline_code.stories.js.map +1 -0
- package/dist/src/components/code/one_line_code/one_line_code.stories.d.ts +16 -0
- package/dist/src/components/code/one_line_code/one_line_code.stories.d.ts.map +1 -0
- package/dist/src/components/code/one_line_code/one_line_code.stories.js +81 -0
- package/dist/src/components/code/one_line_code/one_line_code.stories.js.map +1 -0
- package/dist/src/components/color_wheel_gradient.stories.d.ts +38 -0
- package/dist/src/components/color_wheel_gradient.stories.d.ts.map +1 -0
- package/dist/src/components/color_wheel_gradient.stories.js +126 -0
- package/dist/src/components/color_wheel_gradient.stories.js.map +1 -0
- package/dist/src/components/link.stories.d.ts +22 -0
- package/dist/src/components/link.stories.d.ts.map +1 -0
- package/dist/src/components/link.stories.js +112 -0
- package/dist/src/components/link.stories.js.map +1 -0
- package/dist/src/components/rating.stories.d.ts +32 -0
- package/dist/src/components/rating.stories.d.ts.map +1 -0
- package/dist/src/components/rating.stories.js +95 -0
- package/dist/src/components/rating.stories.js.map +1 -0
- package/dist/src/components/simple_markdown/simple_markdown.d.ts +2 -2
- package/dist/src/components/simple_markdown/simple_markdown.d.ts.map +1 -1
- package/dist/src/components/simple_markdown/simple_markdown.stories.d.ts +8 -0
- package/dist/src/components/simple_markdown/simple_markdown.stories.d.ts.map +1 -0
- package/dist/src/components/simple_markdown/simple_markdown.stories.js +60 -0
- package/dist/src/components/simple_markdown/simple_markdown.stories.js.map +1 -0
- package/dist/src/components/tabs/tab.stories.d.ts.map +1 -1
- package/dist/src/components/tabs/tab.stories.js +1 -0
- package/dist/src/components/tabs/tab.stories.js.map +1 -1
- package/dist/src/components/text/text.stories.d.ts +13 -0
- package/dist/src/components/text/text.stories.d.ts.map +1 -0
- package/dist/src/components/text/text.stories.js +14 -0
- package/dist/src/components/text/text.stories.js.map +1 -0
- package/dist/src/design_system/tokens/radiuses.d.ts +2 -0
- package/dist/src/design_system/tokens/radiuses.d.ts.map +1 -1
- package/dist/src/design_system/tokens/radiuses.js +2 -0
- package/dist/src/design_system/tokens/radiuses.js.map +1 -1
- package/dist/src/design_system/tokens/radiuses.stories.d.ts +6 -0
- package/dist/src/design_system/tokens/radiuses.stories.d.ts.map +1 -0
- package/dist/src/design_system/tokens/radiuses.stories.js +30 -0
- package/dist/src/design_system/tokens/radiuses.stories.js.map +1 -0
- package/dist/src/design_system/tokens/shadows.stories.d.ts +6 -0
- package/dist/src/design_system/tokens/shadows.stories.d.ts.map +1 -0
- package/dist/src/design_system/tokens/shadows.stories.js +37 -0
- package/dist/src/design_system/tokens/shadows.stories.js.map +1 -0
- package/dist/src/design_system/tokens/spaces.stories.d.ts +10 -0
- package/dist/src/design_system/tokens/spaces.stories.d.ts.map +1 -0
- package/dist/src/design_system/tokens/spaces.stories.js +92 -0
- package/dist/src/design_system/tokens/spaces.stories.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/components/action_link.stories.tsx +145 -0
- package/src/components/actor_template_card.stories.tsx +179 -0
- package/src/components/badge.doc.mdx +35 -0
- package/src/components/banner.stories.tsx +256 -0
- package/src/components/blog_article.stories.tsx +133 -0
- package/src/components/chip.stories.tsx +301 -0
- package/src/components/code/code_block/code_block.stories.jsx +133 -0
- package/src/components/code/code_block/code_block_with_tabs.stories.tsx +81 -0
- package/src/components/code/code_block/code_block_with_tabs.tsx +1 -1
- package/src/components/code/inline_code/inline_code.stories.tsx +88 -0
- package/src/components/code/one_line_code/one_line_code.stories.tsx +173 -0
- package/src/components/color_wheel_gradient.stories.tsx +157 -0
- package/src/components/floating/tooltip.stories.jsx +0 -1
- package/src/components/link.stories.tsx +127 -0
- package/src/components/message.stories.jsx +116 -0
- package/src/components/rating.stories.tsx +166 -0
- package/src/components/simple_markdown/simple_markdown.stories.tsx +71 -0
- package/src/components/simple_markdown/simple_markdown.tsx +1 -1
- package/src/components/tabs/tab.stories.tsx +1 -0
- package/src/components/tag.doc.mdx +38 -0
- package/src/components/text/text.stories.tsx +61 -0
- package/src/design_system/tokens/radiuses.doc.mdx +12 -0
- package/src/design_system/tokens/radiuses.stories.tsx +49 -0
- package/src/design_system/tokens/radiuses.ts +2 -0
- package/src/design_system/tokens/shadows.doc.mdx +16 -0
- package/src/design_system/tokens/shadows.stories.tsx +58 -0
- package/src/design_system/tokens/spaces.doc.mdx +18 -0
- package/src/design_system/tokens/spaces.stories.tsx +131 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
|
+
|
|
4
|
+
import { BlogArticle } from './blog_article.js';
|
|
5
|
+
|
|
6
|
+
type BlogArticleProps = ComponentProps<typeof BlogArticle>;
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'UI-Library/BlogArticle',
|
|
10
|
+
component: BlogArticle,
|
|
11
|
+
argTypes: {
|
|
12
|
+
imageNode: {
|
|
13
|
+
control: 'object',
|
|
14
|
+
description: 'React node representing the article image or media.',
|
|
15
|
+
},
|
|
16
|
+
title: {
|
|
17
|
+
control: 'text',
|
|
18
|
+
description: 'Title of the blog article.',
|
|
19
|
+
},
|
|
20
|
+
ctaTitle: {
|
|
21
|
+
control: 'text',
|
|
22
|
+
description: 'Call-to-action text displayed in the read more section.',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
parameters: {
|
|
26
|
+
design: {
|
|
27
|
+
type: 'figma',
|
|
28
|
+
url: 'TODO: Add Figma URL',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
} as Meta<BlogArticleProps>;
|
|
32
|
+
|
|
33
|
+
type Story = StoryObj<BlogArticleProps>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Default story for BlogArticle.
|
|
37
|
+
* Shows the component with a sample image, title, and default CTA text.
|
|
38
|
+
*/
|
|
39
|
+
export const Default: Story = {
|
|
40
|
+
args: {
|
|
41
|
+
imageNode: (
|
|
42
|
+
<img
|
|
43
|
+
src="https://images.unsplash.com/photo-1516321318423-f06f85e504b3?w=400&h=225&fit=crop&crop=faces"
|
|
44
|
+
alt="Sample blog cover"
|
|
45
|
+
style={{ width: '100%', height: '100%', objectFit: 'cover', borderRadius: '12px' }}
|
|
46
|
+
/>
|
|
47
|
+
),
|
|
48
|
+
title: 'How to Build Scalable Web Scrapers with Apify',
|
|
49
|
+
ctaTitle: 'Read more',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Story for BlogArticle with a custom CTA title.
|
|
55
|
+
* Demonstrates how the CTA text can be customized from the default "Read more".
|
|
56
|
+
*/
|
|
57
|
+
export const CustomCTA: Story = {
|
|
58
|
+
args: {
|
|
59
|
+
imageNode: (
|
|
60
|
+
<img
|
|
61
|
+
src="https://images.unsplash.com/photo-1555066931-4365d14bab8c?w=400&h=225&fit=crop&crop=faces"
|
|
62
|
+
alt="Custom blog cover"
|
|
63
|
+
style={{ width: '100%', height: '100%', objectFit: 'cover', borderRadius: '12px' }}
|
|
64
|
+
/>
|
|
65
|
+
),
|
|
66
|
+
title: 'Introducing the New Apify SDK',
|
|
67
|
+
ctaTitle: 'Learn more',
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Story for BlogArticle with a long title.
|
|
73
|
+
* Useful for testing text wrapping and layout with lengthy titles.
|
|
74
|
+
*/
|
|
75
|
+
export const LongTitle: Story = {
|
|
76
|
+
args: {
|
|
77
|
+
imageNode: (
|
|
78
|
+
<img
|
|
79
|
+
src="https://images.unsplash.com/photo-1551650975-87deedd944c3?w=400&h=225&fit=crop&crop=faces"
|
|
80
|
+
alt="Long title blog cover"
|
|
81
|
+
style={{ width: '100%', height: '100%', objectFit: 'cover', borderRadius: '12px' }}
|
|
82
|
+
/>
|
|
83
|
+
),
|
|
84
|
+
title: 'A Comprehensive Guide to Web Automation: Best Practices, Common Pitfalls, and Real-World Use Cases for Modern Developers',
|
|
85
|
+
ctaTitle: 'Read more',
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Story for BlogArticle with a short title.
|
|
91
|
+
* Demonstrates the component behavior with minimal text content.
|
|
92
|
+
*/
|
|
93
|
+
export const ShortTitle: Story = {
|
|
94
|
+
args: {
|
|
95
|
+
imageNode: (
|
|
96
|
+
<img
|
|
97
|
+
src="https://images.unsplash.com/photo-1504639725590-34d0984388bd?w=400&h=225&fit=crop&crop=faces"
|
|
98
|
+
alt="Short title blog cover"
|
|
99
|
+
style={{ width: '100%', height: '100%', objectFit: 'cover', borderRadius: '12px' }}
|
|
100
|
+
/>
|
|
101
|
+
),
|
|
102
|
+
title: 'Quick Tips',
|
|
103
|
+
ctaTitle: 'Read more',
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Story for BlogArticle with a placeholder image.
|
|
109
|
+
* Shows how the component handles when no actual image is provided.
|
|
110
|
+
*/
|
|
111
|
+
export const PlaceholderImage: Story = {
|
|
112
|
+
args: {
|
|
113
|
+
imageNode: (
|
|
114
|
+
<div
|
|
115
|
+
style={{
|
|
116
|
+
width: '100%',
|
|
117
|
+
height: '100%',
|
|
118
|
+
backgroundColor: '#f0f0f0',
|
|
119
|
+
display: 'flex',
|
|
120
|
+
alignItems: 'center',
|
|
121
|
+
justifyContent: 'center',
|
|
122
|
+
color: '#666',
|
|
123
|
+
borderRadius: '12px',
|
|
124
|
+
fontSize: '14px',
|
|
125
|
+
}}
|
|
126
|
+
>
|
|
127
|
+
Image placeholder
|
|
128
|
+
</div>
|
|
129
|
+
),
|
|
130
|
+
title: 'Understanding Data Processing Pipelines',
|
|
131
|
+
ctaTitle: 'Read more',
|
|
132
|
+
},
|
|
133
|
+
};
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { Chip, CHIP_SIZES, CHIP_TYPES, type ChipProps } from './chip.js';
|
|
4
|
+
|
|
5
|
+
const mockIcons = {
|
|
6
|
+
star: <span style={{ fontSize: '14px' }}>⭐</span>,
|
|
7
|
+
check: <span style={{ fontSize: '14px' }}>✓</span>,
|
|
8
|
+
warning: <span style={{ fontSize: '14px' }}>⚠️</span>,
|
|
9
|
+
error: <span style={{ fontSize: '14px' }}>❌</span>,
|
|
10
|
+
info: <span style={{ fontSize: '14px' }}>ℹ️</span>,
|
|
11
|
+
heart: <span style={{ fontSize: '14px' }}>❤️</span>,
|
|
12
|
+
tag: <span style={{ fontSize: '14px' }}>#</span>,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
title: 'UI-Library/Chip',
|
|
17
|
+
tags: ['deprecated'],
|
|
18
|
+
component: Chip,
|
|
19
|
+
argTypes: {
|
|
20
|
+
type: {
|
|
21
|
+
control: 'select',
|
|
22
|
+
options: Object.values(CHIP_TYPES),
|
|
23
|
+
},
|
|
24
|
+
size: {
|
|
25
|
+
control: 'select',
|
|
26
|
+
options: Object.values(CHIP_SIZES),
|
|
27
|
+
},
|
|
28
|
+
clickable: {
|
|
29
|
+
control: 'boolean',
|
|
30
|
+
},
|
|
31
|
+
icon: {
|
|
32
|
+
control: false,
|
|
33
|
+
},
|
|
34
|
+
children: {
|
|
35
|
+
control: 'text',
|
|
36
|
+
},
|
|
37
|
+
className: {
|
|
38
|
+
control: 'text',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
parameters: {
|
|
42
|
+
design: {
|
|
43
|
+
type: 'figma',
|
|
44
|
+
url: 'TODO: Add Figma URL',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
} as Meta<ChipProps>;
|
|
48
|
+
|
|
49
|
+
type Story = StoryObj<ChipProps>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Default chip with medium size and default type
|
|
53
|
+
*/
|
|
54
|
+
export const Default: Story = {
|
|
55
|
+
args: {
|
|
56
|
+
children: 'Default Chip',
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Extra small chip - the smallest size available
|
|
62
|
+
*/
|
|
63
|
+
export const ExtraSmall: Story = {
|
|
64
|
+
args: {
|
|
65
|
+
size: CHIP_SIZES.EXTRA_SMALL,
|
|
66
|
+
children: 'XS Chip',
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Small chip size
|
|
72
|
+
*/
|
|
73
|
+
export const Small: Story = {
|
|
74
|
+
args: {
|
|
75
|
+
size: CHIP_SIZES.SMALL,
|
|
76
|
+
children: 'Small Chip',
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Medium chip size (default)
|
|
82
|
+
*/
|
|
83
|
+
export const Medium: Story = {
|
|
84
|
+
args: {
|
|
85
|
+
size: CHIP_SIZES.MEDIUM,
|
|
86
|
+
children: 'Medium Chip',
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Large chip size
|
|
92
|
+
*/
|
|
93
|
+
export const Large: Story = {
|
|
94
|
+
args: {
|
|
95
|
+
size: CHIP_SIZES.LARGE,
|
|
96
|
+
children: 'Large Chip',
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Primary chip type with brand colors
|
|
102
|
+
*/
|
|
103
|
+
export const Primary: Story = {
|
|
104
|
+
args: {
|
|
105
|
+
type: CHIP_TYPES.PRIMARY,
|
|
106
|
+
children: 'Primary Chip',
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Success chip type for positive states
|
|
112
|
+
*/
|
|
113
|
+
export const Success: Story = {
|
|
114
|
+
args: {
|
|
115
|
+
type: CHIP_TYPES.SUCCESS,
|
|
116
|
+
children: 'Success Chip',
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Warning chip type for cautionary states
|
|
122
|
+
*/
|
|
123
|
+
export const Warning: Story = {
|
|
124
|
+
args: {
|
|
125
|
+
type: CHIP_TYPES.WARNING,
|
|
126
|
+
children: 'Warning Chip',
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Danger chip type for error or critical states
|
|
132
|
+
*/
|
|
133
|
+
export const Danger: Story = {
|
|
134
|
+
args: {
|
|
135
|
+
type: CHIP_TYPES.DANGER,
|
|
136
|
+
children: 'Danger Chip',
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Chip with an icon on the right side
|
|
142
|
+
*/
|
|
143
|
+
export const WithIcon: Story = {
|
|
144
|
+
args: {
|
|
145
|
+
children: 'Starred',
|
|
146
|
+
icon: mockIcons.star,
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Primary chip with check icon
|
|
152
|
+
*/
|
|
153
|
+
export const PrimaryWithIcon: Story = {
|
|
154
|
+
args: {
|
|
155
|
+
type: CHIP_TYPES.PRIMARY,
|
|
156
|
+
children: 'Completed',
|
|
157
|
+
icon: mockIcons.check,
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Success chip with check icon
|
|
163
|
+
*/
|
|
164
|
+
export const SuccessWithIcon: Story = {
|
|
165
|
+
args: {
|
|
166
|
+
type: CHIP_TYPES.SUCCESS,
|
|
167
|
+
children: 'Verified',
|
|
168
|
+
icon: mockIcons.check,
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Warning chip with warning icon
|
|
174
|
+
*/
|
|
175
|
+
export const WarningWithIcon: Story = {
|
|
176
|
+
args: {
|
|
177
|
+
type: CHIP_TYPES.WARNING,
|
|
178
|
+
children: 'Caution',
|
|
179
|
+
icon: mockIcons.warning,
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Danger chip with error icon
|
|
185
|
+
*/
|
|
186
|
+
export const DangerWithIcon: Story = {
|
|
187
|
+
args: {
|
|
188
|
+
type: CHIP_TYPES.DANGER,
|
|
189
|
+
children: 'Error',
|
|
190
|
+
icon: mockIcons.error,
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Clickable chip with pointer cursor
|
|
196
|
+
*/
|
|
197
|
+
export const Clickable: Story = {
|
|
198
|
+
args: {
|
|
199
|
+
children: 'Click me',
|
|
200
|
+
clickable: true,
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Non-clickable chip with default cursor
|
|
206
|
+
*/
|
|
207
|
+
export const NonClickable: Story = {
|
|
208
|
+
args: {
|
|
209
|
+
children: 'Static chip',
|
|
210
|
+
clickable: false,
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Large primary clickable chip with icon
|
|
216
|
+
*/
|
|
217
|
+
export const LargePrimaryClickableWithIcon: Story = {
|
|
218
|
+
args: {
|
|
219
|
+
type: CHIP_TYPES.PRIMARY,
|
|
220
|
+
size: CHIP_SIZES.LARGE,
|
|
221
|
+
children: 'Premium Feature',
|
|
222
|
+
icon: mockIcons.star,
|
|
223
|
+
clickable: true,
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Small success chip showing status
|
|
229
|
+
*/
|
|
230
|
+
export const SmallStatusChip: Story = {
|
|
231
|
+
args: {
|
|
232
|
+
type: CHIP_TYPES.SUCCESS,
|
|
233
|
+
size: CHIP_SIZES.SMALL,
|
|
234
|
+
children: 'Active',
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Extra small chip for compact layouts
|
|
240
|
+
*/
|
|
241
|
+
export const ExtraSmallTag: Story = {
|
|
242
|
+
args: {
|
|
243
|
+
size: CHIP_SIZES.EXTRA_SMALL,
|
|
244
|
+
children: 'Tag',
|
|
245
|
+
icon: mockIcons.tag,
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Chip with longer text content
|
|
251
|
+
*/
|
|
252
|
+
export const WithLongText: Story = {
|
|
253
|
+
args: {
|
|
254
|
+
children: 'This is a longer chip text',
|
|
255
|
+
type: CHIP_TYPES.PRIMARY,
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Multiple chips showcasing different types in one view
|
|
261
|
+
*/
|
|
262
|
+
export const AllTypes: Story = {
|
|
263
|
+
render: () => (
|
|
264
|
+
<div style={{ display: 'flex', gap: '8px', flexWrap: 'wrap' }}>
|
|
265
|
+
<Chip type={CHIP_TYPES.DEFAULT}>Default</Chip>
|
|
266
|
+
<Chip type={CHIP_TYPES.PRIMARY}>Primary</Chip>
|
|
267
|
+
<Chip type={CHIP_TYPES.SUCCESS}>Success</Chip>
|
|
268
|
+
<Chip type={CHIP_TYPES.WARNING}>Warning</Chip>
|
|
269
|
+
<Chip type={CHIP_TYPES.DANGER}>Danger</Chip>
|
|
270
|
+
</div>
|
|
271
|
+
),
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Multiple chips showcasing different sizes in one view
|
|
276
|
+
*/
|
|
277
|
+
export const AllSizes: Story = {
|
|
278
|
+
render: () => (
|
|
279
|
+
<div style={{ display: 'flex', gap: '8px', alignItems: 'center', flexWrap: 'wrap' }}>
|
|
280
|
+
<Chip size={CHIP_SIZES.EXTRA_SMALL}>XS</Chip>
|
|
281
|
+
<Chip size={CHIP_SIZES.SMALL}>Small</Chip>
|
|
282
|
+
<Chip size={CHIP_SIZES.MEDIUM}>Medium</Chip>
|
|
283
|
+
<Chip size={CHIP_SIZES.LARGE}>Large</Chip>
|
|
284
|
+
</div>
|
|
285
|
+
),
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Chips with various icons demonstrating versatility
|
|
290
|
+
*/
|
|
291
|
+
export const WithVariousIcons: Story = {
|
|
292
|
+
render: () => (
|
|
293
|
+
<div style={{ display: 'flex', gap: '8px', flexWrap: 'wrap' }}>
|
|
294
|
+
<Chip type={CHIP_TYPES.SUCCESS} icon={mockIcons.check}>Approved</Chip>
|
|
295
|
+
<Chip type={CHIP_TYPES.WARNING} icon={mockIcons.warning}>Pending</Chip>
|
|
296
|
+
<Chip type={CHIP_TYPES.DANGER} icon={mockIcons.error}>Failed</Chip>
|
|
297
|
+
<Chip type={CHIP_TYPES.PRIMARY} icon={mockIcons.heart}>Favorite</Chip>
|
|
298
|
+
<Chip type={CHIP_TYPES.DEFAULT} icon={mockIcons.info}>Info</Chip>
|
|
299
|
+
</div>
|
|
300
|
+
),
|
|
301
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
2
|
+
import { CodeBlock } from './code_block.tsx';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'ui-library/CodeBlock',
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: 'centered',
|
|
8
|
+
design: {
|
|
9
|
+
type: 'figma',
|
|
10
|
+
url: 'https://www.figma.com/design/duSsGnk84UMYav8mg8QNgR/%F0%9F%93%96-Shared-library?node-id=2131-609&t=tH2x12cMH5yh0fuf-4',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
tags: [],
|
|
14
|
+
component: CodeBlock,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const shuffleLines = (code) => {
|
|
18
|
+
const lines = code.split('\n');
|
|
19
|
+
const shuffledLines = lines.sort(() => Math.random() - 0.5);
|
|
20
|
+
return shuffledLines.join('\n');
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const Template = ({ content, ...args }) => {
|
|
24
|
+
const longCode = `${Array.from(
|
|
25
|
+
{ length: 20 },
|
|
26
|
+
() => content.split('\n')[1],
|
|
27
|
+
).join(' ')}\n${Array.from({ length: 10 }, () => content).join('\n')}`;
|
|
28
|
+
const multipleCodes = Array.from({ length: 5 }, (_, i) => ({
|
|
29
|
+
key: i,
|
|
30
|
+
label: `Code ${i}`,
|
|
31
|
+
code: shuffleLines(content),
|
|
32
|
+
}));
|
|
33
|
+
const multipleLongCodes = Array.from({ length: 5 }, (_, i) => ({
|
|
34
|
+
key: i,
|
|
35
|
+
label: `Code ${i}`,
|
|
36
|
+
code: shuffleLines(longCode),
|
|
37
|
+
highlightLines: Array.from({ length: 3 }, () => Math.floor(Math.random() * 10)),
|
|
38
|
+
}));
|
|
39
|
+
return (
|
|
40
|
+
<div
|
|
41
|
+
style={{
|
|
42
|
+
display: 'flex',
|
|
43
|
+
flexDirection: 'column',
|
|
44
|
+
justifyContent: 'center',
|
|
45
|
+
width: '98vw',
|
|
46
|
+
overflow: 'hidden',
|
|
47
|
+
gap: '10px',
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
<h2>CodeBlock</h2>
|
|
51
|
+
<CodeBlock content={content} {...args} />
|
|
52
|
+
<h2>CodeBlock with title</h2>
|
|
53
|
+
<CodeBlock title="What a code"
|
|
54
|
+
|
|
55
|
+
content={content}
|
|
56
|
+
{...args}
|
|
57
|
+
/>
|
|
58
|
+
<h2>CodeBlock with gradient, dots and action</h2>
|
|
59
|
+
<CodeBlock
|
|
60
|
+
content={content}
|
|
61
|
+
highlightLines={[2, 3, 7]}
|
|
62
|
+
showGradient
|
|
63
|
+
showDotsHeader
|
|
64
|
+
showActionButton
|
|
65
|
+
{...args}
|
|
66
|
+
/>
|
|
67
|
+
<h2>CodeBlock with long lines, action and gradient</h2>
|
|
68
|
+
<CodeBlock
|
|
69
|
+
content={longCode}
|
|
70
|
+
showGradient
|
|
71
|
+
showActionButton
|
|
72
|
+
{...args}
|
|
73
|
+
/>
|
|
74
|
+
|
|
75
|
+
<h2>CodeBlock with multiple long codes, highlighted lines, action and gradient</h2>
|
|
76
|
+
<CodeBlock
|
|
77
|
+
content={multipleLongCodes}
|
|
78
|
+
showGradient
|
|
79
|
+
showActionButton
|
|
80
|
+
{...args}
|
|
81
|
+
/>
|
|
82
|
+
<h2>CodeBlock with multiple codes</h2>
|
|
83
|
+
<CodeBlock
|
|
84
|
+
content={multipleCodes}
|
|
85
|
+
{...args}
|
|
86
|
+
/>
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const JavascriptCodeBlock = Template.bind({});
|
|
92
|
+
JavascriptCodeBlock.args = {
|
|
93
|
+
language: 'javascript',
|
|
94
|
+
content: `const a = 1;
|
|
95
|
+
const b = 2;
|
|
96
|
+
const c = a + b;
|
|
97
|
+
console.log(c);`,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const PythonCodeBlock = Template.bind({});
|
|
101
|
+
PythonCodeBlock.args = {
|
|
102
|
+
language: 'python',
|
|
103
|
+
content: `a = 1
|
|
104
|
+
b = 2
|
|
105
|
+
c = a + b
|
|
106
|
+
print(c)`,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const TypescriptCodeBlock = Template.bind({});
|
|
110
|
+
TypescriptCodeBlock.args = {
|
|
111
|
+
language: 'typescript',
|
|
112
|
+
content: `const a: number = 1;
|
|
113
|
+
const b: number = 2;
|
|
114
|
+
const c: number = a + b;
|
|
115
|
+
console.log(c);`,
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const BashCodeBlock = Template.bind({});
|
|
119
|
+
BashCodeBlock.args = {
|
|
120
|
+
language: 'bash',
|
|
121
|
+
content: `#!/bin/bash
|
|
122
|
+
echo "Hello World"`,
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const JSONCodeBlock = Template.bind({});
|
|
126
|
+
JSONCodeBlock.args = {
|
|
127
|
+
language: 'json',
|
|
128
|
+
content: `{
|
|
129
|
+
"name": "apify",
|
|
130
|
+
"version": "0.1.0",
|
|
131
|
+
"private": true,
|
|
132
|
+
}`,
|
|
133
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
theme,
|
|
6
|
+
} from '../../../design_system/theme.js';
|
|
7
|
+
import {
|
|
8
|
+
type CodeBlockTabKey,
|
|
9
|
+
CodeBlockWithTabs, type CodeBlockWithTabsProps,
|
|
10
|
+
} from './code_block_with_tabs.js';
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
title: 'UI-Library/Code/CodeBlockWithTabs',
|
|
14
|
+
parameters: {
|
|
15
|
+
design: {
|
|
16
|
+
type: 'figma',
|
|
17
|
+
url: 'https://www.figma.com/design/duSsGnk84UMYav8mg8QNgR/Shared-library?node-id=5266-34497&t=aaAINB9GEUOOBZVl-4',
|
|
18
|
+
},
|
|
19
|
+
layout: 'centered',
|
|
20
|
+
},
|
|
21
|
+
component: CodeBlockWithTabs,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const Container = styled.div`
|
|
25
|
+
width: 360px;
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
|
|
30
|
+
@media ${theme.device.tablet} {
|
|
31
|
+
width: 840px;
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
export const Default = ({ tabs, ...args }: Omit<CodeBlockWithTabsProps, 'currentTabKey'>) => {
|
|
36
|
+
const [currentTabKey, setCurrentTabKey] = useState(tabs[0]?.key);
|
|
37
|
+
const extendedTabs = useMemo(() => tabs.map((tab) => ({
|
|
38
|
+
...tab,
|
|
39
|
+
onClick: () => setCurrentTabKey(tab.key),
|
|
40
|
+
})), [tabs]);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Container>
|
|
44
|
+
<CodeBlockWithTabs
|
|
45
|
+
currentTabKey={currentTabKey as CodeBlockTabKey}
|
|
46
|
+
tabs={extendedTabs}
|
|
47
|
+
{...args}
|
|
48
|
+
/>
|
|
49
|
+
</Container>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
Default.args = {
|
|
54
|
+
tabs: [
|
|
55
|
+
{
|
|
56
|
+
key: 'python',
|
|
57
|
+
content: `
|
|
58
|
+
a = 1
|
|
59
|
+
b = 2
|
|
60
|
+
c = a + b
|
|
61
|
+
print(c)`,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
key: 'javascript',
|
|
65
|
+
content: `
|
|
66
|
+
const a = 1;
|
|
67
|
+
const b = 2;
|
|
68
|
+
const c = a + b;
|
|
69
|
+
console.log(c);`,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
key: 'typescript',
|
|
73
|
+
content: `
|
|
74
|
+
const a: number = 1;
|
|
75
|
+
const b: number = 2;
|
|
76
|
+
const c: number = a + b;
|
|
77
|
+
console.log(c);`
|
|
78
|
+
,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
};
|
|
@@ -71,7 +71,7 @@ export type CodeBlockTabProps = {
|
|
|
71
71
|
onClick?: (e: React.MouseEvent) => void;
|
|
72
72
|
} & Partial<SharedLinkProps>;
|
|
73
73
|
|
|
74
|
-
type CodeBlockWithTabsProps = SharedBoxProps & {
|
|
74
|
+
export type CodeBlockWithTabsProps = SharedBoxProps & {
|
|
75
75
|
codeBlockProps: SharedCodeBlockProps;
|
|
76
76
|
currentTabKey: CodeBlockTabKey;
|
|
77
77
|
tabs: CodeBlockTabProps[];
|