Skip to content

Commit 7a89269

Browse files
authored
feat: Button component with icon (#6259)
* feat: button with icon * chore: story example updated
1 parent 2776912 commit 7a89269

File tree

9 files changed

+52
-19
lines changed

9 files changed

+52
-19
lines changed

app/[locale]/error.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client';
22

3+
import { ArrowRightIcon } from '@heroicons/react/24/solid';
34
import { captureException } from '@sentry/nextjs';
45
import { useTranslations } from 'next-intl';
56
import type { FC } from 'react';
@@ -37,7 +38,10 @@ const ErrorPage: FC<{ error: Error }> = ({ error }) => {
3738
<p className="-mt-4 max-w-sm text-center text-lg">
3839
{t('layouts.error.internalServerError.description')}
3940
</p>
40-
<Button href="/">{t('layouts.error.backToHome')}</Button>
41+
<Button href="/">
42+
{t('layouts.error.backToHome')}
43+
<ArrowRightIcon />
44+
</Button>
4145
</main>
4246
</CenteredLayout>
4347
);

app/[locale]/not-found.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client';
22

3+
import { ArrowRightIcon } from '@heroicons/react/24/solid';
34
import { useTranslations } from 'next-intl';
45
import type { FC } from 'react';
56

@@ -32,7 +33,10 @@ const NotFoundPage: FC = () => {
3233
<p className="-mt-4 max-w-sm text-center text-lg">
3334
{t('layouts.error.notFound.description')}
3435
</p>
35-
<Button href="/">{t('layouts.error.backToHome')}</Button>
36+
<Button href="/">
37+
{t('layouts.error.backToHome')}
38+
<ArrowRightIcon />
39+
</Button>
3640
</main>
3741
</CenteredLayout>
3842
);

app/global-error.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client';
22

3+
import { ArrowRightIcon } from '@heroicons/react/24/solid';
34
import { captureException } from '@sentry/nextjs';
45
import ErrorComponent from 'next/error';
56
import type { FC } from 'react';
@@ -39,7 +40,10 @@ const GlobalErrorPage: FC<{ error: Error }> = ({ error }) => {
3940
<p className="-mt-4 max-w-sm text-center text-lg">
4041
This page has thrown a non-recoverable error.
4142
</p>
42-
<Button href="/">Back to Home</Button>
43+
<Button href="/">
44+
Back to Home
45+
<ArrowRightIcon />
46+
</Button>
4347
</main>
4448
</CenteredLayout>
4549
</BaseLayout>

components/Common/Button/index.module.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
.button {
22
@apply relative
3+
inline-flex
4+
items-center
5+
gap-2
36
px-4.5
47
py-2.5
58
text-center
69
font-semibold;
710

11+
svg {
12+
@apply size-5;
13+
}
14+
815
&[aria-disabled='true'] {
916
@apply cursor-not-allowed;
1017
}

components/Common/Button/index.stories.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ArrowRightIcon } from '@heroicons/react/24/solid';
12
import type { Meta as MetaObj, StoryObj } from '@storybook/react';
23

34
import Button from '@/components/Common/Button';
@@ -37,4 +38,17 @@ export const Special: Story = {
3738
},
3839
};
3940

41+
export const WithIcon: Story = {
42+
args: {
43+
kind: 'primary',
44+
children: (
45+
<>
46+
Back to Home
47+
<ArrowRightIcon />
48+
</>
49+
),
50+
disabled: false,
51+
},
52+
};
53+
4054
export default { component: Button } as Meta;

components/Common/CodeBox/index.module.css

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@
6666
}
6767

6868
& > .action {
69-
@apply flex
70-
items-center
71-
gap-2
72-
px-3
69+
@apply px-3
7370
py-1.5
7471
font-medium;
7572
}

components/Common/Pagination/index.module.css

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010

1111
.previousButton,
1212
.nextButton {
13-
@apply flex
14-
items-center
15-
gap-2
16-
text-sm;
13+
@apply text-sm;
1714
}
1815

1916
.previousButton {
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
.downloadButton {
2-
@apply flex-row
3-
items-center
4-
justify-center
5-
gap-2;
2+
@apply justify-center;
3+
4+
&.primary {
5+
@apply inline-flex
6+
dark:hidden;
7+
}
8+
9+
&.special {
10+
@apply hidden
11+
dark:inline-flex;
12+
}
613

714
svg {
8-
@apply size-5
9-
dark:opacity-50;
15+
@apply dark:opacity-50;
1016
}
1117
}

components/Downloads/DownloadButton/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const DownloadButton: FC<PropsWithChildren<DownloadButtonProps>> = ({
2525
<Button
2626
kind="special"
2727
href={downloadLink}
28-
className={classNames(styles.downloadButton, 'hidden dark:flex')}
28+
className={classNames(styles.downloadButton, styles.special)}
2929
>
3030
{children}
3131

@@ -35,7 +35,7 @@ const DownloadButton: FC<PropsWithChildren<DownloadButtonProps>> = ({
3535
<Button
3636
kind="primary"
3737
href={downloadLink}
38-
className={classNames(styles.downloadButton, 'flex dark:hidden')}
38+
className={classNames(styles.downloadButton, styles.primary)}
3939
>
4040
{children}
4141

0 commit comments

Comments
 (0)