From 7670446f7cd055c401e1f4327ecfd27bb58d9130 Mon Sep 17 00:00:00 2001 From: Ifeoluwa Sanni <47613365+pheobeayo@users.noreply.github.com> Date: Sat, 1 Feb 2025 20:15:29 +0100 Subject: [PATCH] docs: enhance component documentation and storybook integration (#114) --- apps/web/.env.example | 13 ----- apps/web/src/stories/Alert.stories.tsx | 8 ++- apps/web/src/stories/Badge.stories.tsx | 19 ++++++- apps/web/src/stories/Button.stories.tsx | 23 ++++++++- apps/web/src/stories/CarouselCard.stories.tsx | 17 ++++++- .../src/stories/ChatWithSeller.stories.tsx | 17 ++++++- apps/web/src/stories/IconButton.stories.tsx | 23 ++++++++- apps/web/src/stories/InfoCard.stories.tsx | 26 ++++++++-- apps/web/src/stories/Modal.stories.tsx | 10 +++- apps/web/src/stories/NftCard.stories.tsx | 9 ++-- apps/web/src/stories/Page.stories.ts | 7 ++- apps/web/src/stories/Particle.stories.tsx | 31 +++++++++++- apps/web/src/stories/ProductCard.stories.tsx | 47 +++++++++++++++++- apps/web/src/stories/Skeleton.stories.tsx | 33 ++++++++++-- apps/web/src/stories/Tooltip.stories.tsx | 7 ++- apps/web/src/stories/dataCard.stories.tsx | 25 +++++++++- apps/web/src/stories/typography.stories.tsx | 22 +++++++- bun.lockb | Bin 611520 -> 611520 bytes 18 files changed, 290 insertions(+), 47 deletions(-) delete mode 100644 apps/web/.env.example diff --git a/apps/web/.env.example b/apps/web/.env.example deleted file mode 100644 index a3a1561..0000000 --- a/apps/web/.env.example +++ /dev/null @@ -1,13 +0,0 @@ -# DATABASE_URL='mysql://root:RbofLLysJtcYrazMMsSzpuTAYxMkaVsw@roundhouse.proxy.rlwy.net:21057/railway' -DATABASE_URL="" -NEXTAUTH_URL="http://localhost:3000" -NODE_ENV="development" -NEXT_PUBLIC_STARKNETKIT_PROJECT_ID=abc123 -NEXTAUTH_SECRET=secret -NEXT_PUBLIC_BASE_URL=/ -NEXT_PUBLIC_SIGNER_ADDRESS=0x123 - -PINATA_JWT= -NEXT_PUBLIC_GATEWAY_URL=https://api.cartridge.gg/x/starknet/sepolia - -STARKNET_ENV=sepolia \ No newline at end of file diff --git a/apps/web/src/stories/Alert.stories.tsx b/apps/web/src/stories/Alert.stories.tsx index 1f67966..3b5fe77 100644 --- a/apps/web/src/stories/Alert.stories.tsx +++ b/apps/web/src/stories/Alert.stories.tsx @@ -3,14 +3,18 @@ import type { Meta, StoryObj } from "@storybook/react"; import type React from "react"; import { useState } from "react"; +//This meta object defines metadata for the Alert component story, +// including its title, tags, and component settings. + const meta: Meta = { - title: "Components/Alert", + title: "Components/Alert", //Specifies the name and hierarchical path for the story given an example "Alert" tags: ["autodocs"], component: Alert, parameters: { controls: { expanded: true }, }, argTypes: { + //Defines controls for component props, enabling dynamic interaction in the Storybook UI. type: { control: { type: "select" }, options: ["success", "error", "info"], @@ -22,6 +26,7 @@ export default meta; type Story = StoryObj; +//This Template story demonstrates how the Alert component behaves with specific arguments (args). It includes a state (isVisible) to manage the visibility of the Alert export const Template: Story = ( args: React.JSX.IntrinsicAttributes & { message: string; @@ -30,6 +35,7 @@ export const Template: Story = ( onDismiss: () => void; }, ) => { + //Example code const [isVisible, setIsVisible] = useState(true); if (!isVisible) return null; diff --git a/apps/web/src/stories/Badge.stories.tsx b/apps/web/src/stories/Badge.stories.tsx index 293ae10..4473916 100644 --- a/apps/web/src/stories/Badge.stories.tsx +++ b/apps/web/src/stories/Badge.stories.tsx @@ -1,11 +1,14 @@ +//The Badge component is a versatile UI element designed to display small amounts of contextual information + import type { Meta, StoryFn } from "@storybook/react"; import React from "react"; import Badge from "../../../../packages/ui/src/badge"; export default { - title: "Components/Badge", + // This meta object configures the Storybook settings for the Badge component + title: "Components/Badge", //organises the components under the "Components" section here. component: Badge, - tags: ["autodocs"], + tags: ["autodocs"], //automates documentation generation argTypes: { variant: { control: "radio", @@ -20,6 +23,7 @@ export default { const Template: StoryFn = (args) => ; +//This is the default story that showcases the basic badge components export const Default = Template.bind({}); Default.args = { text: "Default Badge", @@ -27,6 +31,7 @@ Default.args = { size: "md", }; +//This showcases variant options of the Badge component. export const Variants: StoryFn = () => (
@@ -36,6 +41,7 @@ export const Variants: StoryFn = () => (
); +//This demonstrates all the size options of the Badge component. export const Sizes: StoryFn = () => (
@@ -43,3 +49,12 @@ export const Sizes: StoryFn = () => (
); + +// Aria best practices with the Badge include using aria-live for a content to dynamically update as in below: +; + +// for an interactive badge ; example +; + +//If the badge contains icons or dynamic data, ensure there is an accessible label using aria-label or visually hidden text.e.g +; diff --git a/apps/web/src/stories/Button.stories.tsx b/apps/web/src/stories/Button.stories.tsx index 62930a4..3118ab7 100644 --- a/apps/web/src/stories/Button.stories.tsx +++ b/apps/web/src/stories/Button.stories.tsx @@ -1,10 +1,13 @@ +//This is a reusable UI component for intereactive actions + import { ArrowRightIcon } from "@heroicons/react/24/solid"; import Button from "@repo/ui/button"; import type { Meta, StoryFn } from "@storybook/react"; export default { - title: "Components/Button", - tags: ["autodocs"], + //Meta configures the settings for the Button component + title: "Components/Button", //organizes components under the "Button component" + tags: ["autodocs"], //automates documentation generation component: Button, argTypes: { variant: { @@ -34,12 +37,14 @@ export default { const Template: StoryFn = (args) => @@ -54,6 +60,7 @@ export const Variants: StoryFn = () => ( ); +//showcases all size options for the button component export const Sizes: StoryFn = () => (
); + +// Aria best practices with the Button include using aria-label or aria-labelledby attribute +// to provide accessible name without visible text such as +; + +//using accessible label with icon button example: +