Skip to content

Commit

Permalink
Refactor/card (#841)
Browse files Browse the repository at this point in the history
Refactor/card
  • Loading branch information
kodiakhq[bot] authored Oct 29, 2023
2 parents 658e36d + 1e54865 commit b25544c
Show file tree
Hide file tree
Showing 24 changed files with 1,652 additions and 981 deletions.
3 changes: 2 additions & 1 deletion __tests__/pages/Blog/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ describe('Blog Pages', () => {
const { utils } = await renderBlogSlug()

const result = utils.getAllByRole('article').map((article) => {
return within(article).getByRole('heading').textContent
return within(article).getByRole('heading', { level: 3 })
.textContent
})

expect(result).toMatchInlineSnapshot(`
Expand Down
3 changes: 2 additions & 1 deletion __tests__/pages/project/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ describe('Project Pages', () => {
const { utils } = await renderBlogSlug()

const result = utils.getAllByRole('article').map((article) => {
return within(article).getByRole('heading').textContent
return within(article).getByRole('heading', { level: 3 })
.textContent
})

expect(result).toMatchInlineSnapshot(`
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,20 @@
"@commitlint/cli": "^17.8.0",
"@commitlint/config-conventional": "^17.8.0",
"@commitlint/types": "^17.4.4",
"@next/plugin-storybook": "^13.5.4",
"@storybook/addon-actions": "^7.4.6",
"@storybook/addon-docs": "^7.4.6",
"@storybook/addon-essentials": "^7.4.6",
"@storybook/addon-interactions": "^7.4.6",
"@storybook/addon-links": "^7.4.6",
"@storybook/addon-mdx-gfm": "^7.4.6",
"@next/plugin-storybook": "^14.0.0",
"@storybook/addon-actions": "^7.5.1",
"@storybook/addon-docs": "^7.5.1",
"@storybook/addon-essentials": "^7.5.1",
"@storybook/addon-interactions": "^7.5.1",
"@storybook/addon-links": "^7.5.1",
"@storybook/addon-mdx-gfm": "^7.5.1",
"@storybook/addon-postcss": "^2.0.0",
"@storybook/addon-styling": "^1.3.7",
"@storybook/manager-api": "^7.4.6",
"@storybook/nextjs": "^7.4.6",
"@storybook/react": "^7.4.6",
"@storybook/manager-api": "^7.5.1",
"@storybook/nextjs": "^7.5.1",
"@storybook/react": "^7.5.1",
"@storybook/testing-library": "^0.2.2",
"@storybook/theming": "^7.4.6",
"@storybook/theming": "^7.5.1",
"@swc/core": "^1.2.197",
"@swc/jest": "^0.2.29",
"@tailwindcss/typography": "^0.5.0",
Expand Down Expand Up @@ -129,7 +129,7 @@
"postcss-import": "^15.1.0",
"prettier": "^3.0.3",
"react-test-renderer": "^18.1.0",
"storybook": "^7.4.6",
"storybook": "^7.5.1",
"storybook-dark-mode": "^3.0.1",
"tailwindcss": "^3.3.3",
"tinycolor2": "^1.6.0",
Expand Down
4 changes: 2 additions & 2 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const Navbar: React.FC = () => {
>
Jerens
</HighlightLink>
<div className="flex text-center my-auto h-full">
<div className="text-center relative h-full w-full hidden md:flex">
<div className="flex text-center my-auto">
<div className="text-center relative h-full hidden md:flex">
{pageLinks
.filter(({ name }) => name !== 'Home')
.map(({ name, url }) => {
Expand Down
18 changes: 0 additions & 18 deletions src/components/Tag.tsx

This file was deleted.

13 changes: 0 additions & 13 deletions src/components/Tags.stories.mdx

This file was deleted.

62 changes: 41 additions & 21 deletions src/components/ThemeToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faMoon, faSun } from '@fortawesome/free-solid-svg-icons'
import { useTheme } from 'next-themes'
import { IconButton } from './buttons/IconBoxButton'
import { IconToggle } from './buttons/IconToggle'

const ThemeToggle: React.FC = () => {
const { systemTheme, theme, setTheme } = useTheme()
Expand All @@ -18,33 +18,53 @@ const ThemeToggle: React.FC = () => {

if (currentTheme === 'dark') {
return (
<IconButton
aria-label="light theme toggle"
<IconToggle
ariaLabel="light theme toggle"
onClick={() => setTheme('light')}
shape="circle"
variant="outlined"
isSelected={false}
dataTestID="theme-dark"
>
<FontAwesomeIcon
className="block"
size="lg"
icon={faSun}
data-testid="theme-dark"
/>
</IconButton>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
className="w-6 h-6 m-auto"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M12 3v2.25m6.364.386l-1.591 1.591M21 12h-2.25m-.386 6.364l-1.591-1.591M12 18.75V21m-4.773-4.227l-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0z"
/>
</svg>
</IconToggle>
)
} else {
return (
<IconButton
aria-label="dark theme toggle"
<IconToggle
ariaLabel="dark theme toggle"
onClick={() => setTheme('dark')}
shape="circle"
variant="outlined"
isSelected={false}
dataTestID="theme-light"
>
<FontAwesomeIcon
className="block px-1"
icon={faMoon}
size="lg"
data-testid="theme-light"
/>
</IconButton>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
className="w-6 h-6 m-auto"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M21.752 15.002A9.718 9.718 0 0118 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 003 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 009.002-5.998z"
/>
</svg>
</IconToggle>
)
}
}
Expand Down
55 changes: 55 additions & 0 deletions src/components/buttons/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import type { Meta, StoryObj } from '@storybook/react'
import { Button } from './Button'

const meta: Meta<typeof Button> = {
title: 'Components/Buttons/Button',
component: Button,
}

export default meta
type Story = StoryObj<typeof Button>

export const Elevated: Story = {
args: {
onClick: () => {},
variant: 'elevated',
label: 'Home',
},
decorators: [],
}

export const Filled: Story = {
args: {
onClick: () => {},
variant: 'filled',
label: 'Home',
},
decorators: [],
}

export const FilledTonal: Story = {
args: {
onClick: () => {},
variant: 'filled-tonal',
label: 'Home',
},
decorators: [],
}

export const Outlined: Story = {
args: {
onClick: () => {},
variant: 'outlined',
label: 'Home',
},
decorators: [],
}

export const Text: Story = {
args: {
onClick: () => {},
variant: 'text',
label: 'Home',
},
decorators: [],
}
49 changes: 49 additions & 0 deletions src/components/buttons/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react'
import clsx from 'clsx'

type IButtonVariants =
| 'elevated'
| 'filled'
| 'filled-tonal'
| 'outlined'
| 'text'

export type ButtonProps = {
onClick: () => void
variant: IButtonVariants
label: string
dataCy?: string
fullWidth?: boolean
}

export const Button = ({
onClick,
variant,
label,
fullWidth,
dataCy,
}: ButtonProps) => {
return (
<button
data-cy={dataCy}
onClick={onClick}
className={clsx(
'rounded-full text-sm w-fit font-medium px-5 py-2 shadow-elevation-0',
{
'text-primary shadow-elevation-1 hover:bg-primary/8 hover:shadow-elevation-2 focus:shadow-elevation-1':
variant === 'elevated',
'text-on-primary bg-primary hover:brightness-108 hover:saturate-108':
variant === 'filled',
'text-on-secondary-container bg-secondary-container hover:brightness-108 hover:saturate-108':
variant === 'filled-tonal',
'text-primary border border-outline bg-surface hover:brightness-108 hover:saturate-108':
variant === 'outlined',
'text-primary hover:bg-primary/8': variant === 'text',
'block w-full': fullWidth,
}
)}
>
{label}
</button>
)
}
Loading

0 comments on commit b25544c

Please sign in to comment.