@redis-ui/components 51.6.0 → 51.7.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 CHANGED
@@ -7,9 +7,11 @@ The Redis UI component library — a themed, accessible React component library
7
7
  Install the components package and its required peer dependencies:
8
8
 
9
9
  ```bash
10
- npm install @redis-ui/components @redis-ui/styles @redis-ui/icons styled-components
10
+ npm install @redis-ui/components @redis-ui/styles @redis-ui/icons styled-components modern-normalize
11
11
  ```
12
12
 
13
+ Peer dependencies: `react` and `react-dom` 18 or 19, `styled-components` 5, `@redis-ui/styles` 21.4 or later, `@redis-ui/icons` 8–10. For tables and charts, add [`@redis-ui/table`](https://www.npmjs.com/package/@redis-ui/table) and [`@redis-ui/charts`](https://www.npmjs.com/package/@redis-ui/charts).
14
+
13
15
  ## Setup
14
16
 
15
17
  ### 1. Import global styles
@@ -17,8 +19,9 @@ npm install @redis-ui/components @redis-ui/styles @redis-ui/icons styled-compone
17
19
  Import the normalized styles and fonts from `@redis-ui/styles` in your app entry point:
18
20
 
19
21
  ```ts
22
+ import 'modern-normalize/modern-normalize.css';
20
23
  import '@redis-ui/styles/normalized-styles.css';
21
- import '@redis-ui/styles/fonts.css';
24
+ import '@redis-ui/styles/fonts.css'; // or fonts-next.css with themesNext, see below
22
25
  ```
23
26
 
24
27
  ### 2. Provide the theme and render global styles
@@ -41,6 +44,15 @@ function App() {
41
44
  }
42
45
  ```
43
46
 
47
+ #### Choosing a theme bundle
48
+
49
+ `@redis-ui/styles` exports two bundles, each with `light` and `dark`:
50
+
51
+ - `themes` with `fonts.css`: the current (classic) Redis brand
52
+ - `themesNext` with `fonts-next.css`: the next brand, used by the Redis Ultra console
53
+
54
+ Use one bundle per app. Pass `themesNext.light` (or `.dark`) wherever the examples use `themes.light`, and import the matching fonts file. See [`@redis-ui/styles`](https://www.npmjs.com/package/@redis-ui/styles).
55
+
44
56
  #### Dark mode support
45
57
 
46
58
  For automatic light/dark mode switching with persistence, use the `SwitchableModeThemeProvider`:
@@ -76,4 +88,14 @@ function MyPage() {
76
88
  </div>
77
89
  );
78
90
  }
79
- ```
91
+ ```
92
+
93
+ ## Documentation
94
+
95
+ - **Storybook**: every component with live examples, props tables and composition guides: https://redislabsdev.github.io/redis-ui/
96
+ - **Agent skill**: `skills/redis-ui-components` ships in this package, with a reference per component. See [Redis UI Skills](https://github.com/redislabsdev/redis-ui#redis-ui-skills) to link it into your project.
97
+ - **Release notes**: [GitHub Releases](https://github.com/redislabsdev/redis-ui/releases)
98
+
99
+ ## Contributing
100
+
101
+ See [CONTRIBUTING.md](https://github.com/redislabsdev/redis-ui/blob/master/packages/components/CONTRIBUTING.md) for how components are built (Radix, folder structure, conventions, tests), and the [root README](https://github.com/redislabsdev/redis-ui) for Storybook, visual testing and releasing.
@@ -18,6 +18,9 @@ var Label = (0, styled_components.default)(require_Typography.default.Body).with
18
18
  ""
19
19
  ], ({ $isExpanded, $transitionEnd }) => $isExpanded && $transitionEnd ? "1" : "0", () => require_SideBar_utils.useStateStyle((theme) => styled_components.css`
20
20
  color: ${theme.groupTitle.textColor};
21
+ ${theme.groupTitle.fontSize && styled_components.css`
22
+ font-size: ${theme.groupTitle.fontSize};
23
+ `}
21
24
  `));
22
25
  //#endregion
23
26
  exports.Container = Container;
@@ -16,6 +16,9 @@ var Label = _styled(Typography.Body).withConfig({
16
16
  ""
17
17
  ], ({ $isExpanded, $transitionEnd }) => $isExpanded && $transitionEnd ? "1" : "0", () => useStateStyle((theme) => css`
18
18
  color: ${theme.groupTitle.textColor};
19
+ ${theme.groupTitle.fontSize && css`
20
+ font-size: ${theme.groupTitle.fontSize};
21
+ `}
19
22
  `));
20
23
  //#endregion
21
24
  export { Container, Label };
@@ -30,7 +30,7 @@ var SideBarItem = styled_components.default.li.withConfig({
30
30
  height: ${require_SideBar_constants.SIDEBAR_CONSTANTS.item.height};
31
31
  padding: ${require_SideBar_constants.SIDEBAR_CONSTANTS.item.padding};
32
32
  border-radius: ${require_SideBar_constants.SIDEBAR_CONSTANTS.item.borderRadius};
33
- gap: ${require_SideBar_constants.SIDEBAR_CONSTANTS.item.gap};
33
+ gap: ${theme.gap ?? require_SideBar_constants.SIDEBAR_CONSTANTS.item.gap};
34
34
 
35
35
  & {
36
36
  ${require_css_utils.styleFromTokens({
@@ -28,7 +28,7 @@ var SideBarItem = _styled.li.withConfig({
28
28
  height: ${SIDEBAR_CONSTANTS.item.height};
29
29
  padding: ${SIDEBAR_CONSTANTS.item.padding};
30
30
  border-radius: ${SIDEBAR_CONSTANTS.item.borderRadius};
31
- gap: ${SIDEBAR_CONSTANTS.item.gap};
31
+ gap: ${theme.gap ?? SIDEBAR_CONSTANTS.item.gap};
32
32
 
33
33
  & {
34
34
  ${styleFromTokens({
@@ -1,10 +1,17 @@
1
1
  const require_Icon_style = require("./Icon.style.cjs");
2
+ let _redislabsdev_redis_ui_styles = require("@redis-ui/styles");
2
3
  let react_jsx_runtime = require("react/jsx-runtime");
3
4
  //#region src/SideBar/components/Item/components/Icon/Icon.tsx
4
- var Icon = ({ icon: ItemIcon, ...restProps }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Icon_style.SideBarItemIcon, {
5
- "aria-hidden": true,
6
- ...restProps,
7
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ItemIcon, { size: "L" })
8
- });
5
+ var Icon = ({ icon: ItemIcon, ...restProps }) => {
6
+ const { iconSize } = (0, _redislabsdev_redis_ui_styles.useTheme)().components.sideBar.item;
7
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Icon_style.SideBarItemIcon, {
8
+ "aria-hidden": true,
9
+ ...restProps,
10
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ItemIcon, {
11
+ size: "L",
12
+ customSize: iconSize
13
+ })
14
+ });
15
+ };
9
16
  //#endregion
10
17
  exports.default = Icon;
@@ -1,10 +1,17 @@
1
1
  import { SideBarItemIcon } from "./Icon.style.js";
2
+ import { useTheme } from "@redis-ui/styles";
2
3
  import { jsx } from "react/jsx-runtime";
3
4
  //#region src/SideBar/components/Item/components/Icon/Icon.tsx
4
- var Icon = ({ icon: ItemIcon, ...restProps }) => /* @__PURE__ */ jsx(SideBarItemIcon, {
5
- "aria-hidden": true,
6
- ...restProps,
7
- children: /* @__PURE__ */ jsx(ItemIcon, { size: "L" })
8
- });
5
+ var Icon = ({ icon: ItemIcon, ...restProps }) => {
6
+ const { iconSize } = useTheme().components.sideBar.item;
7
+ return /* @__PURE__ */ jsx(SideBarItemIcon, {
8
+ "aria-hidden": true,
9
+ ...restProps,
10
+ children: /* @__PURE__ */ jsx(ItemIcon, {
11
+ size: "L",
12
+ customSize: iconSize
13
+ })
14
+ });
15
+ };
9
16
  //#endregion
10
17
  export { Icon as default };
@@ -10,6 +10,7 @@ var Text = (props) => {
10
10
  component: "span",
11
11
  $isExpanded: isExpanded,
12
12
  $transitionEnd: transitionEnd,
13
+ $useThemeFontSize: props.size === void 0,
13
14
  ...props
14
15
  });
15
16
  };
@@ -10,6 +10,7 @@ var Text = (props) => {
10
10
  component: "span",
11
11
  $isExpanded: isExpanded,
12
12
  $transitionEnd: transitionEnd,
13
+ $useThemeFontSize: props.size === void 0,
13
14
  ...props
14
15
  });
15
16
  };
@@ -2,10 +2,20 @@ const require_runtime = require("../../../../../_virtual/_rolldown/runtime.cjs")
2
2
  const require_Typography = require("../../../../../Typography/Typography.cjs");
3
3
  let styled_components = require("styled-components");
4
4
  styled_components = require_runtime.__toESM(styled_components, 1);
5
+ let _redislabsdev_redis_ui_styles = require("@redis-ui/styles");
5
6
  //#region src/SideBar/components/Item/components/Text/Text.style.ts
6
7
  var SideBarItemText = (0, styled_components.default)(require_Typography.default.Body).withConfig({
7
8
  displayName: "Textstyle__SideBarItemText",
8
9
  componentId: "RedisUI__sc-17tjfvd-0"
9
- })(["transition:opacity 0.4s;@media (prefers-reduced-motion:reduce){transition:none;}opacity:", ";"], ({ $isExpanded, $transitionEnd }) => $isExpanded && $transitionEnd ? "1" : "0");
10
+ })([
11
+ "transition:opacity 0.4s;@media (prefers-reduced-motion:reduce){transition:none;}opacity:",
12
+ ";",
13
+ ""
14
+ ], ({ $isExpanded, $transitionEnd }) => $isExpanded && $transitionEnd ? "1" : "0", ({ $useThemeFontSize }) => {
15
+ const { fontSize } = (0, _redislabsdev_redis_ui_styles.useTheme)().components.sideBar.item;
16
+ return $useThemeFontSize && fontSize && styled_components.css`
17
+ font-size: ${fontSize};
18
+ `;
19
+ });
10
20
  //#endregion
11
21
  exports.SideBarItemText = SideBarItemText;
@@ -1,4 +1,5 @@
1
1
  export declare const SideBarItemText: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../../../../..").TypographyBodyProps & import("react").RefAttributes<HTMLElement>>, any, {
2
2
  $isExpanded: boolean;
3
3
  $transitionEnd: boolean;
4
+ $useThemeFontSize: boolean;
4
5
  }, never>;
@@ -1,9 +1,19 @@
1
1
  import Typography from "../../../../../Typography/Typography.js";
2
- import _styled from "styled-components";
2
+ import _styled, { css } from "styled-components";
3
+ import { useTheme } from "@redis-ui/styles";
3
4
  //#region src/SideBar/components/Item/components/Text/Text.style.ts
4
5
  var SideBarItemText = _styled(Typography.Body).withConfig({
5
6
  displayName: "Textstyle__SideBarItemText",
6
7
  componentId: "RedisUI__sc-17tjfvd-0"
7
- })(["transition:opacity 0.4s;@media (prefers-reduced-motion:reduce){transition:none;}opacity:", ";"], ({ $isExpanded, $transitionEnd }) => $isExpanded && $transitionEnd ? "1" : "0");
8
+ })([
9
+ "transition:opacity 0.4s;@media (prefers-reduced-motion:reduce){transition:none;}opacity:",
10
+ ";",
11
+ ""
12
+ ], ({ $isExpanded, $transitionEnd }) => $isExpanded && $transitionEnd ? "1" : "0", ({ $useThemeFontSize }) => {
13
+ const { fontSize } = useTheme().components.sideBar.item;
14
+ return $useThemeFontSize && fontSize && css`
15
+ font-size: ${fontSize};
16
+ `;
17
+ });
8
18
  //#endregion
9
19
  export { SideBarItemText };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@redis-ui/components",
3
3
  "license": "UNLICENSED",
4
- "version": "51.6.0",
4
+ "version": "51.7.1",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "repository": "git@github.com:redislabsdev/redis-ui.git",
@@ -92,7 +92,7 @@ The tooltip text is used as the collapsed label and tooltip placement defaults t
92
92
 
93
93
  ### SideBar.Item.Text Props
94
94
 
95
- This slot inherits `TypographyBodyProps`. Use it for the sidebar item text label.
95
+ This slot inherits `TypographyBodyProps`. Use it for the sidebar item text label. Without a `size`, it takes the theme's sidebar item font size when the theme sets one, so items and `CollapseButton` stay the same size.
96
96
 
97
97
  ### SideBar.Item.Button Props
98
98
 
@@ -389,6 +389,66 @@ const [activeLink, setActiveLink] = useState(groups[0].items[0].content);
389
389
  </SideBar>
390
390
  ```
391
391
 
392
+ ### ThemeSizing
393
+
394
+ > Theme defaults next to a theme that sets the SideBar sizing keys.
395
+
396
+ ```tsx
397
+ import { SideBar, Typography } from '@redis-ui/components';
398
+ import { Theme } from '@redis-ui/styles';
399
+ import { PanelLeftIcon } from '@redis-ui/icons';
400
+ import { ThemeProvider } from 'styled-components';
401
+ import { groups } from './SideBar.data';
402
+
403
+ const withSideBarSizing = (theme: Theme): Theme => ({
404
+ ...theme,
405
+ components: {
406
+ ...theme.components,
407
+ sideBar: {
408
+ ...theme.components.sideBar,
409
+ item: { ...theme.components.sideBar.item, fontSize: '1.3rem', gap: '1.6rem', iconSize: '1.8rem' },
410
+ groupTitle: { ...theme.components.sideBar.groupTitle, fontSize: '1rem' }
411
+ }
412
+ }
413
+ });
414
+
415
+ const SizingSideBar = () => (
416
+ <SideBar isExpanded expandedWidth="24rem" showActiveIndicator={false} style={{ paddingTop: '1rem' }}>
417
+ <SideBar.ScrollContainer>
418
+ <SideBar.Group>
419
+ <SideBar.Group.Title>{groups[1].title}</SideBar.Group.Title>
420
+ <SideBar.ItemsContainer>
421
+ {groups[1].items.map((item, index) => (
422
+ <SideBar.Item
423
+ key={item.content}
424
+ isActive={index === 0}
425
+ tooltipProps={{ text: item.content, placement: 'right' }}
426
+ >
427
+ <SideBar.Item.Icon icon={item.icon} />
428
+ <SideBar.Item.Text>{item.content}</SideBar.Item.Text>
429
+ </SideBar.Item>
430
+ ))}
431
+ </SideBar.ItemsContainer>
432
+ </SideBar.Group>
433
+ </SideBar.ScrollContainer>
434
+ <SideBar.Footer>
435
+ <SideBar.Divider fullWidth noMargin />
436
+ <SideBar.CollapseButton icon={PanelLeftIcon} onToggle={() => undefined} />
437
+ </SideBar.Footer>
438
+ </SideBar>
439
+ );
440
+
441
+ <>
442
+ <Typography.Body size="S">Theme defaults</Typography.Body>
443
+ <SizingSideBar />
444
+
445
+ <Typography.Body size="S">Theme sizing keys</Typography.Body>
446
+ <ThemeProvider theme={withSideBarSizing}>
447
+ <SizingSideBar />
448
+ </ThemeProvider>
449
+ </>
450
+ ```
451
+
392
452
  ### HeaderAndFooter
393
453
 
394
454
  > `Header` includes toggle button and. Set `onToggle` handler to switch expanded state.
@@ -611,3 +671,4 @@ const [expanded, setExpanded] = useState(true);
611
671
  - `SideBar.Group` wraps a section's `Group.Title` (optional) and items so the title and the items stay together as one logical unit.
612
672
  - `SideBar.Group.Title` labels a group of items. Pair `SideBar.Item.Badge` with `Item.Text` if you need to mark individual items as `NEW`, `BETA`, etc.
613
673
  - **Theme Architecture (v17.0.0+)**: The SideBar theme uses a flattened structure where state-dependent theme properties (`collapseButton.border`, `collapseButton.right`, `footer.meta.visibility`, `footer.meta.whiteSpace`) are defined as `{ collapsed: string; expanded: string }` objects directly on the theme. Structural layout values (widths, heights, margins, paddings, gaps, radii, shadows) that don't vary across light/dark themes are defined in `SIDEBAR_CONSTANTS` rather than duplicated in each theme file. This eliminates the need for runtime theme merging and provides full type safety.
674
+ - **Optional sizing theme keys**: a theme can set `item.fontSize`, `item.gap`, `item.iconSize` and `groupTitle.fontSize` to resize the sidebar. `item.gap` replaces `SIDEBAR_CONSTANTS.item.gap`, `item.iconSize` replaces the `L` icon size, `item.fontSize` applies to `Item.Text` without a `size` (including `CollapseButton`), and `groupTitle.fontSize` replaces the `S` group title size. Themes that leave them unset keep the defaults; the Next themes set them for Ultra.