@apify/ui-library 0.62.1 → 0.63.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apify/ui-library",
3
- "version": "0.62.1",
3
+ "version": "0.63.1",
4
4
  "description": "React UI library used by apify.com",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -66,5 +66,5 @@
66
66
  "typescript": "^5.1.6",
67
67
  "typescript-eslint": "^8.24.0"
68
68
  },
69
- "gitHead": "ea30934a6190ba7c66dd9af5e0d0a8a667967a94"
69
+ "gitHead": "578d4492a2df2afbc48bb0fe0a2bffd11ba8a06f"
70
70
  }
@@ -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
- export const BADGE_SIZES = ['medium', 'small'] as const;
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
- medium: '16',
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
- export type BadgeProps = Omit<RegularBoxProps, 'onClick'> & MarginSpacingProps & {
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
- medium: ($code) => css`
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: ($code) => css`
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, (code: boolean) => FlattenSimpleInterpolation>;
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' | 'code'>>
89
+ Required<Pick<BadgeProps, 'size' | 'variant'>>
97
90
  >;
98
91
 
99
92
  const StyledBadge = styled(Box)<StyledBadgeProps>`
100
- ${({ $size, $code }) => badgeSizeStyle[$size]($code)};
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
  },
@@ -6,20 +6,21 @@ 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 type { RegularButtonProps } from './button.js';
9
10
  import { Link, type RegularLinkProps } from './link.js';
11
+ import { Text } from './text/index.js';
12
+ import { type SharedTextSize, type SharedTextType } from './text/text_shared.js';
10
13
 
11
- export const TAG_SIZES = ['large', 'medium', 'small'] as const;
12
-
13
- type TagSize = typeof TAG_SIZES[number];
14
+ type TagSize = SharedTextSize;
15
+ export const TAG_SIZES: TagSize[] = ['big', 'regular', 'small'];
14
16
 
15
17
  const TAG_ICON_SIZES = {
16
- large: '20',
17
- medium: '16',
18
+ big: '20',
19
+ regular: '16',
18
20
  small: '12',
19
21
  } satisfies Record<TagSize, IconSize>;
20
22
 
21
- export const TAG_VARIANTS = ['primary', 'secondary', 'accent', 'success', 'warning', 'error'] as const;
22
-
23
+ export const TAG_VARIANTS = ['primary', 'secondary', 'subtle', 'accent', 'success', 'warning', 'error'] as const;
23
24
  type TagVariant = typeof TAG_VARIANTS[number];
24
25
 
25
26
  type TagNodeType = Extract<React.ElementType, 'a' | 'button'>;
@@ -30,36 +31,35 @@ type TagNodePropsMap = {
30
31
  };
31
32
  button: {
32
33
  element: HTMLButtonElement;
33
- props: React.ButtonHTMLAttributes<HTMLButtonElement>;
34
+ props: RegularButtonProps;
34
35
  };
35
36
  }
36
37
 
37
- export type TagProps<T extends TagNodeType> = RegularBoxProps & MarginSpacingProps & ({
38
+ type SharedTagProps = Omit<RegularBoxProps, 'as'> & MarginSpacingProps;
39
+ export type TagProps<T extends TagNodeType> = SharedTagProps & ({
38
40
  as?: T;
39
41
  size?: TagSize;
42
+ type?: SharedTextType;
40
43
  variant?: TagVariant;
41
44
  LeadingIcon?: IconComponent;
42
45
  TrailingIcon?: IconComponent;
43
46
  } & Omit<TagNodePropsMap[T]['props'], 'size'>);
44
47
 
45
48
  const tagSizeStyle = {
46
- large: css`
49
+ big: css`
47
50
  height: 4rem;
48
51
  padding: ${theme.space.space8} ${theme.space.space12};
49
52
  border-radius: ${theme.radius.radius12};
50
- ${theme.typography.shared.desktop.bodyLMedium}
51
53
  `,
52
- medium: css`
54
+ regular: css`
53
55
  height: 2.8rem;
54
56
  padding: ${theme.space.space4} ${theme.space.space8};
55
57
  border-radius: ${theme.radius.radius8};
56
- ${theme.typography.shared.desktop.bodyMMedium}
57
58
  `,
58
59
  small: css`
59
60
  height: 2rem;
60
61
  padding: ${theme.space.space2} ${theme.space.space6};
61
62
  border-radius: ${theme.radius.radius4};
62
- ${theme.typography.shared.desktop.bodySMedium}
63
63
 
64
64
  &:has(> svg:last-child:nth-child(1)) {
65
65
  padding: ${theme.space.space2} ${theme.space.space4};
@@ -87,6 +87,15 @@ const tagVariantStyle = {
87
87
  background: ${theme.color.neutral.hover};
88
88
  }
89
89
  `,
90
+ subtle: css`
91
+ color: ${theme.color.neutral.text};
92
+ fill: ${theme.color.neutral.icon};
93
+ background: ${theme.color.neutral.backgroundSubtle};
94
+
95
+ &:hover {
96
+ background: ${theme.color.neutral.hover};
97
+ }
98
+ `,
90
99
  accent: css`
91
100
  color: ${theme.color.primary.chipText};
92
101
  fill: ${theme.color.primary.chipText};
@@ -153,6 +162,7 @@ const StyledTag = styled(Box)<StyledTagProps>`
153
162
  function TagWrapper<T extends TagNodeType>({
154
163
  as,
155
164
  size = 'small',
165
+ type = 'body',
156
166
  variant = 'primary',
157
167
  LeadingIcon,
158
168
  TrailingIcon,
@@ -172,7 +182,7 @@ ref: ForwardedRef<TagNodePropsMap[T]['element']>,
172
182
  {...props}
173
183
  >
174
184
  {LeadingIcon && <LeadingIcon size={TAG_ICON_SIZES[size]} />}
175
- {children}
185
+ {children && (<Text size={size} type={type} weight="medium">{children}</Text>)}
176
186
  {TrailingIcon && <TrailingIcon size={TAG_ICON_SIZES[size]} />}
177
187
  </StyledTag>
178
188
  );
@@ -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 type SharedTextType = 'body' | 'code';
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