@apify/ui-library 0.71.1-featcolortokens-178953.56 → 0.71.1-featcolortokens-178953.63
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/design_system/colors/generated/{dark.d.ts → css_variables.dark.d.ts} +1 -1
- package/dist/src/design_system/colors/generated/css_variables.dark.d.ts.map +1 -0
- package/dist/src/design_system/colors/generated/{dark.js → css_variables.dark.js} +1 -1
- package/dist/src/design_system/colors/generated/css_variables.dark.js.map +1 -0
- package/dist/src/design_system/colors/generated/{light.d.ts → css_variables.light.d.ts} +1 -1
- package/dist/src/design_system/colors/generated/css_variables.light.d.ts.map +1 -0
- package/{src/design_system/colors/generated/light.ts → dist/src/design_system/colors/generated/css_variables.light.js} +1 -1
- package/dist/src/design_system/colors/generated/css_variables.light.js.map +1 -0
- package/dist/src/design_system/colors/generated/{palette.dark.d.ts → css_variables_palette.dark.d.ts} +1 -1
- package/dist/src/design_system/colors/generated/css_variables_palette.dark.d.ts.map +1 -0
- package/dist/src/design_system/colors/generated/{palette.dark.js → css_variables_palette.dark.js} +1 -1
- package/dist/src/design_system/colors/generated/css_variables_palette.dark.js.map +1 -0
- package/dist/src/design_system/colors/generated/{palette.light.d.ts → css_variables_palette.light.d.ts} +1 -1
- package/dist/src/design_system/colors/generated/css_variables_palette.light.d.ts.map +1 -0
- package/{src/design_system/colors/generated/palette.light.ts → dist/src/design_system/colors/generated/css_variables_palette.light.js} +1 -1
- package/dist/src/design_system/colors/generated/css_variables_palette.light.js.map +1 -0
- package/dist/src/design_system/colors/index.d.ts +4 -4
- package/dist/src/design_system/colors/index.d.ts.map +1 -1
- package/dist/src/design_system/colors/index.js +4 -4
- package/dist/src/design_system/colors/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +7 -5
- package/.stylelintrc +0 -12
- package/CHANGELOG.md +0 -3334
- package/CODEOWNERS +0 -7
- package/dist/src/design_system/colors/generated/dark.d.ts.map +0 -1
- package/dist/src/design_system/colors/generated/dark.js.map +0 -1
- package/dist/src/design_system/colors/generated/light.d.ts.map +0 -1
- package/dist/src/design_system/colors/generated/light.js +0 -147
- package/dist/src/design_system/colors/generated/light.js.map +0 -1
- package/dist/src/design_system/colors/generated/palette.dark.d.ts.map +0 -1
- package/dist/src/design_system/colors/generated/palette.dark.js.map +0 -1
- package/dist/src/design_system/colors/generated/palette.light.d.ts.map +0 -1
- package/dist/src/design_system/colors/generated/palette.light.js +0 -74
- package/dist/src/design_system/colors/generated/palette.light.js.map +0 -1
- package/dist/src/design_system/colors_theme.d.ts +0 -213
- package/dist/src/design_system/colors_theme.d.ts.map +0 -1
- package/dist/src/design_system/colors_theme.js +0 -213
- package/dist/src/design_system/colors_theme.js.map +0 -1
- package/dist/src/design_system/properties_theme.d.ts +0 -175
- package/dist/src/design_system/properties_theme.d.ts.map +0 -1
- package/dist/src/design_system/properties_theme.js +0 -315
- package/dist/src/design_system/properties_theme.js.map +0 -1
- package/eslint.config.mjs +0 -44
- package/src/codemods/generate_typograpy_tokens_files.mjs +0 -137
- package/src/components/action_link.tsx +0 -60
- package/src/components/actor_template_card.tsx +0 -116
- package/src/components/badge.tsx +0 -148
- package/src/components/banner.tsx +0 -94
- package/src/components/blog_article.tsx +0 -85
- package/src/components/box.tsx +0 -127
- package/src/components/button.tsx +0 -305
- package/src/components/chip.tsx +0 -128
- package/src/components/code/action_button.tsx +0 -96
- package/src/components/code/code_block/code_block.styled.tsx +0 -180
- package/src/components/code/code_block/code_block.tsx +0 -224
- package/src/components/code/code_block/code_block_with_tabs.tsx +0 -257
- package/src/components/code/code_block/utils.tsx +0 -67
- package/src/components/code/index.ts +0 -5
- package/src/components/code/inline_code/inline_code.tsx +0 -62
- package/src/components/code/one_line_code/one_line_code.tsx +0 -228
- package/src/components/code/prism_highlighter.tsx +0 -180
- package/src/components/color_wheel_gradient.tsx +0 -31
- package/src/components/floating/index.ts +0 -3
- package/src/components/floating/menu.tsx +0 -189
- package/src/components/floating/menu_common.tsx +0 -31
- package/src/components/floating/menu_components.tsx +0 -99
- package/src/components/image.tsx +0 -24
- package/src/components/index.ts +0 -22
- package/src/components/link.tsx +0 -114
- package/src/components/message.tsx +0 -153
- package/src/components/rating.tsx +0 -106
- package/src/components/readme_renderer/index.ts +0 -3
- package/src/components/readme_renderer/pythonize_value.ts +0 -76
- package/src/components/readme_renderer/table_of_contents.tsx +0 -272
- package/src/components/readme_renderer/utils.tsx +0 -46
- package/src/components/simple_markdown/index.ts +0 -2
- package/src/components/simple_markdown/simple_markdown.tsx +0 -214
- package/src/components/simple_markdown/simple_markdown_components.tsx +0 -293
- package/src/components/tabs/index.ts +0 -2
- package/src/components/tabs/tab.tsx +0 -217
- package/src/components/tabs/tabs.tsx +0 -169
- package/src/components/tag.tsx +0 -196
- package/src/components/text/heading_content.tsx +0 -56
- package/src/components/text/heading_marketing.tsx +0 -55
- package/src/components/text/heading_shared.tsx +0 -55
- package/src/components/text/index.ts +0 -19
- package/src/components/text/text_base.tsx +0 -52
- package/src/components/text/text_content.tsx +0 -104
- package/src/components/text/text_marketing.tsx +0 -152
- package/src/components/text/text_shared.tsx +0 -95
- package/src/components/tile/horizontal_tile.tsx +0 -77
- package/src/components/tile/index.ts +0 -2
- package/src/components/tile/shared.ts +0 -27
- package/src/components/tile/vertical_tile.tsx +0 -59
- package/src/components/to_consolidate/card.tsx +0 -141
- package/src/components/to_consolidate/index.ts +0 -4
- package/src/components/to_consolidate/markdown.tsx +0 -609
- package/src/components/to_consolidate/pagination.tsx +0 -136
- package/src/components/to_consolidate/tab_number_chip.tsx +0 -31
- package/src/design_system/colors/build_color_tokens.js +0 -175
- package/src/design_system/colors/figma_color_tokens.dark.json +0 -886
- package/src/design_system/colors/figma_color_tokens.light.json +0 -886
- package/src/design_system/colors/generated/colors_theme.dark.ts +0 -110
- package/src/design_system/colors/generated/colors_theme.light.ts +0 -110
- package/src/design_system/colors/generated/dark.ts +0 -147
- package/src/design_system/colors/generated/palette.dark.ts +0 -74
- package/src/design_system/colors/generated/properties_theme.ts +0 -179
- package/src/design_system/colors/index.ts +0 -7
- package/src/design_system/colors_theme.ts +0 -213
- package/src/design_system/properties_theme.ts +0 -453
- package/src/design_system/supernova_typography_tokens.json +0 -657
- package/src/design_system/theme.ts +0 -25
- package/src/design_system/tokens/index.ts +0 -5
- package/src/design_system/tokens/layouts.ts +0 -29
- package/src/design_system/tokens/radiuses.ts +0 -22
- package/src/design_system/tokens/shadows.ts +0 -22
- package/src/design_system/tokens/spaces.ts +0 -15
- package/src/design_system/tokens/transitions.ts +0 -19
- package/src/design_system/typography_theme.ts +0 -197
- package/src/index.ts +0 -8
- package/src/type_utils.ts +0 -7
- package/src/ui_dependency_provider.tsx +0 -58
- package/src/utils/copy_to_clipboard.ts +0 -24
- package/src/utils/image_color.ts +0 -42
- package/src/utils/index.ts +0 -4
- package/src/utils/resize_observer.ts +0 -18
- package/src/utils/sanitization.ts +0 -14
- package/tsconfig.build.json +0 -17
- package/tsconfig.json +0 -10
- /package/{src/design_system/colors/generated → style/colors}/dark.scss +0 -0
- /package/{src/design_system/colors/generated → style/colors}/light.scss +0 -0
- /package/{src/design_system/colors/generated → style/colors}/palette.dark.scss +0 -0
- /package/{src/design_system/colors/generated → style/colors}/palette.light.scss +0 -0
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
2
|
-
import styled, { css } from 'styled-components';
|
|
3
|
-
|
|
4
|
-
import { ExternalLinkIcon } from '@apify/ui-icons';
|
|
5
|
-
|
|
6
|
-
import { theme } from '../design_system/theme.js';
|
|
7
|
-
import { type WithRequired, type WithTransientProps } from '../type_utils.js';
|
|
8
|
-
import { useSharedUiDependencies } from '../ui_dependency_provider.js';
|
|
9
|
-
import { Box, type MarginSpacingProps, type RegularBoxProps } from './box.js';
|
|
10
|
-
import { isUrlExternal, Link, type LinkProps } from './link.js';
|
|
11
|
-
|
|
12
|
-
type ButtonSize = 'medium' | 'small';
|
|
13
|
-
type ButtonColor = 'default' | 'success' | 'danger';
|
|
14
|
-
type ButtonVariant = 'primary' | 'secondary' | 'text';
|
|
15
|
-
|
|
16
|
-
export interface TransientButtonProps {
|
|
17
|
-
size?: ButtonSize;
|
|
18
|
-
color?: ButtonColor;
|
|
19
|
-
variant?: ButtonVariant;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface RegularButtonProps {
|
|
23
|
-
trackingId?: string,
|
|
24
|
-
trackingData?: object,
|
|
25
|
-
LeftIcon?: React.ElementType,
|
|
26
|
-
RightIcon?: React.ElementType,
|
|
27
|
-
disabled?: boolean;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Props shared for both types of the button
|
|
31
|
-
export type CommonButtonProps = RegularButtonProps & TransientButtonProps & MarginSpacingProps;
|
|
32
|
-
// Regular button must have onClick defined
|
|
33
|
-
export type ButtonProps = CommonButtonProps & WithRequired<RegularBoxProps, 'onClick'>;
|
|
34
|
-
// OR it can pass to to become anchor link - in that case onClick is not needed
|
|
35
|
-
export type AnchorButtonProps = CommonButtonProps & RegularBoxProps & LinkProps;
|
|
36
|
-
|
|
37
|
-
// typeguard to distinguish between the two options for props
|
|
38
|
-
function isAnchorButton(props: ButtonProps | AnchorButtonProps): props is AnchorButtonProps {
|
|
39
|
-
return (props as AnchorButtonProps).to !== undefined;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
type ButtonColorCombinations = {
|
|
43
|
-
[Type in ButtonVariant]: {
|
|
44
|
-
[Size in ButtonColor]: {
|
|
45
|
-
textColor: string,
|
|
46
|
-
borderColor: string
|
|
47
|
-
backgroundColor: string,
|
|
48
|
-
|
|
49
|
-
// hover & active state affects both border & background.
|
|
50
|
-
hoverColor?: string,
|
|
51
|
-
activeColor?: string,
|
|
52
|
-
actionTextColor?: string,
|
|
53
|
-
|
|
54
|
-
// only exception is primary outlined button
|
|
55
|
-
actionBorderColor?: string
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
type ButtonSizeCombinations = {
|
|
61
|
-
[Size in ButtonSize]: {
|
|
62
|
-
fontSize: number,
|
|
63
|
-
horizontalPadding: number,
|
|
64
|
-
height: number,
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const BUTTON_COLOR_VARIANTS_CSS: ButtonColorCombinations = {
|
|
69
|
-
primary: {
|
|
70
|
-
default: {
|
|
71
|
-
textColor: theme.color.neutral.backgroundSubtle,
|
|
72
|
-
backgroundColor: theme.color.primary.action,
|
|
73
|
-
borderColor: theme.color.primary.action,
|
|
74
|
-
hoverColor: theme.color.primary.actionHover,
|
|
75
|
-
activeColor: theme.color.primary.actionActive,
|
|
76
|
-
},
|
|
77
|
-
success: {
|
|
78
|
-
textColor: theme.color.neutral.backgroundSubtle,
|
|
79
|
-
backgroundColor: theme.color.success.action,
|
|
80
|
-
borderColor: theme.color.success.action,
|
|
81
|
-
hoverColor: theme.color.success.actionHover,
|
|
82
|
-
activeColor: theme.color.success.actionActive,
|
|
83
|
-
},
|
|
84
|
-
danger: {
|
|
85
|
-
textColor: theme.color.neutral.backgroundSubtle,
|
|
86
|
-
backgroundColor: theme.color.danger.action,
|
|
87
|
-
borderColor: theme.color.danger.action,
|
|
88
|
-
hoverColor: theme.color.danger.actionHover,
|
|
89
|
-
activeColor: theme.color.danger.actionActive,
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
secondary: {
|
|
93
|
-
default: {
|
|
94
|
-
textColor: theme.color.neutral.text,
|
|
95
|
-
backgroundColor: theme.color.neutral.backgroundMuted,
|
|
96
|
-
borderColor: theme.color.neutral.border,
|
|
97
|
-
hoverColor: theme.color.neutral.actionSecondaryHover,
|
|
98
|
-
activeColor: theme.color.neutral.actionSecondaryActive,
|
|
99
|
-
actionBorderColor: theme.color.neutral.border,
|
|
100
|
-
},
|
|
101
|
-
success: {
|
|
102
|
-
textColor: theme.color.success.text,
|
|
103
|
-
backgroundColor: theme.color.neutral.backgroundMuted,
|
|
104
|
-
borderColor: theme.color.neutral.border,
|
|
105
|
-
hoverColor: theme.color.success.actionHover,
|
|
106
|
-
activeColor: theme.color.success.actionActive,
|
|
107
|
-
actionTextColor: theme.color.neutral.background,
|
|
108
|
-
},
|
|
109
|
-
danger: {
|
|
110
|
-
textColor: theme.color.danger.text,
|
|
111
|
-
backgroundColor: theme.color.neutral.backgroundMuted,
|
|
112
|
-
borderColor: theme.color.neutral.border,
|
|
113
|
-
hoverColor: theme.color.danger.actionHover,
|
|
114
|
-
activeColor: theme.color.danger.actionActive,
|
|
115
|
-
actionTextColor: theme.color.neutral.background,
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
text: {
|
|
119
|
-
default: {
|
|
120
|
-
textColor: theme.color.neutral.text,
|
|
121
|
-
backgroundColor: 'transparent',
|
|
122
|
-
borderColor: 'transparent',
|
|
123
|
-
// TODO: Not sure about these
|
|
124
|
-
hoverColor: theme.color.neutral.hover,
|
|
125
|
-
activeColor: theme.color.neutral.actionSecondaryActive,
|
|
126
|
-
},
|
|
127
|
-
success: {
|
|
128
|
-
textColor: theme.color.success.text,
|
|
129
|
-
backgroundColor: 'transparent',
|
|
130
|
-
borderColor: 'transparent',
|
|
131
|
-
hoverColor: theme.color.success.backgroundSubtleHover,
|
|
132
|
-
activeColor: theme.color.success.backgroundSubtleActive,
|
|
133
|
-
},
|
|
134
|
-
danger: {
|
|
135
|
-
textColor: theme.color.danger.text,
|
|
136
|
-
backgroundColor: 'transparent',
|
|
137
|
-
borderColor: 'transparent',
|
|
138
|
-
hoverColor: theme.color.danger.backgroundSubtleHover,
|
|
139
|
-
activeColor: theme.color.danger.backgroundSubtleActive,
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export const BUTTON_SIZE_VARIANTS_CSS: ButtonSizeCombinations = {
|
|
145
|
-
medium: {
|
|
146
|
-
fontSize: 14,
|
|
147
|
-
height: 36,
|
|
148
|
-
horizontalPadding: 12,
|
|
149
|
-
},
|
|
150
|
-
small: {
|
|
151
|
-
fontSize: 14,
|
|
152
|
-
height: 28,
|
|
153
|
-
horizontalPadding: 8,
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
export const getButtonColorStyles = (variant: ButtonVariant = 'primary', color: ButtonColor = 'default') => {
|
|
158
|
-
const {
|
|
159
|
-
backgroundColor,
|
|
160
|
-
borderColor,
|
|
161
|
-
textColor,
|
|
162
|
-
actionTextColor,
|
|
163
|
-
activeColor,
|
|
164
|
-
hoverColor,
|
|
165
|
-
actionBorderColor,
|
|
166
|
-
} = BUTTON_COLOR_VARIANTS_CSS[variant][color];
|
|
167
|
-
|
|
168
|
-
return css`
|
|
169
|
-
color: ${textColor};
|
|
170
|
-
background-color: ${backgroundColor};
|
|
171
|
-
border-color: ${borderColor};
|
|
172
|
-
|
|
173
|
-
&:hover {
|
|
174
|
-
color: ${actionTextColor || textColor};
|
|
175
|
-
background-color: ${hoverColor};
|
|
176
|
-
border-color: ${actionBorderColor || hoverColor};
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
&:active {
|
|
180
|
-
color: ${actionTextColor || textColor};
|
|
181
|
-
background-color: ${activeColor};
|
|
182
|
-
border-color: ${actionBorderColor || activeColor};
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
&:disabled {
|
|
186
|
-
color: ${theme.color.neutral.textDisabled};
|
|
187
|
-
background-color: ${theme.color.neutral.disabled};
|
|
188
|
-
border-color: ${variant === 'text' ? 'transparent' : theme.color.neutral.disabled};
|
|
189
|
-
|
|
190
|
-
cursor: default;
|
|
191
|
-
}
|
|
192
|
-
`;
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
export const getButtonSizeStyles = (size: ButtonSize = 'medium') => {
|
|
196
|
-
const {
|
|
197
|
-
fontSize,
|
|
198
|
-
height,
|
|
199
|
-
horizontalPadding,
|
|
200
|
-
} = BUTTON_SIZE_VARIANTS_CSS[size];
|
|
201
|
-
|
|
202
|
-
return css`
|
|
203
|
-
height: ${height}px;
|
|
204
|
-
font-size: ${fontSize}px;
|
|
205
|
-
/* We just want to ensure padding on the sides. Height is set the the hard way for simplicity */
|
|
206
|
-
padding: 0 ${horizontalPadding}px;
|
|
207
|
-
`;
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
const StyledButton = styled(Box)<WithTransientProps<TransientButtonProps>>`
|
|
211
|
-
/* Basic positioning */
|
|
212
|
-
display: inline-flex;
|
|
213
|
-
align-items: center;
|
|
214
|
-
/* NOT sure about this. It needs to be set when we want 100% width button */
|
|
215
|
-
/* Maybe we can add block property */
|
|
216
|
-
justify-content: center;
|
|
217
|
-
gap: ${theme.space.space8};
|
|
218
|
-
|
|
219
|
-
/* Basic styles */
|
|
220
|
-
font-weight: 500;
|
|
221
|
-
white-space: nowrap;
|
|
222
|
-
cursor: pointer;
|
|
223
|
-
transition: border-color ${theme.transition.fastEaseOut}, background-color ${theme.transition.fastEaseOut};
|
|
224
|
-
|
|
225
|
-
/* Border is always defined, but it can be set to transparent */
|
|
226
|
-
border-style: solid;
|
|
227
|
-
border-width: 1px;
|
|
228
|
-
border-radius: ${theme.radius.radius6};
|
|
229
|
-
border-color: transparent;
|
|
230
|
-
|
|
231
|
-
/* Colors */
|
|
232
|
-
${(props) => getButtonColorStyles(props.$variant, props.$color)}
|
|
233
|
-
|
|
234
|
-
/* Paddings & font size */
|
|
235
|
-
${(props) => getButtonSizeStyles(props.$size)}
|
|
236
|
-
`;
|
|
237
|
-
|
|
238
|
-
export const Button = forwardRef<HTMLElement, ButtonProps | AnchorButtonProps>((props, ref) => {
|
|
239
|
-
const {
|
|
240
|
-
as,
|
|
241
|
-
children,
|
|
242
|
-
size,
|
|
243
|
-
color,
|
|
244
|
-
variant,
|
|
245
|
-
LeftIcon,
|
|
246
|
-
RightIcon,
|
|
247
|
-
onClick,
|
|
248
|
-
trackingId,
|
|
249
|
-
trackingData,
|
|
250
|
-
...rest
|
|
251
|
-
} = props;
|
|
252
|
-
|
|
253
|
-
const {
|
|
254
|
-
trackClick,
|
|
255
|
-
windowLocationHost,
|
|
256
|
-
} = useSharedUiDependencies();
|
|
257
|
-
const trackedOnClick = (e: React.MouseEvent) => {
|
|
258
|
-
if (trackClick && trackingId) trackClick(trackingId, trackingData);
|
|
259
|
-
if (onClick) onClick(e);
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
const iconSize = size === 'medium' ? '16' : '12';
|
|
263
|
-
|
|
264
|
-
if (isAnchorButton(props)) {
|
|
265
|
-
const isExternal = isUrlExternal(props.to, windowLocationHost);
|
|
266
|
-
const EffectiveRightIcon = (isExternal && !props.hideExternalIcon) ? ExternalLinkIcon : RightIcon;
|
|
267
|
-
|
|
268
|
-
return (
|
|
269
|
-
<StyledButton
|
|
270
|
-
$size={size}
|
|
271
|
-
$color={color}
|
|
272
|
-
$variant={variant}
|
|
273
|
-
// If anchor is undefined, we just render it as a regular button
|
|
274
|
-
forwardedAs={props.disabled ? 'button' : Link}
|
|
275
|
-
ref={ref}
|
|
276
|
-
onClick={trackedOnClick}
|
|
277
|
-
to={props.to}
|
|
278
|
-
{...rest}
|
|
279
|
-
// If we want to show external icon, we use button's slot for icon
|
|
280
|
-
hideExternalIcon={true}
|
|
281
|
-
>
|
|
282
|
-
{LeftIcon && <LeftIcon size={iconSize} />}
|
|
283
|
-
{children}
|
|
284
|
-
{EffectiveRightIcon && <EffectiveRightIcon size={iconSize} />}
|
|
285
|
-
</StyledButton>
|
|
286
|
-
);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
return (
|
|
290
|
-
<StyledButton
|
|
291
|
-
$size={size}
|
|
292
|
-
$color={color}
|
|
293
|
-
$variant={variant}
|
|
294
|
-
forwardedAs={ as || 'button'}
|
|
295
|
-
ref={ref}
|
|
296
|
-
onClick={trackedOnClick}
|
|
297
|
-
type='button'
|
|
298
|
-
{...rest}
|
|
299
|
-
>
|
|
300
|
-
{LeftIcon && <LeftIcon size={iconSize} />}
|
|
301
|
-
{children}
|
|
302
|
-
{RightIcon && <RightIcon size={iconSize} />}
|
|
303
|
-
</StyledButton>
|
|
304
|
-
);
|
|
305
|
-
});
|
package/src/components/chip.tsx
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
|
-
import type { FC } from 'react';
|
|
3
|
-
import React, { forwardRef } from 'react';
|
|
4
|
-
import styled, { css } from 'styled-components';
|
|
5
|
-
|
|
6
|
-
import type { ValueOf } from '@apify-packages/types';
|
|
7
|
-
|
|
8
|
-
import { theme } from '../design_system/theme.js';
|
|
9
|
-
import type { RegularBoxProps } from './box.js';
|
|
10
|
-
|
|
11
|
-
const CHIP_SIZES = {
|
|
12
|
-
EXTRA_SMALL: 'XS',
|
|
13
|
-
SMALL: 'S',
|
|
14
|
-
MEDIUM: 'M',
|
|
15
|
-
LARGE: 'L',
|
|
16
|
-
} as const;
|
|
17
|
-
type CHIP_SIZES = ValueOf<typeof CHIP_SIZES>;
|
|
18
|
-
|
|
19
|
-
const CHIP_TYPES = {
|
|
20
|
-
DEFAULT: 'DEFAULT',
|
|
21
|
-
PRIMARY: 'PRIMARY',
|
|
22
|
-
SUCCESS: 'SUCCESS',
|
|
23
|
-
WARNING: 'WARNING',
|
|
24
|
-
DANGER: 'DANGER',
|
|
25
|
-
} as const;
|
|
26
|
-
type CHIP_TYPES = ValueOf<typeof CHIP_TYPES>;
|
|
27
|
-
|
|
28
|
-
export const classNames = {
|
|
29
|
-
BODY: 'Chip-body',
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const chipSizeStyle = {
|
|
33
|
-
[CHIP_SIZES.EXTRA_SMALL]: css`
|
|
34
|
-
font-size: 12px;
|
|
35
|
-
line-height: 16px;
|
|
36
|
-
padding: 0 4px;
|
|
37
|
-
border-radius: 6px;
|
|
38
|
-
`,
|
|
39
|
-
[CHIP_SIZES.SMALL]: css`
|
|
40
|
-
font-size: 12px;
|
|
41
|
-
line-height: 16px;
|
|
42
|
-
padding: 2px 4px;
|
|
43
|
-
border-radius: 6px;
|
|
44
|
-
`,
|
|
45
|
-
[CHIP_SIZES.MEDIUM]: css`
|
|
46
|
-
font-size: 14px;
|
|
47
|
-
line-height: 20px;
|
|
48
|
-
padding: 2px 8px;
|
|
49
|
-
border-radius: 100px;
|
|
50
|
-
`,
|
|
51
|
-
[CHIP_SIZES.LARGE]: css`
|
|
52
|
-
font-size: 16px;
|
|
53
|
-
line-height: 20px;
|
|
54
|
-
padding: 2px 8px;
|
|
55
|
-
border-radius: 100px;
|
|
56
|
-
`,
|
|
57
|
-
} satisfies Record<CHIP_SIZES, unknown>;
|
|
58
|
-
|
|
59
|
-
const chipTypeStyle = {
|
|
60
|
-
[CHIP_TYPES.DEFAULT]: css`
|
|
61
|
-
color: ${theme.color.neutral.text};
|
|
62
|
-
background: ${theme.color.neutral.chipBackground};
|
|
63
|
-
`,
|
|
64
|
-
[CHIP_TYPES.PRIMARY]: css`
|
|
65
|
-
color: ${theme.color.primary.chipText};
|
|
66
|
-
background: ${theme.color.primary.chipBackground};
|
|
67
|
-
`,
|
|
68
|
-
[CHIP_TYPES.SUCCESS]: css`
|
|
69
|
-
color: ${theme.color.success.chipText};
|
|
70
|
-
background: ${theme.color.success.chipBackground};
|
|
71
|
-
`,
|
|
72
|
-
[CHIP_TYPES.WARNING]: css`
|
|
73
|
-
color: ${theme.color.warning.chipText};
|
|
74
|
-
background: ${theme.color.warning.chipBackground};
|
|
75
|
-
`,
|
|
76
|
-
[CHIP_TYPES.DANGER]: css`
|
|
77
|
-
color: ${theme.color.danger.chipText};
|
|
78
|
-
background: ${theme.color.danger.chipBackground};
|
|
79
|
-
`,
|
|
80
|
-
} satisfies Record<CHIP_TYPES, unknown>;
|
|
81
|
-
|
|
82
|
-
const StyledChip = styled.span<{size: CHIP_SIZES, type: CHIP_TYPES, clickable: boolean}>`
|
|
83
|
-
${({ size }) => chipSizeStyle[size]};
|
|
84
|
-
${({ type }) => chipTypeStyle[type]};
|
|
85
|
-
/* Static styles */
|
|
86
|
-
width: fit-content;
|
|
87
|
-
display: flex;
|
|
88
|
-
flex-direction: row;
|
|
89
|
-
justify-content: center;
|
|
90
|
-
align-items: center;
|
|
91
|
-
font-weight: normal;
|
|
92
|
-
white-space: nowrap;
|
|
93
|
-
cursor: ${({ clickable }) => (clickable ? 'pointer' : 'default')};
|
|
94
|
-
gap: ${theme.space.space4};
|
|
95
|
-
`;
|
|
96
|
-
|
|
97
|
-
export type ChipProps = RegularBoxProps & {
|
|
98
|
-
type?: CHIP_TYPES
|
|
99
|
-
size?: CHIP_SIZES
|
|
100
|
-
icon?: React.ReactNode
|
|
101
|
-
clickable?: boolean
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Component for displaying status and for labelling other components.
|
|
106
|
-
*/
|
|
107
|
-
export const Chip = forwardRef(({
|
|
108
|
-
type = CHIP_TYPES.DEFAULT,
|
|
109
|
-
size = CHIP_SIZES.MEDIUM,
|
|
110
|
-
icon,
|
|
111
|
-
children,
|
|
112
|
-
className,
|
|
113
|
-
...passThroughProps
|
|
114
|
-
}: ChipProps, ref) => {
|
|
115
|
-
const otherProps = { ...passThroughProps, type, size, className: clsx(className, classNames.BODY) };
|
|
116
|
-
|
|
117
|
-
return <StyledChip ref={ref} {...otherProps}>{children}{icon}</StyledChip>;
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
Chip.displayName = 'Chip';
|
|
121
|
-
|
|
122
|
-
type SpecificChipProps = Omit<ChipProps, 'type'>
|
|
123
|
-
|
|
124
|
-
export const PrimaryChip: FC<SpecificChipProps> = (props) => <Chip type={CHIP_TYPES.PRIMARY} {...props} />;
|
|
125
|
-
export const NeutralChip: FC<SpecificChipProps> = (props) => <Chip type={CHIP_TYPES.DEFAULT} {...props} />;
|
|
126
|
-
export const SuccessChip: FC<SpecificChipProps> = (props) => <Chip type={CHIP_TYPES.SUCCESS} {...props} />;
|
|
127
|
-
export const DangerChip: FC<SpecificChipProps> = (props) => <Chip type={CHIP_TYPES.DANGER} {...props} />;
|
|
128
|
-
export const WarningChip: FC<SpecificChipProps> = (props) => <Chip type={CHIP_TYPES.WARNING} {...props} />;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import styled, { css } from 'styled-components';
|
|
3
|
-
|
|
4
|
-
import { CheckIcon, CopyIcon } from '@apify/ui-icons';
|
|
5
|
-
|
|
6
|
-
import { theme } from '../../design_system/theme.js';
|
|
7
|
-
import { useCopyToClipboard } from '../../utils/index.js';
|
|
8
|
-
import { Text } from '../text/index.js';
|
|
9
|
-
|
|
10
|
-
interface StyledButtonProps {
|
|
11
|
-
$successStyle?: boolean;
|
|
12
|
-
$hasText?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const StyledButton = styled.button<StyledButtonProps>`
|
|
16
|
-
display: flex;
|
|
17
|
-
justify-content: center;
|
|
18
|
-
align-items: center;
|
|
19
|
-
|
|
20
|
-
border: 1px solid ${theme.color.neutral.border};
|
|
21
|
-
border-radius: ${theme.radius.radius6};
|
|
22
|
-
|
|
23
|
-
cursor: pointer;
|
|
24
|
-
|
|
25
|
-
background: ${theme.color.neutral.backgroundMuted};
|
|
26
|
-
color: ${theme.color.neutral.icon};
|
|
27
|
-
&:hover {
|
|
28
|
-
background-color: ${theme.color.neutral.hover};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
padding: ${theme.space.space4};
|
|
32
|
-
height: 2.8rem;
|
|
33
|
-
width: 2.8rem;
|
|
34
|
-
|
|
35
|
-
svg {
|
|
36
|
-
width: 2rem;
|
|
37
|
-
height: 2rem;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
${({ $hasText }) => $hasText
|
|
41
|
-
&& css`
|
|
42
|
-
width: auto;
|
|
43
|
-
padding: ${theme.space.space4} ${theme.space.space8};
|
|
44
|
-
p {
|
|
45
|
-
white-space: nowrap;
|
|
46
|
-
}
|
|
47
|
-
`}
|
|
48
|
-
|
|
49
|
-
${({ $successStyle }) => $successStyle
|
|
50
|
-
&& css`
|
|
51
|
-
background-color: ${theme.color.success.action};
|
|
52
|
-
color: ${theme.color.neutral.textOnPrimary};
|
|
53
|
-
border: none;
|
|
54
|
-
:active {
|
|
55
|
-
background-color: ${theme.color.success.actionActive};
|
|
56
|
-
}
|
|
57
|
-
:hover {
|
|
58
|
-
background-color: ${theme.color.success.action};
|
|
59
|
-
}
|
|
60
|
-
`}
|
|
61
|
-
`;
|
|
62
|
-
|
|
63
|
-
interface ActionButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
64
|
-
successStyle?: boolean;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export const ActionButton = ({
|
|
68
|
-
successStyle,
|
|
69
|
-
children,
|
|
70
|
-
...props
|
|
71
|
-
}: ActionButtonProps) => {
|
|
72
|
-
const hasText = typeof children === 'string';
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<StyledButton
|
|
76
|
-
$successStyle={successStyle}
|
|
77
|
-
$hasText={hasText}
|
|
78
|
-
{...props}
|
|
79
|
-
>
|
|
80
|
-
{hasText ? <Text weight="bold">{children}</Text> : children}
|
|
81
|
-
</StyledButton>
|
|
82
|
-
);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
interface CopyButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
86
|
-
code: string;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export const CopyButton = ({ code, ...props }: CopyButtonProps) => {
|
|
90
|
-
const [isCopied, handleClick] = useCopyToClipboard({ text: code });
|
|
91
|
-
return (
|
|
92
|
-
<ActionButton onClick={handleClick} data-test='copy_to_clipboard' {...props}>
|
|
93
|
-
{isCopied ? <CheckIcon size="16" /> : <CopyIcon size="16" />}
|
|
94
|
-
</ActionButton>
|
|
95
|
-
);
|
|
96
|
-
};
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import styled, { css } from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { theme } from '../../../design_system/theme.js';
|
|
4
|
-
import { Box } from '../../box.js';
|
|
5
|
-
import type { SharedTextProps, SharedTextSize } from '../../text/text_shared.js';
|
|
6
|
-
|
|
7
|
-
export type SyntaxHighlighterBaseStylesWrapperProps = SharedTextProps & {
|
|
8
|
-
$fullWidth?: boolean;
|
|
9
|
-
$fullHeight?: string;
|
|
10
|
-
$showLineNumbers?: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const SyntaxHighlighterBaseStylesWrapper = styled(Box)<SyntaxHighlighterBaseStylesWrapperProps>`
|
|
14
|
-
background-color: ${theme.color.neutral.backgroundMuted} !important;
|
|
15
|
-
border: 1px solid ${theme.color.neutral.border};
|
|
16
|
-
border-radius: ${theme.radius.radius12};
|
|
17
|
-
overflow: hidden;
|
|
18
|
-
|
|
19
|
-
width: 100%;
|
|
20
|
-
${({ $fullWidth }) => !$fullWidth && css`max-width: 860px;`}
|
|
21
|
-
${({ $fullHeight }) => !$fullHeight && css`max-height: 600px;`}
|
|
22
|
-
|
|
23
|
-
background-color: transparent;
|
|
24
|
-
position: relative;
|
|
25
|
-
`;
|
|
26
|
-
|
|
27
|
-
export const CodeBlockWrapper = styled(SyntaxHighlighterBaseStylesWrapper) <{
|
|
28
|
-
$hasHeader: boolean;
|
|
29
|
-
$gradientRotation?: number;
|
|
30
|
-
$highlightLines?: number[];
|
|
31
|
-
$hasActionButton?: boolean;
|
|
32
|
-
$hasTabs?: boolean;
|
|
33
|
-
$fullWidth?: boolean;
|
|
34
|
-
$showLineNumbers?: boolean;
|
|
35
|
-
$fullHeight?: boolean;
|
|
36
|
-
size?: SharedTextSize,
|
|
37
|
-
}>`
|
|
38
|
-
position: relative;
|
|
39
|
-
display: flex;
|
|
40
|
-
flex-direction: column;
|
|
41
|
-
min-width: 266px;
|
|
42
|
-
|
|
43
|
-
.CodeBlock-Header {
|
|
44
|
-
padding-top: 7px; /* only 7 due to transform translateY(1px) */
|
|
45
|
-
gap: ${theme.space.space4};
|
|
46
|
-
background-color: ${theme.color.neutral.backgroundSubtle};
|
|
47
|
-
border-bottom: 1px solid ${theme.color.neutral.border};
|
|
48
|
-
z-index: 3;
|
|
49
|
-
position: relative;
|
|
50
|
-
display: flex;
|
|
51
|
-
height: 4rem;
|
|
52
|
-
|
|
53
|
-
.CodeBlock-HeaderTitle {
|
|
54
|
-
margin-left: ${theme.space.space16};
|
|
55
|
-
margin-bottom: ${theme.space.space8};
|
|
56
|
-
margin-top: 0.5rem;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.CodeBlock-HeaderTabsWrapper {
|
|
60
|
-
display: flex;
|
|
61
|
-
transform: translateY(1px);
|
|
62
|
-
padding-right: ${theme.space.space32};
|
|
63
|
-
padding-left: ${theme.space.space8};
|
|
64
|
-
overflow-x: auto;
|
|
65
|
-
overflow-y: hidden;
|
|
66
|
-
gap: ${theme.space.space4};
|
|
67
|
-
|
|
68
|
-
margin-right: ${({ $hasActionButton }) => ($hasActionButton ? '128' : '20')}px;
|
|
69
|
-
|
|
70
|
-
.CodeBlock-Tab {
|
|
71
|
-
border-radius: ${theme.radius.radius8};
|
|
72
|
-
background-color: transparent;
|
|
73
|
-
border: 1px solid transparent;
|
|
74
|
-
border-bottom-left-radius: 0;
|
|
75
|
-
border-bottom-right-radius: 0;
|
|
76
|
-
border-bottom: none;
|
|
77
|
-
cursor: pointer;
|
|
78
|
-
height: 3.2rem;
|
|
79
|
-
max-width: 26rem;
|
|
80
|
-
|
|
81
|
-
color: ${theme.color.neutral.textMuted};
|
|
82
|
-
|
|
83
|
-
text-align: center;
|
|
84
|
-
white-space: nowrap;
|
|
85
|
-
|
|
86
|
-
padding: 0.2rem ${theme.space.space8} 0.6rem ${theme.space.space8};
|
|
87
|
-
p {
|
|
88
|
-
padding-top: 0.2rem;
|
|
89
|
-
text-overflow: ellipsis;
|
|
90
|
-
overflow: hidden;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
&.selected {
|
|
95
|
-
color: ${theme.color.neutral.text};
|
|
96
|
-
border: 1px solid ${theme.color.neutral.border};
|
|
97
|
-
background-color: ${theme.color.neutral.backgroundMuted};
|
|
98
|
-
border-bottom: none;
|
|
99
|
-
padding: 0.6rem ${theme.space.space8};
|
|
100
|
-
p {
|
|
101
|
-
padding-top: 0;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
&:hover {
|
|
106
|
-
border: 1px solid ${theme.color.neutral.border};
|
|
107
|
-
border-bottom: none;
|
|
108
|
-
text-decoration: none;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
&::after {
|
|
112
|
-
/* ensures same width of text when switching tabs and making it bold */
|
|
113
|
-
${theme.typography.shared.tablet.bodyMStrong}
|
|
114
|
-
display: block;
|
|
115
|
-
content: attr(title);
|
|
116
|
-
font-weight: bold;
|
|
117
|
-
height: 0px;
|
|
118
|
-
color: transparent;
|
|
119
|
-
overflow: hidden;
|
|
120
|
-
visibility: hidden;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
.CodeBlock-TopRightActionsWrapper {
|
|
128
|
-
position: absolute;
|
|
129
|
-
top: 0;
|
|
130
|
-
right: 0;
|
|
131
|
-
${({ $hasHeader }) => ($hasHeader
|
|
132
|
-
? css`
|
|
133
|
-
padding-top: 6px;
|
|
134
|
-
padding-right: ${theme.space.space8};`
|
|
135
|
-
: css`
|
|
136
|
-
padding-top: ${theme.space.space16};
|
|
137
|
-
padding-right: ${theme.space.space16};`)}
|
|
138
|
-
|
|
139
|
-
display: flex;
|
|
140
|
-
gap: ${theme.space.space8};
|
|
141
|
-
z-index: 3;
|
|
142
|
-
height: 3.9rem;
|
|
143
|
-
|
|
144
|
-
${({ $hasHeader }) => $hasHeader && css`
|
|
145
|
-
padding-left: ${theme.space.space32};
|
|
146
|
-
background: linear-gradient(
|
|
147
|
-
to right,
|
|
148
|
-
transparent,
|
|
149
|
-
${theme.color.neutral.backgroundSubtle} 20px
|
|
150
|
-
);
|
|
151
|
-
`}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
.CodeBlock-Gradient {
|
|
155
|
-
right: 0px;
|
|
156
|
-
bottom: 0px;
|
|
157
|
-
|
|
158
|
-
aspect-ratio: 1/1;
|
|
159
|
-
height: 250%;
|
|
160
|
-
|
|
161
|
-
transform: translate(50%, 70%) rotate(${({ $gradientRotation }) => $gradientRotation ?? 0}deg) scaleX(-1);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
.CodeBlock-HederDotsWrapper {
|
|
165
|
-
display: flex;
|
|
166
|
-
padding: ${theme.space.space8};
|
|
167
|
-
align-items: flex-start;
|
|
168
|
-
gap: ${theme.space.space8};
|
|
169
|
-
margin-bottom: 0.5rem;
|
|
170
|
-
margin-left: ${theme.space.space8};
|
|
171
|
-
background: transparent;
|
|
172
|
-
|
|
173
|
-
.CodeBlock-HeaderDot {
|
|
174
|
-
width: 1.2rem;
|
|
175
|
-
height: 1.2rem;
|
|
176
|
-
border-radius: 50%;
|
|
177
|
-
background-color: ${theme.color.neutral.iconSubtle};
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
`;
|