@fibery/ui-kit 1.40.2 → 1.40.4

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 (87) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.json +4 -7
  3. package/src/__snapshots__/design-system.test.ts.snap +7265 -0
  4. package/src/a11y-color.test.ts +181 -0
  5. package/src/a11y-color.ts +13 -20
  6. package/src/actions-menu/actions-menu-item.tsx +7 -7
  7. package/src/antd/ant-modal.tsx +10 -5
  8. package/src/antd/styles.ts +6 -6
  9. package/src/app-icon-with-fallback.tsx +2 -2
  10. package/src/app-icon.tsx +2 -2
  11. package/src/button/button.tsx +1 -0
  12. package/src/button/make-button-colors.ts +5 -13
  13. package/src/checkbox.tsx +2 -2
  14. package/src/color-picker/ColorPickerOrLoader.js +2 -2
  15. package/src/color-utils.test.ts +317 -0
  16. package/src/color-utils.ts +180 -0
  17. package/src/comment.tsx +3 -2
  18. package/src/context-menu/index.tsx +12 -7
  19. package/src/create-inline-theme.ts +9 -8
  20. package/src/design-system.colors.ts +760 -0
  21. package/src/design-system.test.ts +287 -7
  22. package/src/design-system.ts +146 -940
  23. package/src/dropdown-menu/index.tsx +21 -16
  24. package/src/emoji-picker/app-icon-picker.tsx +5 -5
  25. package/src/emoji-picker/emoji-picker-content-with-color.tsx +4 -4
  26. package/src/emoji-picker/icon-emoji-picker.tsx +2 -2
  27. package/src/favorites-icon.tsx +1 -1
  28. package/src/file-item/file-icon.tsx +169 -0
  29. package/src/file-item/file-menu-items.tsx +68 -0
  30. package/src/file-item/file-preview-actions.tsx +38 -0
  31. package/src/file-item/file-title.tsx +48 -0
  32. package/src/file-item/types.ts +27 -0
  33. package/src/file-item/use-register-in-image-gallery.tsx +70 -0
  34. package/src/file-item-2.tsx +35 -345
  35. package/src/file-item.tsx +6 -2
  36. package/src/hue-shift.test.ts +91 -0
  37. package/src/icons/Icon.tsx +1 -0
  38. package/src/icons/ast/FileCounter.ts +8 -0
  39. package/src/icons/ast/FileMultiple.ts +8 -0
  40. package/src/icons/ast/Print.ts +8 -0
  41. package/src/icons/ast/ValueEdit.ts +8 -0
  42. package/src/icons/ast/index.tsx +4 -0
  43. package/src/icons/react/Dividers.tsx +1 -1
  44. package/src/icons/react/FileCounter.tsx +13 -0
  45. package/src/icons/react/FileMultiple.tsx +13 -0
  46. package/src/icons/react/Print.tsx +13 -0
  47. package/src/icons/react/ValueEdit.tsx +13 -0
  48. package/src/icons/react/index.tsx +4 -0
  49. package/src/icons/svg/file-counter.svg +3 -0
  50. package/src/icons/svg/file-multiple.svg +3 -0
  51. package/src/icons/svg/print.svg +3 -0
  52. package/src/icons/svg/value-edit.svg +3 -0
  53. package/src/images-gallery/slide-buttons.tsx +4 -11
  54. package/src/lists/actions-menu-row-surface.tsx +5 -5
  55. package/src/mobile-keyboard-aware-popup.tsx +4 -3
  56. package/src/palette-generator.test.ts +566 -0
  57. package/src/palette-generator.ts +166 -0
  58. package/src/palette.ts +71 -55
  59. package/src/platform.ts +0 -3
  60. package/src/popover/index.tsx +20 -28
  61. package/src/progress.tsx +2 -2
  62. package/src/reactions/reaction-button.tsx +12 -6
  63. package/src/root-theme-provider.test.tsx +316 -0
  64. package/src/scale-generator.ts +347 -0
  65. package/src/select/components/menu-list-virtualized.tsx +7 -22
  66. package/src/select/components/menu.tsx +12 -2
  67. package/src/select/select.tsx +2 -1
  68. package/src/select/styles.ts +0 -1
  69. package/src/static-palettes.ts +146 -0
  70. package/src/thematic-color-picker.tsx +266 -0
  71. package/src/thematic-constants.tsx +27 -0
  72. package/src/thematic-controls.tsx +144 -0
  73. package/src/thematic-scales.tsx +122 -0
  74. package/src/thematic-state.ts +333 -0
  75. package/src/thematic.tsx +382 -0
  76. package/src/theme-provider.test.tsx +808 -0
  77. package/src/theme-provider.tsx +132 -69
  78. package/src/theme-settings.ts +1 -1
  79. package/src/theme-styles.ts +12 -5
  80. package/src/toast/toast-action.tsx +1 -1
  81. package/src/toggle-on-off.tsx +2 -2
  82. package/src/toggle.tsx +5 -6
  83. package/src/tooltip.tsx +13 -10
  84. package/src/type-badge.tsx +3 -3
  85. package/src/unit/styles.ts +2 -2
  86. package/src/unit/unit-with-tooltip.tsx +3 -2
  87. package/src/use-long-press.tsx +2 -2
@@ -0,0 +1,181 @@
1
+ import {a11yColor} from "./a11y-color";
2
+
3
+ describe("a11yColor", () => {
4
+ describe("returns original color when", () => {
5
+ it("color already passes contrast on light background", () => {
6
+ // Dark blue on white should already pass
7
+ const result = a11yColor("#000080", "#ffffff");
8
+ expect(result).toMatchInlineSnapshot(`"rgb(0,0,128)"`);
9
+ });
10
+
11
+ it("color already passes contrast on dark background", () => {
12
+ // White on black should already pass
13
+ const result = a11yColor("#ffffff", "#000000");
14
+ expect(result).toBe("rgb(255,255,255)");
15
+ });
16
+
17
+ it("invalid toMakeA11y color is provided", () => {
18
+ const result = a11yColor("invalid-color", "#ffffff");
19
+ expect(result).toBe("invalid-color");
20
+ });
21
+
22
+ it("invalid background color is provided", () => {
23
+ const result = a11yColor("#ff0000", "invalid-bg");
24
+ expect(result).toBe("#ff0000");
25
+ });
26
+
27
+ it("transparent is provided as toMakeA11y", () => {
28
+ const result = a11yColor("transparent", "#ffffff");
29
+ expect(result).toBe("transparent");
30
+ });
31
+
32
+ it("transparent is provided as background", () => {
33
+ const result = a11yColor("#ff0000", "transparent");
34
+ expect(result).toBe("#ff0000");
35
+ });
36
+ });
37
+
38
+ describe("adjusts colors for contrast", () => {
39
+ it("makes light color darker on white background", () => {
40
+ // Light yellow on white needs to be darker
41
+ const result = a11yColor("#ffff00", "#ffffff");
42
+ expect(result).toMatchInlineSnapshot(`"rgb(154,154,0)"`);
43
+ // Result should be different (darker) than input
44
+ expect(result).not.toBe("rgb(255,255,0)");
45
+ });
46
+
47
+ it("makes dark color lighter on black background", () => {
48
+ // Dark blue on black needs to be lighter
49
+ const result = a11yColor("#000033", "#000000");
50
+ expect(result).toMatchInlineSnapshot(`"rgb(49,49,255)"`);
51
+ // Result should be different (lighter) than input
52
+ expect(result).not.toBe("rgb(0,0,51)");
53
+ });
54
+
55
+ it("handles medium colors on light backgrounds", () => {
56
+ // Medium gray on white
57
+ const result = a11yColor("#808080", "#ffffff");
58
+ expect(result).toMatchInlineSnapshot(`"rgb(128,128,128)"`);
59
+ });
60
+
61
+ it("handles medium colors on dark backgrounds", () => {
62
+ // Medium gray on black
63
+ const result = a11yColor("#808080", "#000000");
64
+ expect(result).toMatchInlineSnapshot(`"rgb(128,128,128)"`);
65
+ });
66
+ });
67
+
68
+ describe("respects minimum contrast ratio", () => {
69
+ it("uses default 3.0 contrast ratio", () => {
70
+ const result = a11yColor("#cccccc", "#ffffff");
71
+ expect(result).toMatchInlineSnapshot(`"rgb(148,148,148)"`);
72
+ });
73
+
74
+ it("adjusts for higher contrast ratio (4.5 WCAG AA)", () => {
75
+ const result = a11yColor("#cccccc", "#ffffff", 4.5);
76
+ expect(result).toMatchInlineSnapshot(`"rgb(118,118,118)"`);
77
+ });
78
+
79
+ it("adjusts for highest contrast ratio (7.0 WCAG AAA)", () => {
80
+ const result = a11yColor("#cccccc", "#ffffff", 7.0);
81
+ expect(result).toMatchInlineSnapshot(`"rgb(89,89,89)"`);
82
+ });
83
+ });
84
+
85
+ describe("handles various color formats", () => {
86
+ it("handles 3-digit hex colors", () => {
87
+ const result = a11yColor("#f00", "#fff");
88
+ expect(result).toMatchInlineSnapshot(`"rgb(255,0,0)"`);
89
+ });
90
+
91
+ it("handles 6-digit hex colors", () => {
92
+ const result = a11yColor("#ff0000", "#ffffff");
93
+ expect(result).toMatchInlineSnapshot(`"rgb(255,0,0)"`);
94
+ });
95
+
96
+ it("handles rgb() colors", () => {
97
+ const result = a11yColor("rgb(255, 0, 0)", "#ffffff");
98
+ expect(result).toMatchInlineSnapshot(`"rgb(255,0,0)"`);
99
+ });
100
+
101
+ it("handles named colors", () => {
102
+ const result = a11yColor("red", "white");
103
+ expect(result).toMatchInlineSnapshot(`"rgb(255,0,0)"`);
104
+ });
105
+
106
+ it("handles hsl() colors", () => {
107
+ const result = a11yColor("hsl(0, 100%, 50%)", "#ffffff");
108
+ expect(result).toMatchInlineSnapshot(`"rgb(255,0,0)"`);
109
+ });
110
+ });
111
+
112
+ describe("caching", () => {
113
+ it("returns same result for same inputs", () => {
114
+ const result1 = a11yColor("#ff0000", "#ffffff");
115
+ const result2 = a11yColor("#ff0000", "#ffffff");
116
+ expect(result1).toBe(result2);
117
+ });
118
+
119
+ it("returns different results for different contrast ratios", () => {
120
+ const result1 = a11yColor("#cccccc", "#ffffff", 3.0);
121
+ const result2 = a11yColor("#cccccc", "#ffffff", 7.0);
122
+ // Higher contrast requirement may produce different result
123
+ expect(result1).not.toBe(result2);
124
+ });
125
+ });
126
+
127
+ describe("real-world use cases", () => {
128
+ it("brand green on white background", () => {
129
+ const result = a11yColor("#69AC5E", "#ffffff");
130
+ expect(result).toMatchInlineSnapshot(`"rgb(96,164,85)"`);
131
+ });
132
+
133
+ it("brand blue on white background", () => {
134
+ const result = a11yColor("#4978D4", "#ffffff");
135
+ expect(result).toMatchInlineSnapshot(`"rgb(73,120,212)"`);
136
+ });
137
+
138
+ it("light text on dark theme background", () => {
139
+ const result = a11yColor("#aaaaaa", "#1a1a1a");
140
+ expect(result).toMatchInlineSnapshot(`"rgb(170,170,170)"`);
141
+ });
142
+
143
+ it("card type colors on white", () => {
144
+ const cardColors = [
145
+ "#F0D0DD",
146
+ "#F5D3CA",
147
+ "#FAE0B7",
148
+ "#FCEAA2",
149
+ "#E3ECAB",
150
+ "#CFEFC8",
151
+ "#C1F3DF",
152
+ "#C1EDF5",
153
+ "#C1E0F5",
154
+ "#C7D6F9",
155
+ "#D8D3F5",
156
+ "#E8D1EF",
157
+ "#E6DFDA",
158
+ "#D2D2D2",
159
+ "#FFFF8D",
160
+ ];
161
+
162
+ expect(cardColors.map((color) => a11yColor(color, "#ffffff"))).toEqual([
163
+ "rgb(212,120,158)",
164
+ "rgb(224,119,91)",
165
+ "rgb(207,132,14)",
166
+ "rgb(180,145,6)",
167
+ "rgb(140,157,36)",
168
+ "rgb(71,169,49)",
169
+ "rgb(33,169,115)",
170
+ "rgb(30,162,186)",
171
+ "rgb(57,156,223)",
172
+ "rgb(107,146,239)",
173
+ "rgb(150,137,228)",
174
+ "rgb(189,124,209)",
175
+ "rgb(169,144,127)",
176
+ "rgb(148,148,148)",
177
+ "rgb(154,154,0)",
178
+ ]);
179
+ });
180
+ });
181
+ });
package/src/a11y-color.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // https://github.com/alex-page/a11ycolor
2
- import chroma from "chroma-js";
2
+ import {fromHSL, getContrastRatio, getHsl, isValidColor, toCss} from "./color-utils";
3
3
 
4
4
  class LRUCache<TKey, TValue> {
5
5
  #capacity: number;
@@ -41,12 +41,7 @@ const checkColor = (colorValue: string) => {
41
41
  if (colorValue === "transparent") {
42
42
  return false;
43
43
  }
44
-
45
- try {
46
- return chroma.valid(colorValue);
47
- } catch (error) {
48
- return false;
49
- }
44
+ return isValidColor(colorValue);
50
45
  };
51
46
 
52
47
  /**
@@ -58,10 +53,10 @@ const checkColor = (colorValue: string) => {
58
53
  *
59
54
  * @return {string} - The closest hex color for `toMakeA11y` on `background`
60
55
  */
61
- export function a11yColor(toMakeA11y: string, background: string, minimumContrast = 3.0) {
56
+ export function a11yColor(toMakeA11y: string, background: string, minimumContrast = 3.0): string {
62
57
  const key = toMakeA11y + background + minimumContrast;
63
58
  if (cache.has(key)) {
64
- return cache.get(key);
59
+ return cache.get(key)!;
65
60
  }
66
61
  if (!checkColor(toMakeA11y) || !checkColor(background)) {
67
62
  cache.put(key, toMakeA11y);
@@ -71,23 +66,21 @@ export function a11yColor(toMakeA11y: string, background: string, minimumContras
71
66
  if (minimumContrast < 0 && minimumContrast > 21) {
72
67
  throw new Error(`Minimum contrast must be a number between 0 and 21. It was ${minimumContrast}`);
73
68
  }
74
- const a11y = chroma(toMakeA11y);
75
- const bg = chroma(background);
76
69
 
77
70
  // Check the ratio straight away, if it passes return the value as hex
78
- if (chroma.contrast(background, toMakeA11y) >= minimumContrast) {
79
- const val = a11y.hex();
71
+ if (getContrastRatio(background, toMakeA11y) >= minimumContrast) {
72
+ const val = toCss(toMakeA11y);
80
73
  cache.put(key, val);
81
74
  return val;
82
75
  }
83
76
 
84
77
  // Ratio didn't pass so we need to find the nearest color
85
- const a11yHSL = a11y.hsl();
78
+ const a11yHSL = getHsl(toMakeA11y);
86
79
  const a11yLightness = a11yHSL[2] * 100;
87
80
  const minHexDiff = 100 / 255; // 255 Colors / 100% HSL
88
81
 
89
- const isBlackBgContrast = chroma.contrast(background, "#000") >= minimumContrast;
90
- const isWhiteBgContrast = chroma.contrast(background, "#FFF") >= minimumContrast;
82
+ const isBlackBgContrast = getContrastRatio(background, "#000") >= minimumContrast;
83
+ const isWhiteBgContrast = getContrastRatio(background, "#FFF") >= minimumContrast;
91
84
  let minLightness = 0;
92
85
  let maxLightness = 100;
93
86
  let isDarkColor = false;
@@ -117,19 +110,19 @@ export function a11yColor(toMakeA11y: string, background: string, minimumContras
117
110
  // Binary search until we find the colour that meets contrast
118
111
  while (!foundColor) {
119
112
  const midLightness = (minLightness + maxLightness) / 2;
120
- const midA11y = chroma.hsl(a11yHSL[0], a11yHSL[1], midLightness / 100);
113
+ const midA11yHex = fromHSL(a11yHSL[0], a11yHSL[1], midLightness / 100);
121
114
 
122
115
  // Give up if we are stuck
123
116
  if (Math.abs(maxLightness - minLightness) < 0.01) {
124
- foundColor = midA11y.hex();
117
+ foundColor = midA11yHex;
125
118
  break;
126
119
  }
127
120
 
128
121
  // The colour meets contrast
129
- if (chroma.contrast(midA11y.hex(), bg) >= minimumContrast) {
122
+ if (getContrastRatio(midA11yHex, background) >= minimumContrast) {
130
123
  // It is the minimal lightness range for one hexadecimal
131
124
  if (maxLightness - minLightness <= minHexDiff) {
132
- foundColor = midA11y.hex();
125
+ foundColor = midA11yHex;
133
126
  } else if (isDarkColor) {
134
127
  // If it is going to be a dark color move the min to mid
135
128
  minLightness = midLightness;
@@ -2,7 +2,7 @@ import {stopPropagation} from "@fibery/react/src/stop-propagation";
2
2
  import {useCallbackRef} from "@fibery/react/src/use-callback-ref";
3
3
  import {css, cx} from "@linaria/core";
4
4
  import {FunctionComponent, memo, ReactNode, useId} from "react";
5
- import {border, colors, layout, layoutVars, lineHeight, space, textStyles, themeVars} from "../design-system";
5
+ import {border, layout, layoutVars, lineHeight, space, textStyles, themeVars} from "../design-system";
6
6
  import CheckedIcon from "../icons/react/Checked";
7
7
  import {IconBaseProps} from "../icons/types";
8
8
  import {Spinner} from "../loaders";
@@ -41,7 +41,7 @@ const rowCss = css`
41
41
  }
42
42
  `;
43
43
 
44
- const dangerousItemCss = css`
44
+ export const dangerousItemCss = css`
45
45
  &.${rowCss} {
46
46
  &[data-highlighted] {
47
47
  color: ${themeVars.danger};
@@ -52,21 +52,21 @@ const dangerousItemCss = css`
52
52
  }
53
53
  `;
54
54
 
55
- const dangerousConfirmationCss = css`
55
+ export const dangerousConfirmationCss = css`
56
56
  &.${rowCss} {
57
57
  background-color: ${themeVars.colorBgActionsMenuItemDangerActive};
58
- color: ${colors.inversedTextColor};
58
+ color: ${themeVars.inversedTextColor};
59
59
  border-radius: ${border.radius6}px;
60
60
 
61
- --actions-menu-item-icon-color: ${colors.inversedTextColor};
61
+ --actions-menu-item-icon-color: ${themeVars.inversedTextColor};
62
62
 
63
63
  &:hover,
64
64
  &[data-highlighted] {
65
65
  background-color: ${themeVars.colorBgActionsMenuItemDangerActive};
66
- color: ${colors.inversedTextColor};
66
+ color: ${themeVars.inversedTextColor};
67
67
  border-radius: ${border.radius6}px;
68
68
 
69
- --actions-menu-item-icon-color: ${colors.inversedTextColor};
69
+ --actions-menu-item-icon-color: ${themeVars.inversedTextColor};
70
70
  }
71
71
  }
72
72
  `;
@@ -1,9 +1,10 @@
1
1
  import Modal from "antd/lib/modal";
2
2
  import {ModalProps} from "antd/lib/modal/Modal";
3
3
  import "antd/lib/modal/style/css";
4
- import {border, createInlineTheme, space, themeVars} from "../design-system";
5
- import {useTheme} from "../theme-provider";
4
+ import {border, space, themeVars} from "../design-system";
5
+ import {ThemeProvider} from "../theme-provider";
6
6
  import {css, cx} from "@linaria/core";
7
+ import {ReactNode} from "react";
7
8
 
8
9
  const modalCss = css`
9
10
  & .ant-modal-content {
@@ -19,8 +20,12 @@ const modalCss = css`
19
20
  }
20
21
  `;
21
22
 
23
+ function renderWithTheme(node: ReactNode): ReactNode {
24
+ return <ThemeProvider portal>{node}</ThemeProvider>;
25
+ }
26
+
22
27
  export function AntModal({bodyStyle = {}, className, ...restProps}: ModalProps) {
23
- const theme = useTheme();
24
- const inlineTheme = createInlineTheme(theme);
25
- return <Modal bodyStyle={{...bodyStyle, ...inlineTheme}} className={cx(className, modalCss)} {...restProps} />;
28
+ return (
29
+ <Modal bodyStyle={bodyStyle} className={cx(className, modalCss)} modalRender={renderWithTheme} {...restProps} />
30
+ );
26
31
  }
@@ -1,5 +1,5 @@
1
1
  import {css} from "@linaria/core";
2
- import {border, colors, layout, shadows, space, textStyles, themeVars, transition} from "../design-system";
2
+ import {border, layout, shadows, space, textStyles, themeVars, transition} from "../design-system";
3
3
 
4
4
  const inputVariables = {
5
5
  default: {
@@ -30,7 +30,7 @@ export const inputOverrides = {
30
30
  paddingLeft: space.s12,
31
31
  paddingRight: space.s12,
32
32
  border: 0,
33
- borderColor: colors.transparent,
33
+ borderColor: themeVars.transparent,
34
34
  transition: `box-shadow ${transition}`,
35
35
  boxShadow: `var(--input-border, ${themeVars.inputBorderColor})`,
36
36
  letterSpacing: 0,
@@ -49,7 +49,7 @@ export const inputOverrides = {
49
49
  disabled: {
50
50
  color: `${themeVars.textColor}`,
51
51
  backgroundColor: `${themeVars.inputDisabledBgColor} !important`,
52
- borderColor: colors.transparent,
52
+ borderColor: themeVars.transparent,
53
53
  boxShadow: `${themeVars.inputDisabledBorderColor} !important`,
54
54
  transition: `box-shadow ${transition}`,
55
55
  WebkitTextFillColor: "currentColor",
@@ -69,7 +69,7 @@ export const inputStyles = css`
69
69
  ${{
70
70
  ...textStyles.regular,
71
71
  "& .ant-input-group-addon": {
72
- backgroundColor: colors.transparent,
72
+ backgroundColor: themeVars.transparent,
73
73
  border: "none",
74
74
  padding: 0,
75
75
  textAlign: "left",
@@ -93,7 +93,7 @@ export const inputStyles = css`
93
93
  padding: 0,
94
94
  border: "none",
95
95
  boxShadow: "none",
96
- backgroundColor: colors.transparent,
96
+ backgroundColor: themeVars.transparent,
97
97
  },
98
98
  "& .ant-input-affix-wrapper.ant-input-affix-wrapper-readonly": {
99
99
  border: "none !important",
@@ -118,7 +118,7 @@ export const inputStyles = css`
118
118
  paddingBottom: space.s8,
119
119
  },
120
120
  "& .ant-select-disabled .ant-select-selection": {
121
- backgroundColor: colors.transparent,
121
+ backgroundColor: themeVars.transparent,
122
122
  },
123
123
  "&& input:hover:not(:focus):not(:disabled), && textarea:hover:not(:focus):not(:disabled), && .ant-input:hover:not(:focus):not(:disabled)":
124
124
  inputOverrides.hover,
@@ -3,7 +3,7 @@ import _ from "lodash";
3
3
  import {FC, Suspense, lazy} from "react";
4
4
  import {a11yColor} from "./a11y-color";
5
5
  import {AppIconWrapper} from "./app-icon-wrapper";
6
- import {getAppIconBackgroundColor, getOpacities, getThemeValue, iconSize, layout} from "./design-system";
6
+ import {getOpacities, getThemeValue, iconSize, layout} from "./design-system";
7
7
  import {Icon} from "./icons/Icon";
8
8
  import {useTheme} from "./theme-provider";
9
9
  import {useIsPhone} from "./use-is-phone";
@@ -134,7 +134,7 @@ export const AppIcon: FC<AppIconProps> = ({icon, color, isSelected, ...rest}) =>
134
134
  light2: a11yColor(getOpacities(color).opacity95, theme.menuBg, 5),
135
135
  });
136
136
 
137
- const bgColor = getAppIconBackgroundColor(theme.mode, color);
137
+ const bgColor = theme.fns.getAppIconBackground(color);
138
138
 
139
139
  return (
140
140
  <AppIconWrapper color={bgColor as string} borderless={isSelected} containerSize={containerSize}>
package/src/app-icon.tsx CHANGED
@@ -3,7 +3,7 @@ import cx from "classnames";
3
3
  import {FC} from "react";
4
4
  import {a11yColor} from "./a11y-color";
5
5
  import {AppIconWithFallback} from "./app-icon-with-fallback";
6
- import {border, getAppIconBackgroundColor, getOpacities, getThemeValue} from "./design-system";
6
+ import {border, getOpacities, getThemeValue} from "./design-system";
7
7
  import {useTheme} from "./theme-provider";
8
8
 
9
9
  interface AppIconProps {
@@ -22,7 +22,7 @@ export const AppIcon: FC<AppIconProps> = ({color, icon, containerSize = 54, icon
22
22
  light2: a11yColor(getOpacities(color).opacity95, theme.menuBg, 5),
23
23
  });
24
24
 
25
- const bgColor = getAppIconBackgroundColor(theme.mode, color);
25
+ const bgColor = theme.fns.getAppIconBackground(color);
26
26
 
27
27
  const appIconGradientStyle = getThemeValue(theme.mode, {
28
28
  dark: "linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0))",
@@ -27,6 +27,7 @@ const button = css`
27
27
  justify-content: center;
28
28
  font-weight: ${fontWeight.medium};
29
29
  white-space: nowrap;
30
+ touch-action: manipulation;
30
31
  `;
31
32
 
32
33
  const shortcutContainer = css`
@@ -3,18 +3,10 @@
3
3
  // so it's easier to find buttons with custom colors
4
4
 
5
5
  import {CSSProperties} from "@linaria/core";
6
- import {
7
- getDarkenColor,
8
- getEnumBackgroundColor,
9
- getIconColor,
10
- getOpacities,
11
- getThemeValue,
12
- themeVars,
13
- } from "../design-system";
6
+ import {getDarkenColor, getOpacities, getThemeValue, ThemeColors, themeVars} from "../design-system";
14
7
  import {ButtonVariant} from "./base-button";
15
- import {ThemeMode} from "../theme-settings";
16
8
 
17
- export const makeButtonColors = (color: string, variant: ButtonVariant, mode: ThemeMode = "light"): CSSProperties => {
9
+ export const makeButtonColors = (color: string, variant: ButtonVariant, theme: ThemeColors): CSSProperties => {
18
10
  switch (variant) {
19
11
  case "solid":
20
12
  return {
@@ -43,12 +35,12 @@ export const makeButtonColors = (color: string, variant: ButtonVariant, mode: Th
43
35
  };
44
36
  default:
45
37
  case "soft": {
46
- const bgColor = getEnumBackgroundColor(mode, color) as string;
47
- const textColor = getIconColor(mode, color) as string;
38
+ const bgColor = theme.fns.getEnumBackground(color) as string;
39
+ const textColor = theme.fns.getIconColor(color) as string;
48
40
 
49
41
  return {
50
42
  "--fibery-button-color": bgColor,
51
- "--fibery-button-hover-color": getThemeValue(mode, {
43
+ "--fibery-button-hover-color": getThemeValue(theme.mode, {
52
44
  light: getOpacities(color).opacity30,
53
45
  dark: getOpacities(color).opacity45,
54
46
  }),
package/src/checkbox.tsx CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  useEffect,
13
13
  useRef,
14
14
  } from "react";
15
- import {colors, getDarkenColor, getOpacities, layout, space, textStyles, ThemeColors, themeVars} from "./design-system";
15
+ import {getDarkenColor, getOpacities, layout, space, textStyles, ThemeColors, themeVars} from "./design-system";
16
16
  import {smallHtmlStylesClass} from "./html-styles";
17
17
  import {mobileRootSelector} from "./mobile-styles";
18
18
 
@@ -127,7 +127,7 @@ const checkmarkStyle = css`
127
127
  opacity: 0;
128
128
  transition: transform 0.2s, opacity 0.2s;
129
129
  pointer-events: none;
130
- color: ${colors.inversedTextColor};
130
+ color: ${themeVars.inversedTextColor};
131
131
  width: ${layout.checkboxSize}px;
132
132
  height: ${layout.checkboxSize}px;
133
133
 
@@ -1,10 +1,10 @@
1
- import {colors, border, space} from "../design-system";
2
1
  import {css} from "@linaria/core";
3
2
  import {lazy, Suspense} from "react";
3
+ import {border, space, themeVars} from "../design-system";
4
4
 
5
5
  const colorPickerLoaderStyle = css`
6
6
  ${{
7
- backgroundColor: colors.inversedTextColor,
7
+ backgroundColor: themeVars.inversedTextColor,
8
8
  borderRadius: border.radius4,
9
9
  boxShadow: "rgba(0, 0, 0, 0.15) 0px 0px 0px 1px, rgba(0, 0, 0, 0.15) 0px 8px 16px",
10
10
  padding: space.s12,