@apify/ui-library 0.62.0 → 0.63.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/CHANGELOG.md +19 -0
- package/dist/src/components/badge.d.ts +8 -6
- package/dist/src/components/badge.d.ts.map +1 -1
- package/dist/src/components/badge.js +8 -13
- package/dist/src/components/badge.js.map +1 -1
- package/dist/src/components/tag.d.ts +8 -5
- package/dist/src/components/tag.d.ts.map +1 -1
- package/dist/src/components/tag.js +18 -11
- package/dist/src/components/tag.js.map +1 -1
- package/dist/src/components/text/index.d.ts +3 -2
- package/dist/src/components/text/index.d.ts.map +1 -1
- package/dist/src/components/text/index.js +2 -2
- package/dist/src/components/text/index.js.map +1 -1
- package/dist/src/components/text/text_shared.d.ts +2 -1
- package/dist/src/components/text/text_shared.d.ts.map +1 -1
- package/dist/src/components/text/text_shared.js +1 -0
- package/dist/src/components/text/text_shared.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/components/badge.tsx +15 -23
- package/src/components/tag.tsx +23 -14
- package/src/components/text/index.ts +2 -1
- package/src/components/text/text_shared.tsx +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apify/ui-library",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.0",
|
|
4
4
|
"description": "React UI library used by apify.com",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@apify/log": "^2.5.11",
|
|
30
|
-
"@apify/ui-icons": "^0.
|
|
30
|
+
"@apify/ui-icons": "^0.9.0",
|
|
31
31
|
"@floating-ui/react": "^0.26.2",
|
|
32
32
|
"clsx": "^2.0.0",
|
|
33
33
|
"dayjs": "1.11.9",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"typescript": "^5.1.6",
|
|
67
67
|
"typescript-eslint": "^8.24.0"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "5b121861db91f0c4cb6869acbf6d708423e731c3"
|
|
70
70
|
}
|
package/src/components/badge.tsx
CHANGED
|
@@ -6,47 +6,40 @@ import type { IconComponent, IconSize } from '@apify/ui-icons';
|
|
|
6
6
|
import { theme } from '../design_system/theme.js';
|
|
7
7
|
import type { WithTransientProps } from '../type_utils.js';
|
|
8
8
|
import { Box, type MarginSpacingProps, type RegularBoxProps } from './box.js';
|
|
9
|
+
import { Text } from './text/index.js';
|
|
10
|
+
import type { SharedTextSize, SharedTextType } from './text/text_shared.js';
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type BadgeSize = typeof BADGE_SIZES[number];
|
|
12
|
+
type BadgeSize = Exclude<SharedTextSize, 'big'>;
|
|
13
|
+
export const BADGE_SIZES: BadgeSize[] = ['regular', 'small'];
|
|
13
14
|
|
|
14
15
|
const BADGE_ICON_SIZES = {
|
|
15
|
-
|
|
16
|
+
regular: '16',
|
|
16
17
|
small: '12',
|
|
17
18
|
} satisfies Record<BadgeSize, IconSize>;
|
|
18
19
|
|
|
19
20
|
export const BADGE_VARIANTS = ['neutral', 'neutral_muted', 'neutral_subtle', 'primary_black', 'primary_blue', 'success', 'warning', 'danger'] as const;
|
|
20
|
-
|
|
21
21
|
type BadgeVariant = typeof BADGE_VARIANTS[number];
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
type SharedBadgeProps = Omit<RegularBoxProps, 'as' | 'onClick'> & MarginSpacingProps;
|
|
24
|
+
export type BadgeProps = SharedBadgeProps & {
|
|
24
25
|
as?: Exclude<React.ElementType, 'a' | 'button'>;
|
|
25
26
|
size?: BadgeSize;
|
|
27
|
+
type?: SharedTextType;
|
|
26
28
|
variant?: BadgeVariant;
|
|
27
29
|
LeadingIcon?: IconComponent;
|
|
28
|
-
code?: boolean;
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
const badgeSizeStyle = {
|
|
32
|
-
|
|
33
|
+
regular: css`
|
|
33
34
|
padding: ${theme.space.space4} ${theme.space.space8};
|
|
34
35
|
border-radius: ${theme.radius.radius6};
|
|
35
|
-
${$code
|
|
36
|
-
? theme.typography.shared.desktop.codeMMedium
|
|
37
|
-
: theme.typography.shared.desktop.bodyMMedium
|
|
38
|
-
}
|
|
39
36
|
`,
|
|
40
|
-
small:
|
|
37
|
+
small: css`
|
|
41
38
|
height: 2rem;
|
|
42
39
|
padding: ${theme.space.space2} ${theme.space.space6};
|
|
43
40
|
border-radius: ${theme.radius.radius4};
|
|
44
|
-
${$code
|
|
45
|
-
? theme.typography.shared.desktop.codeSMedium
|
|
46
|
-
: theme.typography.shared.desktop.bodySMedium
|
|
47
|
-
}
|
|
48
41
|
`,
|
|
49
|
-
} satisfies Record<BadgeSize,
|
|
42
|
+
} satisfies Record<BadgeSize, FlattenSimpleInterpolation>;
|
|
50
43
|
|
|
51
44
|
const badgeVariantStyle = {
|
|
52
45
|
neutral: css`
|
|
@@ -93,11 +86,11 @@ const badgeVariantStyle = {
|
|
|
93
86
|
} satisfies Record<BadgeVariant, FlattenSimpleInterpolation>;
|
|
94
87
|
|
|
95
88
|
type StyledBadgeProps = WithTransientProps<
|
|
96
|
-
Required<Pick<BadgeProps, 'size' | 'variant'
|
|
89
|
+
Required<Pick<BadgeProps, 'size' | 'variant'>>
|
|
97
90
|
>;
|
|
98
91
|
|
|
99
92
|
const StyledBadge = styled(Box)<StyledBadgeProps>`
|
|
100
|
-
${({ $size
|
|
93
|
+
${({ $size }) => badgeSizeStyle[$size]};
|
|
101
94
|
${({ $variant }) => badgeVariantStyle[$variant]};
|
|
102
95
|
|
|
103
96
|
/* Static styles */
|
|
@@ -118,10 +111,10 @@ const StyledBadge = styled(Box)<StyledBadgeProps>`
|
|
|
118
111
|
export const Badge = forwardRef(
|
|
119
112
|
({
|
|
120
113
|
size = 'small',
|
|
114
|
+
type = 'body',
|
|
121
115
|
variant = 'neutral',
|
|
122
116
|
LeadingIcon,
|
|
123
117
|
children,
|
|
124
|
-
code = false,
|
|
125
118
|
...props
|
|
126
119
|
}: BadgeProps,
|
|
127
120
|
ref,
|
|
@@ -131,11 +124,10 @@ export const Badge = forwardRef(
|
|
|
131
124
|
ref={ref}
|
|
132
125
|
$size={size}
|
|
133
126
|
$variant={variant}
|
|
134
|
-
$code={code}
|
|
135
127
|
{...props}
|
|
136
128
|
>
|
|
137
129
|
{LeadingIcon && <LeadingIcon size={BADGE_ICON_SIZES[size]} />}
|
|
138
|
-
{children}
|
|
130
|
+
{children && (<Text size={size} type={type} weight="medium">{children}</Text>)}
|
|
139
131
|
</StyledBadge>
|
|
140
132
|
);
|
|
141
133
|
},
|
package/src/components/tag.tsx
CHANGED
|
@@ -7,19 +7,19 @@ import { theme } from '../design_system/theme.js';
|
|
|
7
7
|
import type { WithTransientProps } from '../type_utils.js';
|
|
8
8
|
import { Box, type MarginSpacingProps, type RegularBoxProps } from './box.js';
|
|
9
9
|
import { Link, type RegularLinkProps } from './link.js';
|
|
10
|
+
import { Text } from './text/index.js';
|
|
11
|
+
import { type SharedTextSize, type SharedTextType } from './text/text_shared.js';
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type TagSize = typeof TAG_SIZES[number];
|
|
13
|
+
type TagSize = SharedTextSize;
|
|
14
|
+
export const TAG_SIZES: TagSize[] = ['big', 'regular', 'small'];
|
|
14
15
|
|
|
15
16
|
const TAG_ICON_SIZES = {
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
big: '20',
|
|
18
|
+
regular: '16',
|
|
18
19
|
small: '12',
|
|
19
20
|
} satisfies Record<TagSize, IconSize>;
|
|
20
21
|
|
|
21
|
-
export const TAG_VARIANTS = ['primary', 'secondary', 'accent', 'success', 'warning', 'error'] as const;
|
|
22
|
-
|
|
22
|
+
export const TAG_VARIANTS = ['primary', 'secondary', 'subtle', 'accent', 'success', 'warning', 'error'] as const;
|
|
23
23
|
type TagVariant = typeof TAG_VARIANTS[number];
|
|
24
24
|
|
|
25
25
|
type TagNodeType = Extract<React.ElementType, 'a' | 'button'>;
|
|
@@ -34,32 +34,31 @@ type TagNodePropsMap = {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
type SharedTagProps = Omit<RegularBoxProps, 'as'> & MarginSpacingProps;
|
|
38
|
+
export type TagProps<T extends TagNodeType> = SharedTagProps & ({
|
|
38
39
|
as?: T;
|
|
39
40
|
size?: TagSize;
|
|
41
|
+
type?: SharedTextType;
|
|
40
42
|
variant?: TagVariant;
|
|
41
43
|
LeadingIcon?: IconComponent;
|
|
42
44
|
TrailingIcon?: IconComponent;
|
|
43
45
|
} & Omit<TagNodePropsMap[T]['props'], 'size'>);
|
|
44
46
|
|
|
45
47
|
const tagSizeStyle = {
|
|
46
|
-
|
|
48
|
+
big: css`
|
|
47
49
|
height: 4rem;
|
|
48
50
|
padding: ${theme.space.space8} ${theme.space.space12};
|
|
49
51
|
border-radius: ${theme.radius.radius12};
|
|
50
|
-
${theme.typography.shared.desktop.bodyLMedium}
|
|
51
52
|
`,
|
|
52
|
-
|
|
53
|
+
regular: css`
|
|
53
54
|
height: 2.8rem;
|
|
54
55
|
padding: ${theme.space.space4} ${theme.space.space8};
|
|
55
56
|
border-radius: ${theme.radius.radius8};
|
|
56
|
-
${theme.typography.shared.desktop.bodyMMedium}
|
|
57
57
|
`,
|
|
58
58
|
small: css`
|
|
59
59
|
height: 2rem;
|
|
60
60
|
padding: ${theme.space.space2} ${theme.space.space6};
|
|
61
61
|
border-radius: ${theme.radius.radius4};
|
|
62
|
-
${theme.typography.shared.desktop.bodySMedium}
|
|
63
62
|
|
|
64
63
|
&:has(> svg:last-child:nth-child(1)) {
|
|
65
64
|
padding: ${theme.space.space2} ${theme.space.space4};
|
|
@@ -87,6 +86,15 @@ const tagVariantStyle = {
|
|
|
87
86
|
background: ${theme.color.neutral.hover};
|
|
88
87
|
}
|
|
89
88
|
`,
|
|
89
|
+
subtle: css`
|
|
90
|
+
color: ${theme.color.neutral.text};
|
|
91
|
+
fill: ${theme.color.neutral.icon};
|
|
92
|
+
background: ${theme.color.neutral.backgroundSubtle};
|
|
93
|
+
|
|
94
|
+
&:hover {
|
|
95
|
+
background: ${theme.color.neutral.hover};
|
|
96
|
+
}
|
|
97
|
+
`,
|
|
90
98
|
accent: css`
|
|
91
99
|
color: ${theme.color.primary.chipText};
|
|
92
100
|
fill: ${theme.color.primary.chipText};
|
|
@@ -153,6 +161,7 @@ const StyledTag = styled(Box)<StyledTagProps>`
|
|
|
153
161
|
function TagWrapper<T extends TagNodeType>({
|
|
154
162
|
as,
|
|
155
163
|
size = 'small',
|
|
164
|
+
type = 'body',
|
|
156
165
|
variant = 'primary',
|
|
157
166
|
LeadingIcon,
|
|
158
167
|
TrailingIcon,
|
|
@@ -172,7 +181,7 @@ ref: ForwardedRef<TagNodePropsMap[T]['element']>,
|
|
|
172
181
|
{...props}
|
|
173
182
|
>
|
|
174
183
|
{LeadingIcon && <LeadingIcon size={TAG_ICON_SIZES[size]} />}
|
|
175
|
-
{children}
|
|
184
|
+
{children && (<Text size={size} type={type} weight="medium">{children}</Text>)}
|
|
176
185
|
{TrailingIcon && <TrailingIcon size={TAG_ICON_SIZES[size]} />}
|
|
177
186
|
</StyledTag>
|
|
178
187
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HeadingShared } from './heading_shared.js';
|
|
2
2
|
import type { SharedTextProps } from './text_shared.js';
|
|
3
|
-
import { TextShared } from './text_shared.js';
|
|
3
|
+
import { SHARED_TEXT_TYPES, TextShared } from './text_shared.js';
|
|
4
4
|
|
|
5
5
|
export * from './text_base.js';
|
|
6
6
|
export * from './text_content.js';
|
|
@@ -11,6 +11,7 @@ export * from './heading_marketing.js';
|
|
|
11
11
|
export {
|
|
12
12
|
TextShared as Text, // Shared typography is the default
|
|
13
13
|
HeadingShared as Heading, // Shared typography is the default
|
|
14
|
+
SHARED_TEXT_TYPES,
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
export type {
|
|
@@ -6,7 +6,9 @@ import type { WithTransientProps } from '../../type_utils.js';
|
|
|
6
6
|
import type { TextBaseProps } from './text_base.js';
|
|
7
7
|
import { TextBaseComponent } from './text_base.js';
|
|
8
8
|
|
|
9
|
-
export
|
|
9
|
+
export const SHARED_TEXT_TYPES = ['body', 'code'] as const;
|
|
10
|
+
export type SharedTextType = typeof SHARED_TEXT_TYPES[number];
|
|
11
|
+
|
|
10
12
|
export type SharedTextSize = 'regular' | 'small' | 'big';
|
|
11
13
|
export type SharedTextWeight = 'normal' | 'medium' | 'bold';
|
|
12
14
|
|