@apify/ui-library 1.155.2-fixbranddarkoverlayseparator-a7f48f.3 → 1.156.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.
Files changed (48) hide show
  1. package/dist/components/button/button.d.ts +6 -33
  2. package/dist/components/button/button.d.ts.map +1 -1
  3. package/dist/components/button/button.js +46 -231
  4. package/dist/components/button/button.style.d.ts +37 -0
  5. package/dist/components/button/button.style.d.ts.map +1 -0
  6. package/dist/components/button/button.style.js +250 -0
  7. package/dist/components/icon_button/icon_button.js +2 -1
  8. package/dist/components/select/select.js +2 -2
  9. package/dist/components/select/select.test_ids.d.ts +1 -0
  10. package/dist/components/select/select.test_ids.d.ts.map +1 -1
  11. package/dist/components/select/select.test_ids.js +2 -1
  12. package/dist/components/tabs/tab.d.ts.map +1 -1
  13. package/dist/components/tabs/tab.js +1 -1
  14. package/dist/files_hash_at_build.txt +1 -1
  15. package/dist/index.js +2 -1
  16. package/dist/src/components/button/button.d.ts +6 -33
  17. package/dist/src/components/button/button.d.ts.map +1 -1
  18. package/dist/src/components/button/button.js +24 -221
  19. package/dist/src/components/button/button.js.map +1 -1
  20. package/dist/src/components/button/button.style.d.ts +37 -0
  21. package/dist/src/components/button/button.style.d.ts.map +1 -0
  22. package/dist/src/components/button/button.style.js +256 -0
  23. package/dist/src/components/button/button.style.js.map +1 -0
  24. package/dist/src/components/select/select.js +2 -2
  25. package/dist/src/components/select/select.js.map +1 -1
  26. package/dist/src/components/select/select.test_ids.d.ts +1 -0
  27. package/dist/src/components/select/select.test_ids.d.ts.map +1 -1
  28. package/dist/src/components/select/select.test_ids.js +2 -0
  29. package/dist/src/components/select/select.test_ids.js.map +1 -1
  30. package/dist/src/components/tabs/tab.d.ts.map +1 -1
  31. package/dist/src/components/tabs/tab.js +1 -1
  32. package/dist/src/components/tabs/tab.js.map +1 -1
  33. package/dist/src/test_ids.d.ts +1 -1
  34. package/dist/src/test_ids.d.ts.map +1 -1
  35. package/dist/src/test_ids.js +1 -1
  36. package/dist/src/test_ids.js.map +1 -1
  37. package/dist/test_ids.d.ts +1 -1
  38. package/dist/test_ids.d.ts.map +1 -1
  39. package/dist/test_ids.js +2 -2
  40. package/dist/tsconfig.build.tsbuildinfo +1 -1
  41. package/package.json +2 -2
  42. package/src/components/button/button.stories.tsx +55 -0
  43. package/src/components/button/button.style.ts +311 -0
  44. package/src/components/button/button.tsx +75 -293
  45. package/src/components/select/select.test_ids.ts +3 -0
  46. package/src/components/select/select.tsx +2 -2
  47. package/src/components/tabs/tab.tsx +6 -1
  48. package/src/test_ids.ts +1 -1
@@ -1,11 +1,11 @@
1
1
  import { AriaAttributes, default as React } from 'react';
2
- import { IconSize } from '@apify/ui-icons';
3
2
  import { WithRequired } from '../../type_utils';
4
3
  import { MarginSpacingProps, RegularBoxProps } from '../box';
5
4
  import { LinkProps } from '../link';
5
+ export { BUTTON_COLOR_VARIANTS_CSS, BUTTON_SIZE_VARIANTS_CSS, getButtonColorStyles, getButtonSizeStyles, } from './button.style';
6
6
  export type ButtonSize = 'extraLarge' | 'large' | 'medium' | 'small' | 'extraSmall';
7
- type ButtonColor = 'default' | 'success' | 'danger' | 'primaryBlack';
8
- type ButtonVariant = 'primary' | 'secondary' | 'tertiary';
7
+ export type ButtonColor = 'default' | 'success' | 'danger' | 'primaryBlack';
8
+ export type ButtonVariant = 'primary' | 'secondary' | 'tertiary';
9
9
  type ButtonType = 'button' | 'submit';
10
10
  export interface TransientButtonProps {
11
11
  size?: ButtonSize;
@@ -21,37 +21,10 @@ export interface RegularButtonProps {
21
21
  type?: ButtonType;
22
22
  }
23
23
  type ButtonAriaProps = Pick<AriaAttributes, 'aria-label' | 'aria-labelledby'>;
24
- export type CommonButtonProps = RegularButtonProps & ButtonAriaProps & TransientButtonProps & MarginSpacingProps;
24
+ export type CommonButtonProps = RegularButtonProps & ButtonAriaProps & TransientButtonProps & MarginSpacingProps & {
25
+ animated?: boolean;
26
+ };
25
27
  export type ButtonProps = CommonButtonProps & WithRequired<RegularBoxProps, 'onClick'>;
26
28
  export type AnchorButtonProps = CommonButtonProps & RegularBoxProps & LinkProps;
27
- type ButtonColorCombinations = {
28
- [Type in ButtonVariant]: {
29
- [Size in ButtonColor]: {
30
- textColor: string;
31
- borderColor: string;
32
- backgroundColor: string;
33
- actionTextColor?: string;
34
- actionBorderColor?: string;
35
- hoverColor?: string;
36
- hoverGradient?: string;
37
- activeColor?: string;
38
- activeTextColor?: string;
39
- };
40
- };
41
- };
42
- type ButtonSizeCombinations = {
43
- [Size in ButtonSize]: {
44
- typography: string;
45
- size: number;
46
- horizontalPadding: number;
47
- borderRadius: string;
48
- iconSize: IconSize;
49
- };
50
- };
51
- export declare const BUTTON_COLOR_VARIANTS_CSS: ButtonColorCombinations;
52
- export declare const BUTTON_SIZE_VARIANTS_CSS: ButtonSizeCombinations;
53
- export declare const getButtonColorStyles: (variant?: ButtonVariant, color?: ButtonColor) => import('styled-components').RuleSet<object>;
54
- export declare const getButtonSizeStyles: (size?: ButtonSize) => import('styled-components').RuleSet<object>;
55
29
  export declare const Button: React.ForwardRefExoticComponent<(ButtonProps | AnchorButtonProps) & React.RefAttributes<HTMLElement>>;
56
- export {};
57
30
  //# sourceMappingURL=button.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/button/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAoB,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGlE,OAAO,EAAE,KAAK,YAAY,EAA2B,MAAM,kBAAkB,CAAC;AAE9E,OAAO,EAAO,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAE9D,MAAM,MAA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ependency_provider.js";
4
2
  import { Link, isUrlExternal } from "../link/link.js";
5
- import styled, { css } from "styled-components";
3
+ import { AnimatedBorder, BUTTON_SIZE_VARIANTS_CSS, StyledButton } from "./button.style.js";
6
4
  import { forwardRef } from "react";
7
5
  import { jsx, jsxs } from "react/jsx-runtime";
8
6
  import { ExternalLinkIcon } from "@apify/ui-icons";
@@ -10,252 +8,69 @@ import { ExternalLinkIcon } from "@apify/ui-icons";
10
8
  function isAnchorButton(props) {
11
9
  return props.to !== void 0;
12
10
  }
13
- var BUTTON_COLOR_VARIANTS_CSS = {
14
- primary: {
15
- default: {
16
- textColor: theme.color.neutral.textOnPrimary,
17
- backgroundColor: theme.color.primary.action,
18
- borderColor: theme.color.primary.action,
19
- hoverColor: theme.color.primary.actionHover,
20
- activeColor: theme.color.primary.actionActive
21
- },
22
- success: {
23
- textColor: theme.color.neutral.textOnPrimary,
24
- backgroundColor: theme.color.success.action,
25
- borderColor: theme.color.success.action,
26
- hoverColor: theme.color.success.actionHover,
27
- activeColor: theme.color.success.actionActive
28
- },
29
- danger: {
30
- textColor: theme.color.neutral.textOnPrimary,
31
- backgroundColor: theme.color.danger.action,
32
- borderColor: theme.color.danger.action,
33
- hoverColor: theme.color.danger.actionHover,
34
- activeColor: theme.color.danger.actionActive
35
- },
36
- primaryBlack: {
37
- textColor: theme.color.neutral.textOnPrimary,
38
- backgroundColor: theme.color.primaryBlack.action,
39
- borderColor: theme.color.primaryBlack.action,
40
- hoverGradient: `linear-gradient(to bottom, color-mix(in srgb, ${theme.color.neutral.textOnPrimary} 16%, transparent), transparent)`,
41
- activeColor: theme.color.primaryBlack.actionActive
42
- }
43
- },
44
- secondary: {
45
- default: {
46
- textColor: theme.color.neutral.text,
47
- backgroundColor: theme.color.neutral.backgroundMuted,
48
- borderColor: theme.color.neutral.border,
49
- hoverColor: theme.color.neutral.actionSecondaryHover,
50
- activeColor: theme.color.neutral.actionSecondaryActive,
51
- actionBorderColor: theme.color.neutral.border
52
- },
53
- success: {
54
- textColor: theme.color.success.text,
55
- backgroundColor: theme.color.neutral.backgroundMuted,
56
- borderColor: theme.color.neutral.border,
57
- hoverColor: theme.color.success.actionHover,
58
- activeColor: theme.color.success.actionActive,
59
- actionTextColor: theme.color.neutral.background
60
- },
61
- danger: {
62
- textColor: theme.color.danger.text,
63
- backgroundColor: theme.color.neutral.backgroundMuted,
64
- borderColor: theme.color.neutral.border,
65
- hoverColor: theme.color.danger.backgroundHover,
66
- actionBorderColor: theme.color.danger.borderSubtle,
67
- activeColor: theme.color.danger.actionActive,
68
- activeTextColor: theme.color.neutral.textOnPrimary
69
- },
70
- primaryBlack: {
71
- textColor: theme.color.neutral.textOnPrimary,
72
- backgroundColor: theme.color.primaryBlack.action,
73
- borderColor: theme.color.primaryBlack.action,
74
- hoverGradient: `linear-gradient(to bottom, color-mix(in srgb, ${theme.color.neutral.textOnPrimary} 16%, transparent), transparent)`,
75
- activeColor: theme.color.primaryBlack.actionActive
76
- }
77
- },
78
- tertiary: {
79
- default: {
80
- textColor: theme.color.neutral.text,
81
- backgroundColor: "transparent",
82
- borderColor: "transparent",
83
- hoverColor: theme.color.neutral.hover,
84
- activeColor: theme.color.neutral.actionSecondaryActive
85
- },
86
- success: {
87
- textColor: theme.color.success.text,
88
- backgroundColor: "transparent",
89
- borderColor: "transparent",
90
- hoverColor: theme.color.success.backgroundSubtleHover,
91
- activeColor: theme.color.success.backgroundSubtleActive
92
- },
93
- danger: {
94
- textColor: theme.color.danger.text,
95
- backgroundColor: "transparent",
96
- borderColor: "transparent",
97
- hoverColor: theme.color.danger.backgroundSubtleHover,
98
- activeColor: theme.color.danger.backgroundSubtleActive
99
- },
100
- primaryBlack: {
101
- textColor: theme.color.neutral.textOnPrimary,
102
- backgroundColor: theme.color.primaryBlack.action,
103
- borderColor: theme.color.primaryBlack.action,
104
- hoverGradient: `linear-gradient(to bottom, color-mix(in srgb, ${theme.color.neutral.textOnPrimary} 16%, transparent), transparent)`,
105
- activeColor: theme.color.primaryBlack.actionActive
106
- }
107
- }
108
- };
109
- var BUTTON_SIZE_VARIANTS_CSS = {
110
- extraLarge: {
111
- typography: theme.typography.shared.mobile.bodyMMedium,
112
- size: 40,
113
- horizontalPadding: 12,
114
- borderRadius: theme.radius.radius8,
115
- iconSize: "20"
116
- },
117
- large: {
118
- typography: theme.typography.shared.mobile.bodyMMedium,
119
- size: 36,
120
- horizontalPadding: 12,
121
- borderRadius: theme.radius.radius6,
122
- iconSize: "20"
123
- },
124
- medium: {
125
- typography: theme.typography.shared.mobile.bodyMMedium,
126
- size: 32,
127
- horizontalPadding: 12,
128
- borderRadius: theme.radius.radius6,
129
- iconSize: "20"
130
- },
131
- small: {
132
- typography: theme.typography.shared.mobile.bodySMedium,
133
- size: 28,
134
- horizontalPadding: 8,
135
- borderRadius: theme.radius.radius6,
136
- iconSize: "16"
137
- },
138
- extraSmall: {
139
- typography: theme.typography.shared.mobile.bodySMedium,
140
- size: 24,
141
- horizontalPadding: 6,
142
- borderRadius: theme.radius.radius6,
143
- iconSize: "16"
144
- }
145
- };
146
- var getButtonColorStyles = (variant = "primary", color = "default") => {
147
- const { backgroundColor, borderColor, textColor, actionBorderColor, actionTextColor, hoverColor, hoverGradient, activeColor, activeTextColor } = BUTTON_COLOR_VARIANTS_CSS[variant][color];
148
- return css`
149
- color: ${textColor};
150
- background-color: ${backgroundColor};
151
- border-color: ${borderColor};
152
-
153
- &:hover {
154
- color: ${actionTextColor || textColor};
155
- ${hoverGradient ? css`
156
- background-image: ${hoverGradient};
157
- background-color: ${backgroundColor};
158
- ` : css`
159
- background-color: ${hoverColor};
160
- `}
161
- border-color: ${actionBorderColor || (hoverGradient ? borderColor : hoverColor)};
162
- }
163
-
164
- &:active {
165
- color: ${activeTextColor || actionTextColor || textColor};
166
- background-color: ${activeColor};
167
- ${hoverGradient && "background-image: none;"}
168
- border-color: ${actionBorderColor || activeColor};
169
- }
170
-
171
- &:disabled {
172
- color: ${theme.color.neutral.textDisabled};
173
- background-color: ${variant === "tertiary" ? "transparent" : theme.color.neutral.disabled};
174
- border-color: ${variant === "tertiary" ? "transparent" : theme.color.neutral.disabled};
175
-
176
- cursor: default;
177
- }
178
- `;
179
- };
180
- var getButtonSizeStyles = (size = "medium") => {
181
- const { typography, size: height, horizontalPadding, borderRadius } = BUTTON_SIZE_VARIANTS_CSS[size];
182
- return css`
183
- ${typography};
184
- height: ${height}px;
185
- /* We just want to ensure padding on the sides. Height is set the the hard way for simplicity */
186
- padding: 0 ${horizontalPadding}px;
187
- border-radius: ${borderRadius};
188
- `;
189
- };
190
- var StyledButton = styled(Box)`
191
- /* Basic positioning */
192
- display: inline-flex;
193
- align-items: center;
194
- /* NOT sure about this. It needs to be set when we want 100% width button */
195
- /* Maybe we can add block property */
196
- justify-content: center;
197
- gap: ${theme.space.space4};
198
-
199
- /* Basic styles */
200
- white-space: nowrap;
201
- cursor: pointer;
202
- transition:
203
- border-color ${theme.transition.fastEaseOut},
204
- background-color ${theme.transition.fastEaseOut};
205
-
206
- /* Border is always defined, but it can be set to transparent */
207
- border-style: solid;
208
- border-width: 1px;
209
- border-color: transparent;
210
-
211
- /* Colors */
212
- ${(props) => getButtonColorStyles(props.$variant, props.$color)}
213
-
214
- /* Paddings & font size */
215
- ${(props) => getButtonSizeStyles(props.$size)}
216
- `;
217
11
  var Button = forwardRef((props, ref) => {
218
- const { as, children, size = "medium", color = "default", variant = "primary", type = "button", LeftIcon, RightIcon, onClick, trackingId, trackingData, ...rest } = props;
12
+ const { as, children, size = "medium", color = "default", variant = "primary", animated = false, type = "button", LeftIcon, RightIcon, onClick, trackingId, trackingData, className, m, mt, mb, ml, mr, mx, my, ...rest } = props;
219
13
  const { trackClick, windowLocationHost } = useSharedUiDependencies();
220
14
  const trackedOnClick = (e) => {
221
15
  if (trackClick && trackingId) trackClick(trackingId, trackingData);
222
16
  if (onClick) onClick(e);
223
17
  };
224
- const { iconSize } = BUTTON_SIZE_VARIANTS_CSS[size];
225
- if (isAnchorButton(props)) {
226
- const EffectiveRightIcon = isUrlExternal(props.to, windowLocationHost) && !props.hideExternalIcon ? ExternalLinkIcon : RightIcon;
18
+ const { iconSize, borderRadius } = BUTTON_SIZE_VARIANTS_CSS[size];
19
+ const layoutProps = {
20
+ className,
21
+ m,
22
+ mt,
23
+ mb,
24
+ ml,
25
+ mr,
26
+ mx,
27
+ my
28
+ };
29
+ const renderButton = (buttonLayoutProps = {}) => {
30
+ if (isAnchorButton(props)) {
31
+ const EffectiveRightIcon = isUrlExternal(props.to, windowLocationHost) && !props.hideExternalIcon ? ExternalLinkIcon : RightIcon;
32
+ return /* @__PURE__ */ jsxs(StyledButton, {
33
+ $size: size,
34
+ $color: color,
35
+ $variant: variant,
36
+ forwardedAs: props.disabled ? "button" : Link,
37
+ ref,
38
+ onClick: trackedOnClick,
39
+ to: props.to,
40
+ ...rest,
41
+ ...buttonLayoutProps,
42
+ hideExternalIcon: true,
43
+ children: [
44
+ LeftIcon && /* @__PURE__ */ jsx(LeftIcon, { size: iconSize }),
45
+ children,
46
+ EffectiveRightIcon && /* @__PURE__ */ jsx(EffectiveRightIcon, { size: iconSize })
47
+ ]
48
+ });
49
+ }
227
50
  return /* @__PURE__ */ jsxs(StyledButton, {
228
51
  $size: size,
229
52
  $color: color,
230
53
  $variant: variant,
231
- forwardedAs: props.disabled ? "button" : Link,
54
+ forwardedAs: as || "button",
232
55
  ref,
233
56
  onClick: trackedOnClick,
234
- to: props.to,
57
+ type,
235
58
  ...rest,
236
- hideExternalIcon: true,
59
+ ...buttonLayoutProps,
237
60
  children: [
238
61
  LeftIcon && /* @__PURE__ */ jsx(LeftIcon, { size: iconSize }),
239
62
  children,
240
- EffectiveRightIcon && /* @__PURE__ */ jsx(EffectiveRightIcon, { size: iconSize })
63
+ RightIcon && /* @__PURE__ */ jsx(RightIcon, { size: iconSize })
241
64
  ]
242
65
  });
243
- }
244
- return /* @__PURE__ */ jsxs(StyledButton, {
245
- $size: size,
246
- $color: color,
247
- $variant: variant,
248
- forwardedAs: as || "button",
249
- ref,
250
- onClick: trackedOnClick,
251
- type,
252
- ...rest,
253
- children: [
254
- LeftIcon && /* @__PURE__ */ jsx(LeftIcon, { size: iconSize }),
255
- children,
256
- RightIcon && /* @__PURE__ */ jsx(RightIcon, { size: iconSize })
257
- ]
66
+ };
67
+ if (animated && variant === "primary" && !props.disabled) return /* @__PURE__ */ jsx(AnimatedBorder, {
68
+ forwardedAs: "span",
69
+ $radius: borderRadius,
70
+ ...layoutProps,
71
+ children: renderButton()
258
72
  });
73
+ return renderButton(layoutProps);
259
74
  });
260
75
  //#endregion
261
- export { BUTTON_COLOR_VARIANTS_CSS, BUTTON_SIZE_VARIANTS_CSS, Button, getButtonColorStyles, getButtonSizeStyles };
76
+ export { Button };
@@ -0,0 +1,37 @@
1
+ import { IconSize } from '@apify/ui-icons';
2
+ import { WithTransientProps } from '../../type_utils';
3
+ import { ButtonColor, ButtonSize, ButtonVariant, TransientButtonProps } from './button';
4
+ type ButtonColorCombinations = {
5
+ [Type in ButtonVariant]: {
6
+ [Size in ButtonColor]: {
7
+ textColor: string;
8
+ borderColor: string;
9
+ backgroundColor: string;
10
+ actionTextColor?: string;
11
+ actionBorderColor?: string;
12
+ hoverColor?: string;
13
+ hoverGradient?: string;
14
+ activeColor?: string;
15
+ activeTextColor?: string;
16
+ };
17
+ };
18
+ };
19
+ type ButtonSizeCombinations = {
20
+ [Size in ButtonSize]: {
21
+ typography: string;
22
+ size: number;
23
+ horizontalPadding: number;
24
+ borderRadius: string;
25
+ iconSize: IconSize;
26
+ };
27
+ };
28
+ export declare const BUTTON_COLOR_VARIANTS_CSS: ButtonColorCombinations;
29
+ export declare const BUTTON_SIZE_VARIANTS_CSS: ButtonSizeCombinations;
30
+ export declare const getButtonColorStyles: (variant?: ButtonVariant, color?: ButtonColor) => import('styled-components').RuleSet<object>;
31
+ export declare const getButtonSizeStyles: (size?: ButtonSize) => import('styled-components').RuleSet<object>;
32
+ export declare const StyledButton: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<(import('..').BoxProps & import('react').RefAttributes<HTMLElement>) & import('styled-components/dist/types').BaseObject, WithTransientProps<Required<TransientButtonProps>>>> & string & Omit<import('react').ForwardRefExoticComponent<import('..').BoxProps & import('react').RefAttributes<HTMLElement>>, keyof import('react').Component<any, {}, any>>;
33
+ export declare const AnimatedBorder: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<(import('..').BoxProps & import('react').RefAttributes<HTMLElement>) & import('styled-components/dist/types').BaseObject, {
34
+ $radius: string;
35
+ }>> & string & Omit<import('react').ForwardRefExoticComponent<import('..').BoxProps & import('react').RefAttributes<HTMLElement>>, keyof import('react').Component<any, {}, any>>;
36
+ export {};
37
+ //# sourceMappingURL=button.style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button.style.d.ts","sourceRoot":"","sources":["../../../src/components/button/button.style.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE7F,KAAK,uBAAuB,GAAG;KAC1B,IAAI,IAAI,aAAa,GAAG;SACpB,IAAI,IAAI,WAAW,GAAG;YACnB,SAAS,EAAE,MAAM,CAAC;YAClB,WAAW,EAAE,MAAM,CAAC;YACpB,eAAe,EAAE,MAAM,CAAC;YAGxB,eAAe,CAAC,EAAE,MAAM,CAAC;YAEzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;YAG3B,UAAU,CAAC,EAAE,MAAM,CAAC;YAEpB,aAAa,CAAC,EAAE,MAAM,CAAC;YAGvB,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,eAAe,CAAC,EAAE,MAAM,CAAC;SAC5B;KACJ;CACJ,CAAC;AAEF,KAAK,sBAAsB,GAAG;KACzB,IAAI,IAAI,UAAU,GAAG;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,iBAAiB,EAAE,MAAM,CAAC;QAC1B,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,QAAQ,CAAC;KACtB;CACJ,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,uBAgGvC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,sBAoCtC,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,UAAS,aAAyB,EAAE,QAAO,WAAuB,gDA8CtG,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,OAAM,UAAqB,gDAU9D,CAAC;AAEF,eAAO,MAAM,YAAY,mdA0BxB,CAAC;AAWF,eAAO,MAAM,cAAc;aAA0B,MAAM;iLAkC1D,CAAC"}
@@ -0,0 +1,250 @@
1
+ import { theme } from "../../design_system/theme.js";
2
+ import { Box } from "../box/box.js";
3
+ import styled, { css, keyframes } from "styled-components";
4
+ import "@apify/ui-icons";
5
+ //#region src/components/button/button.style.ts
6
+ var BUTTON_COLOR_VARIANTS_CSS = {
7
+ primary: {
8
+ default: {
9
+ textColor: theme.color.neutral.textOnPrimary,
10
+ backgroundColor: theme.color.primary.action,
11
+ borderColor: theme.color.primary.action,
12
+ hoverColor: theme.color.primary.actionHover,
13
+ activeColor: theme.color.primary.actionActive
14
+ },
15
+ success: {
16
+ textColor: theme.color.neutral.textOnPrimary,
17
+ backgroundColor: theme.color.success.action,
18
+ borderColor: theme.color.success.action,
19
+ hoverColor: theme.color.success.actionHover,
20
+ activeColor: theme.color.success.actionActive
21
+ },
22
+ danger: {
23
+ textColor: theme.color.neutral.textOnPrimary,
24
+ backgroundColor: theme.color.danger.action,
25
+ borderColor: theme.color.danger.action,
26
+ hoverColor: theme.color.danger.actionHover,
27
+ activeColor: theme.color.danger.actionActive
28
+ },
29
+ primaryBlack: {
30
+ textColor: theme.color.neutral.textOnPrimary,
31
+ backgroundColor: theme.color.primaryBlack.action,
32
+ borderColor: theme.color.primaryBlack.action,
33
+ hoverGradient: `linear-gradient(to bottom, color-mix(in srgb, ${theme.color.neutral.textOnPrimary} 16%, transparent), transparent)`,
34
+ activeColor: theme.color.primaryBlack.actionActive
35
+ }
36
+ },
37
+ secondary: {
38
+ default: {
39
+ textColor: theme.color.neutral.text,
40
+ backgroundColor: theme.color.neutral.backgroundMuted,
41
+ borderColor: theme.color.neutral.border,
42
+ hoverColor: theme.color.neutral.actionSecondaryHover,
43
+ activeColor: theme.color.neutral.actionSecondaryActive,
44
+ actionBorderColor: theme.color.neutral.border
45
+ },
46
+ success: {
47
+ textColor: theme.color.success.text,
48
+ backgroundColor: theme.color.neutral.backgroundMuted,
49
+ borderColor: theme.color.neutral.border,
50
+ hoverColor: theme.color.success.actionHover,
51
+ activeColor: theme.color.success.actionActive,
52
+ actionTextColor: theme.color.neutral.background
53
+ },
54
+ danger: {
55
+ textColor: theme.color.danger.text,
56
+ backgroundColor: theme.color.neutral.backgroundMuted,
57
+ borderColor: theme.color.neutral.border,
58
+ hoverColor: theme.color.danger.backgroundHover,
59
+ actionBorderColor: theme.color.danger.borderSubtle,
60
+ activeColor: theme.color.danger.actionActive,
61
+ activeTextColor: theme.color.neutral.textOnPrimary
62
+ },
63
+ primaryBlack: {
64
+ textColor: theme.color.neutral.textOnPrimary,
65
+ backgroundColor: theme.color.primaryBlack.action,
66
+ borderColor: theme.color.primaryBlack.action,
67
+ hoverGradient: `linear-gradient(to bottom, color-mix(in srgb, ${theme.color.neutral.textOnPrimary} 16%, transparent), transparent)`,
68
+ activeColor: theme.color.primaryBlack.actionActive
69
+ }
70
+ },
71
+ tertiary: {
72
+ default: {
73
+ textColor: theme.color.neutral.text,
74
+ backgroundColor: "transparent",
75
+ borderColor: "transparent",
76
+ hoverColor: theme.color.neutral.hover,
77
+ activeColor: theme.color.neutral.actionSecondaryActive
78
+ },
79
+ success: {
80
+ textColor: theme.color.success.text,
81
+ backgroundColor: "transparent",
82
+ borderColor: "transparent",
83
+ hoverColor: theme.color.success.backgroundSubtleHover,
84
+ activeColor: theme.color.success.backgroundSubtleActive
85
+ },
86
+ danger: {
87
+ textColor: theme.color.danger.text,
88
+ backgroundColor: "transparent",
89
+ borderColor: "transparent",
90
+ hoverColor: theme.color.danger.backgroundSubtleHover,
91
+ activeColor: theme.color.danger.backgroundSubtleActive
92
+ },
93
+ primaryBlack: {
94
+ textColor: theme.color.neutral.textOnPrimary,
95
+ backgroundColor: theme.color.primaryBlack.action,
96
+ borderColor: theme.color.primaryBlack.action,
97
+ hoverGradient: `linear-gradient(to bottom, color-mix(in srgb, ${theme.color.neutral.textOnPrimary} 16%, transparent), transparent)`,
98
+ activeColor: theme.color.primaryBlack.actionActive
99
+ }
100
+ }
101
+ };
102
+ var BUTTON_SIZE_VARIANTS_CSS = {
103
+ extraLarge: {
104
+ typography: theme.typography.shared.mobile.bodyMMedium,
105
+ size: 40,
106
+ horizontalPadding: 12,
107
+ borderRadius: theme.radius.radius8,
108
+ iconSize: "20"
109
+ },
110
+ large: {
111
+ typography: theme.typography.shared.mobile.bodyMMedium,
112
+ size: 36,
113
+ horizontalPadding: 12,
114
+ borderRadius: theme.radius.radius6,
115
+ iconSize: "20"
116
+ },
117
+ medium: {
118
+ typography: theme.typography.shared.mobile.bodyMMedium,
119
+ size: 32,
120
+ horizontalPadding: 12,
121
+ borderRadius: theme.radius.radius6,
122
+ iconSize: "20"
123
+ },
124
+ small: {
125
+ typography: theme.typography.shared.mobile.bodySMedium,
126
+ size: 28,
127
+ horizontalPadding: 8,
128
+ borderRadius: theme.radius.radius6,
129
+ iconSize: "16"
130
+ },
131
+ extraSmall: {
132
+ typography: theme.typography.shared.mobile.bodySMedium,
133
+ size: 24,
134
+ horizontalPadding: 6,
135
+ borderRadius: theme.radius.radius6,
136
+ iconSize: "16"
137
+ }
138
+ };
139
+ var getButtonColorStyles = (variant = "primary", color = "default") => {
140
+ const { backgroundColor, borderColor, textColor, actionBorderColor, actionTextColor, hoverColor, hoverGradient, activeColor, activeTextColor } = BUTTON_COLOR_VARIANTS_CSS[variant][color];
141
+ return css`
142
+ color: ${textColor};
143
+ background-color: ${backgroundColor};
144
+ border-color: ${borderColor};
145
+
146
+ &:hover {
147
+ color: ${actionTextColor || textColor};
148
+ ${hoverGradient ? css`
149
+ background-image: ${hoverGradient};
150
+ background-color: ${backgroundColor};
151
+ ` : css`
152
+ background-color: ${hoverColor};
153
+ `}
154
+ border-color: ${actionBorderColor || (hoverGradient ? borderColor : hoverColor)};
155
+ }
156
+
157
+ &:active {
158
+ color: ${activeTextColor || actionTextColor || textColor};
159
+ background-color: ${activeColor};
160
+ ${hoverGradient && "background-image: none;"}
161
+ border-color: ${actionBorderColor || activeColor};
162
+ }
163
+
164
+ &:disabled {
165
+ color: ${theme.color.neutral.textDisabled};
166
+ background-color: ${variant === "tertiary" ? "transparent" : theme.color.neutral.disabled};
167
+ border-color: ${variant === "tertiary" ? "transparent" : theme.color.neutral.disabled};
168
+
169
+ cursor: default;
170
+ }
171
+ `;
172
+ };
173
+ var getButtonSizeStyles = (size = "medium") => {
174
+ const { typography, size: height, horizontalPadding, borderRadius } = BUTTON_SIZE_VARIANTS_CSS[size];
175
+ return css`
176
+ ${typography};
177
+ height: ${height}px;
178
+ /* We just want to ensure padding on the sides. Height is set the the hard way for simplicity */
179
+ padding: 0 ${horizontalPadding}px;
180
+ border-radius: ${borderRadius};
181
+ `;
182
+ };
183
+ var StyledButton = styled(Box)`
184
+ /* Basic positioning */
185
+ display: inline-flex;
186
+ align-items: center;
187
+ /* NOT sure about this. It needs to be set when we want 100% width button */
188
+ /* Maybe we can add block property */
189
+ justify-content: center;
190
+ gap: ${theme.space.space4};
191
+
192
+ /* Basic styles */
193
+ white-space: nowrap;
194
+ cursor: pointer;
195
+ transition:
196
+ border-color ${theme.transition.fastEaseOut},
197
+ background-color ${theme.transition.fastEaseOut};
198
+
199
+ /* Border is always defined, but it can be set to transparent */
200
+ border-style: solid;
201
+ border-width: 1px;
202
+ border-color: transparent;
203
+
204
+ /* Colors */
205
+ ${(props) => getButtonColorStyles(props.$variant, props.$color)}
206
+
207
+ /* Paddings & font size */
208
+ ${(props) => getButtonSizeStyles(props.$size)}
209
+ `;
210
+ var shine = keyframes`
211
+ 0% { transform: translateX(-100%) skewX(-20deg); }
212
+ 50%, 100% { transform: translateX(200%) skewX(-20deg); }
213
+ `;
214
+ var AnimatedBorder = styled(Box)`
215
+ position: relative;
216
+ display: inline-flex;
217
+ align-self: center;
218
+ border-radius: ${(props) => props.$radius};
219
+ overflow: hidden;
220
+ isolation: isolate;
221
+
222
+ /* Stretch the inner button to fill the wrapper, so full-width buttons (e.g. on small screens)
223
+ don't leave a gap between the button and the overlay. The overlay is aria-hidden. */
224
+ & > :not([aria-hidden]) {
225
+ flex: 1;
226
+ }
227
+
228
+ /* Diagonal highlight sweeping across the button - width is relative so it scales to any button */
229
+ &::after {
230
+ content: '';
231
+ position: absolute;
232
+ top: 0;
233
+ bottom: 0;
234
+ left: 0;
235
+ width: 50%;
236
+ z-index: 2;
237
+ pointer-events: none;
238
+ background: linear-gradient(90deg, transparent 20%, rgba(255, 255, 255, 0.35) 50%, transparent 80%);
239
+ animation: ${shine} 3s linear infinite;
240
+ }
241
+
242
+ @media (prefers-reduced-motion: reduce) {
243
+ &::after {
244
+ animation: none;
245
+ display: none;
246
+ }
247
+ }
248
+ `;
249
+ //#endregion
250
+ export { AnimatedBorder, BUTTON_COLOR_VARIANTS_CSS, BUTTON_SIZE_VARIANTS_CSS, StyledButton, getButtonColorStyles, getButtonSizeStyles };
@@ -1,6 +1,7 @@
1
1
  import { theme } from "../../design_system/theme.js";
2
2
  import { Link } from "../link/link.js";
3
- import { BUTTON_SIZE_VARIANTS_CSS, Button } from "../button/button.js";
3
+ import { BUTTON_SIZE_VARIANTS_CSS } from "../button/button.style.js";
4
+ import { Button } from "../button/button.js";
4
5
  import { Tooltip } from "../floating/tooltip.js";
5
6
  import { InlineSpinner, spinnerClassNames } from "../spinner/spinner.js";
6
7
  import styled, { css } from "styled-components";