@apify/ui-library 1.94.0 → 1.94.2
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/tabs/tab.d.ts +0 -1
- package/dist/src/components/tabs/tab.d.ts.map +1 -1
- package/dist/src/components/tabs/tab.js +1 -7
- package/dist/src/components/tabs/tab.js.map +1 -1
- package/dist/src/components/tabs/tab.stories.d.ts +38 -0
- package/dist/src/components/tabs/tab.stories.d.ts.map +1 -0
- package/dist/src/components/tabs/tab.stories.js +88 -0
- package/dist/src/components/tabs/tab.stories.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/components/tabs/tab.stories.tsx +137 -0
- package/src/components/tabs/tab.tsx +2 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apify/ui-library",
|
|
3
|
-
"version": "1.94.
|
|
3
|
+
"version": "1.94.2",
|
|
4
4
|
"description": "React UI library used by apify.com",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"It's not nice, but helps us to get around the problem of multiple react instances."
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@apify/ui-icons": "^1.18.
|
|
29
|
+
"@apify/ui-icons": "^1.18.1",
|
|
30
30
|
"@floating-ui/react": "^0.26.2",
|
|
31
31
|
"@react-hook/resize-observer": "^2.0.2",
|
|
32
32
|
"clsx": "^2.0.0",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"src",
|
|
67
67
|
"style"
|
|
68
68
|
],
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "9102c42cfcde185901959e4ba302a95e400dd522"
|
|
70
70
|
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { Meta } from '@storybook/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
|
|
5
|
+
import { PlaceholderIcon } from '@apify/ui-icons';
|
|
6
|
+
|
|
7
|
+
import { Tab as TabComponent, type TabVariant } from './tab.js';
|
|
8
|
+
import { Tabs as TabsComponent } from './tabs.js';
|
|
9
|
+
|
|
10
|
+
const meta: Meta<typeof TabComponent> = {
|
|
11
|
+
title: 'UI-Library/Tab',
|
|
12
|
+
component: TabComponent,
|
|
13
|
+
parameters: {
|
|
14
|
+
design: {
|
|
15
|
+
type: 'figma',
|
|
16
|
+
url: 'https://www.figma.com/design/duSsGnk84UMYav8mg8QNgR/Shared-library?node-id=5236-76563&p=f&t=FXAwKd9KH4obWP9V-0',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
argTypes: {
|
|
20
|
+
variant: {
|
|
21
|
+
control: { type: 'select' },
|
|
22
|
+
options: ['default', 'boxed', 'buttoned'] as TabVariant[],
|
|
23
|
+
},
|
|
24
|
+
active: {
|
|
25
|
+
control: { type: 'boolean' },
|
|
26
|
+
description: 'Whether the tab is active',
|
|
27
|
+
defaultValue: false,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default meta;
|
|
33
|
+
|
|
34
|
+
const Container = styled.div`
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
gap: 2rem;
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
const TabRow = styled.div`
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
gap: 1rem;
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
const TabRowLabel = styled.h3`
|
|
48
|
+
font-size: 1.25rem;
|
|
49
|
+
font-weight: 600;
|
|
50
|
+
margin-bottom: 0.5rem;
|
|
51
|
+
`;
|
|
52
|
+
|
|
53
|
+
// Sample tab data for the variants story
|
|
54
|
+
const sampleTabs = [
|
|
55
|
+
{ id: 'tab-1', title: 'Dashboard', to: '#' },
|
|
56
|
+
{ id: 'tab-2', title: 'Analytics', to: '#' },
|
|
57
|
+
{ id: 'tab-3', title: 'Settings', to: '#' },
|
|
58
|
+
{ id: 'tab-4', title: 'Users', to: '#' },
|
|
59
|
+
{ id: 'tab-5', title: 'Reports', to: '#' },
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
export const TabVariants = (args: {
|
|
63
|
+
Icon?: boolean;
|
|
64
|
+
chip?: string;
|
|
65
|
+
rollout?: 'alpha' | 'beta' | 'none';
|
|
66
|
+
}) => {
|
|
67
|
+
const { Icon = false, chip = '', rollout = 'none' } = args;
|
|
68
|
+
const [activeTab, setActiveTab] = React.useState('tab-1');
|
|
69
|
+
|
|
70
|
+
const handleTabSelect = ({ id }: { id: string; href: string; event: React.MouseEvent }) => {
|
|
71
|
+
setActiveTab(id);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Create configurable tabs based on args
|
|
75
|
+
const configurableTabs = sampleTabs.map((tab) => ({
|
|
76
|
+
...tab,
|
|
77
|
+
...(Icon && { Icon: PlaceholderIcon }),
|
|
78
|
+
...(chip && { chip }),
|
|
79
|
+
...(rollout !== 'none' && { rollout }),
|
|
80
|
+
}));
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<Container>
|
|
84
|
+
<TabRow>
|
|
85
|
+
<TabRowLabel>Default Variant</TabRowLabel>
|
|
86
|
+
<TabsComponent
|
|
87
|
+
variant="default"
|
|
88
|
+
tabs={configurableTabs}
|
|
89
|
+
activeTab={activeTab}
|
|
90
|
+
onSelect={handleTabSelect}
|
|
91
|
+
/>
|
|
92
|
+
</TabRow>
|
|
93
|
+
|
|
94
|
+
<TabRow>
|
|
95
|
+
<TabRowLabel>Boxed Variant</TabRowLabel>
|
|
96
|
+
<TabsComponent
|
|
97
|
+
variant="boxed"
|
|
98
|
+
tabs={configurableTabs}
|
|
99
|
+
activeTab={activeTab}
|
|
100
|
+
onSelect={handleTabSelect}
|
|
101
|
+
/>
|
|
102
|
+
</TabRow>
|
|
103
|
+
|
|
104
|
+
<TabRow>
|
|
105
|
+
<TabRowLabel>Buttoned Variant</TabRowLabel>
|
|
106
|
+
<TabsComponent
|
|
107
|
+
variant="buttoned"
|
|
108
|
+
tabs={configurableTabs}
|
|
109
|
+
activeTab={activeTab}
|
|
110
|
+
onSelect={handleTabSelect}
|
|
111
|
+
/>
|
|
112
|
+
</TabRow>
|
|
113
|
+
</Container>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
TabVariants.args = {
|
|
118
|
+
Icon: false,
|
|
119
|
+
chip: '',
|
|
120
|
+
rollout: 'none',
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
TabVariants.argTypes = {
|
|
124
|
+
Icon: {
|
|
125
|
+
control: { type: 'boolean' },
|
|
126
|
+
description: 'Show icons on all tabs',
|
|
127
|
+
},
|
|
128
|
+
chip: {
|
|
129
|
+
control: { type: 'text' },
|
|
130
|
+
description: 'Chip value to show on all tabs (leave empty for no chips)',
|
|
131
|
+
},
|
|
132
|
+
rollout: {
|
|
133
|
+
control: { type: 'select' },
|
|
134
|
+
options: ['none', 'alpha', 'beta'],
|
|
135
|
+
description: 'Rollout badge to show on all tabs',
|
|
136
|
+
},
|
|
137
|
+
};
|
|
@@ -144,7 +144,6 @@ type TabWrapperProps = WithTransientProps<Required<Pick<TabProps, 'variant'>>> &
|
|
|
144
144
|
export const TAB_CLASSNAMES = {
|
|
145
145
|
ICON: 'Tab-icon',
|
|
146
146
|
TITLE: 'Tab-title',
|
|
147
|
-
BADGE: 'Tab-badge',
|
|
148
147
|
};
|
|
149
148
|
|
|
150
149
|
const TabWrapper = styled(Link)<TabWrapperProps>`
|
|
@@ -177,16 +176,10 @@ const TabWrapper = styled(Link)<TabWrapperProps>`
|
|
|
177
176
|
text-overflow: ellipsis;
|
|
178
177
|
white-space: nowrap;
|
|
179
178
|
}
|
|
180
|
-
|
|
181
|
-
.${TAB_CLASSNAMES.BADGE} {
|
|
182
|
-
flex-shrink: 0;
|
|
183
|
-
text-transform: uppercase;
|
|
184
|
-
}
|
|
185
179
|
`;
|
|
186
180
|
|
|
187
181
|
export const Tab = ({ variant = 'default', id, to, Icon, title, chip, rollout, className, onSelect, active = false, disabled = false, ...props }: TabProps) => {
|
|
188
182
|
const href = typeof (to) === 'string' ? to : createPath(to);
|
|
189
|
-
|
|
190
183
|
return (
|
|
191
184
|
<TabWrapper
|
|
192
185
|
{...props}
|
|
@@ -200,17 +193,16 @@ export const Tab = ({ variant = 'default', id, to, Icon, title, chip, rollout, c
|
|
|
200
193
|
$variant={variant}
|
|
201
194
|
>
|
|
202
195
|
{Icon && <Icon size="16" className={TAB_CLASSNAMES.ICON} />}
|
|
203
|
-
<Text size={tabVariantTextSize[variant]} className={TAB_CLASSNAMES.
|
|
196
|
+
<Text size={tabVariantTextSize[variant]} className={TAB_CLASSNAMES.TITLE} weight="bold" as="div">{title}</Text>
|
|
204
197
|
{chip && (
|
|
205
198
|
<Badge
|
|
206
199
|
size={tabVariantBadgeSize[variant]}
|
|
207
200
|
variant={active ? 'primary_black' : 'neutral_subtle'}
|
|
208
|
-
className={TAB_CLASSNAMES.ICON}
|
|
209
201
|
>
|
|
210
202
|
{chip}
|
|
211
203
|
</Badge>
|
|
212
204
|
)}
|
|
213
|
-
{rollout && <Badge size={tabVariantBadgeSize[variant]} variant="primary_blue"
|
|
205
|
+
{rollout && <Badge size={tabVariantBadgeSize[variant]} variant="primary_blue">{rollout}</Badge>}
|
|
214
206
|
</TabWrapper>
|
|
215
207
|
);
|
|
216
208
|
};
|