-
Notifications
You must be signed in to change notification settings - Fork 55
feat(spx-gui): add UIButtonTest #2879
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: ui
Are you sure you want to change the base?
Changes from all commits
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 | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,107 @@ | ||||||
| <template> | ||||||
| <button | ||||||
| class="ui-button-test" | ||||||
| :class="{ disabled, loading }" | ||||||
|
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. The Additionally, |
||||||
| :disabled="disabled || loading" | ||||||
| :type="htmlType" | ||||||
| > | ||||||
| <div class="content"> | ||||||
| <UIIcon v-if="loading" class="icon" type="loading" /> | ||||||
| <UIIcon v-else-if="icon" class="icon" :type="icon" /> | ||||||
| <slot v-else name="icon"></slot> | ||||||
| <slot></slot> | ||||||
| </div> | ||||||
| </button> | ||||||
| </template> | ||||||
|
|
||||||
| <script setup lang="ts"> | ||||||
| import { computed } from 'vue' | ||||||
| import UIIcon, { type Type as IconType } from './icons/UIIcon.vue' | ||||||
|
|
||||||
| const props = withDefaults( | ||||||
| defineProps<{ | ||||||
| icon?: IconType | ||||||
| disabled?: boolean | ||||||
| loading?: boolean | ||||||
| htmlType?: 'button' | 'submit' | 'reset' | ||||||
| }>(), | ||||||
| { | ||||||
| icon: undefined, | ||||||
| disabled: false, | ||||||
| loading: false, | ||||||
| htmlType: 'button' | ||||||
| } | ||||||
| ) | ||||||
|
|
||||||
| const disabled = computed(() => props.disabled) | ||||||
|
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.
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. This computed is a no-op pass-through — it adds a reactive watcher and dependency hop with no transformation.
Suggested change
If this is aligned with |
||||||
| </script> | ||||||
|
|
||||||
| <style lang="scss" scoped> | ||||||
| .ui-button-test { | ||||||
| display: flex; | ||||||
| flex-direction: column; | ||||||
| justify-content: flex-end; | ||||||
| align-items: center; | ||||||
| background: none; | ||||||
| border: none; | ||||||
| cursor: pointer; | ||||||
| padding: 0 0 4px 0; | ||||||
| height: 40px; // Total height of 40px (36px content + 4px shadow offset) | ||||||
|
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. The comment says "36px content + 4px shadow offset = 40px" but the 4px comes from
Suggested change
|
||||||
| border-radius: 12px; | ||||||
| outline: none; | ||||||
| transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); | ||||||
|
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.
Prefer enumerating only the properties that actually change:
Suggested change
(And set |
||||||
|
|
||||||
| .content { | ||||||
| flex: 1; | ||||||
| width: 100%; | ||||||
| display: flex; | ||||||
| justify-content: center; | ||||||
| align-items: center; | ||||||
| padding: 0 24px; | ||||||
| border-radius: 12px; | ||||||
| font-size: 15px; | ||||||
| line-height: 1.6; | ||||||
| gap: 8px; | ||||||
| font-weight: normal; | ||||||
| color: var(--ui-color-grey-100); | ||||||
| background-color: var(--ui-color-primary-main); | ||||||
| box-shadow: 0 4px var(--ui-color-primary-700); | ||||||
| transition: inherit; | ||||||
| font-family: var(--ui-font-family-main); | ||||||
| } | ||||||
|
|
||||||
| .icon { | ||||||
| width: 18px; | ||||||
| height: 18px; | ||||||
| } | ||||||
|
|
||||||
| &:hover:not(:disabled):not(.loading) { | ||||||
| .content { | ||||||
| background-color: var(--ui-color-primary-400); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| &:active:not(:disabled):not(.loading), | ||||||
| &.loading { | ||||||
| padding-bottom: 0; | ||||||
| .content { | ||||||
| box-shadow: none; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| &:disabled:not(.loading) { | ||||||
| cursor: not-allowed; | ||||||
| .content { | ||||||
| // These colors are specifically requested in the design draft (via variables in colors.ts) | ||||||
| color: var(--ui-color-primary-700); // Specified as $turquoise700 | ||||||
|
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. The |
||||||
| background-color: var(--ui-color-grey-300); // Specified as $grey300 | ||||||
| box-shadow: 0 4px var(--ui-color-grey-500); // Specified as $grey500 | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| &:focus-visible { | ||||||
| outline: 2px solid var(--ui-color-primary-700); | ||||||
| outline-offset: 2px; | ||||||
| } | ||||||
| } | ||||||
| </style> | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ export { default as UIConfigProvider, useUIVariables, type Config } from './UICo | |
| export { default as UICard } from './UICard.vue' | ||
| export { default as UICardHeader } from './UICardHeader.vue' | ||
| export { default as UIButton } from './UIButton.vue' | ||
| export { default as UIButtonTest } from './UIButtonTest.vue' | ||
|
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. Exporting More importantly, after comparing both components: Could you clarify the intent? If this is meant to be a simplified preset or a replacement for |
||
| export { default as UIDropdown, type Pos as DropdownPos } from './UIDropdown' | ||
| export { default as UITooltip } from './UITooltip.vue' | ||
| export { UIMenu, UIMenuGroup, UIMenuItem } from './menu' | ||
|
|
||
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.
The component name
UIButtonTest.vueand its classui-button-testcould be misleading. TheTestsuffix often implies temporary or experimental code not meant for production. If this is a permanent addition to your UI library, consider a more descriptive name that reflects its style (e.g.,UIShadowButton) to improve clarity and maintainability.