-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
feat: add Badge component #5776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
594027d
fix: tailwind darkMode config updated
canerakdas 7464011
feat: badge component
canerakdas d30fc35
chore: component enums added
canerakdas 89bdcc2
docs: storybook for badge
canerakdas cccc685
refactor: unnecessary children type removed
canerakdas 67ae5cd
fix: tailwind darkMode config updated
canerakdas e481113
feat: badge component
canerakdas cd041b6
chore: component enums added
canerakdas f036aab
docs: storybook for badge
canerakdas d332ee3
refactor: unnecessary children type removed
canerakdas 46dc0be
refactor: class names updated, components moved into the single compo…
canerakdas 2e5048c
chore: resolve conflict
canerakdas 4e85ddb
refactor: feedbacks from review
canerakdas 465091a
refactor: classnames replaced with template literals
canerakdas 3e901db
refactor: font information moved to wrapper
canerakdas 86663e9
Merge remote-tracking branch 'upstream/main' into badge-component/5759
canerakdas ab8f969
chore: Unnecessary stories removed
canerakdas 73656de
chore: Badge component import order and return statement
canerakdas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| .wrapper { | ||
| @apply border rounded-full flex items-center w-fit py-1 pl-1 pr-2.5 text-sm font-medium; | ||
|
|
||
| .icon { | ||
| @apply w-4 h-4; | ||
| } | ||
|
|
||
| .badge { | ||
| @apply rounded-full border px-2.5 py-0.5 mr-2 text-white; | ||
| } | ||
|
|
||
| .message { | ||
| @apply mr-1; | ||
| } | ||
|
|
||
| &.default { | ||
| @apply border-green-200 bg-green-100 dark:border-green-700 dark:bg-neutral-900; | ||
|
|
||
| .icon { | ||
| @apply text-green-500 dark:text-green-300; | ||
| } | ||
|
|
||
| .badge { | ||
| @apply border-green-200 dark:border-green-600 bg-green-600; | ||
| } | ||
|
|
||
| .message { | ||
| @apply text-green-700 dark:text-green-300; | ||
| } | ||
| } | ||
|
|
||
| &.error { | ||
| @apply border-danger-200 dark:border-danger-700 bg-danger-100 dark:bg-neutral-900; | ||
|
|
||
| .icon { | ||
| @apply text-danger-500 dark:text-danger-300; | ||
| } | ||
|
|
||
| .badge { | ||
| @apply border-danger-200 dark:border-danger-600 bg-danger-600; | ||
| } | ||
|
|
||
| .message { | ||
| @apply text-danger-700 dark:text-danger-300; | ||
| } | ||
| } | ||
|
|
||
| &.warning { | ||
| @apply border-warning-200 dark:border-warning-700 bg-warning-100 dark:bg-neutral-900; | ||
|
|
||
| .icon { | ||
| @apply text-warning-500 dark:text-warning-300; | ||
| } | ||
|
|
||
| .badge { | ||
| @apply border-warning-200 dark:border-warning-600 bg-warning-600; | ||
| } | ||
|
|
||
| .message { | ||
| @apply text-warning-700 dark:text-warning-300; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import Badge from './'; | ||
| import type { Meta as MetaObj, StoryObj } from '@storybook/react'; | ||
|
|
||
| type Story = StoryObj<typeof Badge>; | ||
| type Meta = MetaObj<typeof Badge>; | ||
|
|
||
| export const Default: Story = { | ||
| args: { | ||
| href: '/', | ||
| children: 'OpenJS Foundation Certification 2023', | ||
| kind: 'default', | ||
| badgeText: 'New', | ||
| }, | ||
| }; | ||
|
|
||
| export const Error: Story = { | ||
| args: { | ||
| href: '/', | ||
| children: 'OpenJS Foundation Certification 2023', | ||
| kind: 'error', | ||
| badgeText: 'New', | ||
| }, | ||
| }; | ||
|
|
||
| export const Warning: Story = { | ||
| args: { | ||
| href: '/', | ||
| children: 'OpenJS Foundation Certification 2023', | ||
| kind: 'warning', | ||
| badgeText: 'New', | ||
| }, | ||
| }; | ||
|
|
||
| export default { component: Badge } as Meta; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import ArrowRightIcon from '@heroicons/react/24/solid/ArrowRightIcon'; | ||
| import LocalizedLink from '@/components/LocalizedLink'; | ||
| import type { ComponentProps, FC, PropsWithChildren } from 'react'; | ||
| import type Link from 'next/link'; | ||
|
|
||
| import styles from './index.module.scss'; | ||
|
|
||
| type BadgeProps = { | ||
| kind?: 'default' | 'warning' | 'error'; | ||
| badgeText?: string; | ||
| } & ComponentProps<typeof Link>; | ||
|
|
||
| const Badge: FC<PropsWithChildren<BadgeProps>> = ({ | ||
| kind = 'default', | ||
| badgeText, | ||
| children, | ||
| ...args | ||
| }) => ( | ||
| <LocalizedLink className={`${styles.wrapper} ${styles[kind]}`} {...args}> | ||
| {badgeText && <span className={styles.badge}>{badgeText}</span>} | ||
| <span className={styles.message}>{children}</span> | ||
| <ArrowRightIcon className={styles.icon} /> | ||
| </LocalizedLink> | ||
| ); | ||
|
|
||
| export default Badge; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.