-
-
Notifications
You must be signed in to change notification settings - Fork 424
fix(ui): improve design of buttons/links with icons #1542
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
ccebf91
bb0cc7e
39b1337
ff4be8b
28016fc
66a9a1d
4d3d6cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,8 @@ const props = withDefaults( | |
| ) | ||
|
|
||
| const el = useTemplateRef('el') | ||
| const slots = useSlots() | ||
| const iconOnly = computed(() => !!props.classicon && !slots.default) | ||
|
Comment on lines
+28
to
+31
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n app/components/Button/Base.vueRepository: npmx-dev/npmx.dev Length of output: 3513 🏁 Script executed: # Search for ButtonBase usages with classicon
rg -n 'classicon' app/components --type vue -B 2 -A 10Repository: npmx-dev/npmx.dev Length of output: 88 🏁 Script executed: # Search for icon-only components with sr-only or responsive hidden labels
rg -n 'sr-only|max-sm:sr-only|sm:not-sr-only' app/components --type vue -B 3 -A 3Repository: npmx-dev/npmx.dev Length of output: 88 🏁 Script executed: # Look for Button/LinkBase usages in pages and other components
rg -n '<(Button|Link)Base' app --type vue | head -20Repository: npmx-dev/npmx.dev Length of output: 88 🏁 Script executed: # Search for ButtonBase and LinkBase usages with more context
rg -n 'ButtonBase|LinkBase' app/components app/pages --glob '*.vue' -A 5 | head -60Repository: npmx-dev/npmx.dev Length of output: 3848 🏁 Script executed: # Search for sr-only and responsive visibility patterns
rg -n 'sr-only|max-sm:sr-only|sm:not-sr-only' app/components app/pages --glob '*.vue' -B 2 -A 2Repository: npmx-dev/npmx.dev Length of output: 20276 🏁 Script executed: # Look specifically for patterns combining classicon with hidden content
rg -n 'classicon' app/components app/pages --glob '*.vue' -A 15 | grep -A 15 'sr-only\|max-sm'Repository: npmx-dev/npmx.dev Length of output: 6555 Icon-only detection doesn't account for responsive hidden labels. At line 31, Consider adding an optional Proposed approach const props = withDefaults(
defineProps<{
@@
classicon?: IconClass
+ /** Override icon-only spacing when label content is visually hidden via CSS. */
+ iconOnly?: boolean
}>(),
@@
const slots = defineSlots<{
default?: () => unknown
}>()
-const iconOnly = computed(() => !!props.classicon && !slots.default)
+const inferred = computed(() => !!props.classicon && !slots.default)
+const iconOnly = computed(() => props.iconOnly ?? inferred.value)Responsive hidden labels exist in multiple call-sites (e.g., |
||
|
|
||
| defineExpose({ | ||
| focus: () => el.value?.focus(), | ||
|
|
@@ -32,8 +34,14 @@ defineExpose({ | |
| :class="{ | ||
| 'inline-flex': !block, | ||
| 'flex': block, | ||
| 'text-sm px-4 py-2': size === 'medium', | ||
| 'text-xs px-2 py-0.5': size === 'small', | ||
| 'text-sm py-2': size === 'medium' && !iconOnly, | ||
| 'text-sm p-2': size === 'medium' && !!iconOnly, | ||
| 'px-4': size === 'medium' && !classicon && !iconOnly, | ||
| 'ps-3 pe-4': size === 'medium' && !!classicon && !iconOnly, | ||
| 'text-xs py-0.5': size === 'small' && !iconOnly, | ||
| 'text-xs p-0.5': size === 'small' && !!iconOnly, | ||
| 'px-2': size === 'small' && !classicon && !iconOnly, | ||
| 'ps-1.5 pe-2': size === 'small' && !!classicon && !iconOnly, | ||
| 'bg-transparent text-fg hover:enabled:(bg-fg/10) focus-visible:enabled:(bg-fg/10) aria-pressed:(bg-fg/10 border-fg/20 hover:enabled:(bg-fg/20 text-fg/50))': | ||
| variant === 'secondary', | ||
| 'text-bg bg-fg hover:enabled:(bg-fg/50) focus-visible:enabled:(bg-fg/50) aria-pressed:(bg-fg text-bg border-fg hover:enabled:(text-bg/50))': | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.