mirror of
https://github.com/aljazceru/landscape-template.git
synced 2025-12-28 11:34:24 +01:00
feat: refactor project structure
Refactored the project structure so that each page has its own tree of components and a global "Components" folder for the components that is used by more than one page. - Added an "assets" directory that exports all static images/icons/fonts/...etc
This commit is contained in:
40
src/Components/Button/Button.stories.tsx
Normal file
40
src/Components/Button/Button.stories.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
||||
|
||||
import Button from './Button';
|
||||
|
||||
export default {
|
||||
title: 'Shared/Button',
|
||||
component: Button,
|
||||
|
||||
} as ComponentMeta<typeof Button>;
|
||||
|
||||
const Template: ComponentStory<typeof Button> = (args) => <Button {...args} >Click Me 🔥</Button>;
|
||||
|
||||
export const Default = Template.bind({});
|
||||
|
||||
|
||||
export const Primary = Template.bind({});
|
||||
Primary.args = {
|
||||
color: 'primary'
|
||||
}
|
||||
|
||||
export const Gray = Template.bind({});
|
||||
Gray.args = {
|
||||
color: 'gray'
|
||||
}
|
||||
|
||||
|
||||
export const MediumSize = Template.bind({});
|
||||
MediumSize.args = {
|
||||
size: 'md'
|
||||
}
|
||||
|
||||
export const FullWidth = Template.bind({});
|
||||
FullWidth.args = {
|
||||
fullWidth: true
|
||||
}
|
||||
|
||||
export const Link = Template.bind({});
|
||||
Link.args = {
|
||||
href: '#'
|
||||
}
|
||||
32
src/Components/Button/Button.tsx
Normal file
32
src/Components/Button/Button.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { Link } from 'react-router-dom'
|
||||
|
||||
interface Props {
|
||||
color?: 'primary' | 'white' | 'gray'
|
||||
size?: 'md' | 'lg'
|
||||
children: ReactNode;
|
||||
href?: string;
|
||||
fullWidth?: boolean;
|
||||
onClick?: () => void;
|
||||
className?: string
|
||||
}
|
||||
|
||||
export default function Button(props: Props) {
|
||||
let classes = "btn inline-block";
|
||||
|
||||
if (props.color === 'primary') classes += ' btn-primary';
|
||||
else if (props.color === 'gray') classes += ' btn-gray';
|
||||
|
||||
if (props.size === 'md') classes += ' py-12 px-24';
|
||||
|
||||
if (props.fullWidth) classes += ' w-full'
|
||||
|
||||
const handleClick = () => {
|
||||
if (props.onClick) props.onClick();
|
||||
}
|
||||
|
||||
return (
|
||||
props.href ? <Link to={props.href} className={`${classes} ${props.className}`} onClick={handleClick}>{props.children}</Link> : <button className={`${classes} ${props.className}`} onClick={handleClick}>{props.children}</button>
|
||||
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user