@dcrackel/hematournamentui 1.0.22 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +18 -18
- package/.gitattributes +2 -2
- package/.prettierignore +1 -1
- package/.storybook/main.js +18 -18
- package/.storybook/mockRoutes.js +9 -9
- package/.storybook/preview-head.html +3 -3
- package/.storybook/preview.js +17 -17
- package/LICENSE +21 -21
- package/README.md +83 -83
- package/dist/HemaTouranmentUI-lib.es.js +7060 -6920
- package/dist/HemaTouranmentUI-lib.umd.js +27 -27
- package/dist/style.css +1 -1
- package/index.html +12 -12
- package/package.json +58 -58
- package/postcss.config.js +6 -6
- package/prettier.config.js +10 -10
- package/src/index.js +25 -25
- package/src/main.js +2 -2
- package/src/mocks/fileMock.js +1 -1
- package/src/mocks/tournamentMock.js +34 -34
- package/src/stories/Atoms/Icon/BaseIcon.stories.js +54 -54
- package/src/stories/Atoms/Icon/BaseIcon.test.js +91 -91
- package/src/stories/Atoms/Icon/BaseIcon.vue +48 -48
- package/src/stories/Atoms/Input/BaseInput.stories.js +29 -28
- package/src/stories/Atoms/Input/BaseInput.test.js +87 -87
- package/src/stories/Atoms/Input/BaseInput.vue +85 -73
- package/src/stories/Atoms/RadioGroup/BaseRadioGroup.stories.js +31 -31
- package/src/stories/Atoms/RadioGroup/BaseRadioGroup.test.js +49 -49
- package/src/stories/Atoms/RadioGroup/BaseRadioGroup.vue +49 -49
- package/src/stories/Atoms/Tag/BaseTag.stories.js +29 -29
- package/src/stories/Atoms/Tag/BaseTag.test.js +42 -42
- package/src/stories/Atoms/Tag/BaseTag.vue +57 -57
- package/src/stories/Atoms/Text/BaseText.stories.js +77 -77
- package/src/stories/Atoms/Text/BaseText.test.js +172 -172
- package/src/stories/Atoms/Text/BaseText.vue +170 -170
- package/src/stories/Configure.mdx +320 -320
- package/src/stories/Molecules/Breadcrumb/Admin/Breadcrumb.stories.js +41 -41
- package/src/stories/Molecules/Breadcrumb/Admin/Breadcrumb.test.js +80 -80
- package/src/stories/Molecules/Breadcrumb/Admin/Breadcrumb.vue +31 -31
- package/src/stories/Molecules/Button/BaseButton.stories.js +93 -76
- package/src/stories/Molecules/Button/BaseButton.test.js +147 -147
- package/src/stories/Molecules/Button/BaseButton.vue +116 -125
- package/src/stories/Molecules/Cards/Detail/TournamentCardDetail.stories.js +33 -33
- package/src/stories/Molecules/Cards/Detail/TournamentCardDetail.vue +38 -38
- package/src/stories/Molecules/Cards/Header/TournamentCardHeader.stories.js +48 -48
- package/src/stories/Molecules/Cards/Header/TournamentCardHeader.vue +40 -40
- package/src/stories/Molecules/Filters/FilterAndSortBar/FilterAndSortBar.stories.js +36 -36
- package/src/stories/Molecules/Filters/FilterAndSortBar/FilterAndSortBar.vue +49 -49
- package/src/stories/Molecules/Filters/FilterUpcomingPast/FilterUpcomingPast.stories.js +32 -32
- package/src/stories/Molecules/Filters/FilterUpcomingPast/FilterUpcomingPast.vue +46 -46
- package/src/stories/Organisms/AddressAutocomplete/AddressAutocomplete.stories.js +25 -25
- package/src/stories/Organisms/AddressAutocomplete/AddressAutocomplete.vue +51 -51
- package/src/stories/Organisms/DatePicker/DatePicker.stories.js +25 -25
- package/src/stories/Organisms/DatePicker/DatePicker.vue +62 -62
- package/src/stories/Organisms/DropDown/DropDownMenu.stories.js +34 -34
- package/src/stories/Organisms/DropDown/DropDownMenu.vue +51 -51
- package/src/stories/Organisms/Grid/GridContainer.stories.js +47 -47
- package/src/stories/Organisms/Grid/GridContainer.vue +108 -108
- package/src/stories/Organisms/ImageCropper/ImageCropper.stories.js +28 -28
- package/src/stories/Organisms/ImageCropper/ImageCropper.vue +86 -86
- package/src/stories/Organisms/TextBoxEditor/TextBoxEditor.stories.js +28 -28
- package/src/stories/Organisms/TextBoxEditor/TextBoxEditor.vue +97 -97
- package/src/stories/Organisms/TournamentCard/TournamentCard.stories.js +37 -37
- package/src/stories/Organisms/TournamentCard/TournamentCard.vue +35 -35
- package/src/stories/Templates/Forms/AddTournamentPageOne/AddTournamentPageOne.stories.js +25 -25
- package/src/stories/Templates/Forms/AddTournamentPageOne/AddTournamentPageOne.vue +138 -137
- package/src/stories/Templates/Forms/AddTournamentPageTwo/AddTournamentPageTwo.stories.js +35 -0
- package/src/stories/Templates/Forms/AddTournamentPageTwo/AddTournamentPageTwo.vue +121 -0
- package/src/stories/Templates/Menu/Admin/AdminLeftMenu.stories.js +28 -28
- package/src/stories/Templates/Menu/Admin/AdminLeftMenu.vue +57 -57
- package/tailwind/output.css +1247 -1212
- package/tailwind/tailwind.css +4 -4
- package/tailwind.config.js +50 -50
- package/vite.config.js +23 -23
|
@@ -1,73 +1,85 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="iconName ? '' : ''">
|
|
3
|
+
<input
|
|
4
|
+
v-model="internalValue"
|
|
5
|
+
:class="baseClasses"
|
|
6
|
+
:placeholder="placeholder"
|
|
7
|
+
@input="onInput"
|
|
8
|
+
/>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
import {computed, ref, watch} from 'vue';
|
|
15
|
+
import BaseIcon from "../Icon/BaseIcon.vue";
|
|
16
|
+
import BaseButton from "../../Molecules/Button/BaseButton.vue";
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
name: 'BaseInput',
|
|
20
|
+
components: {BaseButton, BaseIcon},
|
|
21
|
+
props: {
|
|
22
|
+
placeholder: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: ''
|
|
25
|
+
},
|
|
26
|
+
value: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: ''
|
|
29
|
+
},
|
|
30
|
+
invalid: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false
|
|
33
|
+
},
|
|
34
|
+
iconName: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: ''
|
|
37
|
+
},
|
|
38
|
+
iconStyle: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: 'fa-solid',
|
|
41
|
+
validator: value => ['fa-solid', 'fa-regular', 'fa-light', 'fa-thing'].includes(value)
|
|
42
|
+
},
|
|
43
|
+
size: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: 'sm',
|
|
46
|
+
validator: value => ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl'].includes(value)
|
|
47
|
+
},
|
|
48
|
+
iconColor: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: 'primary',
|
|
51
|
+
validator: value => ['neutral', 'primary', 'secondary', 'tertiary', 'quaternary', 'bright', 'white', 'alarm'].includes(value)
|
|
52
|
+
},
|
|
53
|
+
emits: ['click'],
|
|
54
|
+
},
|
|
55
|
+
setup(props, {emit}) {
|
|
56
|
+
const internalValue = ref(props.value);
|
|
57
|
+
const timeout = ref(null);
|
|
58
|
+
|
|
59
|
+
watch(() => props.value, newValue => {
|
|
60
|
+
internalValue.value = newValue;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const baseClasses = computed(() => {
|
|
64
|
+
let baseClasses = 'appearance-none focus:outline-none w-full text-sm border rounded-lg p-2';
|
|
65
|
+
|
|
66
|
+
props.invalid ? baseClasses += ' border border-alarm rounded-lg p-2' : baseClasses += ' border-dropdownSelect';
|
|
67
|
+
return baseClasses;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const onInput = () => {
|
|
71
|
+
clearTimeout(timeout.value);
|
|
72
|
+
timeout.value = setTimeout(() => {
|
|
73
|
+
emit('update:value', internalValue.value);
|
|
74
|
+
}, 300);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
internalValue,
|
|
79
|
+
baseClasses,
|
|
80
|
+
onInput
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
};
|
|
85
|
+
</script>
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import BaseRadioGroup from './BaseRadioGroup.vue';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: 'Atoms/BaseRadioGroup',
|
|
5
|
-
component: BaseRadioGroup,
|
|
6
|
-
tags: ['autodocs'],
|
|
7
|
-
argTypes: {
|
|
8
|
-
items: {
|
|
9
|
-
control: {
|
|
10
|
-
type: 'object',
|
|
11
|
-
},
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const Template = (args) => ({
|
|
17
|
-
components: { BaseRadioGroup },
|
|
18
|
-
setup() {
|
|
19
|
-
return { args };
|
|
20
|
-
},
|
|
21
|
-
template: '<BaseRadioGroup v-bind="args" />',
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
export const Default = Template.bind({});
|
|
25
|
-
Default.args = {
|
|
26
|
-
items: [
|
|
27
|
-
{ label: 'Option 1', value: 'opt1', description: 'Description for Item1' },
|
|
28
|
-
{ label: 'Option 2', value: 'opt2', description: 'Description for Item2' },
|
|
29
|
-
{ label: 'Option 2', value: 'opt2', description: 'Description for Item3' },
|
|
30
|
-
]
|
|
31
|
-
};
|
|
1
|
+
import BaseRadioGroup from './BaseRadioGroup.vue';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Atoms/BaseRadioGroup',
|
|
5
|
+
component: BaseRadioGroup,
|
|
6
|
+
tags: ['autodocs'],
|
|
7
|
+
argTypes: {
|
|
8
|
+
items: {
|
|
9
|
+
control: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
},
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const Template = (args) => ({
|
|
17
|
+
components: { BaseRadioGroup },
|
|
18
|
+
setup() {
|
|
19
|
+
return { args };
|
|
20
|
+
},
|
|
21
|
+
template: '<BaseRadioGroup v-bind="args" />',
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const Default = Template.bind({});
|
|
25
|
+
Default.args = {
|
|
26
|
+
items: [
|
|
27
|
+
{ label: 'Option 1', value: 'opt1', description: 'Description for Item1' },
|
|
28
|
+
{ label: 'Option 2', value: 'opt2', description: 'Description for Item2' },
|
|
29
|
+
{ label: 'Option 2', value: 'opt2', description: 'Description for Item3' },
|
|
30
|
+
]
|
|
31
|
+
};
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { mount } from '@vue/test-utils';
|
|
3
|
-
import BaseRadioGroup from './BaseRadioGroup.vue';
|
|
4
|
-
|
|
5
|
-
const items = [
|
|
6
|
-
{ label: 'Option 1', description: 'Description 1', value: '1' },
|
|
7
|
-
{ label: 'Option 2', description: 'Description 2', value: '2' },
|
|
8
|
-
{ label: 'Option 3', description: 'Description 3', value: '3' },
|
|
9
|
-
// Add more items as needed
|
|
10
|
-
];
|
|
11
|
-
|
|
12
|
-
describe('BaseRadioGroup', () => {
|
|
13
|
-
it('renders correct number of items', () => {
|
|
14
|
-
const wrapper = mount(BaseRadioGroup, {
|
|
15
|
-
props: { items }
|
|
16
|
-
});
|
|
17
|
-
expect(wrapper.findAll('[role="radio"]').length).toBe(items.length);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('applies correct classes based on selectedIndex and invalid prop', async () => {
|
|
21
|
-
const wrapper = mount(BaseRadioGroup, {
|
|
22
|
-
props: { items, invalid: true }
|
|
23
|
-
});
|
|
24
|
-
await wrapper.vm.selectItem(0);
|
|
25
|
-
expect(wrapper.findAll('.bg-tertiary').length).toBe(1);
|
|
26
|
-
expect(wrapper.find('.border-alarm').exists()).toBeTruthy();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('updates selectedIndex and emits event on item click', async () => {
|
|
30
|
-
const wrapper = mount(BaseRadioGroup, {
|
|
31
|
-
props: { items }
|
|
32
|
-
});
|
|
33
|
-
await wrapper.findAll('[role="radio"]')[0].trigger('click');
|
|
34
|
-
|
|
35
|
-
// console.log(wrapper.emitted())
|
|
36
|
-
|
|
37
|
-
expect(wrapper.vm.selectedIndex).toBe(0);
|
|
38
|
-
expect(wrapper.emitted('update:value')[0]).toEqual([items[0].value]);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('handles keyboard interaction correctly', async () => {
|
|
42
|
-
const wrapper = mount(BaseRadioGroup, {
|
|
43
|
-
props: { items }
|
|
44
|
-
});
|
|
45
|
-
await wrapper.findAll('[role="radio"]')[0].trigger('keydown.enter');
|
|
46
|
-
expect(wrapper.vm.selectedIndex).toBe(0);
|
|
47
|
-
expect(wrapper.emitted('update:value')[0]).toEqual([items[0].value]);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { mount } from '@vue/test-utils';
|
|
3
|
+
import BaseRadioGroup from './BaseRadioGroup.vue';
|
|
4
|
+
|
|
5
|
+
const items = [
|
|
6
|
+
{ label: 'Option 1', description: 'Description 1', value: '1' },
|
|
7
|
+
{ label: 'Option 2', description: 'Description 2', value: '2' },
|
|
8
|
+
{ label: 'Option 3', description: 'Description 3', value: '3' },
|
|
9
|
+
// Add more items as needed
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
describe('BaseRadioGroup', () => {
|
|
13
|
+
it('renders correct number of items', () => {
|
|
14
|
+
const wrapper = mount(BaseRadioGroup, {
|
|
15
|
+
props: { items }
|
|
16
|
+
});
|
|
17
|
+
expect(wrapper.findAll('[role="radio"]').length).toBe(items.length);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('applies correct classes based on selectedIndex and invalid prop', async () => {
|
|
21
|
+
const wrapper = mount(BaseRadioGroup, {
|
|
22
|
+
props: { items, invalid: true }
|
|
23
|
+
});
|
|
24
|
+
await wrapper.vm.selectItem(0);
|
|
25
|
+
expect(wrapper.findAll('.bg-tertiary').length).toBe(1);
|
|
26
|
+
expect(wrapper.find('.border-alarm').exists()).toBeTruthy();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('updates selectedIndex and emits event on item click', async () => {
|
|
30
|
+
const wrapper = mount(BaseRadioGroup, {
|
|
31
|
+
props: { items }
|
|
32
|
+
});
|
|
33
|
+
await wrapper.findAll('[role="radio"]')[0].trigger('click');
|
|
34
|
+
|
|
35
|
+
// console.log(wrapper.emitted())
|
|
36
|
+
|
|
37
|
+
expect(wrapper.vm.selectedIndex).toBe(0);
|
|
38
|
+
expect(wrapper.emitted('update:value')[0]).toEqual([items[0].value]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('handles keyboard interaction correctly', async () => {
|
|
42
|
+
const wrapper = mount(BaseRadioGroup, {
|
|
43
|
+
props: { items }
|
|
44
|
+
});
|
|
45
|
+
await wrapper.findAll('[role="radio"]')[0].trigger('keydown.enter');
|
|
46
|
+
expect(wrapper.vm.selectedIndex).toBe(0);
|
|
47
|
+
expect(wrapper.emitted('update:value')[0]).toEqual([items[0].value]);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="text-xl" role="radiogroup">
|
|
3
|
-
<div
|
|
4
|
-
class="flex flex-row p-4 text-quaternary rounded-lg mb-2 shadow border hover:bg-tertiary"
|
|
5
|
-
v-for="(item, index) in items"
|
|
6
|
-
:key="index"
|
|
7
|
-
:class="[selectedIndex === index ? ' bg-tertiary' : ' bg-white', invalid ? ' border-alarm' : ' border-dropdownSelect']"
|
|
8
|
-
@click="selectItem(index)"
|
|
9
|
-
role="radio"
|
|
10
|
-
:aria-checked="selectedIndex === index ? 'true' : 'false'"
|
|
11
|
-
tabindex="0"
|
|
12
|
-
@keydown.enter.prevent="selectItem(index)"
|
|
13
|
-
>
|
|
14
|
-
<i :class="[selectedIndex === index ? 'fa-circle-dot text-quaternary ' : 'fa-circle ' ]" class="fa-regular pr-4 pt-2" ></i>
|
|
15
|
-
<div class="flex flex-col">
|
|
16
|
-
<p :class="[selectedIndex === index ? 'text-quaternary ' : '' ]" class="font-bold text-sm">{{ item.label }}</p>
|
|
17
|
-
<p :class="[selectedIndex === index ? 'text-quaternary ' : '' ]" class="text-sm">{{ item.description }}</p>
|
|
18
|
-
</div>
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
</template>
|
|
22
|
-
|
|
23
|
-
<script>
|
|
24
|
-
export default {
|
|
25
|
-
name: 'BaseRadioGroup',
|
|
26
|
-
props: {
|
|
27
|
-
invalid: {
|
|
28
|
-
type: Boolean,
|
|
29
|
-
default: false,
|
|
30
|
-
},
|
|
31
|
-
items: {
|
|
32
|
-
type: Array,
|
|
33
|
-
required: true,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
data() {
|
|
37
|
-
return {
|
|
38
|
-
selectedIndex: null,
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
methods: {
|
|
42
|
-
selectItem(index) {
|
|
43
|
-
this.selectedIndex = index;
|
|
44
|
-
this.$emit('update:value', this.items[index].value);
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
</script>
|
|
49
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div class="text-xl" role="radiogroup">
|
|
3
|
+
<div
|
|
4
|
+
class="flex flex-row p-4 text-quaternary rounded-lg mb-2 shadow border hover:bg-tertiary"
|
|
5
|
+
v-for="(item, index) in items"
|
|
6
|
+
:key="index"
|
|
7
|
+
:class="[selectedIndex === index ? ' bg-tertiary' : ' bg-white', invalid ? ' border-alarm' : ' border-dropdownSelect']"
|
|
8
|
+
@click="selectItem(index)"
|
|
9
|
+
role="radio"
|
|
10
|
+
:aria-checked="selectedIndex === index ? 'true' : 'false'"
|
|
11
|
+
tabindex="0"
|
|
12
|
+
@keydown.enter.prevent="selectItem(index)"
|
|
13
|
+
>
|
|
14
|
+
<i :class="[selectedIndex === index ? 'fa-circle-dot text-quaternary ' : 'fa-circle ' ]" class="fa-regular pr-4 pt-2" ></i>
|
|
15
|
+
<div class="flex flex-col">
|
|
16
|
+
<p :class="[selectedIndex === index ? 'text-quaternary ' : '' ]" class="font-bold text-sm">{{ item.label }}</p>
|
|
17
|
+
<p :class="[selectedIndex === index ? 'text-quaternary ' : '' ]" class="text-sm">{{ item.description }}</p>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script>
|
|
24
|
+
export default {
|
|
25
|
+
name: 'BaseRadioGroup',
|
|
26
|
+
props: {
|
|
27
|
+
invalid: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: false,
|
|
30
|
+
},
|
|
31
|
+
items: {
|
|
32
|
+
type: Array,
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
data() {
|
|
37
|
+
return {
|
|
38
|
+
selectedIndex: null,
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
methods: {
|
|
42
|
+
selectItem(index) {
|
|
43
|
+
this.selectedIndex = index;
|
|
44
|
+
this.$emit('update:value', this.items[index].value);
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
</script>
|
|
49
|
+
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import BaseTag from './BaseTag.vue';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: 'Atoms/BaseTag',
|
|
5
|
-
component: BaseTag,
|
|
6
|
-
tags: ['autodocs'],
|
|
7
|
-
argTypes: {
|
|
8
|
-
label: {
|
|
9
|
-
control: {
|
|
10
|
-
type: 'text',
|
|
11
|
-
defaultValue: 'Default Label'
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
backgroundColor: {
|
|
15
|
-
control: {
|
|
16
|
-
type: 'select'
|
|
17
|
-
},
|
|
18
|
-
options: ['primary', 'secondary', 'tertiary', 'neutral', 'bright'],
|
|
19
|
-
defaultValue: 'primary'
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const Basic = {
|
|
25
|
-
args: {
|
|
26
|
-
label: 'default tag',
|
|
27
|
-
backgroundColor: 'primary'
|
|
28
|
-
}
|
|
29
|
-
};
|
|
1
|
+
import BaseTag from './BaseTag.vue';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Atoms/BaseTag',
|
|
5
|
+
component: BaseTag,
|
|
6
|
+
tags: ['autodocs'],
|
|
7
|
+
argTypes: {
|
|
8
|
+
label: {
|
|
9
|
+
control: {
|
|
10
|
+
type: 'text',
|
|
11
|
+
defaultValue: 'Default Label'
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
backgroundColor: {
|
|
15
|
+
control: {
|
|
16
|
+
type: 'select'
|
|
17
|
+
},
|
|
18
|
+
options: ['primary', 'secondary', 'tertiary', 'neutral', 'bright'],
|
|
19
|
+
defaultValue: 'primary'
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const Basic = {
|
|
25
|
+
args: {
|
|
26
|
+
label: 'default tag',
|
|
27
|
+
backgroundColor: 'primary'
|
|
28
|
+
}
|
|
29
|
+
};
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import BaseTag from './BaseTag.vue';
|
|
2
|
-
import { mount } from "@vue/test-utils";
|
|
3
|
-
import { describe, expect, test, it } from "vitest";
|
|
4
|
-
|
|
5
|
-
describe('base-tag.vue', () => {
|
|
6
|
-
|
|
7
|
-
it('renders with default classes and primary background color', () => {
|
|
8
|
-
const wrapper = mount(BaseTag, {
|
|
9
|
-
props: { label: 'Test Tag' }
|
|
10
|
-
});
|
|
11
|
-
const tagElement = wrapper.find('div');
|
|
12
|
-
|
|
13
|
-
expect(tagElement.classes()).toContain('cursor-pointer');
|
|
14
|
-
expect(tagElement.classes()).toContain('bg-primary');
|
|
15
|
-
expect(tagElement.text()).toBe('Test Tag');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('renders with specified background color classes', () => {
|
|
19
|
-
const backgrounds = ['primary', 'secondary', 'tertiary', 'neutral', 'bright'];
|
|
20
|
-
|
|
21
|
-
backgrounds.forEach(async (bg) => {
|
|
22
|
-
const wrapper = mount(BaseTag, {
|
|
23
|
-
props: { label: 'Test Tag', backgroundColor: bg }
|
|
24
|
-
});
|
|
25
|
-
const tagElement = wrapper.find('div');
|
|
26
|
-
|
|
27
|
-
expect(tagElement.classes()).toContain(`bg-${bg}`);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('renders with primary background color for unknown values', () => {
|
|
32
|
-
const wrapper = mount(BaseTag, {
|
|
33
|
-
props: { label: 'Test Tag', backgroundColor: 'unknown' }
|
|
34
|
-
});
|
|
35
|
-
const tagElement = wrapper.find('div');
|
|
36
|
-
|
|
37
|
-
expect(tagElement.classes()).toContain('bg-primary');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
1
|
+
import BaseTag from './BaseTag.vue';
|
|
2
|
+
import { mount } from "@vue/test-utils";
|
|
3
|
+
import { describe, expect, test, it } from "vitest";
|
|
4
|
+
|
|
5
|
+
describe('base-tag.vue', () => {
|
|
6
|
+
|
|
7
|
+
it('renders with default classes and primary background color', () => {
|
|
8
|
+
const wrapper = mount(BaseTag, {
|
|
9
|
+
props: { label: 'Test Tag' }
|
|
10
|
+
});
|
|
11
|
+
const tagElement = wrapper.find('div');
|
|
12
|
+
|
|
13
|
+
expect(tagElement.classes()).toContain('cursor-pointer');
|
|
14
|
+
expect(tagElement.classes()).toContain('bg-primary');
|
|
15
|
+
expect(tagElement.text()).toBe('Test Tag');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('renders with specified background color classes', () => {
|
|
19
|
+
const backgrounds = ['primary', 'secondary', 'tertiary', 'neutral', 'bright'];
|
|
20
|
+
|
|
21
|
+
backgrounds.forEach(async (bg) => {
|
|
22
|
+
const wrapper = mount(BaseTag, {
|
|
23
|
+
props: { label: 'Test Tag', backgroundColor: bg }
|
|
24
|
+
});
|
|
25
|
+
const tagElement = wrapper.find('div');
|
|
26
|
+
|
|
27
|
+
expect(tagElement.classes()).toContain(`bg-${bg}`);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('renders with primary background color for unknown values', () => {
|
|
32
|
+
const wrapper = mount(BaseTag, {
|
|
33
|
+
props: { label: 'Test Tag', backgroundColor: 'unknown' }
|
|
34
|
+
});
|
|
35
|
+
const tagElement = wrapper.find('div');
|
|
36
|
+
|
|
37
|
+
expect(tagElement.classes()).toContain('bg-primary');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
});
|