Commit 9846f0f8 by Syed Abdul Rahman

mplemented storybook changes

parent 16cc6dcc
...@@ -18,9 +18,10 @@ const preview: Preview = { ...@@ -18,9 +18,10 @@ const preview: Preview = {
default: 'light', default: 'light',
options: { options: {
light: { name: 'light', value: '#ffe788' }, light: { name: 'light', value: '#ffe788' },
dark: { name: 'dark', value: 'black' }, dark: { name: 'dark', value: '#0b0d0e' },
}, },
}, },
layout: "fullscreen",
controls: { controls: {
matchers: { matchers: {
color: /(background|color)$/i, color: /(background|color)$/i,
...@@ -35,7 +36,7 @@ const preview: Preview = { ...@@ -35,7 +36,7 @@ const preview: Preview = {
decorators: [ThemeDecorator], decorators: [ThemeDecorator],
initialGlobals: { initialGlobals: {
backgrounds: { value: 'white' }, backgrounds: { value: '#ffe788' },
}, },
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
--primary-text-color: #2d3748; --primary-text-color: #2d3748;
--secondary-text-color: #9d99b3; --secondary-text-color: #9d99b3;
--disabled-button-bg: rgba(115, 40, 255, 0.26); --disabled-button-bg: rgba(115, 40, 255, 0.26);
--story-bg: #ffe788;
} }
[data-theme="dark-theme"] { [data-theme="dark-theme"] {
...@@ -13,6 +14,7 @@ ...@@ -13,6 +14,7 @@
--primary-text-color: #e4e4e4; --primary-text-color: #e4e4e4;
--secondary-text-color: #8fa2ae; --secondary-text-color: #8fa2ae;
--disabled-button-bg: rgba(193, 180, 216, 0.516); --disabled-button-bg: rgba(193, 180, 216, 0.516);
--story-bg: #0b0d0e;
} }
html, html,
......
...@@ -9,9 +9,11 @@ export const Primary = { ...@@ -9,9 +9,11 @@ export const Primary = {
args: {}, args: {},
render: () => { render: () => {
return ( return (
<> <div className="bg-[var(--story-bg)] h-full w-[100vw]">
<h2 className={styles.storyTitle}>Size</h2> <h2 className="text-[var(--primary-text-color)] font-[Inter-Medium] p-4 text-2xl">
<section className={styles["btn-wrapper"]}> Size
</h2>
<section className="flex gap-[2rem] flex-wrap items-center p-3">
<Button variant="primary" size="sm" disabled={false}> <Button variant="primary" size="sm" disabled={false}>
Small Small
</Button> </Button>
...@@ -22,8 +24,10 @@ export const Primary = { ...@@ -22,8 +24,10 @@ export const Primary = {
Large Large
</Button> </Button>
</section> </section>
<h2 className={styles.storyTitle}>Loader</h2> <h2 className="text-[var(--primary-text-color)] font-[Inter-Medium] p-4 text-2xl">
<section className={styles["btn-wrapper"]}> Loader
</h2>
<section className="flex gap-[2rem] flex-wrap items-center p-3">
<Button variant="primary" size="sm" loading={true}> <Button variant="primary" size="sm" loading={true}>
Button Button
</Button> </Button>
...@@ -34,8 +38,10 @@ export const Primary = { ...@@ -34,8 +38,10 @@ export const Primary = {
Button Button
</Button> </Button>
</section> </section>
<h2 className={styles.storyTitle}>Disabled</h2> <h2 className="text-[var(--primary-text-color)] font-[Inter-Medium] p-4 text-2xl">
<section className={styles["btn-wrapper"]}> Disabled
</h2>
<section className="flex gap-[2rem] flex-wrap items-center p-3">
<Button variant="primary" size="sm" disabled={true}> <Button variant="primary" size="sm" disabled={true}>
Button Button
</Button> </Button>
...@@ -46,8 +52,10 @@ export const Primary = { ...@@ -46,8 +52,10 @@ export const Primary = {
Button Button
</Button> </Button>
</section> </section>
<h2 className={styles.storyTitle}>Loader and Disabled</h2> <h2 className="text-[var(--primary-text-color)] font-[Inter-Medium] p-4 text-2xl">
<section className={styles["btn-wrapper"]}> Loader and Disabled
</h2>
<section className="flex gap-[2rem] flex-wrap items-center p-3">
<Button variant="primary" size="sm" loading={true} disabled={true}> <Button variant="primary" size="sm" loading={true} disabled={true}>
Button Button
</Button> </Button>
...@@ -58,7 +66,73 @@ export const Primary = { ...@@ -58,7 +66,73 @@ export const Primary = {
Button Button
</Button> </Button>
</section> </section>
</> </div>
);
},
};
export const Secondary = {
args: {},
render: () => {
return (
<div className="bg-[var(--story-bg)] h-full w-[100vw]">
<h2 className="text-[var(--primary-text-color)] font-[Inter-Medium] p-4 text-2xl">
Size
</h2>
<section className="flex gap-[2rem] flex-wrap items-center p-3">
<Button variant="secondary" size="sm" disabled={false}>
Small
</Button>
<Button variant="secondary" size="md">
Medium
</Button>
<Button variant="secondary" size="lg">
Large
</Button>
</section>
<h2 className="text-[var(--primary-text-color)] font-[Inter-Medium] p-4 text-2xl">
Loader
</h2>
<section className="flex gap-[2rem] flex-wrap items-center p-3">
<Button variant="secondary" size="sm" loading={true}>
Button
</Button>
<Button variant="secondary" size="md" loading={true}>
Button
</Button>
<Button variant="secondary" size="lg" loading={true}>
Button
</Button>
</section>
<h2 className="text-[var(--primary-text-color)] font-[Inter-Medium] p-4 text-2xl">
Disabled
</h2>
<section className="flex gap-[2rem] flex-wrap items-center p-3">
<Button variant="secondary" size="sm" disabled={true}>
Button
</Button>
<Button variant="secondary" size="md" disabled={true}>
Button
</Button>
<Button variant="secondary" size="lg" disabled={true}>
Button
</Button>
</section>
<h2 className="text-[var(--primary-text-color)] font-[Inter-Medium] p-4 text-2xl">
Loader and Disabled
</h2>
<section className="flex gap-[2rem] flex-wrap items-center p-3">
<Button variant="secondary" size="sm" loading={true} disabled={true}>
Button
</Button>
<Button variant="secondary" size="md" loading={true} disabled={true}>
Button
</Button>
<Button variant="secondary" size="lg" loading={true} disabled={true}>
Button
</Button>
</section>
</div>
); );
}, },
}; };
...@@ -11,7 +11,12 @@ export default { ...@@ -11,7 +11,12 @@ export default {
export const Default = (args: any) => { export const Default = (args: any) => {
const [value, setValue] = useState(""); const [value, setValue] = useState("");
const [errorvalue, setErrorValue] = useState("");
return ( return (
<div className="bg-[var(--story-bg)] h-[100vh] p-10">
<h1 className="pt-8 pb-3 font-[Inter-Medium] text-2xl text-[var(--primary-text-color)]">
Default
</h1>
<Input <Input
{...args} {...args}
value={value} value={value}
...@@ -19,5 +24,18 @@ export const Default = (args: any) => { ...@@ -19,5 +24,18 @@ export const Default = (args: any) => {
onChange={(e) => setValue(e.target.value)} onChange={(e) => setValue(e.target.value)}
onClear={() => setValue("")} onClear={() => setValue("")}
/> />
<h1 className="pt-8 pb-3 font-[Inter-Medium] text-2xl text-[var(--primary-text-color)]">
Error
</h1>
<Input
{...args}
value={errorvalue}
placeholder="Discover news, articles and more..."
onChange={(e) => setErrorValue(e.target.value)}
onClear={() => setErrorValue("")}
error={true}
message="Please enter a valid email address."
/>
</div>
); );
}; };
...@@ -5,6 +5,7 @@ import classNames from "classnames"; ...@@ -5,6 +5,7 @@ import classNames from "classnames";
type InputProps = { type InputProps = {
label?: string; label?: string;
error?: boolean; error?: boolean;
message?: string;
onClear?: () => void; onClear?: () => void;
onEnter?: (value: string) => void; onEnter?: (value: string) => void;
} & React.InputHTMLAttributes<HTMLInputElement>; } & React.InputHTMLAttributes<HTMLInputElement>;
...@@ -15,6 +16,7 @@ export default function Input({ ...@@ -15,6 +16,7 @@ export default function Input({
value, value,
error, error,
onEnter, onEnter,
message,
...props ...props
}: InputProps) { }: InputProps) {
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => { const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
...@@ -24,12 +26,12 @@ export default function Input({ ...@@ -24,12 +26,12 @@ export default function Input({
}; };
const inputWrapper = classNames( const inputWrapper = classNames(
"flex items-center rounded-[10px] border-[rgba(255,255,255,0.451)] border-[0.2px]", "flex items-center rounded-[10px] border-[rgba(255,255,255,0.451)] border-[0.2px] ",
{ "shadow-[0_0_3px_3px_rgb(223,56,56)]": error === true } { "shadow-[0_0_3px_3px_rgb(223,56,56)]": error === true }
); );
const inputClass = classNames( const inputClass = classNames(
"outline-none h-[12px] w-full text-[15px] text-[var(--primary-text-color)] bg-[var(--secondary-bg-color)] py-[1.5rem] font-[Inter-Medium]", "outline-none h-[12px] w-full text-[15px] text-[var(--primary-text-color)] bg-[var(--secondary-bg-color)] py-[1.5rem] font-[Inter-Medium] ",
{ {
"!px-[1rem] !py-[1.5rem] rounded-tl-[10px] rounded-bl-[10px]": "!px-[1rem] !py-[1.5rem] rounded-tl-[10px] rounded-bl-[10px]":
value != "", value != "",
...@@ -38,14 +40,14 @@ export default function Input({ ...@@ -38,14 +40,14 @@ export default function Input({
); );
const searchWrapper = classNames( const searchWrapper = classNames(
"py-[1rem] px-[1rem] bg-[var(--secondary-bg-color)] rounded-tl-[10px] rounded-bl-[10px]", "py-[1.02rem] px-[1rem] bg-[var(--secondary-bg-color)] rounded-tl-[10px] rounded-bl-[10px]",
{ {
hidden: value != "", hidden: value != "",
} }
); );
const clearWrapper = classNames( const clearWrapper = classNames(
"rounded-tr-[10px] rounded-br-[10px] bg-[var(--secondary-bg-color)] p-[1rem] cursor-pointer", "rounded-tr-[10px] rounded-br-[10px] bg-[var(--secondary-bg-color)] p-[0.9rem] cursor-pointer",
{ {
hidden: value === "", hidden: value === "",
} }
...@@ -95,6 +97,11 @@ export default function Input({ ...@@ -95,6 +97,11 @@ export default function Input({
<Image height={20} src={img} alt="img" /> <Image height={20} src={img} alt="img" />
</div> </div>
</div> </div>
{message && (
<div className="text-[var(--primary-text-color)] py-3 font-[inter-Regular] text-red-600">
{message}
</div>
)}
</> </>
); );
} }
.typograpy {
font-family: "Inter-Medium";
color: rgb(111, 111, 111);
}
import styles from "./Typography.module.css";
export default { export default {
tags: ["autodocs"], tags: ["autodocs"],
title: "Components/Base/Typography", title: "Components/Base/Typography",
...@@ -7,14 +6,14 @@ export default { ...@@ -7,14 +6,14 @@ export default {
export const Default = { export const Default = {
render: () => { render: () => {
return ( return (
<div className={styles.typograpy}> <div className="w-[100vw] h-[100vh] text[var(--primary-text-color)] bg-[#ffe788]">
<h1>Heading 1</h1> <h1 className="p-2 text-4xl font-bold">Heading 1</h1>
<h2>Heading 2</h2> <h2 className="p-2 text-3xl font-bold">Heading 2</h2>
<h3>Heading 3</h3> <h3 className="p-2 text-2xl font-bold">Heading 3</h3>
<h4>Heading 4</h4> <h4 className="p-2 text-xl font-bold">Heading 4</h4>
<h5>Heading 5</h5> <h5 className="p-2 text-lg font-bold">Heading 5</h5>
<h6>Heading 6</h6> <h6 className="p-2 text-md font-bold">Heading 6</h6>
<p> <p className="p-2 text-md ">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas nec Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas nec
nulla dignissim, malesuada diam vel, vulputate quam. Nunc nulla dui, nulla dignissim, malesuada diam vel, vulputate quam. Nunc nulla dui,
eleifend vel massa ac, imperdiet tincidunt arcu.Lorem ipsum dolor sit eleifend vel massa ac, imperdiet tincidunt arcu.Lorem ipsum dolor sit
......
import Header from "./Header"; import Header from "./Header";
import "../../../app/globals.css"; import "../../../app/globals.css";
import { useState } from "react";
export default { export default {
title: "Components/Layout/Header", title: "Components/Layout/Header",
component: Header, component: Header,
tags: ["autodocs"], tags: ["autodocs"],
argTypes: {
theme: {
control: { type: "select" },
options: ["light-theme", "dark-theme"],
},
},
}; };
export const Default = {
export const Default = {}; args: {
theme: "light-theme", // ✅ default value
},
render: (args: any) => {
return (
<div className="w-[100vw] h-[100vh] bg-[#ffe788]">
<Header {...args} />
</div>
);
},
};
// export const Default = () => {
// const [theme, setTheme] = useState("light-theme");
// const themeUpdate = (value: string) => {
// setTheme(value);
// };
// return <Header theme={theme} updateTheme={themeUpdate} />;
// };
...@@ -3,20 +3,33 @@ import Input from "@/components/Base/Input/Input"; ...@@ -3,20 +3,33 @@ import Input from "@/components/Base/Input/Input";
import themeLogo from "../../../../public/imgaes/moon-svgrepo-com.svg"; import themeLogo from "../../../../public/imgaes/moon-svgrepo-com.svg";
import lightTheme from "../../../../public/imgaes/sun.svg"; import lightTheme from "../../../../public/imgaes/sun.svg";
import Image from "next/image"; import Image from "next/image";
import { useState } from "react"; import { useEffect, useState } from "react";
export default function Header() { export default function Header({ theme, updateTheme }: any) {
const [isDark, setIsDark] = useState(""); const [isDark, setIsDark] = useState("");
const [searchValue, setSearchValue] = useState(""); const [searchValue, setSearchValue] = useState("");
const handleThemeToggle = () => { useEffect(() => {
setIsDark((prev) => {
document.documentElement.setAttribute( document.documentElement.setAttribute(
"data-theme", "data-theme",
prev === "light-theme" ? "dark-theme" : "light-theme" theme === "dark-theme" ? "dark-theme" : "light-theme"
); );
}, [theme]);
return prev === "light-theme" ? "dark-theme" : "light-theme"; const handleThemeToggle = () => {
}); // setIsDark((prev) => {
// document.documentElement.setAttribute(
// "data-theme",
// prev === "light-theme" ? "dark-theme" : "light-theme"
// );
// return prev === "light-theme" ? "dark-theme" : "light-theme";
// });
// updateTheme((prev: string) => {
// document.documentElement.setAttribute(
// "data-theme",
// prev === "light-theme" ? "dark-theme" : "light-theme"
// );
// return prev === "light-theme" ? "dark-theme" : "light-theme";
// });
}; };
const handleInputChange = (e: any) => { const handleInputChange = (e: any) => {
...@@ -50,7 +63,7 @@ export default function Header() { ...@@ -50,7 +63,7 @@ export default function Header() {
/> />
</div> </div>
<div className="cursor-pointer" onClick={handleThemeToggle}> <div className="cursor-pointer" onClick={handleThemeToggle}>
{isDark == "dark-theme" ? ( {theme === "dark-theme" ? (
<Image src={lightTheme} alt="image" width={25} /> <Image src={lightTheme} alt="image" width={25} />
) : ( ) : (
<Image src={themeLogo} alt="theme-img" width={25} /> <Image src={themeLogo} alt="theme-img" width={25} />
......
...@@ -24,7 +24,6 @@ article { ...@@ -24,7 +24,6 @@ article {
.img-section img { .img-section img {
border-radius: 15px; border-radius: 15px;
object-fit: stretch;
width: 100%; width: 100%;
object-fit: cover; object-fit: cover;
display: block; display: block;
...@@ -37,5 +36,4 @@ article { ...@@ -37,5 +36,4 @@ article {
border-radius: 15px; border-radius: 15px;
background-color: var(--primary-bg-color); background-color: var(--primary-bg-color);
color: var(--primary-text-color); color: var(--primary-text-color);
box-sizing: border-box;
} }
...@@ -9,40 +9,20 @@ export const Default = { ...@@ -9,40 +9,20 @@ export const Default = {
args: { args: {
title: title:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eget venenatis leo. Donec mattis tortor in nisl lacinia, ", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eget venenatis leo. Donec mattis tortor in nisl lacinia, ",
postedOn: "july 11, 2020", postedOn: "July 11, 2020",
postedBy: "Charlotte Maria", postedBy: "Charlotte Maria",
readTime: "1", readTime: "1",
tag: "fashion", tag: "fashion",
img: "https://picsum.photos/1000/300", img: "https://picsum.photos/1000/300",
content: ` content:
# My Developer Journey '\n# My Developer Journey\n\nWelcome to my **developer blog**. I use this space to document what I learn, build, and break. 😅\n\n## 🔧 Skills I’m Learning\n\n- HTML, CSS & JavaScript lorem Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eget venenatis leo. Donec mattis tortor in nisl lacinia, \n- React & Next.js Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eget venenatis leo. Donec mattis tortor in nisl lacinia, \n- Node.js + Express Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eget venenatis leo. Donec mattis tortor in nisl lacinia, \n- MongoDB Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eget venenatis leo. Donec mattis tortor in nisl lacinia, \n- TypeScript Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eget venenatis leo. Donec mattis tortor in nisl lacinia, \n\n## 📚 Favorite Resources\n\n1. [MDN Web Docs](https://developer.mozilla.org)\n2. [FreeCodeCamp](https://freecodecamp.org)\n3. [Frontend Mentor](https://frontendmentor.io)\n\n# Welcome to My Blog\n\nThis is a simple **Markdown** example to demonstrate basic formatting. You can _italicize_ text or make it **bold**.\n\n## Things I Like:\n\n- 🧠 Learning new tech\n- 📝 Writing blogs\n- 🔗 [Check my website](https://example.com)\n\nHere’s a sample code snippet:\n\n```js\nconsole.log("Hello world!");\n```\n',
},
Welcome to my **developer blog**. I use this space to document what I learn, build, and break. 😅
## 🔧 Skills I’m Learning
- HTML, CSS & JavaScript
- React & Next.js
- Node.js + Express
- MongoDB
- TypeScript
## 📚 Favorite Resources
1. [MDN Web Docs](https://developer.mozilla.org)
2. [FreeCodeCamp](https://freecodecamp.org)
3. [Frontend Mentor](https://frontendmentor.io)
# Welcome to My Blog
This is a simple **Markdown** example to demonstrate basic formatting. You can _italicize_ text or make it **bold**.
## Things I Like:
- 🧠 Learning new tech
- 📝 Writing blogs
- 🔗 [Check my website](https://example.com)
Here’s a sample code snippet:`, render: (args: any) => {
return (
<div className="bg-[var(--secondary-bg-color)] py-4">
<BlogDetail {...args} />
</div>
);
}, },
}; };
import ReactMarkdown from "react-markdown"; import ReactMarkdown from "react-markdown";
import styles from "./BlogDetail.module.css";
type BlogDetailProps = {
title: string;
postedOn: string;
postedBy: string;
tag: string;
readTime: string;
img: string;
content: string;
};
function BlogDetail({ function BlogDetail({
title, title,
...@@ -9,30 +18,54 @@ function BlogDetail({ ...@@ -9,30 +18,54 @@ function BlogDetail({
readTime, readTime,
img, img,
content, content,
}: any) { }: BlogDetailProps) {
return ( return (
<article> <article className="w-[85%] mx-auto">
<section className={styles["title-section"]}> <section
className={
"font-[Playfair-Medium] max-w-[85%] text-[30px] text-[var(--primary-text-color)] box-border pl-12 "
}
>
<p>{title}</p> <p>{title}</p>
<div className={styles["meta-container"]}> <div
<div> className={"flex font-[Inter-Regular] text-[15px] gap-[2rem] pt-4"}
Posted on <span>{postedOn}</span> >
<div className="text-[var(--secondary-text-color)]">
Posted on{" "}
<span className="font-bold text-[var(--primary-text-color)]">
{postedOn}
</span>
</div>
<div className="text-[var(--secondary-text-color)]">
By{" "}
<span className="font-bold text-[var(--primary-text-color)]">
{postedBy}
</span>
</div> </div>
<div> <div className="text-[var(--secondary-text-color)]">
By <span>{postedBy}</span> Published in{" "}
<span className="font-bold text-[var(--primary-text-color)]">
{tag}
</span>
</div> </div>
<div>Published in {tag}</div> <div className="font-bold text-[var(--primary-text-color)]">
<div> {readTime} <span>min read</span>
<span>{readTime} min read</span>
</div> </div>
</div> </div>
</section> </section>
<section className={styles["img-section"]}> <section className={"rounded py-[2rem] w-[100%]"}>
<img src={img || "https://picsum.photos/1000/400"} alt={title} /> <img
className="rounded-md block w-full object-cover"
src={img || "https://picsum.photos/1000/400"}
alt={title}
/>
</section> </section>
<section
<section className={styles["markdown-section"]}> className={
"p-8 font-[Inter-Medium] w-full rounded-md bg-[var(--primary-bg-color)] text-[var(--primary-text-color)]"
}
>
<ReactMarkdown>{content}</ReactMarkdown> <ReactMarkdown>{content}</ReactMarkdown>
</section> </section>
</article> </article>
......
...@@ -17,4 +17,12 @@ export const Default = { ...@@ -17,4 +17,12 @@ export const Default = {
readTime: "2", readTime: "2",
imgUrl: "https://picsum.photos/350/300", imgUrl: "https://picsum.photos/350/300",
}, },
render: (args: any) => {
return (
<div className="bg-[var(--story-bg)] h-[100vh] flex justify-center items-center">
<Card {...args} />
</div>
);
},
}; };
...@@ -267,5 +267,13 @@ export const Default = { ...@@ -267,5 +267,13 @@ export const Default = {
}, },
}, },
], ],
render: (args: any) => {
return (
<div className="bg-[var(--secondary-bg-color)] ">
<CardWrapper {...args} />
</div>
);
},
}, },
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment