@fibery/ui-kit 2.0.0 → 2.0.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/.oxlintrc.json +24 -0
- package/CHANGELOG.md +7 -0
- package/eslint.config.mjs +1 -1
- package/jest.config.cjs +36 -0
- package/package.json +10 -50
- package/src/@types/css.d.ts +1 -0
- package/src/actions-menu/actions-menu-checkbox-item.tsx +74 -0
- package/src/actions-menu/contexts/actions-menu-context.tsx +1 -0
- package/src/actions-menu/index.tsx +1 -0
- package/src/animated-number.tsx +2 -2
- package/src/antd/AutoComplete.d.ts +1 -0
- package/src/app-icon-with-fallback.tsx +4 -4
- package/src/app-icon.tsx +4 -4
- package/src/appIcons.json +1227 -1227
- package/src/avatar.tsx +44 -5
- package/src/box.tsx +10 -17
- package/src/button/make-button-colors.ts +13 -13
- package/src/checkbox.tsx +3 -3
- package/src/collapsible-section.tsx +1 -1
- package/src/context-menu/index.tsx +4 -0
- package/src/date-picker/date-range-picker.tsx +1 -1
- package/src/date-picker/relative-date-picker.tsx +3 -0
- package/src/date-picker/single-date-picker.tsx +10 -9
- package/src/design-system/alpha.ts +9 -0
- package/src/design-system/colors-css.test.ts +1 -9
- package/src/design-system/colors-css.ts +1 -1
- package/src/design-system/colors.ts +351 -313
- package/src/design-system/layout.ts +1 -1
- package/src/design-system/theme.ts +4 -1
- package/src/design-system/vars.test.ts +4 -0
- package/src/design-system.test.ts +1 -0
- package/src/design-system.ts +1 -1
- package/src/dropdown-menu/index.tsx +4 -0
- package/src/emoji-picker/primitives/emoji.tsx +12 -0
- package/src/emoji-picker/primitives/grid.tsx +100 -104
- package/src/emoji.tsx +1 -0
- package/src/file-item.tsx +308 -265
- package/src/icons/ast/AddDatabase.ts +1 -1
- package/src/icons/ast/AddIntegration.ts +1 -1
- package/src/icons/ast/ArrowsRightLeft.ts +1 -1
- package/src/icons/ast/ChatBubble.ts +1 -1
- package/src/icons/ast/ChatFloat.ts +1 -1
- package/src/icons/ast/ChatSidebar.ts +1 -1
- package/src/icons/ast/Clean.ts +1 -1
- package/src/icons/ast/Create.ts +1 -1
- package/src/icons/ast/ItemsTimeline.ts +1 -1
- package/src/icons/ast/Key.ts +1 -1
- package/src/icons/ast/NetworkAdd.ts +1 -1
- package/src/icons/ast/Print.ts +1 -1
- package/src/icons/ast/Success.ts +1 -1
- package/src/icons/ast/SuggestIntegration.ts +1 -1
- package/src/icons/ast/WarningTriangle.ts +1 -1
- package/src/icons/ast/Windows.ts +1 -1
- package/src/icons/svg/add-database.svg +1 -1
- package/src/icons/svg/add-integration.svg +1 -1
- package/src/icons/svg/arrows-right-left.svg +1 -1
- package/src/icons/svg/chat-bubble.svg +1 -1
- package/src/icons/svg/chat-float.svg +1 -1
- package/src/icons/svg/chat-sidebar.svg +3 -3
- package/src/icons/svg/clean.svg +1 -1
- package/src/icons/svg/create.svg +1 -1
- package/src/icons/svg/items-timeline.svg +1 -1
- package/src/icons/svg/key.svg +1 -1
- package/src/icons/svg/network-add.svg +1 -1
- package/src/icons/svg/print.svg +1 -1
- package/src/icons/svg/success.svg +1 -1
- package/src/icons/svg/suggest-integration.svg +1 -1
- package/src/icons/svg/warning-triangle.svg +1 -1
- package/src/icons/svg/windows.svg +1 -1
- package/src/images-gallery/images-gallery.tsx +24 -0
- package/src/lists/actions-menu-row-surface.tsx +2 -1
- package/src/logo.tsx +14 -13
- package/src/modal-menu/index.tsx +1 -0
- package/src/modal-menu/modal-menu-checkbox-item.tsx +50 -0
- package/src/online-users.tsx +45 -46
- package/src/palettes/slate-arch.colors-snapshot.test.ts +7 -7
- package/src/palettes/slate-user.colors-snapshot.test.ts +11 -11
- package/src/palettes/warm-arch.colors-snapshot.test.ts +7 -7
- package/src/palettes/warm-user.colors-snapshot.test.ts +7 -7
- package/src/popover/index.tsx +91 -203
- package/src/popover/popover-old.tsx +113 -0
- package/src/popover/popup-modifiers-context.ts +1 -1
- package/src/scale-generator.ts +2 -2
- package/src/select/components/clear-indicator.tsx +1 -1
- package/src/select/components/drop-down-indicator.tsx +2 -2
- package/src/select/components/group-heading.tsx +2 -2
- package/src/select/components/menu-list-virtualized.tsx +1 -1
- package/src/select/components/option.tsx +1 -1
- package/src/select/index.tsx +34 -37
- package/src/select/select-in-popover.tsx +34 -202
- package/src/select/select.tsx +5 -4
- package/src/select/styles.ts +3 -0
- package/src/thematic-state.ts +1 -1
- package/src/theme-provider.tsx +14 -2
- package/src/theme-styles.ts +14 -7
- package/src/toggle-button/toggle-button.tsx +48 -35
- package/src/tree-utils.test.ts +166 -0
- package/src/tree-utils.ts +107 -0
- package/src/file-item/use-register-in-image-gallery.tsx +0 -70
- package/src/file-item-2.tsx +0 -357
package/src/avatar.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {css} from "@linaria/core";
|
|
1
|
+
import {css, cx} from "@linaria/core";
|
|
2
2
|
import memoize from "lodash/memoize";
|
|
3
3
|
import {CSSProperties, FC, memo, useCallback, useMemo, useState} from "react";
|
|
4
|
-
import {getDarkenColor, getObjectColorMemoized, textStyles, themeVars} from "./design-system";
|
|
4
|
+
import {getDarkenColor, getObjectColorMemoized, space, textStyles, themeVars} from "./design-system";
|
|
5
5
|
import {FibermojiPlaceholder} from "./fibermoji-placeholder";
|
|
6
6
|
import {getShiftStyle} from "./icons/get-shift-style";
|
|
7
7
|
import {useFeatures} from "./features";
|
|
@@ -89,7 +89,7 @@ type AvatarImageProps = {
|
|
|
89
89
|
placeholder?: React.ReactNode;
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
const AvatarImage: FC<AvatarImageProps> = memo(function AvatarImage({
|
|
93
93
|
size,
|
|
94
94
|
containerSize,
|
|
95
95
|
title,
|
|
@@ -188,7 +188,7 @@ type AvatarPlaceholderProps = {
|
|
|
188
188
|
backgroundColor?: string;
|
|
189
189
|
};
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
const AvatarPlaceholder: FC<AvatarPlaceholderProps> = memo(function AvatarPlaceholder(props) {
|
|
192
192
|
const features = useFeatures<{enableFibermojiAvatars: boolean}>();
|
|
193
193
|
if (features.enableFibermojiAvatars) {
|
|
194
194
|
return <FibermojiPlaceholder {...props} />;
|
|
@@ -230,7 +230,7 @@ type NullUserAvatarProps = {
|
|
|
230
230
|
containerSize: number;
|
|
231
231
|
};
|
|
232
232
|
|
|
233
|
-
|
|
233
|
+
const NullUserAvatar: FC<NullUserAvatarProps> = memo(function NullUserAvatar({size, containerSize}) {
|
|
234
234
|
const dashSize = (Math.PI * size) / magicCoefficient / 12;
|
|
235
235
|
return (
|
|
236
236
|
<div style={getNullUserAvatarContainerStyle({containerSize})}>
|
|
@@ -248,3 +248,42 @@ export const NullUserAvatar: FC<NullUserAvatarProps> = memo(function NullUserAva
|
|
|
248
248
|
</div>
|
|
249
249
|
);
|
|
250
250
|
});
|
|
251
|
+
|
|
252
|
+
const avatarGroupCss = css`
|
|
253
|
+
display: flex;
|
|
254
|
+
`;
|
|
255
|
+
|
|
256
|
+
function AvatarGroup({className, ...props}: React.ComponentProps<"div">) {
|
|
257
|
+
return <div className={cx(avatarGroupCss, className)} {...props} />;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const avatarCss = css`
|
|
261
|
+
margin-left: -${space.s4}px;
|
|
262
|
+
&:first-of-type {
|
|
263
|
+
margin-left: 0;
|
|
264
|
+
}
|
|
265
|
+
z-index: 1;
|
|
266
|
+
`;
|
|
267
|
+
|
|
268
|
+
function Avatar({className, ...props}: React.ComponentProps<"div">) {
|
|
269
|
+
return <div className={cx(avatarCss, className)} {...props} />;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const avatarGroupCountCss = css`
|
|
273
|
+
display: flex;
|
|
274
|
+
align-items: center;
|
|
275
|
+
justify-content: center;
|
|
276
|
+
width: var(--fibery-avatar-group-count-size);
|
|
277
|
+
height: var(--fibery-avatar-group-count-size);
|
|
278
|
+
color: ${themeVars.accentTextColor};
|
|
279
|
+
font-size: calc(var(--fibery-avatar-group-count-size) * 0.5);
|
|
280
|
+
background-color: ${themeVars.badgeBgColor};
|
|
281
|
+
border-radius: 50%;
|
|
282
|
+
`;
|
|
283
|
+
|
|
284
|
+
function AvatarGroupCount({className, size, ...props}: {size: number} & React.ComponentProps<"div">) {
|
|
285
|
+
const style = {"--fibery-avatar-group-count-size": size + "px"} as CSSProperties;
|
|
286
|
+
return <div data-slot="avatar-group-count" style={style} className={cx(avatarGroupCountCss, className)} {...props} />;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export {AvatarGroup, Avatar, AvatarImage, AvatarPlaceholder, AvatarGroupCount, NullUserAvatar};
|
package/src/box.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import {css} from "@linaria/core";
|
|
|
2
2
|
import {styled} from "@linaria/react";
|
|
3
3
|
import cx from "classnames";
|
|
4
4
|
import {CSSProperties, forwardRef, HTMLProps, ReactNode, Ref, useCallback, useMemo, useState} from "react";
|
|
5
|
-
import {border, getLinearGradient,
|
|
5
|
+
import {alpha, border, getLinearGradient, space, textStyles, themeVars, transition} from "./design-system";
|
|
6
6
|
import {useClickOutside} from "./popover/use-click-outside";
|
|
7
7
|
|
|
8
8
|
export const getBg = (backgroundColors: string[]) => {
|
|
@@ -266,22 +266,15 @@ export function getBoxColorCoding({backgroundColors}: {backgroundColors: string[
|
|
|
266
266
|
const colorCodingStyle = colorCodingColor
|
|
267
267
|
? ({
|
|
268
268
|
[colorCodingBackgroundCustomProperty]: colorCodingColor,
|
|
269
|
-
[colorCodingShadowEntityBoxDefaultCustomProperty]: `0px 2px 4px 0px ${
|
|
270
|
-
|
|
271
|
-
}`,
|
|
272
|
-
[
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}`,
|
|
279
|
-
[colorCodingHoverFocusShadowStrokeEntityBoxDefaultCustomProperty]: `0 0 0 2px ${
|
|
280
|
-
getOpacities(colorCodingColor).opacity60
|
|
281
|
-
}`,
|
|
282
|
-
[colorCodingShadowStrokeEntityBoxSelectedCustomProperty]: `0 0 0 1px ${
|
|
283
|
-
getOpacities(colorCodingColor).opacity60
|
|
284
|
-
}, 0 0 0 3px ${getOpacities(colorCodingColor).opacity40}`,
|
|
269
|
+
[colorCodingShadowEntityBoxDefaultCustomProperty]: `0px 2px 4px 0px ${alpha(colorCodingColor, 0.1)}`,
|
|
270
|
+
[colorCodingShadowStrokeEntityBoxDefaultCustomProperty]: `0 0 0 1px ${alpha(colorCodingColor, 0.3)}`,
|
|
271
|
+
[colorCodingBackgroundHoverShadowCustomProperty]: `0px 4px 8px 0px ${alpha(colorCodingColor, 0.1)}`,
|
|
272
|
+
[colorCodingFocusShadowStrokeEntityBoxDefaultCustomProperty]: `0 0 0 2px ${alpha(colorCodingColor, 0.4)}`,
|
|
273
|
+
[colorCodingHoverFocusShadowStrokeEntityBoxDefaultCustomProperty]: `0 0 0 2px ${alpha(colorCodingColor, 0.6)}`,
|
|
274
|
+
[colorCodingShadowStrokeEntityBoxSelectedCustomProperty]: `0 0 0 1px ${alpha(
|
|
275
|
+
colorCodingColor,
|
|
276
|
+
0.6
|
|
277
|
+
)}, 0 0 0 3px ${alpha(colorCodingColor, 0.4)}`,
|
|
285
278
|
} as CSSProperties)
|
|
286
279
|
: {};
|
|
287
280
|
return {
|
|
@@ -3,7 +3,7 @@
|
|
|
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 {alpha, getDarkenColor, ThemeColors, themeVars} from "../design-system";
|
|
7
7
|
import {ButtonVariant} from "./base-button";
|
|
8
8
|
|
|
9
9
|
export const makeButtonColors = (color: string, variant: ButtonVariant, theme: ThemeColors): CSSProperties => {
|
|
@@ -14,24 +14,24 @@ export const makeButtonColors = (color: string, variant: ButtonVariant, theme: T
|
|
|
14
14
|
"--fibery-button-hover-color": getDarkenColor(color),
|
|
15
15
|
"--fibery-button-text-color": themeVars.buttonPrimaryTextColor,
|
|
16
16
|
"--fibery-button-text-active-color": themeVars.buttonPrimaryTextColor,
|
|
17
|
-
"--fibery-button-focus-color":
|
|
17
|
+
"--fibery-button-focus-color": alpha(color, 0.3),
|
|
18
18
|
};
|
|
19
19
|
case "ghost":
|
|
20
20
|
return {
|
|
21
21
|
"--fibery-button-color": "transparent",
|
|
22
|
-
"--fibery-button-hover-color":
|
|
22
|
+
"--fibery-button-hover-color": alpha(color, 0.15),
|
|
23
23
|
"--fibery-button-text-color": color,
|
|
24
|
-
"--fibery-button-text-active-color":
|
|
25
|
-
"--fibery-button-focus-color":
|
|
24
|
+
"--fibery-button-text-active-color": alpha(color, 0.8),
|
|
25
|
+
"--fibery-button-focus-color": alpha(color, 0.3),
|
|
26
26
|
};
|
|
27
27
|
case "outline":
|
|
28
28
|
return {
|
|
29
29
|
"--fibery-button-color": "transparent",
|
|
30
|
-
"--fibery-button-hover-color":
|
|
30
|
+
"--fibery-button-hover-color": alpha(color, 0.15),
|
|
31
31
|
"--fibery-button-text-color": color,
|
|
32
|
-
"--fibery-button-text-active-color":
|
|
33
|
-
"--fibery-button-focus-color":
|
|
34
|
-
"--fibery-button-border-color":
|
|
32
|
+
"--fibery-button-text-active-color": alpha(color, 0.8),
|
|
33
|
+
"--fibery-button-focus-color": alpha(color, 0.3),
|
|
34
|
+
"--fibery-button-border-color": alpha(color, 0.3),
|
|
35
35
|
};
|
|
36
36
|
default:
|
|
37
37
|
case "soft": {
|
|
@@ -41,12 +41,12 @@ export const makeButtonColors = (color: string, variant: ButtonVariant, theme: T
|
|
|
41
41
|
return {
|
|
42
42
|
"--fibery-button-color": bgColor,
|
|
43
43
|
"--fibery-button-hover-color": theme.select({
|
|
44
|
-
light:
|
|
45
|
-
dark:
|
|
44
|
+
light: alpha(color, 0.3),
|
|
45
|
+
dark: alpha(color, 0.45),
|
|
46
46
|
}),
|
|
47
47
|
"--fibery-button-text-color": textColor,
|
|
48
|
-
"--fibery-button-text-active-color":
|
|
49
|
-
"--fibery-button-focus-color":
|
|
48
|
+
"--fibery-button-text-active-color": alpha(textColor, 0.8),
|
|
49
|
+
"--fibery-button-focus-color": alpha(color, 0.3),
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
}
|
package/src/checkbox.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
useEffect,
|
|
13
13
|
useRef,
|
|
14
14
|
} from "react";
|
|
15
|
-
import {
|
|
15
|
+
import {alpha, getDarkenColor, layout, space, textStyles, ThemeColors, themeVars} from "./design-system";
|
|
16
16
|
import {smallHtmlStylesClass} from "./html-styles";
|
|
17
17
|
import {mobileRootSelector} from "./mobile-styles";
|
|
18
18
|
|
|
@@ -154,8 +154,8 @@ const CheckboxComponent = memo(
|
|
|
154
154
|
const indeterminate = checked === null;
|
|
155
155
|
const defaultIndeterminate = defaultChecked === null;
|
|
156
156
|
const cColor = color || theme.primaryBlue;
|
|
157
|
-
const fColor =
|
|
158
|
-
const hColor =
|
|
157
|
+
const fColor = alpha(cColor, 0.25);
|
|
158
|
+
const hColor = alpha(cColor, 0.1);
|
|
159
159
|
const dColor = getDarkenColor(cColor);
|
|
160
160
|
const bColor = themeVars.checkboxColor;
|
|
161
161
|
|
|
@@ -84,7 +84,7 @@ export const CollapsibleSection = ({
|
|
|
84
84
|
const regularHeader = label && <div className={headerCss}>{label}</div>;
|
|
85
85
|
|
|
86
86
|
return (
|
|
87
|
-
<div className={className}>
|
|
87
|
+
<div className={className} data-testid="collapsible-section">
|
|
88
88
|
{collapsible ? collapsibleHeader : regularHeader}
|
|
89
89
|
<div style={{display: collapsible && isCollapsed ? "none" : "block"}}>{children}</div>
|
|
90
90
|
</div>
|
|
@@ -111,6 +111,10 @@ export const Item = styled(ContextMenuPrimitive.Item)`
|
|
|
111
111
|
${rowItemStyles}
|
|
112
112
|
`;
|
|
113
113
|
|
|
114
|
+
export const CheckboxItem = styled(ContextMenuPrimitive.CheckboxItem)`
|
|
115
|
+
${rowItemStyles}
|
|
116
|
+
`;
|
|
117
|
+
|
|
114
118
|
export const Separator = styled(ContextMenuPrimitive.Separator)`
|
|
115
119
|
${{
|
|
116
120
|
backgroundColor: themeVars.actionMenuSeparatorColor,
|
|
@@ -37,7 +37,7 @@ export const DateRangePicker = forwardRef<
|
|
|
37
37
|
|
|
38
38
|
const dateValue = [value[0] ? value[0].toDate() : null, value[1] ? value[1].toDate() : null] as [
|
|
39
39
|
Date | null,
|
|
40
|
-
Date | null
|
|
40
|
+
Date | null,
|
|
41
41
|
];
|
|
42
42
|
const onDatesChange = useCallback(
|
|
43
43
|
(value: [Date | null, Date | null]) => {
|
|
@@ -94,6 +94,7 @@ export const RelativeDatePicker = (props: RelativeDatePickerProps) => {
|
|
|
94
94
|
>
|
|
95
95
|
<div>
|
|
96
96
|
<AntInputNumber
|
|
97
|
+
aria-label="Amount"
|
|
97
98
|
autoFocus={true}
|
|
98
99
|
value={valueWithDefault.amount}
|
|
99
100
|
controls={false}
|
|
@@ -109,6 +110,7 @@ export const RelativeDatePicker = (props: RelativeDatePickerProps) => {
|
|
|
109
110
|
`}
|
|
110
111
|
>
|
|
111
112
|
<SingleRowReactSelect
|
|
113
|
+
aria-label="Unit"
|
|
112
114
|
value={unitOptions.find((option) => option.value === valueWithDefault.unit)}
|
|
113
115
|
components={{
|
|
114
116
|
DropdownIndicator: AlwaysVisibleDropdownIndicator,
|
|
@@ -127,6 +129,7 @@ export const RelativeDatePicker = (props: RelativeDatePickerProps) => {
|
|
|
127
129
|
`}
|
|
128
130
|
>
|
|
129
131
|
<SingleRowReactSelect
|
|
132
|
+
aria-label="Direction"
|
|
130
133
|
value={isBeforeNowOptions.find(
|
|
131
134
|
(option) => option.value === (valueWithDefault.isBeforeNow ? "ago" : "from now")
|
|
132
135
|
)}
|
|
@@ -69,9 +69,9 @@ interface SingleDatePickerWithForwardRefType extends React.FC<SingleDatePickerPr
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
interface ControlledSingleDatePickerWithForwardRefType extends React.FC<UncontrolledSingleDatePickerProps<boolean>> {
|
|
72
|
-
<T extends boolean>(
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
<T extends boolean>(
|
|
73
|
+
props: UncontrolledSingleDatePickerProps<T>
|
|
74
|
+
): ReturnType<React.FC<UncontrolledSingleDatePickerProps<T>>>;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
type DatePickerRef = {
|
|
@@ -221,12 +221,12 @@ export const SingleDatePicker: SingleDatePickerWithForwardRefType = forwardRef<
|
|
|
221
221
|
const dateValueFormatted = isRelativeValue
|
|
222
222
|
? formatRelativeDate(value as RelativeDateValue)
|
|
223
223
|
: value
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
224
|
+
? formatDateInputValue((value as Moment).toDate(), {
|
|
225
|
+
showTime,
|
|
226
|
+
dateFormat,
|
|
227
|
+
dateTimeFormat,
|
|
228
|
+
})
|
|
229
|
+
: null;
|
|
230
230
|
|
|
231
231
|
const fakeWrapperRef = useRef<HTMLDivElement>(null);
|
|
232
232
|
|
|
@@ -249,6 +249,7 @@ export const SingleDatePicker: SingleDatePickerWithForwardRefType = forwardRef<
|
|
|
249
249
|
</Popover.Trigger>
|
|
250
250
|
<Popover.Portal>
|
|
251
251
|
<Popover.Content
|
|
252
|
+
data-testid="single-date-picker-content"
|
|
252
253
|
title={title}
|
|
253
254
|
offset={[0, space.s6]}
|
|
254
255
|
placement="bottom-start"
|
|
@@ -3,6 +3,7 @@ import mapValues from "lodash/mapValues";
|
|
|
3
3
|
import memoize from "lodash/memoize";
|
|
4
4
|
export const transparent = "rgba(255, 255, 255, 0)";
|
|
5
5
|
|
|
6
|
+
// TODO grades may become semantic someday?
|
|
6
7
|
export const opacity = {
|
|
7
8
|
opacity100: 1,
|
|
8
9
|
opacity95: 0.95,
|
|
@@ -39,3 +40,11 @@ export const getOpacities = memoize((color: string) =>
|
|
|
39
40
|
return produceColor(color, (c) => setAlpha(c, opacityValue));
|
|
40
41
|
})
|
|
41
42
|
);
|
|
43
|
+
|
|
44
|
+
// inspired by https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/alpha-value
|
|
45
|
+
export const alpha = memoize(
|
|
46
|
+
(color: string, value: (typeof opacity)[keyof typeof opacity]) => {
|
|
47
|
+
return produceColor(color, (c) => setAlpha(c, value));
|
|
48
|
+
},
|
|
49
|
+
(a, b) => a + b
|
|
50
|
+
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {getLinearGradient} from "./colors-css";
|
|
2
2
|
|
|
3
3
|
describe("getLinearGradient", () => {
|
|
4
4
|
test("single color", () => {
|
|
@@ -29,11 +29,3 @@ describe("getLinearGradient", () => {
|
|
|
29
29
|
);
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
|
-
|
|
33
|
-
describe("getEnumTextColor", () => {
|
|
34
|
-
test("snapshot", () => {
|
|
35
|
-
expect(getEnumTextColor("#4978D4")).toMatchInlineSnapshot(
|
|
36
|
-
`"color-mix(in srgb, #4978D4 25%, var(--fibery-color-textColor) 75%)"`
|
|
37
|
-
);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -9,7 +9,7 @@ export function getLinearGradient(backgroundColors: Array<string>): string {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export function getEnumTextColor(color: string) {
|
|
12
|
-
return `color-mix(in srgb, ${color}
|
|
12
|
+
return `color-mix(in srgb, ${color} 40%, ${themeVars.textColor} 60%)`;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function themeVarWithAlpha(themeVar: string, alpha: number) {
|