diff --git a/app/components/cards/NoRules/NoRules.container.tsx b/app/components/cards/NoRules/NoRules.container.tsx new file mode 100644 index 0000000..354e20b --- /dev/null +++ b/app/components/cards/NoRules/NoRules.container.tsx @@ -0,0 +1,17 @@ +"use client"; + +/** + * Figma: "Card / No Rules" (25032:50447) + * https://www.figma.com/design/agv0VBLiBlcnSAaiAORgPR/Community-Rule-System?node-id=25032-50447 + */ +import { memo } from "react"; +import { NoRulesView } from "./NoRules.view"; +import type { NoRulesProps } from "./NoRules.types"; + +const NoRulesContainer = memo((props) => { + return ; +}); + +NoRulesContainer.displayName = "NoRules"; + +export default NoRulesContainer; diff --git a/app/components/cards/NoRules/NoRules.types.ts b/app/components/cards/NoRules/NoRules.types.ts new file mode 100644 index 0000000..8e011dc --- /dev/null +++ b/app/components/cards/NoRules/NoRules.types.ts @@ -0,0 +1,11 @@ +export type NoRulesProps = { + title: string; + description: string; + createLabel: string; + browseLabel: string; + onCreate: () => void; + browseHref: string; + className?: string; +}; + +export type NoRulesViewProps = NoRulesProps; diff --git a/app/components/cards/NoRules/NoRules.view.tsx b/app/components/cards/NoRules/NoRules.view.tsx new file mode 100644 index 0000000..fe66109 --- /dev/null +++ b/app/components/cards/NoRules/NoRules.view.tsx @@ -0,0 +1,52 @@ +"use client"; + +import { memo } from "react"; +import Button from "../../buttons/Button"; +import NavigationLink from "../../navigation/Link"; +import type { NoRulesViewProps } from "./NoRules.types"; + +export const NoRulesView = memo(function NoRulesView({ + title, + description, + createLabel, + browseLabel, + onCreate, + browseHref, + className = "", +}: NoRulesViewProps) { + return ( +
+

+ {title} +

+

+ {description} +

+
+ + + {browseLabel} + +
+
+ ); +}); + +NoRulesView.displayName = "NoRulesView"; diff --git a/app/components/cards/NoRules/index.tsx b/app/components/cards/NoRules/index.tsx new file mode 100644 index 0000000..9987c06 --- /dev/null +++ b/app/components/cards/NoRules/index.tsx @@ -0,0 +1,2 @@ +export { default } from "./NoRules.container"; +export type { NoRulesProps } from "./NoRules.types"; diff --git a/docs/figma-component-registry.md b/docs/figma-component-registry.md index 2d6892d..748d3d2 100644 --- a/docs/figma-component-registry.md +++ b/docs/figma-component-registry.md @@ -7,7 +7,7 @@ Quick map from the Figma file **Community Rule System** (`agv0VBLiBlcnSAaiAORgPR | [Utility](https://www.figma.com/design/agv0VBLiBlcnSAaiAORgPR/Community-Rule-System?node-id=20515-15809) | `utility/` | Create chrome, tag, scroll, sidebar, dividers, etc. | | [Asset](https://www.figma.com/design/agv0VBLiBlcnSAaiAORgPR/Community-Rule-System?node-id=1240-9089) | **`app/components/asset/`**, **`public/assets/template-mark/`**, **`public/assets/vector/`** | Components under **`asset/`**; flat kebab **`*.svg`** in **`template-mark/`** & **`vector/`** (see conventions below). | | [Button](https://www.figma.com/design/agv0VBLiBlcnSAaiAORgPR/Community-Rule-System?node-id=497-3016) | `buttons/` | PascalCase package per primitive — **`Button/`**, **`InlineTextButton/`** (see conventions below). | -| [Card](https://www.figma.com/design/agv0VBLiBlcnSAaiAORgPR/Community-Rule-System?node-id=17865-24349) | `cards/` | One PascalCase package per surface—**`Selection/`** (Figma **Card / CardSelection**), **`CardStack/`**, **`Rule/`** (Figma **Card / Rule**), **`Icon/`**, **`CaseStudy/`**, **`Mini/`**, **`Stat/`** (Figma **Card / Stat**), **`Step/`** (Figma **Card / Step**), **`TemplateReviewCard/`** (see conventions below). | +| [Card](https://www.figma.com/design/agv0VBLiBlcnSAaiAORgPR/Community-Rule-System?node-id=17865-24349) | `cards/` | One PascalCase package per surface—**`Selection/`** (Figma **Card / CardSelection**), **`CardStack/`**, **`Rule/`** (Figma **Card / Rule**), **`NoRules/`** (Figma **Card / No Rules**), **`Icon/`**, **`CaseStudy/`**, **`Mini/`**, **`Stat/`** (Figma **Card / Stat**), **`Step/`** (Figma **Card / Step**), **`TemplateReviewCard/`** (see conventions below). | | [Control](https://www.figma.com/design/agv0VBLiBlcnSAaiAORgPR/Community-Rule-System?node-id=5944-58611) | `controls/` | Checkbox, radio, text field, select, toggle, switch, incrementer, upload, multi-select, chip, … (see **Control conventions** below). **`InfoMessageBox`** canonical here. | | [Layout](https://www.figma.com/design/agv0VBLiBlcnSAaiAORgPR/Community-Rule-System?node-id=21836-20542) | `layout/` | **`List/`**, **`ListEntry/`**, **`ListItem/`** + **`listSizeLayout.ts`**. **Tabs** / **Accordion** are in Figma only—**not** in code yet (see **Layout conventions**). | | [Modals](https://www.figma.com/design/agv0VBLiBlcnSAaiAORgPR/Community-Rule-System?node-id=5944-47704) | `modals/` | Alert, Create, Dialog, Login, Tooltip, **`ModalHeader`** / **`ModalFooter`** (see **Modals conventions**). | @@ -194,6 +194,7 @@ Inventory aligns with [**CR-104**](https://linear.app/community-rule/issue/CR-10 - **Pattern:** follow the **container / view / types** split (**`Selection/`**, **`CardStack/`**, **`Rule/`**, **`Icon/`**, **`Mini/`**) unless a component stays a single module (**`Step/`** uses one **`Step.tsx`** + **`index.tsx`** only). - **`Rule/`** — Figma **Card / Rule**. **`Rule.container.tsx`**, **`Rule.view.tsx`**, **`Rule.types.ts`**. +- **`NoRules/`** — Figma **Card / No Rules** ([25032:50447](https://www.figma.com/design/agv0VBLiBlcnSAaiAORgPR/Community-Rule-System?node-id=25032-50447)). Empty state on Profile **Your Rules**. - **`Selection/`** — Figma **Card / CardSelection** (e.g. `16775:28762`): optional recommended/selected **`Tag`**, label, support text. Stacked layout uses `orientation="horizontal"`; row + info icon + tag right uses `orientation="vertical"`. - **`Stat/`** — Figma **Card / Stat** (metric tile + decorative shape). Composed by **`sections/Stats`** on **`/about`**. - **`Step/`** — Figma **Card / Step** (numbered step tile + text). Shipped on the home page via **`sections/CardSteps`**. Not the **Progress / Stepper** wizard control. diff --git a/stories/cards/NoRules.stories.js b/stories/cards/NoRules.stories.js new file mode 100644 index 0000000..63ed1a4 --- /dev/null +++ b/stories/cards/NoRules.stories.js @@ -0,0 +1,36 @@ +import NoRules from "../../app/components/cards/NoRules"; + +export default { + title: "Components/Cards/NoRules", + component: NoRules, + parameters: { + layout: "centered", + backgrounds: { default: "dark" }, + docs: { + description: { + component: + "Empty state for Your Rules on Profile when a member has no Rules yet.", + }, + }, + }, + argTypes: { + title: { control: "text" }, + description: { control: "text" }, + createLabel: { control: "text" }, + browseLabel: { control: "text" }, + browseHref: { control: "text" }, + onCreate: { action: "create" }, + }, +}; + +export const Default = { + args: { + title: "No Rules yet", + description: + "Start from a template, or write your first over a few short meetings with the free kit.", + createLabel: "Create rule", + browseLabel: "Browse templates", + browseHref: "/templates?fromFlow=1", + className: "max-w-[560px]", + }, +}; diff --git a/tests/components/cards/NoRules.test.tsx b/tests/components/cards/NoRules.test.tsx new file mode 100644 index 0000000..68609de --- /dev/null +++ b/tests/components/cards/NoRules.test.tsx @@ -0,0 +1,36 @@ +import "@testing-library/jest-dom/vitest"; +import { describe, expect, it, vi } from "vitest"; +import userEvent from "@testing-library/user-event"; +import NoRules from "../../../app/components/cards/NoRules"; +import { renderWithProviders, screen } from "../../utils/test-utils"; + +describe("NoRules", () => { + it("renders the empty-state copy, create action, and templates link", async () => { + const user = userEvent.setup(); + const onCreate = vi.fn(); + renderWithProviders( + , + ); + + expect(screen.getByRole("heading", { name: "No Rules yet" })).toBeInTheDocument(); + expect( + screen.getByText( + "Start from a template, or write your first over a few short meetings with the free kit.", + ), + ).toBeInTheDocument(); + + await user.click(screen.getByRole("button", { name: "Create rule" })); + expect(onCreate).toHaveBeenCalledTimes(1); + + expect( + screen.getByRole("link", { name: "Browse templates" }), + ).toHaveAttribute("href", "/templates?fromFlow=1"); + }); +});