@fibery/ui-kit 1.2.1 → 1.3.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.2.1",
3
+ "version": "1.3.0",
4
4
  "main": "index.ts",
5
5
  "private": false,
6
6
  "files": [
@@ -1,3 +1,6 @@
1
+ declare const VAR_THEME_PREFIX: string | undefined;
2
+ export const varPrefix = typeof VAR_THEME_PREFIX === "string" ? VAR_THEME_PREFIX : "fibery";
3
+
1
4
  export function createInlineTheme<T extends Record<string, unknown>>(
2
5
  themes: T,
3
6
  rejectKeys: Array<string>
@@ -9,54 +12,54 @@ export function createInlineTheme<T extends Record<string, unknown>>(
9
12
 
10
13
  if (key === "opacity") {
11
14
  Object.entries(themes.opacity as Record<string, string>).forEach(([opacityKey, opacityValue]) => {
12
- inlineTheme[`--fibery-opacity-${opacityKey}`] = opacityValue;
15
+ inlineTheme[`--${varPrefix}-opacity-${opacityKey}`] = opacityValue;
13
16
  }, "");
14
17
 
15
18
  return inlineTheme;
16
19
  }
17
20
  if (key === "stateColors") {
18
21
  Object.entries(themes.stateColors as Record<string, string>).forEach(([stateColorKey, stateColorValue]) => {
19
- inlineTheme[`--fibery-state-colors-${stateColorKey}`] = stateColorValue;
22
+ inlineTheme[`--${varPrefix}-state-colors-${stateColorKey}`] = stateColorValue;
20
23
  }, "");
21
24
 
22
25
  return inlineTheme;
23
26
  }
24
27
  if (key === "brandColors") {
25
28
  Object.entries(themes.brandColors as Record<string, string>).forEach(([brandColorKey, brandColorValue]) => {
26
- inlineTheme[`--fibery-brand-colors-${brandColorKey}`] = brandColorValue;
29
+ inlineTheme[`--${varPrefix}-brand-colors-${brandColorKey}`] = brandColorValue;
27
30
  }, "");
28
31
 
29
32
  return inlineTheme;
30
33
  }
31
34
  if (key === "shades") {
32
35
  Object.entries(themes.shades as Record<string, string>).forEach(([shadeKey, shadeValue]) => {
33
- inlineTheme[`--fibery-shades-${shadeKey}`] = shadeValue;
36
+ inlineTheme[`--${varPrefix}-shades-${shadeKey}`] = shadeValue;
34
37
  }, "");
35
38
 
36
39
  return inlineTheme;
37
40
  }
38
41
  if (key === "lights") {
39
42
  Object.entries(themes.lights as Record<string, string>).forEach(([lightKey, lightValue]) => {
40
- inlineTheme[`--fibery-lights-${lightKey}`] = lightValue;
43
+ inlineTheme[`--${varPrefix}-lights-${lightKey}`] = lightValue;
41
44
  }, "");
42
45
 
43
46
  return inlineTheme;
44
47
  }
45
48
  if (key === "separators") {
46
49
  Object.entries(themes.separators as Record<string, string>).forEach(([separatorKey, separatorValue]) => {
47
- inlineTheme[`--fibery-separator-${separatorKey}`] = separatorValue;
50
+ inlineTheme[`--${varPrefix}-separator-${separatorKey}`] = separatorValue;
48
51
  }, "");
49
52
 
50
53
  return inlineTheme;
51
54
  }
52
55
  if (key === "inversedSeparators") {
53
56
  Object.entries(themes.inversedSeparators as Record<string, string>).forEach(([separatorKey, separatorValue]) => {
54
- inlineTheme[`--fibery-inversed-separators-${separatorKey}`] = separatorValue;
57
+ inlineTheme[`--${varPrefix}-inversed-separators-${separatorKey}`] = separatorValue;
55
58
  }, "");
56
59
 
57
60
  return inlineTheme;
58
61
  }
59
- inlineTheme[`--fibery-color-${key}`] = value as string;
62
+ inlineTheme[`--${varPrefix}-color-${key}`] = value as string;
60
63
  return inlineTheme;
61
64
  }, {});
62
65
  }
@@ -18,7 +18,7 @@ import {
18
18
  yellowDark,
19
19
  } from "./Pallete";
20
20
  import _ from "lodash";
21
- import {createInlineTheme as createInlineStyles} from "./create-inline-theme";
21
+ import {createInlineTheme as createInlineStyles, varPrefix} from "./create-inline-theme";
22
22
 
23
23
  export const typeSizes = [28, 24, 18, 16, 14, 12, 10, 8] as const;
24
24
 
@@ -688,37 +688,43 @@ export const getObjectColorMemoized = _.memoize((name) => {
688
688
  export const themeVars = Object.keys(getThemeColors(brandColors.green, "light")).reduce((vars, key) => {
689
689
  if (key === "opacity") {
690
690
  vars[key] = Object.fromEntries(
691
- Object.keys(opacity).map((opacityKey) => [opacityKey, `var(--fibery-opacity-${opacityKey})`])
691
+ Object.keys(opacity).map((opacityKey) => [opacityKey, `var(--${varPrefix}-opacity-${opacityKey})`])
692
692
  );
693
693
  } else if (key === "stateColors") {
694
694
  vars[key] = Object.fromEntries(
695
- Object.keys(stateColors).map((stateColorKey) => [stateColorKey, `var(--fibery-state-colors-${stateColorKey})`])
695
+ Object.keys(stateColors).map((stateColorKey) => [
696
+ stateColorKey,
697
+ `var(--${varPrefix}-state-colors-${stateColorKey})`,
698
+ ])
696
699
  );
697
700
  } else if (key === "brandColors") {
698
701
  vars[key] = Object.fromEntries(
699
- Object.keys(brandColors).map((brandColorKey) => [brandColorKey, `var(--fibery-brand-colors-${brandColorKey})`])
702
+ Object.keys(brandColors).map((brandColorKey) => [
703
+ brandColorKey,
704
+ `var(--${varPrefix}-brand-colors-${brandColorKey})`,
705
+ ])
700
706
  );
701
707
  } else if (key === "shades") {
702
708
  vars[key] = Object.fromEntries(
703
- Object.keys(shades).map((shadeKey) => [shadeKey, `var(--fibery-shades-${shadeKey})`])
709
+ Object.keys(shades).map((shadeKey) => [shadeKey, `var(--${varPrefix}-shades-${shadeKey})`])
704
710
  );
705
711
  } else if (key === "lights") {
706
712
  vars[key] = Object.fromEntries(
707
- Object.keys(lights).map((lightKey) => [lightKey, `var(--fibery-lights-${lightKey})`])
713
+ Object.keys(lights).map((lightKey) => [lightKey, `var(--${varPrefix}-lights-${lightKey})`])
708
714
  );
709
715
  } else if (key === "separators") {
710
716
  vars[key] = Object.fromEntries(
711
- Object.keys(separators).map((separatorKey) => [separatorKey, `var(--fibery-separator-${separatorKey})`])
717
+ Object.keys(separators).map((separatorKey) => [separatorKey, `var(--${varPrefix}-separator-${separatorKey})`])
712
718
  );
713
719
  } else if (key === "inversedSeparators") {
714
720
  vars[key] = Object.fromEntries(
715
721
  Object.keys(inversedSeparators).map((separatorKey) => [
716
722
  separatorKey,
717
- `var(--fibery-inversed-separator-${separatorKey})`,
723
+ `var(--${varPrefix}-inversed-separator-${separatorKey})`,
718
724
  ])
719
725
  );
720
726
  } else {
721
- vars[key] = `var(--fibery-color-${key})`;
727
+ vars[key] = `var(--${varPrefix}-color-${key})`;
722
728
  }
723
729
  return vars;
724
730
  }, {} as Record<string, string | {[k: string]: string}>) as ThemeColors;