-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3473704
commit 12499c3
Showing
7 changed files
with
362 additions
and
1 deletion.
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
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,80 @@ | ||
<template> | ||
<!-- <label for="vl-select-select-3" class="vl-form__label"> | ||
Kies een stad of land | ||
</label> --> | ||
<div @click="showResults = !showResults" class="js-vl-select" role="listbox" data-type="select-one" tabindex="0" | ||
dir="ltr"> | ||
<div class="vl-select__inner"> | ||
<select name="vl-select-select-3" id="vl-select-select-3" | ||
class="vl-select vl-select--block vl-input-field is-hidden" tabindex="-1" style="display:none;" | ||
data-choice="active"> | ||
<option :value="selectedOption.value" selected>{{ selectedOption.label }}</option> | ||
</select> | ||
<div class="vl-input-field"> | ||
<div class="vl-select__item vl-select__item--selectable" data-item="" :data-id="selectedOption.value" | ||
:data-value="selectedOption.value"> | ||
{{ selectedOption.label }} | ||
</div> | ||
</div> | ||
</div> | ||
<div v-if="showResults" class="vl-select__list vl-select__list--dropdown"> | ||
<div class="vl-select__list" dir="ltr" role="listbox"> | ||
<template v-for="option in options"> | ||
<div class="vl-select__item vl-select__item--choice vl-select__item--selectable" | ||
:class="{ 'is-highlighted': option.selected, '': !option.selected }" data-select-text="Press to select" | ||
data-choice="" :data-id="option.value" :data-value="option.value" data-choice-selectable="" :id="option.value" | ||
role="treeitem" @click="selectOption(option)"> | ||
<div> | ||
{{ option.label }} | ||
</div> | ||
</div> | ||
</template> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
<script lang="ts" setup> | ||
import type { ISelectOption } from '@models/select'; | ||
import { ref } from 'vue'; | ||
const showResults = ref<boolean>(false); | ||
const options = [ | ||
{ label: 'België', value: 'België', selected: true }, | ||
{ label: 'Frankrijk', value: 'Frankrijk', selected: false }, | ||
{ | ||
label: 'Duitsland - Land in Centraal-Europa. Het heeft een grondgebied van 357.022 km² en grenst in het noorden aan de Oostzee.', | ||
value: 'Duitsland', selected: false | ||
} | ||
] as ISelectOption[]; | ||
const selectedOption = ref<ISelectOption>(options.find((option) => option.selected) as ISelectOption); | ||
const selectOption = (option: ISelectOption) => { | ||
selectedOption.value = option; | ||
options.forEach(option => option.selected = false); | ||
selectedOption.value.selected = true; | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
@import 'pyoes/scss/base-variables'; | ||
.js-vl-select { | ||
& .vl-select__list--dropdown { | ||
display: block !important; | ||
} | ||
& .vl-select__item.vl-select__item--choice.vl-select__item--selectable:hover { | ||
background-color: $light-purple; | ||
} | ||
.vl-select__item.vl-select__item--choice.vl-select__item--selectable { | ||
height: auto !important; | ||
overflow-x: hidden !important; | ||
overflow-y: auto !important; | ||
} | ||
} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface ISelectOption { | ||
label: string; | ||
value: string; | ||
selected: boolean; | ||
} |
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,115 @@ | ||
import '@/scss/main.scss'; | ||
import OeSelect from '../../components/dumb/OeSelect.vue'; | ||
// import type { IAutocompleteOption } from '../../models/autocomplete'; | ||
import type { Meta, StoryObj } from '@storybook/vue3'; | ||
|
||
const meta: Meta<typeof OeSelect> = { | ||
title: 'Dumb components/Select', | ||
component: OeSelect, | ||
tags: ['autodocs'], | ||
parameters: { | ||
docs: { | ||
story: { | ||
height: '250px', | ||
}, | ||
}, | ||
}, | ||
argTypes: { | ||
// id: { | ||
// control: 'text', | ||
// description: 'Unique id for this autocomplete instance', | ||
// }, | ||
// value: { | ||
// control: 'object', | ||
// description: 'Selected option', | ||
// table: { | ||
// type: { summary: 'IAutocompleteOption' }, | ||
// defaultValue: { summary: 'undefined' }, | ||
// }, | ||
// }, | ||
// autoselect: { | ||
// control: 'boolean', | ||
// description: 'Whether to autoselect the option if only 1 result is left', | ||
// }, | ||
// minChars: { | ||
// control: 'number', | ||
// description: 'Number of characters needed before callbackFn is triggered', | ||
// }, | ||
// placeholder: { | ||
// control: 'text', | ||
// description: 'Placeholder text', | ||
// }, | ||
// callbackFn: { | ||
// control: 'function', | ||
// description: 'Callback function that provides the options', | ||
// table: { | ||
// type: { summary: 'Should return IAutocompleteOption[]' }, | ||
// }, | ||
// }, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof OeSelect>; | ||
|
||
export const Default: Story = {}; | ||
|
||
// export const CustomCallbackFunction: Story = { | ||
// render: () => ({ | ||
// components: { | ||
// OeSelect, | ||
// }, | ||
// setup() { | ||
// const callback = (s: string): Promise<IAutocompleteOption[]> => { | ||
// return new Promise(function (resolve) { | ||
// // Fake delay to show the loader | ||
// setTimeout(function () { | ||
// resolve([ | ||
// { | ||
// title: s, | ||
// }, | ||
// { | ||
// title: 'dummy', | ||
// }, | ||
// ]); | ||
// }, 3000); | ||
// }); | ||
// }; | ||
|
||
// return { callback }; | ||
// }, | ||
// template: `<oe-autocomplete :callbackFn="callback"></oe-autocomplete>`, | ||
// }), | ||
// }; | ||
|
||
export const Autoselect: Story = { | ||
render: () => ({ | ||
components: { | ||
OeSelect, | ||
}, | ||
// setup() { | ||
// const callback = (): Promise<IAutocompleteOption[]> => { | ||
// return new Promise(function (resolve) { | ||
// // Fake delay to show the loader | ||
// setTimeout(function () { | ||
// resolve([ | ||
// { | ||
// title: 'dummy', | ||
// }, | ||
// ]); | ||
// }, 3000); | ||
// }); | ||
// }; | ||
|
||
// return { callback }; | ||
// }, | ||
template: `<oe-select></oe-select>`, | ||
}), | ||
// parameters: { | ||
// docs: { | ||
// description: { | ||
// story: 'Search for "dum" to have 1 result.', | ||
// }, | ||
// }, | ||
// }, | ||
}; |
Oops, something went wrong.