Skip to content

Commit

Permalink
Create all styles for Buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
adrielTosi committed Jan 30, 2024
1 parent 03d0c25 commit 06befb3
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 87 deletions.
5 changes: 3 additions & 2 deletions apps/frontend/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { Preview } from "@storybook/react";
import type { Preview } from '@storybook/react';
import '../src/App.scss';

const preview: Preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
Expand Down
22 changes: 17 additions & 5 deletions apps/frontend/src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
}

// Fonts
$gellix-font-family: "Gellix";
$gellix-fonts-path: "./stories/assets/fonts/";
$gellix-font-family: 'Gellix';
$gellix-fonts-path: './stories/assets/fonts/';
$font-weight-thin: 100;
$font-weight-light: 300;
$font-weight-regular: 400;
Expand All @@ -54,20 +54,32 @@ $font-weight-black: 900;

@font-face {
font-family: $gellix-font-family;
src: url("./stories/assets/fonts/Gellix-Light_R.woff2") format("woff2");
src: url('./stories/assets/fonts/Gellix-Light_R.woff2') format('woff2');
font-weight: $font-weight-light;
}

@font-face {
font-family: $gellix-font-family;
src: url("./stories/assets/fonts/Gellix-Regular_R.woff2") format("woff2");
src: url('./stories/assets/fonts/Gellix-Regular_R.woff2') format('woff2');
font-weight: $font-weight-regular;
font-style: normal;
}

@font-face {
font-family: $gellix-font-family;
src: url("./stories/assets/fonts/Gellix-SemiBold_R.woff2") format("woff2");
src: url('./stories/assets/fonts/Gellix-SemiBold_R.woff2') format('woff2');
font-weight: $font-weight-semibold;
font-style: normal;
}

// BUTTON STYLES
.btn-secondary {
&:hover {
svg path {
fill: theme('colors.midnight-blue');
}
}
svg path {
fill: theme('colors.link-blue');
}
}
3 changes: 3 additions & 0 deletions apps/frontend/src/assets/icons/arrow-right-bold.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 0 additions & 44 deletions apps/frontend/src/components/Button.stories.ts

This file was deleted.

77 changes: 75 additions & 2 deletions apps/frontend/src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,82 @@
import clsx from 'clsx';

type Icon = React.FunctionComponent<
React.SVGProps<SVGSVGElement> & {
title?: string | undefined;
}
>;

export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
variant?: 'primary' | 'secondary' | 'link';
size?: 'default' | 'small' | 'large' | 'tiny';
label: string;
/**
* import { ReactComponent as YourIcon } from '/assets/icons/...svg
*/
IconLeft?: Icon;
/**
* import { ReactComponent as YourIcon } from '/assets/icons/...svg
*/
IconRight?: Icon;
}

export const Button = ({ variant = 'primary', size = 'default', onClick, label, ...props }: ButtonProps) => {
return <button onClick={onClick}>{label}</button>;
const common = 'btn font-gellix flex items-center gap-5px rounded-full font-semibold disabled:opacity-25';
const defaultSize = 'text-xl leading-5 py-15px px-25px';
const small = 'leading-4 px-5 py-3';
const large = 'text-25px leading-25px px-31.25px py-18.75px';
const tiny = 'text-xs leading-3 px-15px py-9px';

const primary =
'bg-dark-teal text-midnight-blue hover:bg-medium-teal active:bg-light-teal focus:outline focus:outline-2 focus:outline-offset-1 focus:outline-link-blue';
const secondary =
'btn-secondary border-2 border-link-blue border-solid text-link-blue hover:text-midnight-blue hover:border-midnight-blue focus:outline focus:outline-2 focus:outline-offset-1 focus:outline-link-blue';
const link = `${secondary} !p-0 !border-none focus:!outline-none`;

export const Button = ({
variant = 'primary',
size = 'default',
onClick,
label,
IconRight,
IconLeft,
disabled,
...props
}: ButtonProps) => {
return (
<button
className={clsx(common, {
[defaultSize]: size === 'default',
[small]: size === 'small',
[large]: size === 'large',
[tiny]: size === 'tiny',
[primary]: variant === 'primary',
[secondary]: variant === 'secondary',
[link]: variant === 'link',
})}
disabled={disabled}
{...props}
>
{IconLeft && (
<IconLeft
className={clsx({
'size-5': size === 'default',
'size-4': size === 'small',
'size-25px': size === 'large',
'size-3': size === 'tiny',
})}
/>
)}
{label}
{IconRight && (
<IconRight
className={clsx({
'size-5': size === 'default',
'size-4': size === 'small',
'size-25px': size === 'large',
'size-3': size === 'tiny',
})}
/>
)}
</button>
);
};
108 changes: 108 additions & 0 deletions apps/frontend/src/stories/Button.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import type { Meta, StoryObj } from '@storybook/react';

import { Button } from '../components/Button';

const meta = {
title: 'Button',
component: Button,
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
} satisfies Meta<typeof Button>;

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

// --- PRIMARY ---
export const PrimaryDefault: Story = {
args: {
label: 'Button',
variant: 'primary',
},
};

export const PrimaryLarge: Story = {
args: {
label: 'Button',
size: 'large',
},
};

export const PrimarySmall: Story = {
args: {
label: 'Button',
size: 'small',
},
};

export const PrimaryTiny: Story = {
args: {
label: 'Button',
size: 'tiny',
},
};

// --- SECONDARY ---
export const SecondaryDefault: Story = {
args: {
label: 'Button',
variant: 'secondary',
},
};

export const SecondaryLarge: Story = {
args: {
label: 'Button',
variant: 'secondary',
size: 'large',
},
};

export const SecondarySmall: Story = {
args: {
label: 'Button',
variant: 'secondary',
size: 'small',
},
};

export const SecondaryTiny: Story = {
args: {
label: 'Button',
variant: 'secondary',
size: 'tiny',
},
};

// --- LINK ---
export const LinkDefault: Story = {
args: {
label: 'Button',
variant: 'link',
},
};

export const LinkLarge: Story = {
args: {
label: 'Button',
variant: 'link',
size: 'large',
},
};

export const LinkSmall: Story = {
args: {
label: 'Button',
variant: 'link',
size: 'small',
},
};

export const LinkTiny: Story = {
args: {
label: 'Button',
variant: 'link',
size: 'tiny',
},
};
30 changes: 0 additions & 30 deletions apps/frontend/src/stories/button.css

This file was deleted.

24 changes: 20 additions & 4 deletions apps/frontend/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,22 @@ const colors = require('tailwindcss/colors');
module.exports = {
content: ['./src/**/*.{html,js,jsx,ts,tsx}'],
theme: {
extend: {},
extend: {
spacing: {
'5px': '5px',
'15px': '15px',
'9px': '9px',
'25px': '25px',
'31.25px': '31.25px',
'18.75px': '18.75px',
},
lineHeight: {
'25px': '25px',
},
fontSize: {
'25px': '25px',
},
},
colors: {
black: colors.black,
white: colors.white,
Expand All @@ -13,10 +28,11 @@ module.exports = {
waterspout: '#A8F9F6',
'midnight-blue': '#000048',
'dark-teal': '#11C7CC',
'medium-teal': '#26EFE9',
'light-teal': 'C9FBFA',
'medium-teal': '#29EEE9',
'light-teal': '#A8F9F6',
'lightest-teal': '#C9FBFA',
'disabled-teal': '#26EFE9',
'medium-blue': '#2F78C4',
'link-blue': '#2F78C4',
},
fontFamily: {
gellix: ['Gellix', 'sans-serif'],
Expand Down

0 comments on commit 06befb3

Please sign in to comment.