@nicolassancho/storybook-core 4.0.1 → 4.1.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/README.md CHANGED
@@ -36,7 +36,7 @@ documented in Storybook. It is published to npm as `@nicolassancho/storybook-cor
36
36
  | Atoms | Button, Chip, ChipLink, Icon, Image, Label, RadioButton, SearchInput, Spinner, Text |
37
37
  | Molecules | Breadcrumbs, CartIcon, ProductCard, ProductDetails, RadioGroup |
38
38
  | Organisms | Footer, Header, ProductGrid |
39
- | Layouts | Grid |
39
+ | Layouts | Container, Grid |
40
40
 
41
41
  The palette and the contrast of each text color are documented under **Foundations / Colors** in
42
42
  Storybook.
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ export interface ContainerProps {
3
+ children: React.ReactNode;
4
+ /** Element to render. Defaults to a `div`; pass `main`, `section` and so on for a landmark. */
5
+ as?: React.ElementType;
6
+ className?: string;
7
+ }
8
+ /**
9
+ * Keeps page content at one width, centered, with matching side padding. `Header` and `Footer`
10
+ * use it for their content, so page content wrapped in a `Container` lines up with both. Their
11
+ * background, shadow and borders stay full-width.
12
+ */
13
+ export declare const Container: React.FC<ContainerProps>;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { tv } from "tailwind-variants";
3
+ const containerStyles = tv({
4
+ base: "mx-auto w-full max-w-6xl px-4 sm:px-6",
5
+ });
6
+ /**
7
+ * Keeps page content at one width, centered, with matching side padding. `Header` and `Footer`
8
+ * use it for their content, so page content wrapped in a `Container` lines up with both. Their
9
+ * background, shadow and borders stay full-width.
10
+ */
11
+ export const Container = ({ children, as: Component = "div", className, }) => _jsx(Component, { className: containerStyles({ className }), children: children });
@@ -36,6 +36,7 @@ export interface FooterProps {
36
36
  }
37
37
  /**
38
38
  * Page footer: a `contentinfo` landmark with an optional brand block, link columns and a legal
39
- * line. It holds no state, so it renders from a Server Component.
39
+ * line. The bar is full-width and its content sits in a `Container`, so it lines up with page
40
+ * content wrapped in one. It holds no state, so it renders from a Server Component.
40
41
  */
41
42
  export declare const Footer: React.FC<FooterProps>;
@@ -1,10 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { tv } from "tailwind-variants";
3
3
  import { Text } from "../../Atoms/Text/Text";
4
+ import { Container } from "../../Layouts/Container/Container";
4
5
  const footerStyles = tv({
5
6
  base: "w-full border-t border-neutral-200 bg-surface",
6
7
  slots: {
7
- inner: "flex flex-col gap-8 px-4 py-10",
8
+ inner: "flex flex-col gap-8 py-10",
8
9
  top: "flex flex-col gap-8 md:flex-row md:justify-between",
9
10
  brand: "md:max-w-xs",
10
11
  columns: "flex flex-wrap gap-x-12 gap-y-8",
@@ -15,10 +16,11 @@ const footerStyles = tv({
15
16
  });
16
17
  /**
17
18
  * Page footer: a `contentinfo` landmark with an optional brand block, link columns and a legal
18
- * line. It holds no state, so it renders from a Server Component.
19
+ * line. The bar is full-width and its content sits in a `Container`, so it lines up with page
20
+ * content wrapped in one. It holds no state, so it renders from a Server Component.
19
21
  */
20
22
  export const Footer = ({ columns = [], brand, legal, LinkComponent = "a", navLabel = "Footer", className, }) => {
21
23
  const styles = footerStyles();
22
24
  const hasColumns = columns.length > 0;
23
- return (_jsx("footer", { className: styles.base({ className }), children: _jsxs("div", { className: styles.inner(), children: [(brand || hasColumns) && (_jsxs("div", { className: styles.top(), children: [brand && _jsx("div", { className: styles.brand(), children: brand }), hasColumns && (_jsx("nav", { "aria-label": navLabel, className: styles.columns(), children: columns.map(({ title, links }) => (_jsxs("div", { children: [_jsx(Text, { as: "h2", size: "small", weight: "semibold", color: "darker", children: title }), _jsx("ul", { className: styles.list(), children: links.map(({ label, href }) => (_jsx("li", { children: _jsx(LinkComponent, { href: href, className: styles.link(), children: label }) }, `${label}-${href}`))) })] }, title))) }))] })), legal && _jsx("div", { className: styles.legal(), children: legal })] }) }));
25
+ return (_jsx("footer", { className: styles.base({ className }), children: _jsxs(Container, { className: styles.inner(), children: [(brand || hasColumns) && (_jsxs("div", { className: styles.top(), children: [brand && _jsx("div", { className: styles.brand(), children: brand }), hasColumns && (_jsx("nav", { "aria-label": navLabel, className: styles.columns(), children: columns.map(({ title, links }) => (_jsxs("div", { children: [_jsx(Text, { as: "h2", size: "small", weight: "semibold", color: "darker", children: title }), _jsx("ul", { className: styles.list(), children: links.map(({ label, href }) => (_jsx("li", { children: _jsx(LinkComponent, { href: href, className: styles.link(), children: label }) }, `${label}-${href}`))) })] }, title))) }))] })), legal && _jsx("div", { className: styles.legal(), children: legal })] }) }));
24
26
  };
@@ -39,7 +39,8 @@ export interface HeaderProps {
39
39
  }
40
40
  /**
41
41
  * Page header: a `banner` landmark with a brand, an optional main navigation and a group of
42
- * actions. It grows with its content instead of overflowing on a phone, and it holds no state, so
43
- * it renders from a Server Component.
42
+ * actions. The bar is full-width and its content sits in a `Container`, so it lines up with page
43
+ * content wrapped in one. It grows with its content instead of overflowing on a phone, and it
44
+ * holds no state, so it renders from a Server Component.
44
45
  */
45
46
  export declare const Header: React.FC<HeaderProps>;
@@ -1,9 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { tv } from "tailwind-variants";
3
+ import { Container } from "../../Layouts/Container/Container";
3
4
  const headerStyles = tv({
4
5
  base: "w-full bg-surface shadow-sm",
5
6
  slots: {
6
- inner: "flex min-h-16 flex-wrap items-center gap-x-6 gap-y-2 px-4 py-3",
7
+ inner: "flex min-h-16 flex-wrap items-center gap-x-6 gap-y-2 py-3",
7
8
  brand: "order-1",
8
9
  actions: "order-2 ml-auto flex items-center gap-2 md:order-3",
9
10
  nav: "order-3 w-full md:order-2 md:w-auto md:flex-1",
@@ -13,10 +14,11 @@ const headerStyles = tv({
13
14
  });
14
15
  /**
15
16
  * Page header: a `banner` landmark with a brand, an optional main navigation and a group of
16
- * actions. It grows with its content instead of overflowing on a phone, and it holds no state, so
17
- * it renders from a Server Component.
17
+ * actions. The bar is full-width and its content sits in a `Container`, so it lines up with page
18
+ * content wrapped in one. It grows with its content instead of overflowing on a phone, and it
19
+ * holds no state, so it renders from a Server Component.
18
20
  */
19
21
  export const Header = ({ brand, actions, navItems = [], navLabel = "Main", LinkComponent = "a", className, }) => {
20
22
  const styles = headerStyles();
21
- return (_jsx("header", { className: styles.base({ className }), children: _jsxs("div", { className: styles.inner(), children: [_jsx("div", { className: styles.brand(), children: brand }), actions && _jsx("div", { className: styles.actions(), children: actions }), navItems.length > 0 && (_jsx("nav", { "aria-label": navLabel, className: styles.nav(), children: _jsx("ul", { className: styles.list(), children: navItems.map(({ label, href }) => (_jsx("li", { children: _jsx(LinkComponent, { href: href, className: styles.link(), children: label }) }, `${label}-${href}`))) }) }))] }) }));
23
+ return (_jsx("header", { className: styles.base({ className }), children: _jsxs(Container, { className: styles.inner(), children: [_jsx("div", { className: styles.brand(), children: brand }), actions && _jsx("div", { className: styles.actions(), children: actions }), navItems.length > 0 && (_jsx("nav", { "aria-label": navLabel, className: styles.nav(), children: _jsx("ul", { className: styles.list(), children: navItems.map(({ label, href }) => (_jsx("li", { children: _jsx(LinkComponent, { href: href, className: styles.link(), children: label }) }, `${label}-${href}`))) }) }))] }) }));
22
24
  };
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from "./components/Atoms/Image/Image";
8
8
  export * from "./components/Atoms/Label/Label";
9
9
  export * from "./components/Atoms/RadioButton/RadioButton";
10
10
  export * from "./components/Atoms/SearchInput/SearchInput";
11
+ export * from "./components/Layouts/Container/Container";
11
12
  export * from "./components/Layouts/Grid/Grid";
12
13
  export * from "./components/Molecules/Breadcrumbs/Breadcrumbs";
13
14
  export * from "./components/Molecules/CartIcon/CartIcon";
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ export * from "./components/Atoms/Label/Label";
10
10
  export * from "./components/Atoms/RadioButton/RadioButton";
11
11
  export * from "./components/Atoms/SearchInput/SearchInput";
12
12
  // Layouts
13
+ export * from "./components/Layouts/Container/Container";
13
14
  export * from "./components/Layouts/Grid/Grid";
14
15
  // Molecules
15
16
  export * from "./components/Molecules/Breadcrumbs/Breadcrumbs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nicolassancho/storybook-core",
3
- "version": "4.0.1",
3
+ "version": "4.1.0",
4
4
  "description": "Accessible React + Tailwind component library built with tailwind-variants and documented in Storybook.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",