@jfrader/storybook-docs 0.7.0 → 0.8.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/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { createRoot } from "react-dom/client";
5
5
  import { site as site3, themeCss, theme as theme2 } from "virtual:storybook-docs/site";
6
6
 
7
7
  // src/app.tsx
8
- import { Children, useEffect as useEffect8, useRef as useRef5, useState as useState9 } from "react";
8
+ import { useEffect as useEffect8, useRef as useRef5, useState as useState9 } from "react";
9
9
  import { catalog as catalog3, groups as groups2 } from "virtual:storybook-docs/catalog";
10
10
  import { pages, site as site2, theme } from "virtual:storybook-docs/site";
11
11
 
@@ -1857,21 +1857,14 @@ function SearchBox() {
1857
1857
  import { releases as releases2 } from "virtual:storybook-docs/releases";
1858
1858
  import { jsx as jsx16, jsxs as jsxs13 } from "react/jsx-runtime";
1859
1859
  var routeHref = (path) => `#${hrefFor(path)}`;
1860
- var NAV_GROUP_WINDOW = 12;
1861
- function NavGroup({ id, title, active, activeIndex = -1, children }) {
1862
- const [open, setOpen] = useState9(false);
1863
- const [showAll, setShowAll] = useState9(false);
1864
- const expanded = active || open;
1865
- const links = Children.toArray(children);
1866
- const capped = active && links.length > NAV_GROUP_WINDOW;
1867
- const start2 = Math.min(Math.max(activeIndex - NAV_GROUP_WINDOW / 2, 0), Math.max(0, links.length - NAV_GROUP_WINDOW));
1868
- const visibleLinks = capped && !showAll ? links.slice(start2, start2 + NAV_GROUP_WINDOW) : links;
1860
+ function NavGroup({ id, title, active, children }) {
1861
+ const [open, setOpen] = useState9(active);
1869
1862
  return /* @__PURE__ */ jsxs13("div", { role: "group", "aria-labelledby": id, children: [
1870
- /* @__PURE__ */ jsx16("button", { type: "button", className: "grp", id, "aria-expanded": expanded, "aria-controls": `${id}-links`, disabled: active, onClick: () => setOpen(!open), children: title }),
1871
- /* @__PURE__ */ jsxs13("div", { id: `${id}-links`, hidden: !expanded, children: [
1872
- /* @__PURE__ */ jsx16("div", { id: `${id}-window`, children: visibleLinks }),
1873
- capped ? /* @__PURE__ */ jsx16("button", { type: "button", className: "nav-more", "aria-expanded": showAll, "aria-controls": `${id}-window`, onClick: () => setShowAll(!showAll), children: showAll ? "Show less" : `Show all ${links.length}` }) : null
1874
- ] })
1863
+ /* @__PURE__ */ jsxs13("button", { type: "button", className: "grp", id, "aria-expanded": open, "aria-controls": `${id}-links`, onClick: () => setOpen(!open), children: [
1864
+ /* @__PURE__ */ jsx16("span", { children: title }),
1865
+ /* @__PURE__ */ jsx16("svg", { className: "grp-chevron", width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.5", "aria-hidden": "true", children: /* @__PURE__ */ jsx16("path", { d: "m6 4 4 4-4 4" }) })
1866
+ ] }),
1867
+ /* @__PURE__ */ jsx16("div", { id: `${id}-links`, hidden: !open, children })
1875
1868
  ] });
1876
1869
  }
1877
1870
  function parseRoute(hash) {
@@ -1999,7 +1992,7 @@ function DocsApp() {
1999
1992
  ]
2000
1993
  }
2001
1994
  ) : null,
2002
- foundations.length > 0 ? /* @__PURE__ */ jsx16(NavGroup, { id: "nav-grp-foundations", title: "Foundations", active: foundations.some((item) => route.kind === item.kind), children: foundations.map((item) => /* @__PURE__ */ jsx16(
1995
+ foundations.length > 0 ? /* @__PURE__ */ jsx16(NavGroup, { id: "nav-grp-foundations", title: "Design tokens", active: foundations.some((item) => route.kind === item.kind), children: foundations.map((item) => /* @__PURE__ */ jsx16(
2003
1996
  "a",
2004
1997
  {
2005
1998
  href: item.href,
@@ -2011,8 +2004,8 @@ function DocsApp() {
2011
2004
  )) }, `foundations-${activeSlug ?? route.kind}`) : null,
2012
2005
  groups2.map((group, index) => {
2013
2006
  const entries = catalog3.filter((entry) => entry.group === group);
2014
- const activeIndex = entries.findIndex((entry) => entry.slug === activeSlug);
2015
- return /* @__PURE__ */ jsx16(NavGroup, { id: `nav-grp-${index}`, title: group, active: activeIndex !== -1, activeIndex, children: entries.map((entry) => /* @__PURE__ */ jsx16(
2007
+ const active = entries.some((entry) => entry.slug === activeSlug);
2008
+ return /* @__PURE__ */ jsx16(NavGroup, { id: `nav-grp-${index}`, title: group, active, children: entries.map((entry) => /* @__PURE__ */ jsx16(
2016
2009
  "a",
2017
2010
  {
2018
2011
  href: routeHref(`/components/${entry.slug}`),
package/dist/styles.css CHANGED
@@ -202,8 +202,7 @@ body {
202
202
  background: var(--sd-surface);
203
203
  padding: 14px 12px 12px;
204
204
  }
205
- .nav a,
206
- .nav-more {
205
+ .nav a {
207
206
  display: flex;
208
207
  align-items: center;
209
208
  box-sizing: border-box;
@@ -214,16 +213,7 @@ body {
214
213
  font-size: 13.5px;
215
214
  text-decoration: none;
216
215
  }
217
- .nav-more {
218
- width: 100%;
219
- background: none;
220
- border: 0;
221
- font-family: inherit;
222
- cursor: pointer;
223
- text-align: left;
224
- }
225
- .nav a:hover,
226
- .nav-more:hover {
216
+ .nav a:hover {
227
217
  background: var(--sd-surface-hover);
228
218
  color: var(--sd-text);
229
219
  }
@@ -234,23 +224,46 @@ body {
234
224
  }
235
225
  .grp {
236
226
  margin: 3px 0 2px;
237
- padding: 0 10px;
227
+ padding: 8px 10px;
238
228
  font-size: 10.5px;
239
229
  letter-spacing: 0.09em;
240
230
  text-transform: uppercase;
241
231
  color: var(--sd-text-muted);
242
232
  font-weight: 700;
243
- display: block;
233
+ display: flex;
234
+ align-items: center;
235
+ justify-content: space-between;
236
+ gap: 8px;
244
237
  width: 100%;
245
238
  text-align: left;
246
239
  font-family: inherit;
247
240
  background: none;
248
241
  border: 0;
242
+ border-radius: 8px;
249
243
  cursor: pointer;
250
- min-height: 28px;
244
+ min-height: 36px;
245
+ }
246
+ .grp[aria-expanded="true"] {
247
+ background: var(--sd-surface-raised);
248
+ color: var(--sd-text);
249
+ }
250
+ .grp:hover {
251
+ background: var(--sd-surface-hover);
252
+ color: var(--sd-text);
253
+ }
254
+ .grp-chevron {
255
+ flex-shrink: 0;
256
+ transition: transform 150ms ease;
257
+ }
258
+ .grp[aria-expanded="true"] .grp-chevron {
259
+ transform: rotate(90deg);
260
+ }
261
+ @media (prefers-reduced-motion: reduce) {
262
+ .grp-chevron {
263
+ transition: none;
264
+ }
251
265
  }
252
- .grp:focus-visible,
253
- .nav-more:focus-visible {
266
+ .grp:focus-visible {
254
267
  outline: 2px solid var(--sd-focus-ring);
255
268
  outline-offset: 2px;
256
269
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jfrader/storybook-docs",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "description": "A documentation front for any design system that has Storybook: navigation, live examples and API tables are generated from the story files themselves.",
6
6
  "exports": {