Show the Profile empty state, phone layout, and Rules you belong to #106
No files matched your search
@@ -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<NoRulesProps>((props) => {
|
||||
return <NoRulesView {...props} />;
|
||||
});
|
||||
|
||||
NoRulesContainer.displayName = "NoRules";
|
||||
|
||||
export default NoRulesContainer;
|
||||
@@ -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;
|
||||
@@ -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 (
|
||||
<div
|
||||
className={`flex w-full flex-col items-start gap-4 rounded-[var(--radius-300)] border border-dashed border-[var(--color-border-default-secondary)] p-8 ${className}`.trim()}
|
||||
data-figma-node="25032:50447"
|
||||
>
|
||||
<h3 className="w-full font-bricolage-grotesque text-small-heading text-[var(--color-content-default-primary)]">
|
||||
{title}
|
||||
</h3>
|
||||
<p className="w-full text-medium-paragraph text-[var(--color-content-default-secondary)]">
|
||||
{description}
|
||||
</p>
|
||||
<div className="flex w-full flex-wrap items-center gap-x-4 gap-y-3 pt-2">
|
||||
<Button
|
||||
type="button"
|
||||
size="large"
|
||||
buttonType="filled"
|
||||
palette="default"
|
||||
onClick={onCreate}
|
||||
>
|
||||
{createLabel}
|
||||
</Button>
|
||||
<NavigationLink
|
||||
href={browseHref}
|
||||
type="primary"
|
||||
theme="dark"
|
||||
leadingIcon={false}
|
||||
trailingIcon={false}
|
||||
>
|
||||
{browseLabel}
|
||||
</NavigationLink>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
NoRulesView.displayName = "NoRulesView";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { default } from "./NoRules.container";
|
||||
export type { NoRulesProps } from "./NoRules.types";
|
||||
@@ -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.
|
||||
|
||||
@@ -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]",
|
||||
},
|
||||
};
|
||||
@@ -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(
|
||||
<NoRules
|
||||
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"
|
||||
onCreate={onCreate}
|
||||
/>,
|
||||
);
|
||||
|
||||
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");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user