The Node.js® Website

feat: Button component with icon (#6259)

* feat: button with icon

* chore: story example updated

authored by Caner Akdas and committed by GitHub 7a892690 2776912f

Changed files
+52 -19
app
components
Common
Downloads
DownloadButton
+5 -1
app/[locale]/error.tsx
··· 1 1 'use client'; 2 2 3 + import { ArrowRightIcon } from '@heroicons/react/24/solid'; 3 4 import { captureException } from '@sentry/nextjs'; 4 5 import { useTranslations } from 'next-intl'; 5 6 import type { FC } from 'react'; ··· 37 38 <p className="-mt-4 max-w-sm text-center text-lg"> 38 39 {t('layouts.error.internalServerError.description')} 39 40 </p> 40 - <Button href="/">{t('layouts.error.backToHome')}</Button> 41 + <Button href="/"> 42 + {t('layouts.error.backToHome')} 43 + <ArrowRightIcon /> 44 + </Button> 41 45 </main> 42 46 </CenteredLayout> 43 47 );
+5 -1
app/[locale]/not-found.tsx
··· 1 1 'use client'; 2 2 3 + import { ArrowRightIcon } from '@heroicons/react/24/solid'; 3 4 import { useTranslations } from 'next-intl'; 4 5 import type { FC } from 'react'; 5 6 ··· 32 33 <p className="-mt-4 max-w-sm text-center text-lg"> 33 34 {t('layouts.error.notFound.description')} 34 35 </p> 35 - <Button href="/">{t('layouts.error.backToHome')}</Button> 36 + <Button href="/"> 37 + {t('layouts.error.backToHome')} 38 + <ArrowRightIcon /> 39 + </Button> 36 40 </main> 37 41 </CenteredLayout> 38 42 );
+5 -1
app/global-error.tsx
··· 1 1 'use client'; 2 2 3 + import { ArrowRightIcon } from '@heroicons/react/24/solid'; 3 4 import { captureException } from '@sentry/nextjs'; 4 5 import ErrorComponent from 'next/error'; 5 6 import type { FC } from 'react'; ··· 39 40 <p className="-mt-4 max-w-sm text-center text-lg"> 40 41 This page has thrown a non-recoverable error. 41 42 </p> 42 - <Button href="/">Back to Home</Button> 43 + <Button href="/"> 44 + Back to Home 45 + <ArrowRightIcon /> 46 + </Button> 43 47 </main> 44 48 </CenteredLayout> 45 49 </BaseLayout>
+7
components/Common/Button/index.module.css
··· 1 1 .button { 2 2 @apply relative 3 + inline-flex 4 + items-center 5 + gap-2 3 6 px-4.5 4 7 py-2.5 5 8 text-center 6 9 font-semibold; 10 + 11 + svg { 12 + @apply size-5; 13 + } 7 14 8 15 &[aria-disabled='true'] { 9 16 @apply cursor-not-allowed;
+14
components/Common/Button/index.stories.tsx
··· 1 + import { ArrowRightIcon } from '@heroicons/react/24/solid'; 1 2 import type { Meta as MetaObj, StoryObj } from '@storybook/react'; 2 3 3 4 import Button from '@/components/Common/Button'; ··· 33 34 args: { 34 35 kind: 'special', 35 36 children: 'Download Node (LTS)', 37 + disabled: false, 38 + }, 39 + }; 40 + 41 + export const WithIcon: Story = { 42 + args: { 43 + kind: 'primary', 44 + children: ( 45 + <> 46 + Back to Home 47 + <ArrowRightIcon /> 48 + </> 49 + ), 36 50 disabled: false, 37 51 }, 38 52 };
+1 -4
components/Common/CodeBox/index.module.css
··· 66 66 } 67 67 68 68 & > .action { 69 - @apply flex 70 - items-center 71 - gap-2 72 - px-3 69 + @apply px-3 73 70 py-1.5 74 71 font-medium; 75 72 }
+1 -4
components/Common/Pagination/index.module.css
··· 10 10 11 11 .previousButton, 12 12 .nextButton { 13 - @apply flex 14 - items-center 15 - gap-2 16 - text-sm; 13 + @apply text-sm; 17 14 } 18 15 19 16 .previousButton {
+12 -6
components/Downloads/DownloadButton/index.module.css
··· 1 1 .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 + } 6 13 7 14 svg { 8 - @apply size-5 9 - dark:opacity-50; 15 + @apply dark:opacity-50; 10 16 } 11 17 }
+2 -2
components/Downloads/DownloadButton/index.tsx
··· 25 25 <Button 26 26 kind="special" 27 27 href={downloadLink} 28 - className={classNames(styles.downloadButton, 'hidden dark:flex')} 28 + className={classNames(styles.downloadButton, styles.special)} 29 29 > 30 30 {children} 31 31 ··· 35 35 <Button 36 36 kind="primary" 37 37 href={downloadLink} 38 - className={classNames(styles.downloadButton, 'flex dark:hidden')} 38 + className={classNames(styles.downloadButton, styles.primary)} 39 39 > 40 40 {children} 41 41