-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add NeBadgeV2 and other fixes #93
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
8 commits
Select commit
Hold shift + click to select a range
d3abbc5
fix(NeButton): add story for icon only button
andre8244 0eda880
fix(NeTooltip): prevent nesting of button elements
andre8244 d0c99d4
feat(NeTable): add hover color to table rows
andre8244 567aea3
fix(NeDropdownFilter): add clearSearchLabel prop
andre8244 78e6612
fix(NeSideDrawer): add show event
andre8244 1fbd4e1
feat(NeBadgeV2): add NeBadgeV2 component
andre8244 74ebaf6
fix(NeListbox): fix width of options list
andre8244 ac6831e
fix(NeBadgeV2): minor fixes
andre8244 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,120 @@ | ||
| <!-- | ||
| Copyright (C) 2025 Nethesis S.r.l. | ||
| SPDX-License-Identifier: GPL-3.0-or-later | ||
| --> | ||
|
|
||
| <script lang="ts" setup> | ||
| import { computed } from 'vue' | ||
| import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' | ||
| import { faXmark } from '@fortawesome/free-solid-svg-icons' | ||
|
|
||
| const { | ||
| size = 'sm', | ||
| kind = 'gray', | ||
| pill = true, | ||
| dismissable = false, | ||
| customKindClasses = '', | ||
| dismissAriaLabel = 'Dismiss' | ||
| } = defineProps<{ | ||
| size?: 'xs' | 'sm' | ||
| kind?: 'primary' | 'indigo' | 'gray' | 'green' | 'amber' | 'rose' | 'blue' | 'custom' | ||
| pill?: boolean | ||
| dismissable?: boolean | ||
| customKindClasses?: string | ||
| dismissAriaLabel?: string | ||
| }>() | ||
|
|
||
| const emit = defineEmits(['dismiss']) | ||
|
|
||
| const textClasses = computed(() => { | ||
| switch (size) { | ||
| case 'xs': | ||
| return 'text-xs' | ||
| case 'sm': | ||
| default: | ||
| return 'text-sm' | ||
| } | ||
| }) | ||
|
|
||
| const paddingClasses = computed(() => { | ||
| switch (size) { | ||
| case 'xs': | ||
| return 'px-3' | ||
| case 'sm': | ||
| default: | ||
| return 'px-2.5' | ||
| } | ||
| }) | ||
|
|
||
| const spacingClasses = computed(() => { | ||
| return 'gap-x-1' | ||
| }) | ||
|
|
||
| const kindClasses = computed(() => { | ||
| switch (kind) { | ||
| case 'primary': | ||
| return 'bg-primary-100 text-primary-800 dark:bg-primary-700 dark:text-primary-100' | ||
| case 'indigo': | ||
| return 'bg-indigo-100 text-indigo-800 dark:bg-indigo-700 dark:text-indigo-100' | ||
| case 'green': | ||
| return 'bg-green-100 text-green-800 dark:bg-green-700 dark:text-green-50' | ||
| case 'amber': | ||
| return 'bg-amber-100 text-amber-800 dark:bg-amber-700 dark:text-amber-50' | ||
| case 'rose': | ||
| return 'bg-rose-100 text-rose-800 dark:bg-rose-700 dark:text-rose-100' | ||
| case 'blue': | ||
| return 'bg-blue-100 text-blue-800 dark:bg-blue-700 dark:text-blue-100' | ||
| case 'custom': | ||
| return `${customKindClasses}` | ||
| case 'gray': | ||
| default: | ||
| return 'bg-gray-200 text-gray-800 dark:bg-gray-600 dark:text-gray-100' | ||
| } | ||
| }) | ||
|
|
||
| const dismissButtonClasses = computed(() => { | ||
| switch (kind) { | ||
| case 'primary': | ||
| return 'hover:bg-primary-200 hover:dark:bg-primary-600' | ||
| case 'indigo': | ||
| return 'hover:bg-indigo-200 hover:dark:bg-indigo-500' | ||
| case 'green': | ||
| return 'hover:bg-green-200 hover:dark:bg-green-600' | ||
| case 'amber': | ||
| return 'hover:bg-amber-200 hover:dark:bg-amber-600' | ||
| case 'rose': | ||
| return 'hover:bg-rose-200 hover:dark:bg-rose-600' | ||
| case 'blue': | ||
| return 'hover:bg-blue-200 hover:dark:bg-blue-600' | ||
| case 'custom': | ||
| return 'hover:bg-white/20' | ||
| case 'gray': | ||
| default: | ||
| return 'hover:bg-gray-300 hover:dark:bg-gray-500' | ||
| } | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div | ||
| :class="[ | ||
| textClasses, | ||
| spacingClasses, | ||
| paddingClasses, | ||
| kindClasses, | ||
| pill ? 'rounded-full' : 'rounded' | ||
| ]" | ||
| class="inline-flex w-fit items-center py-0.5 font-medium" | ||
| > | ||
| <slot /> | ||
| <button | ||
| v-if="dismissable" | ||
| :class="`inline-flex rounded focus:ring-2 focus:ring-offset-2 focus:outline-hidden ${dismissButtonClasses}`" | ||
| type="button" | ||
| @click="emit('dismiss')" | ||
| > | ||
| <span class="sr-only">{{ dismissAriaLabel }}</span> | ||
| <FontAwesomeIcon :icon="faXmark" class="size-4" aria-hidden="true" /> | ||
| </button> | ||
| </div> | ||
| </template> |
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
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
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
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
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
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
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
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,112 @@ | ||
| // Copyright (C) 2025 Nethesis S.r.l. | ||
| // SPDX-License-Identifier: GPL-3.0-or-later | ||
|
|
||
| import { Meta, StoryObj } from '@storybook/vue3-vite' | ||
| import { NeBadgeV2 } from '../src/main' | ||
| import { faAward } from '@fortawesome/free-solid-svg-icons' | ||
| import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' | ||
|
|
||
| const meta: Meta<typeof NeBadgeV2> = { | ||
| title: 'NeBadgeV2', | ||
| component: NeBadgeV2, | ||
| tags: ['autodocs'], | ||
| argTypes: { | ||
| size: { | ||
| options: ['xs', 'sm'], | ||
| control: { type: 'inline-radio' } | ||
| }, | ||
| kind: { | ||
| options: ['primary', 'gray', 'indigo', 'green', 'amber', 'rose', 'blue', 'custom'], | ||
| control: { type: 'inline-radio' } | ||
| } | ||
| }, | ||
| args: { | ||
| size: 'sm', | ||
| kind: 'gray', | ||
| pill: true, | ||
| dismissable: false, | ||
| customKindClasses: '', | ||
| dismissAriaLabel: 'Dismiss' | ||
| } | ||
| } | ||
|
|
||
| export default meta | ||
| type Story = StoryObj<typeof meta> | ||
|
|
||
| const defaultTemplate = `<NeBadgeV2 v-bind="args">Badge</NeBadgeV2>` | ||
|
|
||
| export const Default: Story = { | ||
| render: (args) => ({ | ||
| components: { NeBadgeV2 }, | ||
| setup() { | ||
| return { args } | ||
| }, | ||
| template: defaultTemplate | ||
| }), | ||
| args: {} | ||
| } | ||
|
|
||
| export const Kind: Story = { | ||
| render: (args) => ({ | ||
| components: { NeBadgeV2 }, | ||
| setup() { | ||
| return { args } | ||
| }, | ||
| template: ` | ||
| <div class="flex flex-wrap gap-8"> | ||
| <NeBadgeV2 v-bind="args" kind="gray">gray</NeBadgeV2> | ||
| <NeBadgeV2 v-bind="args" kind="primary">primary</NeBadgeV2> | ||
| <NeBadgeV2 v-bind="args" kind="indigo">indigo</NeBadgeV2> | ||
| <NeBadgeV2 v-bind="args" kind="green">green</NeBadgeV2> | ||
| <NeBadgeV2 v-bind="args" kind="amber">amber</NeBadgeV2> | ||
| <NeBadgeV2 v-bind="args" kind="rose">rose</NeBadgeV2> | ||
| <NeBadgeV2 v-bind="args" kind="blue">blue</NeBadgeV2> | ||
| <NeBadgeV2 v-bind="args" kind="custom" customKindClasses="bg-fuchsia-100 text-fuchsia-700 dark:bg-fuchsia-700 dark:text-fuchsia-50">custom</NeBadgeV2> | ||
| </div> | ||
| ` | ||
| }), | ||
| args: {} | ||
| } | ||
|
|
||
| export const CustomKind: Story = { | ||
| render: (args) => ({ | ||
| components: { NeBadgeV2 }, | ||
| setup() { | ||
| return { args } | ||
| }, | ||
| template: `<NeBadgeV2 v-bind="args">Custom badge</NeBadgeV2>` | ||
| }), | ||
| args: { | ||
| kind: 'custom', | ||
| customKindClasses: 'text-white bg-linear-to-br from-fuchsia-500 to-blue-500' | ||
| } | ||
| } | ||
|
|
||
| const withIconTemplate = `<NeBadgeV2 v-bind="args"> | ||
| <FontAwesomeIcon :icon="faAward" class="size-4" /> | ||
| Badge | ||
| </NeBadgeV2>` | ||
|
|
||
| export const WithIcon: Story = { | ||
| render: (args) => ({ | ||
| components: { NeBadgeV2, FontAwesomeIcon }, | ||
| setup() { | ||
| return { args, faAward } | ||
| }, | ||
| template: withIconTemplate | ||
| }), | ||
| args: {} | ||
| } | ||
|
|
||
| export const Dismissable: Story = { | ||
| render: (args) => ({ | ||
| components: { NeBadgeV2 }, | ||
| setup() { | ||
| return { args } | ||
| }, | ||
| template: defaultTemplate | ||
| }), | ||
| args: { | ||
| dismissable: true | ||
| } | ||
| } | ||
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
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
Oops, something went wrong.
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.