From badff7a75e9bb5e88f5eaa30653959e0431e3209 Mon Sep 17 00:00:00 2001 From: gabaldon Date: Tue, 3 Sep 2024 08:49:08 +0200 Subject: [PATCH 01/13] feat: implement select --- package.json | 4 +- pnpm-lock.yaml | 59 ++++- src/components/Select/WSelect.spec.ts | 61 +++++ src/components/Select/WSelect.stories.ts | 59 +++++ src/components/Select/WSelect.ts | 6 + src/components/Select/WSelect.vue | 209 +++++++++++++++++ .../Select/__snapshots__/WSelect.spec.ts.snap | 215 ++++++++++++++++++ svgComponent.d.ts | 5 +- 8 files changed, 612 insertions(+), 6 deletions(-) create mode 100644 src/components/Select/WSelect.spec.ts create mode 100644 src/components/Select/WSelect.stories.ts create mode 100644 src/components/Select/WSelect.ts create mode 100644 src/components/Select/WSelect.vue create mode 100644 src/components/Select/__snapshots__/WSelect.spec.ts.snap diff --git a/package.json b/package.json index a4b9b0f..41b62cb 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,8 @@ "gsap": "^3.12.5", "postcss-cli": "^11.0.0", "sass": "^1.77.8", - "vite-svg-loader": "^5.1.0" + "vite-svg-loader": "^5.1.0", + "vue-select": "^4.0.0-beta.3" }, "devDependencies": { "@chromatic-com/storybook": "^1.6.1", @@ -49,6 +50,7 @@ "@tsconfig/node20": "^20.1.4", "@types/jsdom": "^21.1.7", "@types/node": "^20.14.5", + "@types/vue-select": "^3.16.8", "@vitejs/plugin-vue": "^5.0.5", "@vue/eslint-config-prettier": "^9.0.0", "@vue/eslint-config-typescript": "^13.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 28ebf69..be808bd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,6 +23,9 @@ importers: vue: specifier: 3.4.38 version: 3.4.38(typescript@5.4.5) + vue-select: + specifier: ^4.0.0-beta.3 + version: 4.0.0-beta.6(vue@3.4.38(typescript@5.4.5)) devDependencies: '@chromatic-com/storybook': specifier: ^1.6.1 @@ -63,6 +66,9 @@ importers: '@types/node': specifier: ^20.14.5 version: 20.16.2 + '@types/vue-select': + specifier: ^3.16.8 + version: 3.16.8 '@vitejs/plugin-vue': specifier: ^5.0.5 version: 5.1.2(vite@5.4.2(@types/node@20.16.2)(sass@1.77.8))(vue@3.4.38(typescript@5.4.5)) @@ -1369,6 +1375,9 @@ packages: '@types/uuid@9.0.8': resolution: {integrity: sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==} + '@types/vue-select@3.16.8': + resolution: {integrity: sha512-ZBovlBrWf/wnPqCmMw24ryIC7ghQLfIBmkl1qssqBGONdx7yOmi/GLwtPxll/6UwXWGNWMeokleOgVAZPis+Ag==} + '@typescript-eslint/eslint-plugin@7.18.0': resolution: {integrity: sha512-94EQTWZ40mzBc42ATNIBimBEDltSJ9RQHCC8vc/PDbxi4k8dVwUAv4o98dk50M1zB+JGFxp43FP7f8+FP8R6Sw==} engines: {node: ^18.18.0 || >=20.0.0} @@ -1494,6 +1503,9 @@ packages: '@vue/compiler-dom@3.4.38': resolution: {integrity: sha512-Osc/c7ABsHXTsETLgykcOwIxFktHfGSUDkb05V61rocEfsFDcjDLH/IHJSNJP+/Sv9KeN2Lx1V6McZzlSb9EhQ==} + '@vue/compiler-sfc@2.7.16': + resolution: {integrity: sha512-KWhJ9k5nXuNtygPU7+t1rX6baZeqOYLEforUPjgNDBnLicfHCoi48H87Q8XyLZOrNNsmhuwKqtpDQWjEFe6Ekg==} + '@vue/compiler-sfc@3.4.38': resolution: {integrity: sha512-s5QfZ+9PzPh3T5H4hsQDJtI8x7zdJaew/dCGgqZ2630XdzaZ3AD8xGZfBqpT8oaD/p2eedd+pL8tD5vvt5ZYJQ==} @@ -3222,6 +3234,11 @@ packages: resolution: {integrity: sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==} engines: {node: '>=6.0.0'} + prettier@2.8.8: + resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} + engines: {node: '>=10.13.0'} + hasBin: true + prettier@3.3.3: resolution: {integrity: sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==} engines: {node: '>=14'} @@ -3952,12 +3969,24 @@ packages: peerDependencies: vue: '>=2' - vue-tsc@2.1.4: - resolution: {integrity: sha512-XTzMXQcsixAvNbpou/9qngEsZawaiJRZH3Ja+lfgRfv2A1TJv9vnZ/Kyv7XxPqv/TaZVFSnjGpM87VbWIg6yQg==} + vue-select@4.0.0-beta.6: + resolution: {integrity: sha512-K+zrNBSpwMPhAxYLTCl56gaMrWZGgayoWCLqe5rWwkB8aUbAUh7u6sXjIR7v4ckp2WKC7zEEUY27g6h1MRsIHw==} + peerDependencies: + vue: 3.x + + vue-template-compiler@2.7.16: + resolution: {integrity: sha512-AYbUWAJHLGGQM7+cNTELw+KsOG9nl2CnSv467WobS5Cv9uk3wFcnr1Etsz2sEIHEZvw1U+o9mRlEO6QbZvUPGQ==} + + vue-tsc@2.0.21: + resolution: {integrity: sha512-E6x1p1HaHES6Doy8pqtm7kQern79zRtIewkf9fiv7Y43Zo4AFDS5hKi+iHi2RwEhqRmuiwliB1LCEFEGwvxQnw==} hasBin: true peerDependencies: typescript: '>=5.0.0' + vue@2.7.16: + resolution: {integrity: sha512-4gCtFXaAA3zYZdTp5s4Hl2sozuySsgz4jy1EnpBHNfpMa9dK1ZCG7viqBPCwXtmgc8nHqUsAu3G4gtmXkkY3Sw==} + deprecated: Vue 2 has reached EOL and is no longer actively maintained. See https://v2.vuejs.org/eol/ for more details. + vue@3.4.38: resolution: {integrity: sha512-f0ZgN+mZ5KFgVv9wz0f4OgVKukoXtS3nwET4c2vLBGQR50aI8G0cqbFtLlX9Yiyg3LFGBitruPHt2PxwTduJEw==} peerDependencies: @@ -5561,6 +5590,10 @@ snapshots: '@types/uuid@9.0.8': {} + '@types/vue-select@3.16.8': + dependencies: + vue: 2.7.16 + '@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5)': dependencies: '@eslint-community/regexpp': 4.11.0 @@ -5744,6 +5777,14 @@ snapshots: '@vue/compiler-core': 3.4.38 '@vue/shared': 3.4.38 + '@vue/compiler-sfc@2.7.16': + dependencies: + '@babel/parser': 7.25.6 + postcss: 8.4.41 + source-map: 0.6.1 + optionalDependencies: + prettier: 2.8.8 + '@vue/compiler-sfc@3.4.38': dependencies: '@babel/parser': 7.25.6 @@ -7520,6 +7561,9 @@ snapshots: dependencies: fast-diff: 1.3.0 + prettier@2.8.8: + optional: true + prettier@3.3.3: {} pretty-format@27.5.1: @@ -8354,13 +8398,22 @@ snapshots: dependencies: vue: 3.4.38(typescript@5.4.5) - vue-tsc@2.1.4(typescript@5.4.5): + vue-select@4.0.0-beta.6(vue@3.4.38(typescript@5.4.5)): + dependencies: + vue: 3.4.38(typescript@5.4.5) + + vue-template-compiler@2.7.16: dependencies: '@volar/typescript': 2.4.1 '@vue/language-core': 2.1.4(typescript@5.4.5) semver: 7.6.3 typescript: 5.4.5 + vue@2.7.16: + dependencies: + '@vue/compiler-sfc': 2.7.16 + csstype: 3.1.3 + vue@3.4.38(typescript@5.4.5): dependencies: '@vue/compiler-dom': 3.4.38 diff --git a/src/components/Select/WSelect.spec.ts b/src/components/Select/WSelect.spec.ts new file mode 100644 index 0000000..2ca7ec1 --- /dev/null +++ b/src/components/Select/WSelect.spec.ts @@ -0,0 +1,61 @@ +import { describe, it, expect } from 'vitest' +import { mount } from '@vue/test-utils' +import WSelect from './WSelect.vue' +import { DropdownPosition } from './WSelect' +import Icon from '@/assets/svg/navigation-cursor.svg?component' + +describe('WSelect', () => { + it('renders properly', () => { + const wrapper = mount(WSelect, { + emits: ['update:modelValue'], + props: { + dropdownPosition: DropdownPosition.bottom, + modelValue: { + key: 'en', + label: 'English', + icon: null + }, + 'onUpdate:modelValue': (e) => wrapper.setProps({ modelValue: e }), + options: [{ + key: 'en', + label: 'English', + icon: null + },{ + key: 'es', + label: 'Español', + icon: null, + } + ] + }, + }) + + expect(wrapper.element).toMatchSnapshot() + }) + + it('renders properly an icon when provided', () => { + const wrapper = mount(WSelect, { + emits: ['update:modelValue'], + props: { + dropdownPosition: DropdownPosition.bottom, + modelValue: { + key: 'en', + label: 'English', + icon: Icon + }, + 'onUpdate:modelValue': (e) => wrapper.setProps({ modelValue: e }), + options: [{ + key: 'en', + label: 'English', + icon: Icon + },{ + key: 'es', + label: 'Español', + icon: Icon, + } + ] + }, + }) + + expect(wrapper.element).toMatchSnapshot() + }) +}) diff --git a/src/components/Select/WSelect.stories.ts b/src/components/Select/WSelect.stories.ts new file mode 100644 index 0000000..1736629 --- /dev/null +++ b/src/components/Select/WSelect.stories.ts @@ -0,0 +1,59 @@ +import type { Meta, StoryObj } from '@storybook/vue3' +import WSelect from './WSelect.vue' +import { dropdownPostions } from './WSelect' +import { ref } from 'vue' +import 'vue-select/dist/vue-select.css' +import Icon from '@/assets/svg/navigation-cursor.svg?component' + +const meta: any = { + title: 'Example/WSelect', + component: WSelect, + tags: ['autodocs'], + argTypes: { + dropdownPosition: { control: 'select', options: dropdownPostions }, + }, + args: { + options: [{ + key: 'en', + label: 'English', + icon: null, + },{ + key: 'es', + label: 'Español', + icon: null, + }]} +} satisfies Meta + +export default meta +type Story = StoryObj + +export const Default: Story = { + render: (args: any) => ({ + components: { WSelect }, + setup() { + const model = ref({ + key: 'en', + label: 'English', + icon: null, + }); + + function update($event: any) { + model.value = $event + } + + return { args, model, update }; + }, + template: ``, + args: { + options: [{ + key: 'en', + label: 'English', + icon: null, + },{ + key: 'es', + label: 'Español', + icon: Icon, + }] + } + }) +} \ No newline at end of file diff --git a/src/components/Select/WSelect.ts b/src/components/Select/WSelect.ts new file mode 100644 index 0000000..2dca31b --- /dev/null +++ b/src/components/Select/WSelect.ts @@ -0,0 +1,6 @@ +export type Option = {key: string, label: string, icon: string | null} +export enum DropdownPosition { + top = 'top', + bottom = 'bottom' +} +export const dropdownPostions = Object.values(DropdownPosition) \ No newline at end of file diff --git a/src/components/Select/WSelect.vue b/src/components/Select/WSelect.vue new file mode 100644 index 0000000..6ffefcf --- /dev/null +++ b/src/components/Select/WSelect.vue @@ -0,0 +1,209 @@ + + + + + diff --git a/src/components/Select/__snapshots__/WSelect.spec.ts.snap b/src/components/Select/__snapshots__/WSelect.spec.ts.snap new file mode 100644 index 0000000..81f9184 --- /dev/null +++ b/src/components/Select/__snapshots__/WSelect.spec.ts.snap @@ -0,0 +1,215 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`WSelect > renders properly 1`] = ` +
+ + + + +
+`; + +exports[`WSelect > renders properly an icon when provided 1`] = ` +
+ + + + +
+`; diff --git a/svgComponent.d.ts b/svgComponent.d.ts index c4712d5..b2dcc09 100644 --- a/svgComponent.d.ts +++ b/svgComponent.d.ts @@ -1,5 +1,6 @@ declare module '*.svg?component' { - const value: string; - export default value; + import { DefineComponent, SVGAttributes } from 'vue' + const src: DefineComponent + export default src } declare module '*.vue'; \ No newline at end of file From 9d4554c5bd6141eb1de0c9a6042d37b36a5b24dc Mon Sep 17 00:00:00 2001 From: gabaldon Date: Tue, 3 Sep 2024 18:27:55 +0200 Subject: [PATCH 02/13] feat: implement tooltip --- src/components/Select/WSelect.spec.ts | 6 +- .../Select/__snapshots__/WSelect.spec.ts.snap | 282 +++++------------- src/components/Tooltip/WTooltip.spec.ts | 19 ++ src/components/Tooltip/WTooltip.stories.ts | 30 ++ src/components/Tooltip/WTooltip.vue | 25 ++ .../__snapshots__/WTooltip.spec.ts.snap | 26 ++ 6 files changed, 179 insertions(+), 209 deletions(-) create mode 100644 src/components/Tooltip/WTooltip.spec.ts create mode 100644 src/components/Tooltip/WTooltip.stories.ts create mode 100644 src/components/Tooltip/WTooltip.vue create mode 100644 src/components/Tooltip/__snapshots__/WTooltip.spec.ts.snap diff --git a/src/components/Select/WSelect.spec.ts b/src/components/Select/WSelect.spec.ts index 2ca7ec1..75104af 100644 --- a/src/components/Select/WSelect.spec.ts +++ b/src/components/Select/WSelect.spec.ts @@ -1,12 +1,12 @@ import { describe, it, expect } from 'vitest' -import { mount } from '@vue/test-utils' +import { shallowMount } from '@vue/test-utils' import WSelect from './WSelect.vue' import { DropdownPosition } from './WSelect' import Icon from '@/assets/svg/navigation-cursor.svg?component' describe('WSelect', () => { it('renders properly', () => { - const wrapper = mount(WSelect, { + const wrapper = shallowMount(WSelect, { emits: ['update:modelValue'], props: { dropdownPosition: DropdownPosition.bottom, @@ -33,7 +33,7 @@ describe('WSelect', () => { }) it('renders properly an icon when provided', () => { - const wrapper = mount(WSelect, { + const wrapper = shallowMount(WSelect, { emits: ['update:modelValue'], props: { dropdownPosition: DropdownPosition.bottom, diff --git a/src/components/Select/__snapshots__/WSelect.spec.ts.snap b/src/components/Select/__snapshots__/WSelect.spec.ts.snap index 81f9184..8611945 100644 --- a/src/components/Select/__snapshots__/WSelect.spec.ts.snap +++ b/src/components/Select/__snapshots__/WSelect.spec.ts.snap @@ -1,215 +1,85 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`WSelect > renders properly 1`] = ` -
- - - - -
+ disabled="false" + dropdownshouldopen="[Function]" + filter="[Function]" + filterable="false" + filterby="[Function]" + getoptionkey="[Function]" + getoptionlabel="[Function]" + label="label" + mapkeydown="[Function]" + modelvalue="[object Object]" + multiple="false" + nodrop="false" + options="[object Object],[object Object]" + placeholder="" + pushtags="false" + reduce="[Function]" + resetonoptionschange="false" + searchable="false" + searchinputqueryselector="[type=search]" + selectable="[Function]" + selectonkeycodes="13" + selectontab="false" + taggable="false" + transition="dropdown" + uid="1" +/> `; exports[`WSelect > renders properly an icon when provided 1`] = ` -
- - - - -
+ disabled="false" + dropdownshouldopen="[Function]" + filter="[Function]" + filterable="false" + filterby="[Function]" + getoptionkey="[Function]" + getoptionlabel="[Function]" + label="label" + mapkeydown="[Function]" + modelvalue="[object Object]" + multiple="false" + nodrop="false" + options="[object Object],[object Object]" + placeholder="" + pushtags="false" + reduce="[Function]" + resetonoptionschange="false" + searchable="false" + searchinputqueryselector="[type=search]" + selectable="[Function]" + selectonkeycodes="13" + selectontab="false" + taggable="false" + transition="dropdown" + uid="2" +/> `; diff --git a/src/components/Tooltip/WTooltip.spec.ts b/src/components/Tooltip/WTooltip.spec.ts new file mode 100644 index 0000000..291b2da --- /dev/null +++ b/src/components/Tooltip/WTooltip.spec.ts @@ -0,0 +1,19 @@ +import { describe, it, expect } from 'vitest' +import { mount } from '@vue/test-utils' +import WTooltip from './WTooltip.vue' + +describe('WTooltip', () => { + it('renders properly', () => { + const wrapper = mount(WTooltip, { + props: { + bgColor: '#000', + }, + slots: { + main: `

Text

`, + tooltip: `

Text info

` + } + }) + + expect(wrapper.element).toMatchSnapshot() + }) +}) diff --git a/src/components/Tooltip/WTooltip.stories.ts b/src/components/Tooltip/WTooltip.stories.ts new file mode 100644 index 0000000..02c25a3 --- /dev/null +++ b/src/components/Tooltip/WTooltip.stories.ts @@ -0,0 +1,30 @@ +import type { Meta, StoryObj } from '@storybook/vue3' +import WTooltip from './WTooltip.vue' + +const meta: any = { + title: 'Example/WTooltip', + component: WTooltip, + tags: ['autodocs'], + argTypes: {}, + args: { + bgColor: '#000', + }, +} satisfies Meta + +export default meta +type Story = StoryObj + +export const Default: Story = { + render: (args: any) => ({ + components: { WTooltip }, + setup() { + return { args } + }, + template: ``, + args: { + bgColor: 'black-950', + } + }) +} diff --git a/src/components/Tooltip/WTooltip.vue b/src/components/Tooltip/WTooltip.vue new file mode 100644 index 0000000..7b5c6d2 --- /dev/null +++ b/src/components/Tooltip/WTooltip.vue @@ -0,0 +1,25 @@ + + + + + diff --git a/src/components/Tooltip/__snapshots__/WTooltip.spec.ts.snap b/src/components/Tooltip/__snapshots__/WTooltip.spec.ts.snap new file mode 100644 index 0000000..acbf789 --- /dev/null +++ b/src/components/Tooltip/__snapshots__/WTooltip.spec.ts.snap @@ -0,0 +1,26 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`WTooltip > renders properly 1`] = ` +
+ +

+ Text +

+ + +
+`; From 228022eea0a50e57fa6d0a76a13c99c230808e90 Mon Sep 17 00:00:00 2001 From: gabaldon Date: Wed, 4 Sep 2024 10:34:16 +0200 Subject: [PATCH 03/13] feat: export select and tooltip components --- src/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 9fbe31c..de5d888 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,8 +26,9 @@ import WNavbar from './components/Navbar/WNavbar.vue' import WPagination from './components/pagination/WPagination.vue' import WSection from './components/Section/WSection.vue' - +import WSelect from './components/Select/WSelect.vue' import WSpinner from './components/Spinner/WSpinner.vue' +import WTooltip from './components/Tooltip/WTooltip.vue' import WSocialsBar from './components/SocialsBar/WSocialsBar.vue' export { SOCIAL_URLS } from './components/SocialsBar/WSocialsBar' @@ -46,6 +47,7 @@ export { WNavbar, WPagination, WSection, + WSelect, WSocialsBar, WSpinner } @@ -63,7 +65,9 @@ export type WNavbar = typeof WNavbar export type WPagination = typeof WPagination export type WSection = typeof WSection export type WSocialsBar = typeof WSocialsBar +export type WSelect = typeof WSelect export type WSpinner = typeof WSpinner +export type WTooltip = typeof WTooltip import type { App } from 'vue' @@ -83,7 +87,9 @@ const WComponents = { app.component('WPagination', WPagination) app.component('WSection', WSection) app.component('WSocialsBar', WSocialsBar) + app.component('WSelect', WSelect) app.component('WSpinner', WSpinner) + app.component('WTooltip', WTooltip) } } From 2945a62ae7d5aa4afaf4e0da898ee12507307808 Mon Sep 17 00:00:00 2001 From: gabaldon Date: Wed, 4 Sep 2024 11:19:26 +0200 Subject: [PATCH 04/13] refactor: update enums --- src/components/Select/WSelect.spec.ts | 4 ++-- src/components/Select/WSelect.ts | 4 ++-- src/components/Select/WSelect.vue | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/Select/WSelect.spec.ts b/src/components/Select/WSelect.spec.ts index 75104af..fa8017b 100644 --- a/src/components/Select/WSelect.spec.ts +++ b/src/components/Select/WSelect.spec.ts @@ -9,7 +9,7 @@ describe('WSelect', () => { const wrapper = shallowMount(WSelect, { emits: ['update:modelValue'], props: { - dropdownPosition: DropdownPosition.bottom, + dropdownPosition: DropdownPosition.Bottom, modelValue: { key: 'en', label: 'English', @@ -36,7 +36,7 @@ describe('WSelect', () => { const wrapper = shallowMount(WSelect, { emits: ['update:modelValue'], props: { - dropdownPosition: DropdownPosition.bottom, + dropdownPosition: DropdownPosition.Bottom, modelValue: { key: 'en', label: 'English', diff --git a/src/components/Select/WSelect.ts b/src/components/Select/WSelect.ts index 2dca31b..e5b0cd4 100644 --- a/src/components/Select/WSelect.ts +++ b/src/components/Select/WSelect.ts @@ -1,6 +1,6 @@ export type Option = {key: string, label: string, icon: string | null} export enum DropdownPosition { - top = 'top', - bottom = 'bottom' + Top = 'top', + Bottom = 'bottom' } export const dropdownPostions = Object.values(DropdownPosition) \ No newline at end of file diff --git a/src/components/Select/WSelect.vue b/src/components/Select/WSelect.vue index 6ffefcf..0a88bfc 100644 --- a/src/components/Select/WSelect.vue +++ b/src/components/Select/WSelect.vue @@ -48,7 +48,7 @@ const props = defineProps({ }, dropdownPosition: { type: String as PropType, - default: DropdownPosition.bottom, + default: DropdownPosition.Bottom, validator(value: DropdownPosition) { return dropdownPostions.includes(value) } @@ -63,7 +63,7 @@ const props = defineProps({ } }) -const position = computed(() => props.dropdownPosition === DropdownPosition.top ? '-210%' : '110%') +const position = computed(() => props.dropdownPosition === DropdownPosition.Top ? '-210%' : '110%') - diff --git a/src/components/Tooltip/WTooltip.spec.ts b/src/components/Tooltip/WTooltip.spec.ts index 291b2da..b632b8f 100644 --- a/src/components/Tooltip/WTooltip.spec.ts +++ b/src/components/Tooltip/WTooltip.spec.ts @@ -6,7 +6,7 @@ describe('WTooltip', () => { it('renders properly', () => { const wrapper = mount(WTooltip, { props: { - bgColor: '#000', + bgColor: '#000' }, slots: { main: `

Text

`, diff --git a/src/components/Tooltip/WTooltip.stories.ts b/src/components/Tooltip/WTooltip.stories.ts index 02c25a3..79ac600 100644 --- a/src/components/Tooltip/WTooltip.stories.ts +++ b/src/components/Tooltip/WTooltip.stories.ts @@ -1,14 +1,18 @@ import type { Meta, StoryObj } from '@storybook/vue3' import WTooltip from './WTooltip.vue' +import { TooltipPosition, tooltipPostions } from './WTooltip' const meta: any = { title: 'Example/WTooltip', component: WTooltip, tags: ['autodocs'], - argTypes: {}, + argTypes: { + position: { control: 'select', options: tooltipPostions } + }, args: { bgColor: '#000', - }, + position: TooltipPosition.CenterTop + } } satisfies Meta export default meta @@ -20,11 +24,11 @@ export const Default: Story = { setup() { return { args } }, - template: ``, args: { - bgColor: 'black-950', + bgColor: 'black-950' } }) } diff --git a/src/components/Tooltip/WTooltip.ts b/src/components/Tooltip/WTooltip.ts new file mode 100644 index 0000000..0ba88d9 --- /dev/null +++ b/src/components/Tooltip/WTooltip.ts @@ -0,0 +1,9 @@ +export enum TooltipPosition { + CenterTop = 'center-top', + RightTop = 'right-top', + LeftTop = 'left-top', + CenterBottom = 'center-bottom', + RightBottom = 'right-bottom', + LeftBottom = 'left-bottom' +} +export const tooltipPostions = Object.values(TooltipPosition) diff --git a/src/components/Tooltip/WTooltip.vue b/src/components/Tooltip/WTooltip.vue index 7b5c6d2..cba96f2 100644 --- a/src/components/Tooltip/WTooltip.vue +++ b/src/components/Tooltip/WTooltip.vue @@ -1,20 +1,42 @@ - From c6bea03dda68de5d6ab17a965786750ffae566ca Mon Sep 17 00:00:00 2001 From: gabaldon Date: Thu, 5 Sep 2024 12:03:58 +0200 Subject: [PATCH 08/13] feat: add position options to select --- src/components/Select/WSelect.stories.ts | 16 ++++-- src/components/Select/WSelect.ts | 9 +++- src/components/Select/WSelect.vue | 69 +++++++++++++++--------- 3 files changed, 63 insertions(+), 31 deletions(-) diff --git a/src/components/Select/WSelect.stories.ts b/src/components/Select/WSelect.stories.ts index f364038..42904bd 100644 --- a/src/components/Select/WSelect.stories.ts +++ b/src/components/Select/WSelect.stories.ts @@ -1,6 +1,11 @@ import type { Meta, StoryObj } from '@storybook/vue3' import WSelect from './WSelect.vue' -import { dropdownPostions } from './WSelect' +import { + DropdownXPosition, + dropdownXPositions, + DropdownYPosition, + dropdownYPositions +} from './WSelect' import { ref } from 'vue' import 'vue-select/dist/vue-select.css' import Icon from '@/assets/svg/navigation-cursor.svg?component' @@ -10,9 +15,12 @@ const meta: any = { component: WSelect, tags: ['autodocs'], argTypes: { - dropdownPosition: { control: 'select', options: dropdownPostions } + dropdownYPosition: { control: 'select', options: dropdownYPositions }, + dropdownXPosition: { control: 'select', options: dropdownXPositions } }, args: { + dropdownXPosition: DropdownXPosition.Right, + dropdownYPosition: DropdownYPosition.Bottom, options: [ { key: 'en', @@ -47,8 +55,10 @@ export const Default: Story = { return { args, model, update } }, - template: ``, + template: `
`, args: { + dropdownXPosition: DropdownXPosition.Right, + dropdownYPosition: DropdownYPosition.Bottom, options: [ { key: 'en', diff --git a/src/components/Select/WSelect.ts b/src/components/Select/WSelect.ts index a9ef07c..eddac86 100644 --- a/src/components/Select/WSelect.ts +++ b/src/components/Select/WSelect.ts @@ -1,6 +1,11 @@ export type Option = { key: string; label: string; icon: string | null } -export enum DropdownPosition { +export enum DropdownYPosition { Top = 'top', Bottom = 'bottom' } -export const dropdownPostions = Object.values(DropdownPosition) +export enum DropdownXPosition { + Right = 'right', + Left = 'left' +} +export const dropdownYPositions = Object.values(DropdownYPosition) +export const dropdownXPositions = Object.values(DropdownXPosition) diff --git a/src/components/Select/WSelect.vue b/src/components/Select/WSelect.vue index 25e249c..b6195af 100644 --- a/src/components/Select/WSelect.vue +++ b/src/components/Select/WSelect.vue @@ -8,6 +8,7 @@ :filterable="false" :searchable="false" class="language-selector" + :class="xPosition" >