@fibery/ui-kit 1.33.6 → 1.34.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 +5 -5
- package/src/button/make-button-colors.ts +52 -24
- package/src/icons/ast/ArrowUpCircle.ts +8 -0
- package/src/icons/ast/SlideMenu.ts +1 -1
- package/src/icons/ast/index.tsx +1 -0
- package/src/icons/react/ArrowUpCircle.tsx +13 -0
- package/src/icons/react/index.tsx +1 -0
- package/src/toggle.tsx +47 -28
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/ui-kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.34.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"files": [
|
|
6
6
|
"src/antd/styles.ts",
|
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
"screenfull": "6.0.1",
|
|
75
75
|
"tabbable": "5.2.1",
|
|
76
76
|
"ua-parser-js": "1.0.39",
|
|
77
|
-
"@fibery/
|
|
77
|
+
"@fibery/emoji-data": "2.6.0",
|
|
78
78
|
"@fibery/helpers": "1.3.0",
|
|
79
|
-
"@fibery/
|
|
79
|
+
"@fibery/react": "1.4.0"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"react": "^18.2.0",
|
|
@@ -110,8 +110,8 @@
|
|
|
110
110
|
"svgo": "2.8.0",
|
|
111
111
|
"typescript": "5.4.3",
|
|
112
112
|
"unist-util-reduce": "0.2.2",
|
|
113
|
-
"@fibery/
|
|
114
|
-
"@fibery/
|
|
113
|
+
"@fibery/eslint-config": "8.6.0",
|
|
114
|
+
"@fibery/babel-preset": "7.4.0"
|
|
115
115
|
},
|
|
116
116
|
"jest": {
|
|
117
117
|
"testEnvironment": "jsdom",
|
|
@@ -3,31 +3,59 @@
|
|
|
3
3
|
// so it's easier to find buttons with custom colors
|
|
4
4
|
|
|
5
5
|
import {CSSProperties} from "@linaria/core";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
getDarkenColor,
|
|
8
|
+
getEnumBackgroundColor,
|
|
9
|
+
getIconColor,
|
|
10
|
+
getOpacities,
|
|
11
|
+
getThemeValue,
|
|
12
|
+
themeVars,
|
|
13
|
+
} from "../design-system";
|
|
7
14
|
import {ButtonVariant} from "./base-button";
|
|
15
|
+
import {ThemeMode} from "../theme-settings";
|
|
8
16
|
|
|
9
|
-
export const makeButtonColors = (color: string, variant: ButtonVariant) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
export const makeButtonColors = (color: string, variant: ButtonVariant, mode: ThemeMode = "light"): CSSProperties => {
|
|
18
|
+
switch (variant) {
|
|
19
|
+
case "solid":
|
|
20
|
+
return {
|
|
21
|
+
"--fibery-button-color": color,
|
|
22
|
+
"--fibery-button-hover-color": getDarkenColor(color),
|
|
23
|
+
"--fibery-button-text-color": themeVars.buttonPrimaryTextColor,
|
|
24
|
+
"--fibery-button-text-active-color": themeVars.buttonPrimaryTextColor,
|
|
25
|
+
"--fibery-button-focus-color": getOpacities(color).opacity30,
|
|
26
|
+
};
|
|
27
|
+
case "ghost":
|
|
28
|
+
return {
|
|
29
|
+
"--fibery-button-color": "transparent",
|
|
30
|
+
"--fibery-button-hover-color": getOpacities(color).opacity15,
|
|
31
|
+
"--fibery-button-text-color": color,
|
|
32
|
+
"--fibery-button-text-active-color": getOpacities(color).opacity80,
|
|
33
|
+
"--fibery-button-focus-color": getOpacities(color).opacity30,
|
|
34
|
+
};
|
|
35
|
+
case "outline":
|
|
36
|
+
return {
|
|
37
|
+
"--fibery-button-color": "transparent",
|
|
38
|
+
"--fibery-button-hover-color": getOpacities(color).opacity15,
|
|
39
|
+
"--fibery-button-text-color": color,
|
|
40
|
+
"--fibery-button-text-active-color": getOpacities(color).opacity80,
|
|
41
|
+
"--fibery-button-focus-color": getOpacities(color).opacity30,
|
|
42
|
+
"--fibery-button-border-color": getOpacities(color).opacity30,
|
|
43
|
+
};
|
|
44
|
+
default:
|
|
45
|
+
case "soft": {
|
|
46
|
+
const bgColor = getEnumBackgroundColor(mode, color) as string;
|
|
47
|
+
const textColor = getIconColor(mode, color) as string;
|
|
26
48
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
49
|
+
return {
|
|
50
|
+
"--fibery-button-color": bgColor,
|
|
51
|
+
"--fibery-button-hover-color": getThemeValue(mode, {
|
|
52
|
+
light: getOpacities(color).opacity30,
|
|
53
|
+
dark: getOpacities(color).opacity45,
|
|
54
|
+
}),
|
|
55
|
+
"--fibery-button-text-color": textColor,
|
|
56
|
+
"--fibery-button-text-active-color": getOpacities(textColor).opacity80,
|
|
57
|
+
"--fibery-button-focus-color": getOpacities(color).opacity30,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
33
61
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
|
|
2
|
+
// This icon file is generated automatically.
|
|
3
|
+
|
|
4
|
+
import { IconDefinition } from '../types';
|
|
5
|
+
|
|
6
|
+
const ArrowUpCircle: IconDefinition = {"icon":{"type":"root","children":[{"type":"element","tagName":"svg","properties":{"viewBox":"0 0 20 20"},"children":[{"type":"element","tagName":"path","properties":{"d":"M10 1.667a8.333 8.333 0 1 0 0 16.666 8.333 8.333 0 0 0 0-16.666Zm0 15a6.667 6.667 0 1 1 0-13.334 6.667 6.667 0 0 1 0 13.334Z"},"children":[]},{"type":"element","tagName":"path","properties":{"d":"M11.97 9.53a.75.75 0 1 0 1.06-1.06l-2.5-2.5a.75.75 0 0 0-1.06 0l-2.5 2.5a.75.75 0 0 0 1.06 1.06l1.22-1.22v5.19a.75.75 0 0 0 1.5 0V8.31l1.22 1.22Z"},"children":[]}],"metadata":""}]},"name":"arrow-up-circle"};
|
|
7
|
+
|
|
8
|
+
export default ArrowUpCircle;
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
import { IconDefinition } from '../types';
|
|
5
5
|
|
|
6
|
-
const SlideMenu: IconDefinition = {"icon":{"type":"root","children":[{"type":"element","tagName":"svg","properties":{"viewBox":"0 0 20 20"},"children":[{"type":"element","tagName":"path","properties":{"d":"M7.25 9.5a.75.75 0 0 0-.75-.75h-1a.75.75 0 0 0 0 1.5h1a.75.75 0 0 0 .75-.
|
|
6
|
+
const SlideMenu: IconDefinition = {"icon":{"type":"root","children":[{"type":"element","tagName":"svg","properties":{"viewBox":"0 0 20 20"},"children":[{"type":"element","tagName":"path","properties":{"d":"M7.25 9.5a.75.75 0 0 0-.75-.75h-1a.75.75 0 0 0 0 1.5h1a.75.75 0 0 0 .75-.75ZM6.5 6.25a.75.75 0 0 1 0 1.5h-1a.75.75 0 0 1 0-1.5h1Z"},"children":[]},{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","clipRule":"evenodd","d":"M15.25 3A2.75 2.75 0 0 1 18 5.75v8.5A2.75 2.75 0 0 1 15.25 17H4.75A2.75 2.75 0 0 1 2 14.25v-8.5A2.75 2.75 0 0 1 4.75 3h10.5Zm1.25 2.75c0-.69-.56-1.25-1.25-1.25h-5.5v11h5.5c.69 0 1.25-.56 1.25-1.25v-8.5ZM8.25 15.5v-11h-3.5c-.69 0-1.25.56-1.25 1.25v8.5c0 .69.56 1.25 1.25 1.25h3.5Z"},"children":[]}],"metadata":""}]},"name":"slide-menu"};
|
|
7
7
|
|
|
8
8
|
export default SlideMenu;
|
package/src/icons/ast/index.tsx
CHANGED
|
@@ -27,6 +27,7 @@ export { default as ArrowForward } from './ArrowForward';
|
|
|
27
27
|
export { default as ArrowLeft } from './ArrowLeft';
|
|
28
28
|
export { default as ArrowRight } from './ArrowRight';
|
|
29
29
|
export { default as ArrowTop } from './ArrowTop';
|
|
30
|
+
export { default as ArrowUpCircle } from './ArrowUpCircle';
|
|
30
31
|
export { default as AskForInput } from './AskForInput';
|
|
31
32
|
export { default as Atom } from './Atom';
|
|
32
33
|
export { default as AutomationsCancelled } from './AutomationsCancelled';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This icon file is generated automatically.
|
|
2
|
+
|
|
3
|
+
import {forwardRef} from 'react';
|
|
4
|
+
import ArrowUpCircleSvg from '../ast/ArrowUpCircle';
|
|
5
|
+
import { Icon } from '../Icon';
|
|
6
|
+
import { IconBaseProps } from '../types';
|
|
7
|
+
|
|
8
|
+
const ArrowUpCircle = forwardRef<SVGSVGElement, IconBaseProps>(function ArrowUpCircle(
|
|
9
|
+
props: IconBaseProps,
|
|
10
|
+
ref: React.Ref<SVGSVGElement>
|
|
11
|
+
) {return <Icon {...props} className={props.className} ref={ref} icon={ArrowUpCircleSvg} />});
|
|
12
|
+
|
|
13
|
+
export default ArrowUpCircle;
|
|
@@ -27,6 +27,7 @@ export { default as ArrowForward } from './ArrowForward';
|
|
|
27
27
|
export { default as ArrowLeft } from './ArrowLeft';
|
|
28
28
|
export { default as ArrowRight } from './ArrowRight';
|
|
29
29
|
export { default as ArrowTop } from './ArrowTop';
|
|
30
|
+
export { default as ArrowUpCircle } from './ArrowUpCircle';
|
|
30
31
|
export { default as AskForInput } from './AskForInput';
|
|
31
32
|
export { default as Atom } from './Atom';
|
|
32
33
|
export { default as AutomationsCancelled } from './AutomationsCancelled';
|
package/src/toggle.tsx
CHANGED
|
@@ -6,7 +6,10 @@ import {layout, space, textStyles, transition} from "./design-system";
|
|
|
6
6
|
import _ from "lodash";
|
|
7
7
|
import SpinnerIcon from "./icons/react/Spinner";
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const toggleIconHeightVar = "--fibery-toggle-icon-height";
|
|
10
|
+
const toggleIconWidthVar = "--fibery-toggle-icon-width";
|
|
11
|
+
|
|
12
|
+
const Input = styled.input<{outlineColor: string}>`
|
|
10
13
|
position: absolute;
|
|
11
14
|
cursor: pointer;
|
|
12
15
|
top: 0;
|
|
@@ -14,9 +17,9 @@ const Input = styled.input<{containerSize: number; containerWidth: number; outli
|
|
|
14
17
|
appearance: none;
|
|
15
18
|
margin-right: 0;
|
|
16
19
|
background-color: transparent;
|
|
17
|
-
height: ${
|
|
18
|
-
width: ${
|
|
19
|
-
border-radius: ${
|
|
20
|
+
height: var(${toggleIconHeightVar});
|
|
21
|
+
width: var(${toggleIconWidthVar});
|
|
22
|
+
border-radius: calc(var(${toggleIconHeightVar}) / 2);
|
|
20
23
|
|
|
21
24
|
&:focus {
|
|
22
25
|
outline: none;
|
|
@@ -28,7 +31,6 @@ const Input = styled.input<{containerSize: number; containerWidth: number; outli
|
|
|
28
31
|
`;
|
|
29
32
|
|
|
30
33
|
const Label = styled.div<{labelPosition: "last" | "first"; disabled?: boolean}>`
|
|
31
|
-
${textStyles.regular}
|
|
32
34
|
margin-left: ${({labelPosition}) => (labelPosition === "last" ? `${space.s8}px` : 0)};
|
|
33
35
|
margin-right: ${({labelPosition}) => (labelPosition === "first" ? `${space.s8}px` : 0)};
|
|
34
36
|
opacity: ${({disabled}) => (disabled ? 0.5 : 1)};
|
|
@@ -56,31 +58,53 @@ const getOutlineColor = _.memoize((color: string) => {
|
|
|
56
58
|
});
|
|
57
59
|
|
|
58
60
|
const CircleContainer = styled.div<{
|
|
59
|
-
containerSize: number;
|
|
60
|
-
containerWidth: number;
|
|
61
61
|
backgroundColor: string;
|
|
62
62
|
disabled?: boolean;
|
|
63
63
|
}>`
|
|
64
64
|
position: relative;
|
|
65
|
-
height: ${
|
|
66
|
-
width: ${
|
|
65
|
+
height: var(${toggleIconHeightVar});
|
|
66
|
+
width: var(${toggleIconWidthVar});
|
|
67
67
|
flex-shrink: 0;
|
|
68
|
-
border-radius: ${
|
|
68
|
+
border-radius: calc(var(${toggleIconHeightVar}) / 2);
|
|
69
69
|
background-color: ${({backgroundColor}) => backgroundColor};
|
|
70
70
|
padding: ${space.s2}px;
|
|
71
71
|
transition: background-color ${transition};
|
|
72
72
|
opacity: ${({disabled}) => (disabled ? 0.5 : 1)};
|
|
73
73
|
`;
|
|
74
74
|
|
|
75
|
-
const Circle = styled.div
|
|
76
|
-
height: ${
|
|
77
|
-
width: ${
|
|
78
|
-
border-radius: ${
|
|
75
|
+
const Circle = styled.div`
|
|
76
|
+
height: calc(var(${toggleIconHeightVar}) - ${space.s2 * 2}px);
|
|
77
|
+
width: calc(var(${toggleIconHeightVar}) - ${space.s2 * 2}px);
|
|
78
|
+
border-radius: calc(var(${toggleIconHeightVar}) / 2 - ${space.s2}px);
|
|
79
79
|
background-color: white;
|
|
80
80
|
transition: transform ${transition};
|
|
81
81
|
`;
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
export type ToggleSize = "small" | "medium" | "large" | "extra-large";
|
|
84
|
+
|
|
85
|
+
const toggleSize = {
|
|
86
|
+
small: css`
|
|
87
|
+
${textStyles.small}
|
|
88
|
+
${toggleIconHeightVar}: 14px;
|
|
89
|
+
`,
|
|
90
|
+
medium: css`
|
|
91
|
+
${textStyles.regular}
|
|
92
|
+
${toggleIconHeightVar}: 16px;
|
|
93
|
+
`,
|
|
94
|
+
large: css`
|
|
95
|
+
${textStyles.regular}
|
|
96
|
+
${toggleIconHeightVar}: 18px;
|
|
97
|
+
`,
|
|
98
|
+
"extra-large": css`
|
|
99
|
+
${textStyles.regular}
|
|
100
|
+
${toggleIconHeightVar}: 20px;
|
|
101
|
+
`,
|
|
102
|
+
};
|
|
103
|
+
const toggleSizeStyle = css`
|
|
104
|
+
${toggleIconWidthVar}: calc(var(${toggleIconHeightVar}) * 1.75)
|
|
105
|
+
`;
|
|
106
|
+
|
|
107
|
+
type ToggleProps = Omit<ComponentProps<"input">, "value" | "size"> & {
|
|
84
108
|
value?: boolean;
|
|
85
109
|
label?: ReactNode;
|
|
86
110
|
labelTitle?: string;
|
|
@@ -89,7 +113,8 @@ interface ToggleProps extends Omit<ComponentProps<"input">, "value"> {
|
|
|
89
113
|
labelPosition?: "first" | "last";
|
|
90
114
|
wrapperClassName?: string;
|
|
91
115
|
pending?: boolean;
|
|
92
|
-
|
|
116
|
+
size?: ToggleSize;
|
|
117
|
+
};
|
|
93
118
|
|
|
94
119
|
export const Toggle: FC<ToggleProps> = ({
|
|
95
120
|
value,
|
|
@@ -98,7 +123,7 @@ export const Toggle: FC<ToggleProps> = ({
|
|
|
98
123
|
pending,
|
|
99
124
|
disabled = false,
|
|
100
125
|
backgroundColor,
|
|
101
|
-
size =
|
|
126
|
+
size = "medium",
|
|
102
127
|
onChange,
|
|
103
128
|
labelPosition = "last",
|
|
104
129
|
labelMutedWhenDisabled = true,
|
|
@@ -106,16 +131,17 @@ export const Toggle: FC<ToggleProps> = ({
|
|
|
106
131
|
wrapperClassName,
|
|
107
132
|
...rest
|
|
108
133
|
}) => {
|
|
109
|
-
const width = size * 1.75;
|
|
110
134
|
const outlineColor = getOutlineColor(backgroundColor);
|
|
111
135
|
|
|
112
136
|
const circleTransformStyle = {
|
|
113
|
-
transform: `translateX(${value ?
|
|
137
|
+
transform: `translateX(${value ? `calc(var(${toggleIconWidthVar}) - var(${toggleIconHeightVar}))` : 0})`,
|
|
114
138
|
};
|
|
115
139
|
|
|
116
140
|
return (
|
|
117
141
|
<label
|
|
118
142
|
className={cx(
|
|
143
|
+
toggleSize[size],
|
|
144
|
+
toggleSizeStyle,
|
|
119
145
|
wrapperClassName,
|
|
120
146
|
labelWrapperStyle,
|
|
121
147
|
disabled
|
|
@@ -137,16 +163,9 @@ export const Toggle: FC<ToggleProps> = ({
|
|
|
137
163
|
>
|
|
138
164
|
{pending && <SpinnerIcon />}
|
|
139
165
|
{!pending && (
|
|
140
|
-
<CircleContainer
|
|
141
|
-
|
|
142
|
-
containerWidth={width}
|
|
143
|
-
backgroundColor={backgroundColor}
|
|
144
|
-
disabled={disabled}
|
|
145
|
-
>
|
|
146
|
-
<Circle containerSize={size} style={circleTransformStyle} />
|
|
166
|
+
<CircleContainer backgroundColor={backgroundColor} disabled={disabled}>
|
|
167
|
+
<Circle style={circleTransformStyle} />
|
|
147
168
|
<Input
|
|
148
|
-
containerSize={size}
|
|
149
|
-
containerWidth={width}
|
|
150
169
|
outlineColor={outlineColor}
|
|
151
170
|
onChange={onChange}
|
|
152
171
|
className={className}
|