Skip to content

Commit

Permalink
feat: Button component with icon (#6259)
Browse files Browse the repository at this point in the history
* feat: button with icon

* chore: story example updated
  • Loading branch information
canerakdas authored Jan 23, 2024
1 parent 2776912 commit 7a89269
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 19 deletions.
6 changes: 5 additions & 1 deletion app/[locale]/error.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { ArrowRightIcon } from '@heroicons/react/24/solid';
import { captureException } from '@sentry/nextjs';
import { useTranslations } from 'next-intl';
import type { FC } from 'react';
Expand Down Expand Up @@ -37,7 +38,10 @@ const ErrorPage: FC<{ error: Error }> = ({ error }) => {
<p className="-mt-4 max-w-sm text-center text-lg">
{t('layouts.error.internalServerError.description')}
</p>
<Button href="/">{t('layouts.error.backToHome')}</Button>
<Button href="/">
{t('layouts.error.backToHome')}
<ArrowRightIcon />
</Button>
</main>
</CenteredLayout>
);
Expand Down
6 changes: 5 additions & 1 deletion app/[locale]/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { ArrowRightIcon } from '@heroicons/react/24/solid';
import { useTranslations } from 'next-intl';
import type { FC } from 'react';

Expand Down Expand Up @@ -32,7 +33,10 @@ const NotFoundPage: FC = () => {
<p className="-mt-4 max-w-sm text-center text-lg">
{t('layouts.error.notFound.description')}
</p>
<Button href="/">{t('layouts.error.backToHome')}</Button>
<Button href="/">
{t('layouts.error.backToHome')}
<ArrowRightIcon />
</Button>
</main>
</CenteredLayout>
);
Expand Down
6 changes: 5 additions & 1 deletion app/global-error.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { ArrowRightIcon } from '@heroicons/react/24/solid';
import { captureException } from '@sentry/nextjs';
import ErrorComponent from 'next/error';
import type { FC } from 'react';
Expand Down Expand Up @@ -39,7 +40,10 @@ const GlobalErrorPage: FC<{ error: Error }> = ({ error }) => {
<p className="-mt-4 max-w-sm text-center text-lg">
This page has thrown a non-recoverable error.
</p>
<Button href="/">Back to Home</Button>
<Button href="/">
Back to Home
<ArrowRightIcon />
</Button>
</main>
</CenteredLayout>
</BaseLayout>
Expand Down
7 changes: 7 additions & 0 deletions components/Common/Button/index.module.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
.button {
@apply relative
inline-flex
items-center
gap-2
px-4.5
py-2.5
text-center
font-semibold;

svg {
@apply size-5;
}

&[aria-disabled='true'] {
@apply cursor-not-allowed;
}
Expand Down
14 changes: 14 additions & 0 deletions components/Common/Button/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ArrowRightIcon } from '@heroicons/react/24/solid';
import type { Meta as MetaObj, StoryObj } from '@storybook/react';

import Button from '@/components/Common/Button';
Expand Down Expand Up @@ -37,4 +38,17 @@ export const Special: Story = {
},
};

export const WithIcon: Story = {
args: {
kind: 'primary',
children: (
<>
Back to Home
<ArrowRightIcon />
</>
),
disabled: false,
},
};

export default { component: Button } as Meta;
5 changes: 1 addition & 4 deletions components/Common/CodeBox/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@
}

& > .action {
@apply flex
items-center
gap-2
px-3
@apply px-3
py-1.5
font-medium;
}
Expand Down
5 changes: 1 addition & 4 deletions components/Common/Pagination/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@

.previousButton,
.nextButton {
@apply flex
items-center
gap-2
text-sm;
@apply text-sm;
}

.previousButton {
Expand Down
18 changes: 12 additions & 6 deletions components/Downloads/DownloadButton/index.module.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
.downloadButton {
@apply flex-row
items-center
justify-center
gap-2;
@apply justify-center;

&.primary {
@apply inline-flex
dark:hidden;
}

&.special {
@apply hidden
dark:inline-flex;
}

svg {
@apply size-5
dark:opacity-50;
@apply dark:opacity-50;
}
}
4 changes: 2 additions & 2 deletions components/Downloads/DownloadButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const DownloadButton: FC<PropsWithChildren<DownloadButtonProps>> = ({
<Button
kind="special"
href={downloadLink}
className={classNames(styles.downloadButton, 'hidden dark:flex')}
className={classNames(styles.downloadButton, styles.special)}
>
{children}

Expand All @@ -35,7 +35,7 @@ const DownloadButton: FC<PropsWithChildren<DownloadButtonProps>> = ({
<Button
kind="primary"
href={downloadLink}
className={classNames(styles.downloadButton, 'flex dark:hidden')}
className={classNames(styles.downloadButton, styles.primary)}
>
{children}

Expand Down

0 comments on commit 7a89269

Please sign in to comment.