-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat: enhance UX with improved icon transitions and button interactions #5344
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
Open
SteKoe
wants to merge
6
commits into
master
Choose a base branch
from
chore/ux-enhancements
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a476219
style: update icon rotation and transition for better UX
SteKoe 6d3c162
style: enhance button and icon interactions for improved UX
SteKoe 2ba927f
style: improve layout and alignment of input fields for better UX
SteKoe b871cb5
style: enhance button component and add translations for instance det…
SteKoe 88d0ba5
Merge branch 'master' into chore/ux-enhancements
ulischulte fc6e46b
Merge branch 'master' into chore/ux-enhancements
ulischulte 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
132 changes: 132 additions & 0 deletions
132
spring-boot-admin-server-ui/src/main/frontend/components/sba-button.spec.ts
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,132 @@ | ||
| import userEvent from '@testing-library/user-event'; | ||
| import { screen } from '@testing-library/vue'; | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { defineComponent } from 'vue'; | ||
|
|
||
| import SbaButton from './sba-button.vue'; | ||
|
|
||
| import { render } from '@/test-utils'; | ||
|
|
||
| describe('SbaButton', () => { | ||
| it('renders as a button element by default', () => { | ||
| render(SbaButton, { slots: { default: 'Click me' } }); | ||
| expect( | ||
| screen.getByRole('button', { name: 'Click me' }), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders slot content', () => { | ||
| render(SbaButton, { slots: { default: 'Submit' } }); | ||
| expect(screen.getByText('Submit')).toBeVisible(); | ||
| }); | ||
|
|
||
| it('renders as an anchor element when as="a"', () => { | ||
| render(SbaButton, { | ||
| props: { as: 'a', href: '#' }, | ||
| slots: { default: 'Link' }, | ||
| }); | ||
| expect(screen.getByRole('link', { name: 'Link' })).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('sets href on anchor element', () => { | ||
| render(SbaButton, { | ||
| props: { as: 'a', href: 'https://example.com' }, | ||
| slots: { default: 'Link' }, | ||
| }); | ||
| expect(screen.getByRole('link', { name: 'Link' })).toHaveAttribute( | ||
| 'href', | ||
| 'https://example.com', | ||
| ); | ||
| }); | ||
|
|
||
| it('sets title attribute', () => { | ||
| render(SbaButton, { | ||
| props: { title: 'My tooltip' }, | ||
| slots: { default: 'Btn' }, | ||
| }); | ||
| expect(screen.getByRole('button', { name: 'Btn' })).toHaveAttribute( | ||
| 'title', | ||
| 'My tooltip', | ||
| ); | ||
| }); | ||
|
|
||
| it('is disabled when disabled prop is true', () => { | ||
| render(SbaButton, { | ||
| props: { disabled: true }, | ||
| slots: { default: 'Disabled' }, | ||
| }); | ||
| expect(screen.getByRole('button', { name: 'Disabled' })).toBeDisabled(); | ||
| }); | ||
|
|
||
| it('is not disabled by default', () => { | ||
| render(SbaButton, { slots: { default: 'Active' } }); | ||
| expect(screen.getByRole('button', { name: 'Active' })).not.toBeDisabled(); | ||
| }); | ||
|
|
||
| it('emits click event when button is clicked', async () => { | ||
| const { emitted } = render(SbaButton, { slots: { default: 'Click' } }); | ||
| await userEvent.click(screen.getByRole('button', { name: 'Click' })); | ||
| expect(emitted().click).toHaveLength(1); | ||
| }); | ||
|
|
||
| it('does not emit click event when rendered as anchor', async () => { | ||
| const { emitted } = render(SbaButton, { | ||
| props: { as: 'a', href: '#' }, | ||
| slots: { default: 'Link' }, | ||
| }); | ||
| await userEvent.click(screen.getByRole('link', { name: 'Link' })); | ||
| expect(emitted().click).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('accepts a Vue component as the as prop and emits click', async () => { | ||
| const StubComponent = defineComponent({ | ||
| template: '<button v-bind="$attrs"><slot /></button>', | ||
| }); | ||
| const { emitted } = render(SbaButton, { | ||
| props: { as: StubComponent }, | ||
| slots: { default: 'Component' }, | ||
| }); | ||
| await userEvent.click(screen.getByRole('button', { name: 'Component' })); | ||
| expect(emitted().click).toHaveLength(1); | ||
| }); | ||
|
|
||
| it('passes attrs through to a component passed as the as prop', () => { | ||
| const StubComponent = defineComponent({ | ||
| template: '<span v-bind="$attrs"><slot /></span>', | ||
| }); | ||
| render(SbaButton, { | ||
| props: { as: StubComponent, primary: true }, | ||
| slots: { default: 'Component' }, | ||
| }); | ||
| expect(screen.getByText('Component')).toHaveClass('is-primary'); | ||
| }); | ||
|
|
||
| it('applies is-primary class when primary prop is true', () => { | ||
| render(SbaButton, { | ||
| props: { primary: true }, | ||
| slots: { default: 'Primary' }, | ||
| }); | ||
| expect(screen.getByRole('button', { name: 'Primary' })).toHaveClass( | ||
| 'is-primary', | ||
| ); | ||
| }); | ||
|
|
||
| it('does not apply is-primary class by default', () => { | ||
| render(SbaButton, { slots: { default: 'Default' } }); | ||
| expect(screen.getByRole('button', { name: 'Default' })).not.toHaveClass( | ||
| 'is-primary', | ||
| ); | ||
| }); | ||
|
|
||
| it.each([ | ||
| ['2xs', 'px-1.5'], | ||
| ['xs', 'px-2'], | ||
| ['sm', 'px-3'], | ||
| ['base', 'px-4'], | ||
| ])('applies correct padding class for size="%s"', (size, expectedClass) => { | ||
| render(SbaButton, { props: { size }, slots: { default: 'Btn' } }); | ||
| expect(screen.getByRole('button', { name: 'Btn' })).toHaveClass( | ||
| expectedClass, | ||
| ); | ||
| }); | ||
| }); |
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
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
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.
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.
type seems not to be defined in defineProps