@fibery/ui-kit 1.1.0 → 1.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/ui-kit",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "main": "index.ts",
5
5
  "private": false,
6
6
  "files": [
package/src/Pallete.ts CHANGED
@@ -239,3 +239,27 @@ export const whiteA = {
239
239
  whiteA11: "hsla(0, 0%, 100%, 0.592)",
240
240
  whiteA12: "hsla(0, 0%, 100%, 0.923)",
241
241
  } as const;
242
+
243
+ export const opacity = {
244
+ opacity100: 1,
245
+ opacity95: 0.95,
246
+ opacity90: 0.9,
247
+ opacity85: 0.85,
248
+ opacity80: 0.8,
249
+ opacity75: 0.75,
250
+ opacity70: 0.7,
251
+ opacity65: 0.65,
252
+ opacity60: 0.6,
253
+ opacity55: 0.55,
254
+ opacity50: 0.5,
255
+ opacity45: 0.45,
256
+ opacity40: 0.4,
257
+ opacity35: 0.35,
258
+ opacity30: 0.3,
259
+ opacity25: 0.25,
260
+ opacity20: 0.2,
261
+ opacity15: 0.15,
262
+ opacity10: 0.1,
263
+ opacity5: 0.05,
264
+ opacity0: 0,
265
+ } as const;
@@ -1,6 +1,7 @@
1
1
  import invariant from "invariant";
2
+ import {themeStyles} from "@fibery/ui-kit/src/theme-styles";
2
3
  import {createContext, ReactNode, useContext, useEffect, useState} from "react";
3
- import {colors, createInlineTheme, getThemeColors, ThemeColors} from "./designSystem";
4
+ import {colors, getThemeColors, ThemeColors} from "./designSystem";
4
5
  import {
5
6
  subscribeOnThemeMenuPreferenceChange,
6
7
  subscribeOnThemeModeChange,
@@ -50,13 +51,6 @@ export function useThemeMenuPreference(): ThemeMenuPreference {
50
51
  return themeMenuPreference;
51
52
  }
52
53
 
53
- export function applyThemeToRoot(theme: ThemeColors) {
54
- const inlineTheme = createInlineTheme(theme);
55
- Object.entries(inlineTheme).forEach(([p, v]) => {
56
- document.body.style.setProperty(p, v);
57
- });
58
- }
59
-
60
54
  export function RootThemeProvider({
61
55
  initialThemeMode,
62
56
  initialPreference,
@@ -90,6 +84,7 @@ export function RootThemeProvider({
90
84
  const documentElement = document.documentElement;
91
85
  documentElement.classList.remove(darkThemeClassName);
92
86
  documentElement.classList.remove(lightThemeAndDarkMenuClassName);
87
+ documentElement.classList.add(themeStyles);
93
88
  if (themeMode === "dark") {
94
89
  documentElement.classList.add(darkThemeClassName);
95
90
  colorScheme = "dark";
@@ -105,9 +100,7 @@ export function RootThemeProvider({
105
100
  documentElement.classList.remove(lightThemeAndDarkMenuClassName);
106
101
  };
107
102
  }, [themeMode]);
108
- useEffect(() => {
109
- applyThemeToRoot(theme);
110
- }, [theme]);
103
+
111
104
  return (
112
105
  <FiberyThemePreferenceContext.Provider value={themePreference}>
113
106
  <FiberyThemeMenuPreferenceContext.Provider value={themeMenuPreference}>
@@ -1,5 +1,12 @@
1
- export function createInlineTheme<T extends Record<string, unknown>>(themes: T): Record<string, string> {
1
+ export function createInlineTheme<T extends Record<string, unknown>>(
2
+ themes: T,
3
+ rejectKeys: Array<string>
4
+ ): Record<string, string> {
2
5
  return Object.entries(themes).reduce<Record<string, string>>((inlineTheme, [key, value]) => {
6
+ if (rejectKeys.includes(key)) {
7
+ return inlineTheme;
8
+ }
9
+
3
10
  if (key === "opacity") {
4
11
  Object.entries(themes.opacity as Record<string, string>).forEach(([opacityKey, opacityValue]) => {
5
12
  inlineTheme[`--fibery-opacity-${opacityKey}`] = opacityValue;
@@ -4,11 +4,11 @@ import {ThemeMode} from "./theme-settings";
4
4
  import ColorHash from "color-hash";
5
5
  import {
6
6
  blackA,
7
+ blue,
8
+ blueDark,
7
9
  indigo,
8
10
  indigoDark,
9
11
  red,
10
- blue,
11
- blueDark,
12
12
  redDark,
13
13
  sage,
14
14
  slate,
@@ -149,15 +149,17 @@ const lightColors = {
149
149
  entityNodeBorder: `1px solid ${getOpacities(slateDark.slate3).opacity30}`,
150
150
  entityNodeHoverColor: slateDark.slate7,
151
151
  entityNodeBorderHover: `1px solid ${getOpacities(slate.slate11).opacity80}`,
152
- entityNodeBgColor: getOpacities(slate.slate3).opacity80,
152
+ entityNodeBgColor: slate.slate2,
153
153
  shortcutTextColor: slate.slate9,
154
154
  shortcutBorderColor: `1px solid ${getOpacities(slate.slate8).opacity20}`,
155
155
  inputBgColor: whiteA.whiteA0,
156
- inputDisabledBgColor: slate.slate2,
156
+ inputDisabledBgColor: getOpacities(slate.slate6).opacity30,
157
157
  inputDisabledBorderColor: `0 0 0 1px ${getOpacities(slate.slate6).opacity20}`,
158
158
  inputCopyBgColor: slate.slate3,
159
159
  inputBorderColor: `0 0 0 1px ${getOpacities(slate.slate6).opacity70}`,
160
- inputBorderHoverColor: `0 0 0 1px ${getOpacities(slate.slate6).opacity100}`,
160
+ inputBorderHoverColor: `0 0 0 1px ${getOpacities(slate.slate7).opacity100}`,
161
+ inputBorderFocusColor: `0 0 0 1px ${getOpacities(slate.slate8).opacity100}`,
162
+ inputBorderBlendMode: "multiply",
161
163
  inputPlaceholderTextColor: slate.slate10,
162
164
  buttonColor: slate.slate10,
163
165
  buttonPrimaryTextColor: slate.slate2,
@@ -195,6 +197,7 @@ const lightColors = {
195
197
  entityCardShadowHover: `0 0 0 1px ${getOpacities(slate.slate10).opacity10}, 0 2px 4px -4px ${
196
198
  getOpacities(slate.slate10).opacity20
197
199
  }`,
200
+ relationViewBgColor: slate.slate2,
198
201
  unitBg: slate.slate3,
199
202
  unitBgHover: slate.slate4,
200
203
  badgeBgColor: getOpacities(slate.slate10).opacity20,
@@ -294,15 +297,17 @@ const darkColors = {
294
297
  entityNodeBorder: `1px solid ${getOpacities(slate.slate8).opacity40}`,
295
298
  entityNodeHoverColor: slate.slate7,
296
299
  entityNodeBorderHover: `1px solid ${getOpacities(slate.slate7).opacity80}`,
297
- entityNodeBgColor: getOpacities(slateDark.slate6).opacity80,
300
+ entityNodeBgColor: slateDark.slate3,
298
301
  shortcutTextColor: slateDark.slate11,
299
302
  shortcutBorderColor: `1px solid ${getOpacities(slateDark.slate10).opacity20}`,
300
303
  inputBgColor: slateDark.slate2,
301
- inputDisabledBgColor: slateDark.slate3,
304
+ inputDisabledBgColor: getOpacities(slateDark.slate6).opacity30,
302
305
  inputDisabledBorderColor: `0 0 0 1px ${getOpacities(slateDark.slate8).opacity20}`,
303
306
  inputCopyBgColor: slateDark.slate4,
304
307
  inputBorderColor: `0 0 0 1px ${getOpacities(slateDark.slate8).opacity70}`,
305
- inputBorderHoverColor: `0 0 0 1px ${getOpacities(slateDark.slate8).opacity70}`,
308
+ inputBorderHoverColor: `0 0 0 1px ${getOpacities(slateDark.slate8).opacity100}`,
309
+ inputBorderFocusColor: `0 0 0 1px ${getOpacities(slateDark.slate9).opacity100}`,
310
+ inputBorderBlendMode: "lighten",
306
311
  inputPlaceholderTextColor: slate.slate10,
307
312
  buttonColor: slateDark.slate10,
308
313
  buttonPrimaryTextColor: slate.slate6,
@@ -336,6 +341,7 @@ const darkColors = {
336
341
  entityCardShadowHover: `0 0 0 1px ${getOpacities(slateDark.slate2).opacity10}, 0 2px 4px -4px ${
337
342
  getOpacities(slateDark.slate2).opacity20
338
343
  }`,
344
+ relationViewBgColor: slateDark.slate3,
339
345
  unitBg: slateDark.slate6,
340
346
  unitBgHover: slateDark.slate7,
341
347
  badgeBgColor: getOpacities(slate.slate10).opacity20,
@@ -439,7 +445,7 @@ function getTypeColors(themeColor: string, theme: ThemeMode) {
439
445
  boardBg: boardBg.hex(),
440
446
  boardBgOverlay: boardBg.alpha(0.8).css(),
441
447
  headerBg: chroma(color).luminance(0.7).desaturate(0.5).set("hsl.h", "+2").css(),
442
- detailsBg: chroma(color).alpha(0.6).luminance(0.85).hex(),
448
+ detailsBg: chroma(color).alpha(0.5).luminance(0.85).hex(),
443
449
  focus: chroma(color).alpha(0.25).css(),
444
450
  separator: chroma(color).alpha(0.3).css(),
445
451
  };
@@ -452,7 +458,7 @@ function getTypeColors(themeColor: string, theme: ThemeMode) {
452
458
  boardBg: boardBg.hex(),
453
459
  boardBgOverlay: boardBg.alpha(0.8).css(),
454
460
  headerBg: chroma(color).luminance(0.7).desaturate(0.5).set("hsl.h", "+2").css(),
455
- detailsBg: chroma(color).alpha(0.03).luminance(0.8).darken(0.1).hex(),
461
+ detailsBg: chroma(color).alpha(0.03).luminance(0.8).desaturate(0.8).darken(0.1).hex(),
456
462
  focus: chroma(color).alpha(0.25).css(),
457
463
  separator: chroma(color).alpha(0.3).css(),
458
464
  };
@@ -679,7 +685,7 @@ export const getObjectColorMemoized = _.memoize((name) => {
679
685
  return colorHash.hex(name);
680
686
  });
681
687
 
682
- export const themeVars = Object.keys(getThemeColors("#FFFFFF", "light")).reduce((vars, key) => {
688
+ export const themeVars = Object.keys(getThemeColors(brandColors.green, "light")).reduce((vars, key) => {
683
689
  if (key === "opacity") {
684
690
  vars[key] = Object.fromEntries(
685
691
  Object.keys(opacity).map((opacityKey) => [opacityKey, `var(--fibery-opacity-${opacityKey})`])
@@ -717,7 +723,8 @@ export const themeVars = Object.keys(getThemeColors("#FFFFFF", "light")).reduce(
717
723
  return vars;
718
724
  }, {} as Record<string, string | {[k: string]: string}>) as ThemeColors;
719
725
 
720
- export const createInlineTheme = (theme: ThemeColors) => createInlineStyles<ThemeColors>(theme);
726
+ export const createInlineTheme = (theme: ThemeColors, rejectKeys = Object.keys(lightColors)) =>
727
+ createInlineStyles<ThemeColors>(theme, rejectKeys);
721
728
 
722
729
  export const textStyles = {
723
730
  heading1: {
@@ -2,7 +2,7 @@ import {css} from "@linaria/core";
2
2
  import {styled} from "@linaria/react";
3
3
  import cn from "classnames";
4
4
  import _ from "lodash";
5
- import {useRef, memo} from "react";
5
+ import {memo, useRef} from "react";
6
6
  import {space, themeVars} from "./designSystem";
7
7
 
8
8
  const getRandomWithSeed = _.memoize((seed: number) => {
@@ -101,7 +101,7 @@ const Container = styled.div<{height: number}>`
101
101
  }
102
102
  `;
103
103
 
104
- type Props = {
104
+ export type LoadingSausageProps = {
105
105
  minWidth?: number;
106
106
  maxWidth?: number;
107
107
  height?: number;
@@ -119,7 +119,7 @@ export const LoadingSausage = memo(function LoadingSausage({
119
119
  inverted = false,
120
120
  margins = true,
121
121
  animateAppearance = false,
122
- }: Props): JSX.Element {
122
+ }: LoadingSausageProps): JSX.Element {
123
123
  const widthRef = useRef(getRandomInt(minWidth, maxWidth, index));
124
124
  return (
125
125
  <Container
@@ -140,7 +140,7 @@ type SausageListProps = {
140
140
  minAmount?: number;
141
141
  maxAmount?: number;
142
142
  WrapperComponent?: ({children}: {children: JSX.Element}) => JSX.Element | null;
143
- } & Omit<Props, "index">;
143
+ } & Omit<LoadingSausageProps, "index">;
144
144
  export const LoadingSausageList = memo<SausageListProps>(function LoadingSausageList({
145
145
  amount,
146
146
  minAmount = 1,