@fibery/ui-kit 1.30.0 → 1.31.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/package.json +5 -5
- package/src/button/actions-button-compact.tsx +3 -3
- package/src/button/actions-button.tsx +5 -5
- package/src/button/button.tsx +2 -0
- package/src/design-system.ts +3 -3
- package/src/emoji-picker/emoji-picker-content-with-color.tsx +4 -11
- package/src/emoji-picker/primitives/category-label.tsx +4 -4
- package/src/emoji-picker/primitives/grid-item.tsx +2 -5
- package/src/emoji-picker/primitives/search.tsx +8 -8
- package/src/emoji-picker/primitives/skin-tone.tsx +2 -2
- package/src/error-alert/error-alert.tsx +3 -3
- package/src/icon-button.tsx +1 -1
- package/src/select/custom-select-partials/clear-indicator.tsx +5 -4
- package/src/select/select-in-popover.tsx +20 -6
- package/src/toast/primitives.tsx +3 -3
- package/src/button/icon-button.tsx +0 -71
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/ui-kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.31.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"files": [
|
|
6
6
|
"src/antd/styles.ts",
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"screenfull": "6.0.1",
|
|
77
77
|
"ua-parser-js": "0.7.24",
|
|
78
78
|
"@fibery/helpers": "1.3.0",
|
|
79
|
-
"@fibery/
|
|
80
|
-
"@fibery/
|
|
79
|
+
"@fibery/react": "1.4.0",
|
|
80
|
+
"@fibery/emoji-data": "2.6.0"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"react": "^18.2.0",
|
|
@@ -111,8 +111,8 @@
|
|
|
111
111
|
"svgo": "2.8.0",
|
|
112
112
|
"typescript": "5.4.3",
|
|
113
113
|
"unist-util-reduce": "0.2.2",
|
|
114
|
-
"@fibery/
|
|
115
|
-
"@fibery/
|
|
114
|
+
"@fibery/babel-preset": "7.4.0",
|
|
115
|
+
"@fibery/eslint-config": "8.6.0"
|
|
116
116
|
},
|
|
117
117
|
"jest": {
|
|
118
118
|
"testEnvironment": "jsdom",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {IconButton, IconButtonProps} from "./icon-button";
|
|
2
|
-
import MoreCompactIcon from "../icons/react/MoreCompact";
|
|
3
1
|
import {forwardRef} from "react";
|
|
2
|
+
import {IconButton, IconButtonProps} from "../button-v2/icon-button";
|
|
3
|
+
import MoreCompactIcon from "../icons/react/MoreCompact";
|
|
4
4
|
|
|
5
5
|
export const ActionsButtonCompact = forwardRef<HTMLButtonElement, IconButtonProps>(
|
|
6
6
|
function ActionsButtonCompactComponent({...rest}, ref) {
|
|
7
7
|
return (
|
|
8
8
|
<IconButton ref={ref} size="small" {...rest}>
|
|
9
|
-
<MoreCompactIcon
|
|
9
|
+
<MoreCompactIcon />
|
|
10
10
|
</IconButton>
|
|
11
11
|
);
|
|
12
12
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {IconButton, IconButtonProps} from "./icon-button";
|
|
2
|
-
import MoreCompact from "../icons/react/MoreCompact";
|
|
3
|
-
import {forwardRef} from "react";
|
|
4
1
|
import {css} from "@linaria/core";
|
|
2
|
+
import {forwardRef} from "react";
|
|
3
|
+
import {IconButton, IconButtonProps} from "../button-v2/icon-button";
|
|
5
4
|
import {border, themeVars} from "../design-system";
|
|
5
|
+
import MoreCompact from "../icons/react/MoreCompact";
|
|
6
6
|
|
|
7
7
|
export const ActionsButton = forwardRef<HTMLButtonElement, IconButtonProps>(function ActionsButtonComponent(
|
|
8
8
|
{...rest},
|
|
9
9
|
ref
|
|
10
10
|
) {
|
|
11
11
|
return (
|
|
12
|
-
<IconButton ref={ref} size="
|
|
13
|
-
<MoreCompact
|
|
12
|
+
<IconButton ref={ref} size="medium" {...rest}>
|
|
13
|
+
<MoreCompact />
|
|
14
14
|
</IconButton>
|
|
15
15
|
);
|
|
16
16
|
});
|
package/src/button/button.tsx
CHANGED
|
@@ -235,6 +235,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button
|
|
|
235
235
|
className,
|
|
236
236
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
237
237
|
noOverflow: _noOverflow,
|
|
238
|
+
width,
|
|
238
239
|
...buttonProps
|
|
239
240
|
} = props;
|
|
240
241
|
|
|
@@ -249,6 +250,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button
|
|
|
249
250
|
variant={primary ? "solid" : borderless ? "ghost" : "outline"}
|
|
250
251
|
size={newSize}
|
|
251
252
|
iconStart={Icon ? <Icon /> : null}
|
|
253
|
+
fullWidth={width === "100%"}
|
|
252
254
|
/>
|
|
253
255
|
);
|
|
254
256
|
}
|
package/src/design-system.ts
CHANGED
|
@@ -419,7 +419,6 @@ export const themeColors = {
|
|
|
419
419
|
// :focus, :focus:hover
|
|
420
420
|
colorBgPinnedFieldsLabel: [slate.slate11, slateDark.slate11],
|
|
421
421
|
colorBgObjectEditorSeparator: [slate.slate12, slateDark.slate12],
|
|
422
|
-
colorBgObjectEditorSeparatorButton: [slate.slate4, slateDark.slate4],
|
|
423
422
|
colorBgMenuItemSelectedFocused: [indigo.indigo6, indigoDark.indigo6],
|
|
424
423
|
colorBgFieldEditorContainer: [slate.slate2, slateDark.slate3],
|
|
425
424
|
colorBgFieldEditorLinkEqualSign: [slate.slate6, slateDark.slate2],
|
|
@@ -887,8 +886,9 @@ export const layout = {
|
|
|
887
886
|
logoSize: 16,
|
|
888
887
|
menuDefaultWidth: 243,
|
|
889
888
|
desktopToolbarHeight: 32,
|
|
890
|
-
desktopMenuMinWidth:
|
|
891
|
-
|
|
889
|
+
desktopMenuMinWidth: 240,
|
|
890
|
+
collapsedMenuMinWidth: 54,
|
|
891
|
+
menuMinWidth: 240, //TODO: make dependency to itemHeight
|
|
892
892
|
menuMaxWidth: 480,
|
|
893
893
|
menuItemMinWidth: 80,
|
|
894
894
|
menuGroupHeaderIndent: 28, // I'm ok
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {css} from "@linaria/core";
|
|
2
|
-
import {
|
|
3
|
-
import {IconButton} from "../button/icon-button";
|
|
2
|
+
import {useRef, useState} from "react";
|
|
3
|
+
import {IconButton} from "../button-v2/icon-button";
|
|
4
4
|
import {CollapsibleContent, CollapsibleRoot, CollapsibleTrigger} from "../collapsible";
|
|
5
5
|
import {ColorPicker} from "../color-picker";
|
|
6
6
|
import {getIconColor, space} from "../design-system";
|
|
@@ -30,15 +30,8 @@ const ColorPickerCollapsibleTrigger: React.FC<ColorPickerCollapsibleTrigger> = (
|
|
|
30
30
|
return (
|
|
31
31
|
<CollapsibleTrigger asChild>
|
|
32
32
|
<Tooltip title={label}>
|
|
33
|
-
<IconButton
|
|
34
|
-
|
|
35
|
-
size="big"
|
|
36
|
-
className={css`
|
|
37
|
-
border-top-left-radius: 0;
|
|
38
|
-
border-bottom-left-radius: 0;
|
|
39
|
-
`}
|
|
40
|
-
>
|
|
41
|
-
<Icon color={iconColor} iconSize={18} containerSize={20} />
|
|
33
|
+
<IconButton data-testid="emoji-picker-color-trigger" size="small">
|
|
34
|
+
<Icon color={iconColor} />
|
|
42
35
|
</IconButton>
|
|
43
36
|
</Tooltip>
|
|
44
37
|
</CollapsibleTrigger>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type {Category} from "@fibery/emoji-data";
|
|
2
2
|
|
|
3
3
|
import {css} from "@linaria/core";
|
|
4
|
+
import {IconButton} from "../../button-v2/icon-button";
|
|
4
5
|
import {space, textStyles, themeVars} from "../../design-system";
|
|
5
|
-
import {useEmojiPickerCtx, useEmojiPickerI18N} from "./root";
|
|
6
|
-
import {IconButton} from "../../button/icon-button";
|
|
7
6
|
import Settings from "../../icons/react/Settings";
|
|
7
|
+
import {useEmojiPickerCtx, useEmojiPickerI18N} from "./root";
|
|
8
8
|
|
|
9
9
|
const categoryLabelCss = css`
|
|
10
10
|
${textStyles.heading6}
|
|
@@ -33,8 +33,8 @@ export const EmojiPickerCategoryLabel: React.FC<EmojiPickerCategoryLabelProps> =
|
|
|
33
33
|
<span>{label}</span>
|
|
34
34
|
|
|
35
35
|
{category.id === "custom" && emojiPickerCtx.onCustomCategorySettings && (
|
|
36
|
-
<IconButton onClick={emojiPickerCtx.onCustomCategorySettings}>
|
|
37
|
-
<Settings
|
|
36
|
+
<IconButton onClick={emojiPickerCtx.onCustomCategorySettings} size="small">
|
|
37
|
+
<Settings />
|
|
38
38
|
</IconButton>
|
|
39
39
|
)}
|
|
40
40
|
</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {EmojiItem} from "@fibery/emoji-data";
|
|
2
2
|
import {css} from "@linaria/core";
|
|
3
3
|
import {memo} from "react";
|
|
4
|
-
import {IconButton} from "../../button/icon-button";
|
|
4
|
+
import {IconButton} from "../../button-v2/icon-button";
|
|
5
5
|
import {themeVars} from "../../design-system";
|
|
6
6
|
import {useEmojiDataStoreSelector} from "../stores/emoji-data-store";
|
|
7
7
|
import {useEmojiPickerContentSettings} from "./content";
|
|
@@ -39,15 +39,12 @@ export const EmojiPickerGridItem = memo<EmojiPickerGridItemProps>(({id, category
|
|
|
39
39
|
width: emojiContentSettings.emojiContainerSize,
|
|
40
40
|
height: emojiContentSettings.emojiContainerSize,
|
|
41
41
|
}}
|
|
42
|
-
size="
|
|
42
|
+
size="large"
|
|
43
43
|
onClick={() => emojiPickerCtx.onEmojiSelect(emoji)}
|
|
44
44
|
onMouseEnter={() => setEmojiPreview({emoji, categoryId})}
|
|
45
45
|
onMouseLeave={() => setEmojiPreview(null)}
|
|
46
46
|
data-highlighted={highlighted}
|
|
47
47
|
className={css`
|
|
48
|
-
display: flex;
|
|
49
|
-
align-items: center;
|
|
50
|
-
justify-content: center;
|
|
51
48
|
&:hover:not(:disabled),
|
|
52
49
|
&:focus-visible,
|
|
53
50
|
&[data-highlighted="true"] {
|
|
@@ -2,16 +2,16 @@ import {EmojiItem} from "@fibery/emoji-data";
|
|
|
2
2
|
import {useComposedRefs} from "@fibery/react/src/use-composed-refs";
|
|
3
3
|
import {css, cx} from "@linaria/core";
|
|
4
4
|
import {startTransition, useId, useRef} from "react";
|
|
5
|
-
import {IconButton} from "../../button/icon-button";
|
|
5
|
+
import {IconButton} from "../../button-v2/icon-button";
|
|
6
6
|
import {border, space, textStyles, themeVars} from "../../design-system";
|
|
7
7
|
import Close from "../../icons/react/Close";
|
|
8
8
|
import Search from "../../icons/react/Search";
|
|
9
9
|
import {useEmojiDataStore} from "../stores/emoji-data-store";
|
|
10
|
+
import type {EmojiPickerGridHandle} from "./grid";
|
|
11
|
+
import {useEmojiPreview, useSetEmojiPreview} from "./preview-provider";
|
|
10
12
|
import {useEmojiPickerCtx, useEmojiPickerI18N} from "./root";
|
|
11
13
|
import {useFoundEmojis, useSetFoundEmojis} from "./search-provider";
|
|
12
14
|
import {useEmojiSkin} from "./skin-provider";
|
|
13
|
-
import {useEmojiPreview, useSetEmojiPreview} from "./preview-provider";
|
|
14
|
-
import type {EmojiPickerGridHandle} from "./grid";
|
|
15
15
|
|
|
16
16
|
const searchCss = css`
|
|
17
17
|
${textStyles.regular}
|
|
@@ -24,7 +24,7 @@ const searchCss = css`
|
|
|
24
24
|
|
|
25
25
|
display: flex;
|
|
26
26
|
align-items: center;
|
|
27
|
-
padding-left: ${space.
|
|
27
|
+
padding-left: ${space.s8}px;
|
|
28
28
|
gap: ${space.s2}px;
|
|
29
29
|
|
|
30
30
|
/* For screenreaders only, via https://stackoverflow.com/a/19758620 */
|
|
@@ -58,13 +58,13 @@ const searchInputCss = css`
|
|
|
58
58
|
`;
|
|
59
59
|
|
|
60
60
|
const searchIconCss = css`
|
|
61
|
-
padding: ${space.
|
|
61
|
+
padding: ${space.s4}px;
|
|
62
62
|
`;
|
|
63
63
|
|
|
64
64
|
const extraActionSlotCss = css`
|
|
65
65
|
background-color: var(--fibery-emoji-hover-color, ${themeVars.inputCopyBgColor});
|
|
66
|
-
border-
|
|
67
|
-
|
|
66
|
+
border-radius: ${space.s6}px;
|
|
67
|
+
margin-right: ${space.s4}px;
|
|
68
68
|
`;
|
|
69
69
|
|
|
70
70
|
export type EmojiPickerSearchProps = {
|
|
@@ -159,7 +159,7 @@ export const EmojiPickerSearch: React.FC<EmojiPickerSearchProps> = ({
|
|
|
159
159
|
<section className={cx(searchCss, className)} aria-label={i18n.search}>
|
|
160
160
|
{foundEmojis ? (
|
|
161
161
|
<IconButton size="small" onClick={clearSearch}>
|
|
162
|
-
<Close
|
|
162
|
+
<Close />
|
|
163
163
|
</IconButton>
|
|
164
164
|
) : (
|
|
165
165
|
<span className={searchIconCss}>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {EmojiSkin} from "@fibery/emoji-data";
|
|
2
2
|
import {css, cx} from "@linaria/core";
|
|
3
3
|
import {useState} from "react";
|
|
4
|
+
import {IconButton} from "../../button-v2/icon-button";
|
|
4
5
|
import {textStyles, themeVars} from "../../design-system";
|
|
5
6
|
import {Emoji} from "./emoji";
|
|
6
7
|
import {useEmojiPickerCtx, useEmojiPickerI18N} from "./root";
|
|
7
8
|
import {useEmojiSkin, useSetEmojiSkin} from "./skin-provider";
|
|
8
|
-
import {IconButton} from "../../button/icon-button";
|
|
9
9
|
|
|
10
10
|
const skinToneWrapperCss = css`
|
|
11
11
|
display: flex;
|
|
@@ -75,7 +75,7 @@ export const EmojiPickerSkinTone: React.FC<EmojiPickerSkinToneProps> = ({classNa
|
|
|
75
75
|
skinToneNodes.push(
|
|
76
76
|
<span key={`skin-tone-${skinTone}`} className={cx(skinToneSwatchCss, (selected || opened) && expandedCss)}>
|
|
77
77
|
<IconButton
|
|
78
|
-
size="
|
|
78
|
+
size="large"
|
|
79
79
|
onClick={() => {
|
|
80
80
|
if (opened) {
|
|
81
81
|
setSkin(skinTone as EmojiSkin);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {css} from "@linaria/core";
|
|
2
|
-
import {IconButton} from "../button/icon-button";
|
|
2
|
+
import {IconButton} from "../button-v2/icon-button";
|
|
3
3
|
import {border, layout, space, textStyles, themeVars} from "../design-system";
|
|
4
4
|
import CloseIcon from "../icons/react/Close";
|
|
5
5
|
import WarningIcon from "../icons/react/WarningTriangle";
|
|
@@ -50,8 +50,8 @@ export const ErrorAlert: React.FC<ErrorAlertProps> = ({message, description, act
|
|
|
50
50
|
</div>
|
|
51
51
|
{action}
|
|
52
52
|
{onClose ? (
|
|
53
|
-
<IconButton onClick={onClose} aria-label="Hide error">
|
|
54
|
-
<CloseIcon
|
|
53
|
+
<IconButton size="small" onClick={onClose} aria-label="Hide error">
|
|
54
|
+
<CloseIcon />
|
|
55
55
|
</IconButton>
|
|
56
56
|
) : null}
|
|
57
57
|
</div>
|
package/src/icon-button.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import RemoveIcon from "../../icons/react/Remove";
|
|
3
1
|
import {ClearIndicatorProps, GroupBase, MultiValueRemoveProps} from "react-select";
|
|
4
|
-
import {
|
|
2
|
+
import {IconButton} from "../../button-v2/icon-button";
|
|
3
|
+
import RemoveIcon from "../../icons/react/Remove";
|
|
5
4
|
|
|
6
5
|
export function ClearIndicator<
|
|
7
6
|
TOption,
|
|
@@ -16,7 +15,9 @@ export function ClearIndicator<
|
|
|
16
15
|
}
|
|
17
16
|
return (
|
|
18
17
|
<div {...innerProps}>
|
|
19
|
-
<
|
|
18
|
+
<IconButton disabled={selectProps.isDisabled} size={"small"}>
|
|
19
|
+
<RemoveIcon />
|
|
20
|
+
</IconButton>
|
|
20
21
|
</div>
|
|
21
22
|
);
|
|
22
23
|
}
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
} from "./index";
|
|
29
29
|
import {SelectControlSettingsProvider} from "./select-control-settings-context";
|
|
30
30
|
import {Menu} from "./custom-select-partials/menu";
|
|
31
|
+
import {useIsPhone} from "../use-is-phone";
|
|
31
32
|
|
|
32
33
|
const offset = [0, space.s4] as [number, number];
|
|
33
34
|
const popupHeightVH = 45;
|
|
@@ -56,6 +57,11 @@ const popupClassName = css`
|
|
|
56
57
|
padding-left: ${space.s8}px;
|
|
57
58
|
padding-right: ${space.s8}px;
|
|
58
59
|
`;
|
|
60
|
+
const mobileClassName = css`
|
|
61
|
+
padding-top: ${space.s12}px;
|
|
62
|
+
padding-left: ${space.s12}px;
|
|
63
|
+
padding-right: ${space.s12}px;
|
|
64
|
+
`;
|
|
59
65
|
|
|
60
66
|
const valueClassName = css`
|
|
61
67
|
border-radius: ${border.radius4}px;
|
|
@@ -301,11 +307,13 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
|
|
|
301
307
|
);
|
|
302
308
|
const paddingPopup = popupPaddingTop + popupPaddingBottom;
|
|
303
309
|
const paddingMenu = 6 + 6 + 6;
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
310
|
+
const isPhone = useIsPhone();
|
|
311
|
+
const maxMenuHeight = isPhone
|
|
312
|
+
? document.body.clientHeight - 45 - valueMaxHeight
|
|
313
|
+
: Math.max((document.body.clientHeight / 100) * popupHeightVH, popupMinHeightPx) -
|
|
314
|
+
valueMaxHeight -
|
|
315
|
+
paddingPopup -
|
|
316
|
+
paddingMenu;
|
|
309
317
|
const mergedComponents = {...defaultComponents, ...components};
|
|
310
318
|
|
|
311
319
|
return (
|
|
@@ -320,9 +328,12 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
|
|
|
320
328
|
</mergedComponents.Trigger>
|
|
321
329
|
{Boolean(triggerElement) && (
|
|
322
330
|
<Popup
|
|
331
|
+
supportMobile
|
|
332
|
+
title={title}
|
|
323
333
|
offset={offset}
|
|
324
334
|
popupContainerClassName={popupContainerClassName}
|
|
325
335
|
popupClassName={cx(popupClassName, popupStyles)}
|
|
336
|
+
mobilePopupContentClassName={mobileClassName}
|
|
326
337
|
placement="bottom-start"
|
|
327
338
|
renderInPortal={renderInPortal}
|
|
328
339
|
open={visible}
|
|
@@ -332,7 +343,7 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
|
|
|
332
343
|
triggerDomElement={triggerElement}
|
|
333
344
|
getPopupContainer={getPopupContainer}
|
|
334
345
|
>
|
|
335
|
-
{title && <div className={titleClassName}>{title}</div>}
|
|
346
|
+
{title && !isPhone && <div className={titleClassName}>{title}</div>}
|
|
336
347
|
{/*Usually we set popupContainerElement for react-select via context (SelectControlSettingsProvider). But here we render react-select in popover.*/}
|
|
337
348
|
{/*Render target in controlled by Popover here. So we just override SelectControlContext here and set popupContainerElement to undefined. */}
|
|
338
349
|
{/*So in dom react-select will be a child of popover. */}
|
|
@@ -350,6 +361,9 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
|
|
|
350
361
|
}}
|
|
351
362
|
autoFocus={autoFocus}
|
|
352
363
|
onBlur={() => {
|
|
364
|
+
if (isPhone) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
353
367
|
blurTimeoutRef.current = setTimeout(() => {
|
|
354
368
|
onHide(false);
|
|
355
369
|
}, 250);
|
package/src/toast/primitives.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import {preventDefault} from "@fibery/react/src/prevent-default";
|
|
|
2
2
|
import {css, cx} from "@linaria/core";
|
|
3
3
|
import * as ToastPrimitives from "@radix-ui/react-toast";
|
|
4
4
|
import {ElementRef, forwardRef} from "react";
|
|
5
|
-
import {IconButton} from "../button/icon-button";
|
|
5
|
+
import {IconButton} from "../button-v2/icon-button";
|
|
6
6
|
import {border, space, textStyles, themeVars} from "../design-system";
|
|
7
7
|
import CloseIcon from "../icons/react/Close";
|
|
8
8
|
|
|
@@ -150,8 +150,8 @@ export const ToastSubtitle = forwardRef<
|
|
|
150
150
|
export const ToastClose = () => {
|
|
151
151
|
return (
|
|
152
152
|
<ToastPrimitives.Close aria-label="Dismiss" asChild>
|
|
153
|
-
<IconButton>
|
|
154
|
-
<CloseIcon
|
|
153
|
+
<IconButton size="small">
|
|
154
|
+
<CloseIcon />
|
|
155
155
|
</IconButton>
|
|
156
156
|
</ToastPrimitives.Close>
|
|
157
157
|
);
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import {css} from "@linaria/core";
|
|
2
|
-
import {styled} from "@linaria/react";
|
|
3
|
-
import cx from "classnames";
|
|
4
|
-
import {forwardRef} from "react";
|
|
5
|
-
import {ButtonBase, ButtonBaseProps} from "./button-base";
|
|
6
|
-
import {iconContainer} from "../icons/Icon";
|
|
7
|
-
import {IconButtonV2} from "../button-v2/icon-button";
|
|
8
|
-
import {isButtonsV2} from "../utils";
|
|
9
|
-
|
|
10
|
-
export type IconButtonSize = "super-small" | "small" | "normal" | "big";
|
|
11
|
-
|
|
12
|
-
export type IconButtonProps = ButtonBaseProps & {
|
|
13
|
-
size?: IconButtonSize;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const Paddings = {
|
|
17
|
-
"super-small": 0,
|
|
18
|
-
small: 2,
|
|
19
|
-
normal: 4,
|
|
20
|
-
big: 6,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type StyledProps = {
|
|
24
|
-
/** The size of the component. `super-small` is equivalent to the dense button styling */
|
|
25
|
-
size: IconButtonSize;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const getPadding = ({size}: StyledProps) => Paddings[size];
|
|
29
|
-
|
|
30
|
-
const weight = css``;
|
|
31
|
-
|
|
32
|
-
const StyledIconButton = styled(ButtonBase)<StyledProps>`
|
|
33
|
-
&.${weight} {
|
|
34
|
-
padding: ${getPadding}px;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
& > .${iconContainer} {
|
|
38
|
-
color: inherit;
|
|
39
|
-
}
|
|
40
|
-
`;
|
|
41
|
-
|
|
42
|
-
/** @deprecated Please consider using IconButtonV2 */
|
|
43
|
-
export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(function IconButton(
|
|
44
|
-
{size = "normal", className, primary, dangerous, borderless = true, ...rest},
|
|
45
|
-
ref
|
|
46
|
-
) {
|
|
47
|
-
if (isButtonsV2) {
|
|
48
|
-
return (
|
|
49
|
-
<IconButtonV2
|
|
50
|
-
ref={ref}
|
|
51
|
-
className={className}
|
|
52
|
-
{...rest}
|
|
53
|
-
size={size === "big" || size === "normal" ? "medium" : "small"}
|
|
54
|
-
color={dangerous ? "error" : primary ? "accent" : "neutral"}
|
|
55
|
-
variant={primary ? "solid" : borderless ? "ghost" : "outline"}
|
|
56
|
-
/>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<StyledIconButton
|
|
62
|
-
ref={ref}
|
|
63
|
-
size={size}
|
|
64
|
-
className={cx(className, weight)}
|
|
65
|
-
primary={primary}
|
|
66
|
-
dangerous={dangerous}
|
|
67
|
-
borderless={borderless}
|
|
68
|
-
{...rest}
|
|
69
|
-
/>
|
|
70
|
-
);
|
|
71
|
-
});
|