@redis-ui/styles 21.12.0 → 21.13.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/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # @redis-ui/styles
2
+
3
+ Design tokens, themes and global styles for Redis UI. Every Redis UI package (`components`, `table`, `charts`, `icons`) reads its colors, spacing, typography and component styles from the theme this package provides.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @redis-ui/styles styled-components modern-normalize
9
+ ```
10
+
11
+ Peer dependencies: `react` and `react-dom` 18 or 19, `styled-components` 5, `modern-normalize` 3.
12
+
13
+ ## Setup
14
+
15
+ Import the CSS once in your app entry, then provide a theme and render `CommonStyles`:
16
+
17
+ ```tsx
18
+ import 'modern-normalize/modern-normalize.css';
19
+ import '@redis-ui/styles/normalized-styles.css';
20
+ import '@redis-ui/styles/fonts.css';
21
+ import { ThemeProvider } from 'styled-components';
22
+ import { CommonStyles, themes } from '@redis-ui/styles';
23
+
24
+ <ThemeProvider theme={themes.light}>
25
+ <CommonStyles />
26
+ <App />
27
+ </ThemeProvider>
28
+ ```
29
+
30
+ | Export | What it is |
31
+ |---|---|
32
+ | `@redis-ui/styles/normalized-styles.css` | Resets for Redis UI elements, so global app styles don't override them. Import it after your normalization sheet. To add your own, target `[class*="RedisUI"]` |
33
+ | `@redis-ui/styles/fonts.css` | Fonts for the classic `themes` |
34
+ | `@redis-ui/styles/fonts-next.css` | Fonts for `themesNext` |
35
+ | `CommonStyles` | Global styles from the theme (body, scrollbars), plus a reduced-motion safety net for users with `prefers-reduced-motion: reduce` |
36
+
37
+ ## Themes
38
+
39
+ Two theme bundles are exported, each with a `light` and a `dark` theme:
40
+
41
+ | Bundle | Fonts | Use for |
42
+ |---|---|---|
43
+ | `themes` | `fonts.css` | The current (classic) Redis brand |
44
+ | `themesNext` | `fonts-next.css` | The next brand, used by the Redis Ultra console |
45
+
46
+ Use one bundle per app, and import the fonts file that matches it. To try components in both, use the theme switcher in [Storybook](https://redislabsdev.github.io/redis-ui/).
47
+
48
+ The `theme` export is the classic light theme and is meant for tests only. Don't use it in apps.
49
+
50
+ ### Light/dark switching
51
+
52
+ `SwitchableModeThemeProvider` replaces `ThemeProvider` when the user can switch modes. It persists the choice under `storageKey`:
53
+
54
+ ```tsx
55
+ import { CommonStyles, SwitchableModeThemeProvider, themes } from '@redis-ui/styles';
56
+
57
+ <SwitchableModeThemeProvider
58
+ lightTheme={themes.light}
59
+ darkTheme={themes.dark}
60
+ storageKey="redis-ui-theme-mode"
61
+ >
62
+ <CommonStyles />
63
+ <App />
64
+ </SwitchableModeThemeProvider>
65
+ ```
66
+
67
+ Pair it with the `ThemeModeSwitch` component from `@redis-ui/components`. See **Others → Theme Providers → Theme Mode Switching** in Storybook.
68
+
69
+ ## Using the theme in your own styles
70
+
71
+ A theme has three parts:
72
+
73
+ - `core`: the scales (`space`, `font`, `icon`, `shadow`, `zIndex`, `motion`, `focus`), e.g. `theme.core.space.space400`
74
+ - `semantic.color`: semantic colors by role (`text`, `background`, `border`, `icon`), e.g. `theme.semantic.color.background.neutral100`
75
+ - `components`: per-component tokens used by Redis UI components, e.g. `theme.components.button`
76
+
77
+ Read it in styled-components, or with the `useTheme` hook:
78
+
79
+ ```tsx
80
+ import styled from 'styled-components';
81
+ import { useTheme } from '@redis-ui/styles';
82
+
83
+ const Panel = styled.div`
84
+ padding: ${({ theme }) => theme.core.space.space400};
85
+ background: ${({ theme }) => theme.semantic.color.background.neutral100};
86
+ `;
87
+
88
+ const { mode } = useTheme(); // 'light' | 'dark'
89
+ ```
90
+
91
+ Use tokens instead of hard-coded values, so your UI follows both themes and both modes.
92
+
93
+ ## Other exports
94
+
95
+ - `getFocusStyle()` / `getFocusStyleProperties()`: the design system's focus ring, for custom interactive elements
96
+ - `usePrefersReducedMotion()`: `true` when the user asked for reduced motion
97
+ - `useStorage()`: the persisted-value hook used by mode switching
98
+ - `withOpacity()` / `withContrast()`: color helpers
99
+ - Theme types (`Theme`, `ThemePair`, ...)
100
+
101
+ ## Development
102
+
103
+ The themes live in `src/themes/<themeLight|themeDark|themeLightNext|themeDarkNext>/`. Each one has `tokens.ts` (semantic colors and core scales) and `theme/components/*` (component tokens). A change to one bundle usually needs the same change in its light/dark sibling. To add or retire a whole bundle (a rebrand), follow the `redis-ui-rebrand-theme` skill in `.agents/skills`.
104
+
105
+ ```bash
106
+ npm run build -w packages/styles
107
+ npm run lint -w packages/styles
108
+ ```
109
+
110
+ This package has no unit tests. Changes show up in the components' stories and visual tests. See the [root README](https://github.com/redislabsdev/redis-ui) for Storybook, visual testing and releasing.
@@ -6,6 +6,11 @@ const bodyStyle = css `
6
6
  font-family: ${({ theme }) => theme.globals.body.fontFamily};
7
7
  font-size: ${({ theme }) => theme.globals.body.fontSize};
8
8
  line-height: ${({ theme }) => theme.globals.body.lineHeight};
9
+ ${({ theme }) => theme.globals.body.antialiased &&
10
+ css `
11
+ -webkit-font-smoothing: antialiased;
12
+ -moz-osx-font-smoothing: grayscale;
13
+ `}
9
14
 
10
15
  &:not(.sb-show-main) {
11
16
  color-scheme: only ${({ theme }) => theme.mode};
package/dist/index.js CHANGED
@@ -7876,24 +7876,24 @@ var mt = (e) => e.reduce((e, t) => (e.light.push(t.light), e.dark.push(t.dark),
7876
7876
  sizes: {
7877
7877
  small: {
7878
7878
  borderRadius: "0.5rem",
7879
- padding: "0.6rem 1.2rem",
7880
- height: "2.6rem",
7879
+ padding: "0.8rem 1.4rem",
7880
+ height: "3rem",
7881
7881
  lineHeight: "1.2rem",
7882
7882
  fontSize: "1.2rem"
7883
7883
  },
7884
7884
  medium: {
7885
7885
  borderRadius: "0.5rem",
7886
- padding: "1rem 2rem",
7887
- height: "3.4rem",
7886
+ padding: "1rem 1.8rem",
7887
+ height: "3.6rem",
7888
7888
  lineHeight: "1.2rem",
7889
7889
  fontSize: "1.2rem"
7890
7890
  },
7891
7891
  large: {
7892
7892
  borderRadius: "0.5rem",
7893
- padding: "1.2rem 1.8rem",
7893
+ padding: "1.2rem 2.8rem",
7894
7894
  height: "4.4rem",
7895
7895
  lineHeight: "1.8rem",
7896
- fontSize: "1.4rem"
7896
+ fontSize: "1.3rem"
7897
7897
  }
7898
7898
  },
7899
7899
  variants: {
@@ -9573,9 +9573,15 @@ var mt = (e) => e.reduce((e, t) => (e.light.push(t.light), e.dark.push(t.dark),
9573
9573
  borderColor: V.semantic.color.border.secondary200,
9574
9574
  textColor: V.semantic.color.text.secondary500
9575
9575
  },
9576
- activeIndicator: { bgColor: "transparent" }
9576
+ activeIndicator: { bgColor: "transparent" },
9577
+ fontSize: V.core.font.fontSize.s13,
9578
+ gap: V.core.space.space200,
9579
+ iconSize: "1.8rem"
9577
9580
  },
9578
- groupTitle: { textColor: V.semantic.color.text.secondary500 }
9581
+ groupTitle: {
9582
+ textColor: V.semantic.color.text.secondary500,
9583
+ fontSize: V.core.font.fontSize.s10
9584
+ }
9579
9585
  }, yi = {
9580
9586
  card: {
9581
9587
  gap: "2.4rem",
@@ -10343,7 +10349,8 @@ var mt = (e) => e.reduce((e, t) => (e.light.push(t.light), e.dark.push(t.dark),
10343
10349
  textColor: V.semantic.color.text.secondary950,
10344
10350
  fontFamily: V.core.font.fontFamily.regular,
10345
10351
  fontSize: V.core.font.fontSize.s14,
10346
- lineHeight: "1.5"
10352
+ lineHeight: "1.5",
10353
+ antialiased: !0
10347
10354
  }, Ii = {
10348
10355
  width: "0.5rem",
10349
10356
  height: "0.5rem",
@@ -10902,24 +10909,24 @@ var mt = (e) => e.reduce((e, t) => (e.light.push(t.light), e.dark.push(t.dark),
10902
10909
  sizes: {
10903
10910
  small: {
10904
10911
  borderRadius: "0.5rem",
10905
- padding: "0.6rem 1.2rem",
10906
- height: "2.6rem",
10912
+ padding: "0.8rem 1.4rem",
10913
+ height: "3rem",
10907
10914
  lineHeight: "1.2rem",
10908
10915
  fontSize: "1.2rem"
10909
10916
  },
10910
10917
  medium: {
10911
10918
  borderRadius: "0.5rem",
10912
- padding: "1rem 2rem",
10913
- height: "3.4rem",
10919
+ padding: "1rem 1.8rem",
10920
+ height: "3.6rem",
10914
10921
  lineHeight: "1.2rem",
10915
10922
  fontSize: "1.2rem"
10916
10923
  },
10917
10924
  large: {
10918
10925
  borderRadius: "0.5rem",
10919
- padding: "1.2rem 1.8rem",
10926
+ padding: "1.2rem 2.8rem",
10920
10927
  height: "4.4rem",
10921
10928
  lineHeight: "1.8rem",
10922
- fontSize: "1.4rem"
10929
+ fontSize: "1.3rem"
10923
10930
  }
10924
10931
  },
10925
10932
  variants: {
@@ -12600,9 +12607,15 @@ var mt = (e) => e.reduce((e, t) => (e.light.push(t.light), e.dark.push(t.dark),
12600
12607
  borderColor: K.semantic.color.border.secondary700,
12601
12608
  textColor: K.semantic.color.text.secondary400
12602
12609
  },
12603
- activeIndicator: { bgColor: "transparent" }
12610
+ activeIndicator: { bgColor: "transparent" },
12611
+ fontSize: K.core.font.fontSize.s13,
12612
+ gap: K.core.space.space200,
12613
+ iconSize: "1.8rem"
12604
12614
  },
12605
- groupTitle: { textColor: K.semantic.color.text.secondary400 }
12615
+ groupTitle: {
12616
+ textColor: K.semantic.color.text.secondary400,
12617
+ fontSize: K.core.font.fontSize.s10
12618
+ }
12606
12619
  }, Aa = {
12607
12620
  card: {
12608
12621
  gap: "2.4rem",
@@ -13370,7 +13383,8 @@ var mt = (e) => e.reduce((e, t) => (e.light.push(t.light), e.dark.push(t.dark),
13370
13383
  textColor: K.semantic.color.text.secondary0,
13371
13384
  fontFamily: K.core.font.fontFamily.regular,
13372
13385
  fontSize: K.core.font.fontSize.s14,
13373
- lineHeight: "1.5"
13386
+ lineHeight: "1.5",
13387
+ antialiased: !0
13374
13388
  }, Ja = {
13375
13389
  width: "0.5rem",
13376
13390
  height: "0.5rem",
@@ -13613,6 +13627,10 @@ var mt = (e) => e.reduce((e, t) => (e.light.push(t.light), e.dark.push(t.dark),
13613
13627
  font-family: ${({ theme: e }) => e.globals.body.fontFamily};
13614
13628
  font-size: ${({ theme: e }) => e.globals.body.fontSize};
13615
13629
  line-height: ${({ theme: e }) => e.globals.body.lineHeight};
13630
+ ${({ theme: e }) => e.globals.body.antialiased && n`
13631
+ -webkit-font-smoothing: antialiased;
13632
+ -moz-osx-font-smoothing: grayscale;
13633
+ `}
13616
13634
 
13617
13635
  &:not(.sb-show-main) {
13618
13636
  color-scheme: only ${({ theme: e }) => e.mode};