Skip to content

Commit 292d934

Browse files
committed
Storybook: configured and add a story for PageTitle
1 parent 73fd725 commit 292d934

File tree

8 files changed

+41
-32
lines changed

8 files changed

+41
-32
lines changed

.storybook/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import type { StorybookConfig } from '@storybook/nextjs'
22

33
const config: StorybookConfig = {
44
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
5+
// staticDirs: ['../public'],
56
addons: [
67
'@storybook/addon-links',
78
'@storybook/addon-essentials',
89
'@storybook/addon-onboarding',
910
'@storybook/addon-interactions',
11+
'@storybook/addon-postcss',
1012
],
1113
framework: {
1214
name: '@storybook/nextjs',

.storybook/preview.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Preview } from '@storybook/react'
2+
import '../src/styles/globals.css';
23

34
const preview: Preview = {
45
parameters: {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"@storybook/addon-interactions": "^7.5.3",
5252
"@storybook/addon-links": "^7.5.3",
5353
"@storybook/addon-onboarding": "^1.0.8",
54+
"@storybook/addon-postcss": "^2.0.0",
5455
"@storybook/blocks": "^7.5.3",
5556
"@storybook/nextjs": "^7.5.3",
5657
"@storybook/react": "^7.5.3",

src/components/__tests__/booleanWrapper.test.tsx

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/components/pageTitle.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
import { COLOR_TYPE } from "../lib/constants"
2+
13
type PageTitleType = {
24
title: string
5+
color?: string
36
}
4-
const PageTitle = ({ title }: PageTitleType) => {
7+
const PageTitle = ({ title, color = 'black' }: PageTitleType) => {
58
return (
69
<h2
710
className="font-bold uppercase subpixel-antialiased
811
tracking-wide text-2xl pt-6 pb-6 border-r pr-10"
12+
style={{ color }}
913
>
1014
{title}
1115
</h2>

src/lib/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export enum COLOR_TYPE {
4040
SUCCESS = 'success',
4141
WARNING = 'warning',
4242
STRING = 'string',
43+
DARK = 'black',
44+
LIGHT = 'white'
4345
}
4446

4547
export enum INPUT_TYPE {

src/stories/pageTitle.stories.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
import PageTitle from '../components/pageTitle';
3+
4+
5+
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
6+
const meta = {
7+
title: 'Example/PageTitle',
8+
component: PageTitle,
9+
parameters: {
10+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/react/configure/story-layout
11+
layout: 'centered',
12+
},
13+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
14+
tags: ['autodocs'],
15+
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
16+
} satisfies Meta<typeof PageTitle>;
17+
18+
export default meta;
19+
type Story = StoryObj<typeof meta>;
20+
21+
export const Title: Story = {
22+
args: {
23+
title: "Page Title",
24+
color: 'black'
25+
}
26+
}

tailwind.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const config: Config = {
55
'./src/pages/**/*.{js,ts,jsx,tsx,mdx}',
66
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',
77
'./src/app/**/*.{js,ts,jsx,tsx,mdx}',
8+
"./src/stories/**/*.{js,ts,jsx,tsx,mdx}",
89
],
910
theme: {
1011
extend: {
@@ -38,5 +39,8 @@ const config: Config = {
3839
prefix: '', // prefix for daisyUI classnames (components, modifiers and responsive class names. Not colors)
3940
logs: true, // Shows info abo
4041
},
42+
safelist: [
43+
'text-black',
44+
]
4145
}
4246
export default config

0 commit comments

Comments
 (0)