Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/update storybook part I #34

Merged
merged 11 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from "path";
const config: StorybookConfig = {
stories: [
"../components/**/*.stories.@(js|jsx|mjs|ts|tsx)",
"../app/**/*.stories.@(js|jsx|mjs|ts|tsx)",
"../docs/*.stories.mdx",
],
addons: [
"@storybook/addon-links",
Expand All @@ -13,6 +13,7 @@ const config: StorybookConfig = {
"@storybook/addon-a11y",
"@storybook/addon-designs",
],
staticDirs: ["../public", "../docs/assets"],
webpackFinal: async (config) => {
if (config && config.resolve && config.resolve.alias) {
config.resolve.alias = {
Expand Down
1 change: 0 additions & 1 deletion .storybook/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const theme = create({

// Brand assets
brandTitle: "NomadHair",
// TODO: Replace with real url.
brandUrl: "https://nomadhair.co/",
brandImage:
"https://res.cloudinary.com/dtsdpcbcv/image/upload/v1712891768/logo-light-lg_pmi0xn.svg",
Expand Down
12 changes: 12 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ const preview: Preview = {
...MINIMAL_VIEWPORTS,
},
},
options: {
storySort: {
method: "",
order: [
"Getting Started",
"Style Guide",
"Atoms",
"Molecules",
"Organisms",
],
},
},
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { Calendar } from "@/components/atoms/calendar";
import { Calendar } from "@/components/molecules/calendar";
import React, { useState } from "react";
import useSWR, { mutate } from "swr";
import AppointmentTimeslots from "./appointmentTimeslots";
Expand Down
3 changes: 3 additions & 0 deletions components/atoms/avatar/avatar.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Meta, StoryObj } from "@storybook/react";
import { Avatar, AvatarImage, AvatarFallback } from "./avatar";

/**
* Avatar component is used to represent a user, and display the profile picture, initials or fallback icon.
*/
const meta: Meta<typeof Avatar> = {
title: "Atoms/Avatar",
component: Avatar,
Expand Down
6 changes: 3 additions & 3 deletions components/atoms/avatar/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { cva, type VariantProps } from "class-variance-authority";

import { cn } from "@/lib/utils";

const avatarVariatnts = cva(
const avatarVariants = cva(
"relative flex shrink-0 overflow-hidden rounded-full",
{
variants: {
Expand All @@ -24,15 +24,15 @@ const avatarVariatnts = cva(

export interface AvatarProps
extends React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>,
VariantProps<typeof avatarVariatnts> {}
VariantProps<typeof avatarVariants> {}

const Avatar = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Root>,
AvatarProps
>(({ className, size, ...props }, ref) => (
<AvatarPrimitive.Root
ref={ref}
className={cn(avatarVariatnts({ size }), className)}
className={cn(avatarVariants({ size }), className)}
{...props}
/>
));
Expand Down
9 changes: 7 additions & 2 deletions components/atoms/button/button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { Meta, StoryObj } from "@storybook/react";
import { Button } from "./button";
import { PlusIcon, icons } from "lucide-react";
import { PlusIcon } from "lucide-react";

/**
* Button allows users to take action, and make choices, with a single step.
* The component can be used as native `<button>` element or can embed `<a>` to redirect user to new page.
*/

const meta: Meta<typeof Button> = {
title: "Atoms/Button",
Expand All @@ -20,7 +25,7 @@ const meta: Meta<typeof Button> = {
},
argTypes: {
intent: {
options: ["primary", "secondary", "tertiary", "danger"],
options: ["primary", "secondary", "danger"],
control: { type: "radio" },
},
variant: {
Expand Down
11 changes: 0 additions & 11 deletions components/atoms/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const buttonVariants = cva(
intent: {
primary: "bg-primary-100 text-white hover:bg-primary-100/90",
secondary: "bg-secondary-100 text-neutral-90 hover:bg-secondary-100/90",
tertiary: "bg-tertiary-100 text-neutral-90 hover:bg-tertiary-100/90",
danger: "bg-danger-100 text-white hover:bg-danger-100/90",
},
variant: {
Expand Down Expand Up @@ -40,11 +39,6 @@ const buttonVariants = cva(
variant: ["outline", "ghost"],
className: "text-secondary-100 hover:bg-secondary-100/5",
},
{
intent: "tertiary",
variant: ["outline", "ghost"],
className: "text-tertiary-100 hover:bg-tertiary-100/5",
},
{
intent: "danger",
variant: ["outline", "ghost"],
Expand All @@ -60,11 +54,6 @@ const buttonVariants = cva(
variant: "link",
className: "text-secondary-100",
},
{
intent: "tertiary",
variant: "link",
className: "text-tertiary-100",
},
{
intent: "danger",
variant: "link",
Expand Down
20 changes: 7 additions & 13 deletions components/atoms/skeleton/skeleton.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,12 @@ type Story = StoryObj<typeof Skeleton>;

export const Default: Story = {
render: () => (
<>
<Card>
<div className="flex w-full items-center gap-4">
<Skeleton className="h-10 w-10 rounded-full" />
<Skeleton className="h-8 w-20 flex-grow" />
</div>
<CardContent className="flex flex-col gap-2">
<Skeleton className="h-6 w-full " />
<Skeleton className="h-6 w-full " />
<Skeleton className="h-6 w-full " />
</CardContent>
</Card>
</>
<div className="flex w-full items-center gap-4">
<Skeleton className="h-10 w-10 rounded-full" />
<div>
<Skeleton className="mb-2 h-4 w-32 flex-grow" />
<Skeleton className="h-4 w-32 flex-grow" />
</div>
</div>
),
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Calendar } from "./calendar";
import { useState } from "react";

const meta: Meta<typeof Calendar> = {
title: "Atoms/Calendar",
title: "Molecules/Calendar",
component: Calendar,
parameters: {
layout: "centered",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ChevronLeftIcon, ChevronRightIcon } from "@radix-ui/react-icons";
import { DayPicker } from "react-day-picker";

import { cn } from "@/lib/utils";
import { buttonVariants } from "../button";
import { buttonVariants } from "../../atoms/button";

export type CalendarProps = React.ComponentProps<typeof DayPicker>;

Expand Down
25 changes: 8 additions & 17 deletions components/molecules/card/card.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,14 @@ const meta: Meta<typeof Card> = {
parameters: {
layout: "centered",
},
args: {
intent: "neutral",
},
argTypes: {
intent: {
options: ["primary", "secondary", "tertiary", "neutral"],
control: { type: "radio" },
},
},
};

export default meta;
type Story = StoryObj<typeof Card>;

export const Default: Story = {
render: ({ intent }) => (
<Card className="w-96" intent={intent}>
render: () => (
<Card className="w-96">
<CardContent>
“Lorem ipsum dolor sit amet, consec tetur adi piscing elit. Praesent
tellus leo, vesti bulum a ipsum sed, suscipit sodales ex. Vestibulum id
Expand All @@ -36,8 +27,8 @@ export const Default: Story = {
};

export const WithHeader: Story = {
render: ({ intent }) => (
<Card className="w-96" intent={intent}>
render: () => (
<Card className="w-96">
<CardHeader headingLevel={2} title="Title" subheader="subheading" />
<CardContent>
“Lorem ipsum dolor sit amet, consec tetur adi piscing elit. Praesent
Expand All @@ -49,8 +40,8 @@ export const WithHeader: Story = {
};

export const WithAvatar: Story = {
render: ({ intent }) => (
<Card className="w-96" intent={intent}>
render: () => (
<Card className="w-96">
<CardHeader
avatar={
<Avatar>
Expand All @@ -71,8 +62,8 @@ export const WithAvatar: Story = {
};

export const WithAction: Story = {
render: ({ intent }) => (
<Card className="w-96" intent={intent}>
render: () => (
<Card className="w-96">
<CardContent>
“Lorem ipsum dolor sit amet, consec tetur adi piscing elit. Praesent
tellus leo, vesti bulum a ipsum sed, suscipit sodales ex. Vestibulum id
Expand Down
44 changes: 14 additions & 30 deletions components/molecules/card/card.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,22 @@
import { cn } from "@/lib/utils";
import React, { forwardRef } from "react";
import { cva, type VariantProps } from "class-variance-authority";

const cardVariants = cva(
"flex min-w-56 flex-col gap-4 p-6 shadow-md rounded-2xl",
{
variants: {
intent: {
primary: "bg-primary-90 text-neutral-10",
secondary: "bg-secondary-90 text-neutral-90",
tertiary: "bg-tertiary-90 text-neutral-90",
neutral: "bg-white text-neutral-90",
},
},
defaultVariants: {
intent: "neutral",
},
const Card = forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, children, ...props }, ref) => {
return (
<div
ref={ref}
className={cn(
"flex min-w-56 flex-col gap-4 rounded-2xl bg-white p-6 text-neutral-90 shadow-md",
className,
)}
{...props}
>
{children}
</div>
);
},
);

const Card = forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof cardVariants>
>(({ className, intent, children, ...props }, ref) => {
return (
<div
ref={ref}
className={cn(cardVariants({ intent }), className)}
{...props}
>
{children}
</div>
);
});
Card.displayName = "Card";

interface CardHeader extends React.HTMLAttributes<HTMLDivElement> {
Expand Down
98 changes: 0 additions & 98 deletions components/molecules/carousel/carousel.stories.tsx

This file was deleted.

Loading