-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12045 from rak-phillip/bugfix/12007-menu-action
Create new `ButtonMultiAction.vue` component
- Loading branch information
Showing
4 changed files
with
94 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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,41 @@ | ||
<script setup lang="ts"> | ||
import { computed, defineEmits } from 'vue'; | ||
defineEmits(['click']); | ||
type Props = { | ||
borderless?: boolean; | ||
invisible?: boolean; | ||
} | ||
const props = defineProps<Props>(); | ||
const buttonClass = computed(() => { | ||
return { | ||
borderless: props?.borderless, | ||
invisible: props?.invisible, | ||
}; | ||
}); | ||
</script> | ||
|
||
<template> | ||
<button | ||
type="button" | ||
class="btn btn-sm role-multi-action actions" | ||
:class="buttonClass" | ||
@click="(e: Event) => $emit('click', e)" | ||
> | ||
<i class="icon icon-actions" /> | ||
</button> | ||
</template> | ||
|
||
<style lang="scss" scoped> | ||
.borderless { | ||
background-color: transparent; | ||
border: none; | ||
&:hover, &:focus { | ||
background-color: var(--accent-btn); | ||
box-shadow: none; | ||
} | ||
} | ||
</style> |
This file contains 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 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 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,31 @@ | ||
import { shallowMount } from '@vue/test-utils'; | ||
import ButtonMultiAction from '@shell/components/ButtonMultiAction.vue'; | ||
|
||
describe('buttonMultiAction.vue', () => { | ||
it('renders correct classes when props are provided', () => { | ||
const wrapper = shallowMount(ButtonMultiAction, { | ||
props: { | ||
borderless: true, | ||
invisible: true, | ||
}, | ||
}); | ||
|
||
expect(wrapper.find('button').classes()).toContain('borderless'); | ||
expect(wrapper.find('button').classes()).toContain('invisible'); | ||
}); | ||
|
||
it('renders correct classes when props are absent', () => { | ||
const wrapper = shallowMount(ButtonMultiAction); | ||
|
||
expect(wrapper.find('button').classes()).not.toContain('borderless'); | ||
expect(wrapper.find('button').classes()).not.toContain('invisible'); | ||
}); | ||
|
||
it('emits click event when button is clicked', () => { | ||
const wrapper = shallowMount(ButtonMultiAction); | ||
|
||
wrapper.find('button').trigger('click'); | ||
|
||
expect(wrapper.emitted('click')).toBeTruthy(); | ||
}); | ||
}); |