@-reddacted-/react-ui 0.3.0 → 0.3.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.
@@ -1,20 +1,17 @@
1
- import type { ElementType, ReactNode } from "react";
2
- export type NavLink = {
3
- label: string;
4
- to: string;
5
- };
1
+ import type { CSSProperties, ReactNode } from "react";
6
2
  type NavBarProps = {
7
- brand: string;
8
- links?: NavLink[];
9
- /** Rendered on the right of the links: sign out, theme select, whatever the page adds. */
10
- actions?: ReactNode;
11
3
  /**
12
- * Link component to render with. Defaults to a plain anchor so the bar works
13
- * without a router; pass a router Link to keep client-side navigation.
4
+ * Anything: logo, router links, buttons, selects. Direct `a` / `button` children get
5
+ * a default look; mark the current one with `aria-current="page"` (react-router's
6
+ * NavLink does it for you) or `aria-pressed="true"` to render it pressed.
14
7
  */
15
- linkAs?: ElementType;
16
- homeTo?: string;
8
+ children: ReactNode;
9
+ className?: string;
10
+ style?: CSSProperties;
17
11
  };
18
- export declare function NavBar({ brand, links, actions, linkAs, homeTo }: NavBarProps): import("react").JSX.Element;
12
+ export declare function NavBar({ children, className, style }: NavBarProps): import("react").JSX.Element;
13
+ export declare namespace NavBar {
14
+ var Spacer: () => import("react").JSX.Element;
15
+ }
19
16
  export {};
20
17
  //# sourceMappingURL=NavBar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NavBar.d.ts","sourceRoot":"","sources":["../../src/components/NavBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAElE,MAAM,MAAM,OAAO,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnD,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,OAAO,EAAE,CAAA;IACjB,0FAA0F;IAC1F,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,wBAAgB,MAAM,CAAC,EAAE,KAAK,EAAE,KAAU,EAAE,OAAO,EAAE,MAAM,EAAE,MAAY,EAAE,EAAE,WAAW,+BAmBvF"}
1
+ {"version":3,"file":"NavBar.d.ts","sourceRoot":"","sources":["../../src/components/NavBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAErD,KAAK,WAAW,GAAG;IACjB;;;;OAIG;IACH,QAAQ,EAAE,SAAS,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,aAAa,CAAA;CACtB,CAAA;AAED,wBAAgB,MAAM,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,WAAW,+BAOjE;yBAPe,MAAM"}
@@ -1,31 +1,51 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export function NavBar({ brand, links = [], actions, linkAs, homeTo = "/" }) {
3
- const Link = linkAs ?? "a";
4
- const linkProps = (to) => (linkAs ? { to } : { href: to });
5
- return (_jsxs("nav", { style: navStyle, children: [_jsx(Link, { ...linkProps(homeTo), style: brandStyle, children: brand }), _jsxs("div", { style: rightStyle, children: [links.map(link => (_jsx(Link, { ...linkProps(link.to), style: linkStyle, children: link.label }, link.to))), actions] })] }));
6
- }
7
- const navStyle = {
8
- display: "flex",
9
- alignItems: "center",
10
- justifyContent: "space-between",
11
- padding: "0 1.5rem",
12
- height: "56px",
13
- borderBottom: "1px solid var(--color-border)",
14
- backgroundColor: "var(--color-surface)",
15
- };
16
- const brandStyle = {
17
- fontWeight: 600,
18
- fontSize: "1rem",
19
- color: "var(--color-text)",
20
- textDecoration: "none",
21
- };
22
- const rightStyle = {
23
- display: "flex",
24
- alignItems: "center",
25
- gap: "1.25rem",
26
- };
27
- const linkStyle = {
28
- color: "var(--color-text-muted)",
29
- textDecoration: "none",
30
- fontSize: "0.875rem",
31
- };
2
+ export function NavBar({ children, className, style }) {
3
+ return (_jsxs("nav", { className: className ? `rui-navbar ${className}` : "rui-navbar", style: style, children: [_jsx("style", { children: navBarCss }), children] }));
4
+ }
5
+ /** Takes the free space, pushing the following children to the right. */
6
+ function Spacer() {
7
+ return _jsx("span", { className: "rui-navbar-spacer", "aria-hidden": "true" });
8
+ }
9
+ NavBar.Spacer = Spacer;
10
+ // Every selector is wrapped in :where() so it has zero specificity:
11
+ // any class or style set by the consuming project wins without !important.
12
+ const navBarCss = `
13
+ :where(.rui-navbar) {
14
+ display: flex;
15
+ align-items: center;
16
+ gap: 0.5rem;
17
+ padding: 0 1.5rem;
18
+ height: 56px;
19
+ border-bottom: 1px solid var(--color-border);
20
+ background-color: var(--color-surface);
21
+ }
22
+ :where(.rui-navbar-spacer) {
23
+ flex: 1;
24
+ }
25
+ :where(.rui-navbar img) {
26
+ display: block;
27
+ max-height: 32px;
28
+ }
29
+ :where(.rui-navbar) > :where(a, button) {
30
+ display: inline-flex;
31
+ align-items: center;
32
+ gap: 0.5rem;
33
+ padding: 0.375rem 0.75rem;
34
+ border: none;
35
+ border-radius: 6px;
36
+ background-color: transparent;
37
+ color: var(--color-text-muted);
38
+ font: inherit;
39
+ font-size: 0.875rem;
40
+ font-weight: 500;
41
+ text-decoration: none;
42
+ cursor: pointer;
43
+ }
44
+ :where(.rui-navbar) > :where(a, button):hover {
45
+ color: var(--color-text);
46
+ }
47
+ :where(.rui-navbar) > :where([aria-current="page"], [aria-pressed="true"]) {
48
+ background-color: var(--color-border);
49
+ color: var(--color-text);
50
+ }
51
+ `;
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export { default as ColorPicker } from "./components/ColorPicker.js";
3
3
  export { default as ConfirmDeleteButton } from "./components/ConfirmDeleteButton.js";
4
4
  export { ColorField } from "./components/ColorField.js";
5
5
  export { Button, type ButtonVariant } from "./components/Button.js";
6
- export { NavBar, type NavLink } from "./components/NavBar.js";
6
+ export { NavBar } from "./components/NavBar.js";
7
7
  export { PageMessage, LoadingMessage, ErrorMessage } from "./components/PageStatus.js";
8
8
  export { ThemeProvider, useTheme } from "./theme/ThemeProvider.js";
9
9
  export { ThemeSelect } from "./theme/ThemeSelect.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAC/E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACnE,OAAO,EAAE,MAAM,EAAE,KAAK,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAEtF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC/F,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAC1F,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE9F,O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",
3
+ "version": "0.3.1",
4
4
  "description": "Theming system, Modal, Button, ColorPicker, NavBar and error popups (imperative, REST or GraphQL fetch) for React",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",