-
-
Notifications
You must be signed in to change notification settings - Fork 425
refactor: extract tag component #742
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
danielroe
merged 8 commits into
npmx-dev:main
from
essenmitsosse:refactor-extract-tag-component
Feb 2, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2fb44eb
refactor: extract tags components
essenmitsosse 2a99783
refactor: move shortcut directly onto component
essenmitsosse 94240a9
style: remove hover from unclickable tags
essenmitsosse bacb5dc
style: unify tag styles
essenmitsosse c51fb34
refactor: move basic styles into reusable tag component
essenmitsosse 0826806
test: add a11y tests for tags
essenmitsosse 70472e0
chore: drop `props.`
danielroe 1b38d5b
Merge remote-tracking branch 'origin/main' into refactor-extract-tag-…
danielroe 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
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,25 @@ | ||
| <script setup lang="ts"> | ||
| const props = withDefaults( | ||
| defineProps<{ as?: string | Component; status?: 'default' | 'active'; disabled?: boolean }>(), | ||
| { | ||
| status: 'default', | ||
| as: 'button', | ||
| }, | ||
| ) | ||
| </script> | ||
|
|
||
| <template> | ||
| <component | ||
| :is="props.as" | ||
| class="inline-flex items-center px-2 py-0.5 text-xs font-mono border rounded transition-colors duration-200 focus-visible:ring-2 focus-visible:ring-fg focus-visible:ring-offset-1" | ||
| :class="{ | ||
| 'bg-bg-muted text-fg-muted border-border hover:(text-fg border-border-hover)': | ||
| status === 'default', | ||
| 'bg-fg text-bg border-fg hover:(text-text-bg/50)': status === 'active', | ||
| 'opacity-50 cursor-not-allowed': disabled, | ||
| }" | ||
| :disabled="disabled" | ||
| > | ||
| <slot /> | ||
| </component> | ||
| </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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <script setup lang="ts"> | ||
| const props = withDefaults(defineProps<{ as?: string | Component }>(), { as: 'span' }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <component | ||
| :is="as" | ||
| class="inline-flex items-center px-2 py-0.5 text-xs font-mono text-fg-muted bg-bg-muted border border-border rounded" | ||
| > | ||
| <slot /> | ||
| </component> | ||
| </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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@essenmitsosse In HTML the
disabledattribute is a boolean attribute and it applies when it is present. I’m seeing it appear in the keyword lists as<a href=wherever disabled=false>. It’s not a huge issue in this case since it has no effect on<a>elements (i.e.disabledisn’t mapped to anything ARIA-related for anchor elements, see: https://www.w3.org/TR/html-aam-1.0/#att-disabled), but if the element did support the mapping then it would always be disabled. Also, worth noting that for therole=radiocase, we’d need to manually maparia-disabledourselves (as an ARIA boolean attribute which does use the"true"and"false"values).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comments. Will take then into account for the next PR. But also feel confident that it is good not to rebuild UI Elements from scratch every time.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m also totally for not needing to rebuild things. What I find though is that it’s really easy to identify and create presentational abstractions (i.e. in this case the class names that produce a tag visually), but how presentational abstractions get applied to elements with various semantics is much harder.
I think we’ll likely need some kind of protocol for what components can be used with the
asprop. For example, if we had a primitive<Link>component which could build on<NuxtLink>, but knows that if thedisabledprop is passed to it to usearia-disabled, then that could solve the issue without turning stuff likeTagClickableinto a monster component that needs to know how to handle every case. It can just focus on how to apply presentation to the more primitive UI components that we’ve defined.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's more or less what I wanted to sketch out. I think having specific components for their style + semantic combination is the most reasonable way to go.