From 319bba35c5edfdc6a8425c1c984ca0b886c54470 Mon Sep 17 00:00:00 2001 From: dcruvolo Date: Thu, 31 Oct 2024 16:51:19 +0100 Subject: [PATCH 01/46] feat: added tw classes for listbox --- apps/tailwind-components/assets/css/main.css | 8 ++++++++ apps/tailwind-components/tailwind.config.js | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/apps/tailwind-components/assets/css/main.css b/apps/tailwind-components/assets/css/main.css index 258b7b4a10..6b5787e37e 100644 --- a/apps/tailwind-components/assets/css/main.css +++ b/apps/tailwind-components/assets/css/main.css @@ -98,6 +98,9 @@ --background-color-invalid: var(--color-red-200); --background-color-input: var(--color-white); --background-color-input-checked: var(--color-yellow-500); + --background-color-listbox: var(--color-white); + --background-color-listbox-hover: var(--color-gray-100); + --background-color-listbox-selected: var(--color-umcg-light-blue); --text-color-button-primary: var(--color-gray-900); --text-color-button-primary-hover: var(--color-gray-900); @@ -143,6 +146,10 @@ --text-color-pagination-input: var(--color-blue-800); --text-color-pagination-hover: var(--color-white); --text-color-footer-link: var(--color-yellow-500); + --text-color-listbox: var(--color-black); + --text-color-listbox-hover: var(--color-black); + --text-color-listbox-selected: var(--color-blue-50); + --text-color-invalid: var(--color-red-500); --text-color-valid: var(--color-green-800); @@ -168,6 +175,7 @@ --border-color-pagination: var(--color-transparent); --border-color-input: var(--color-transparent); --border-color-input-inverted: var(--color-gray-600); + --border-color-listbox-option: var(--color-gray-100); --border-radius-3px: 3px; --border-radius-50px: 50px; diff --git a/apps/tailwind-components/tailwind.config.js b/apps/tailwind-components/tailwind.config.js index d76d8e6b90..a3ca9dc531 100644 --- a/apps/tailwind-components/tailwind.config.js +++ b/apps/tailwind-components/tailwind.config.js @@ -153,6 +153,9 @@ module.exports = { "disabled": "var(--background-color-disabled)", "invalid": "var(--background-color-invalid)", "input": "var(--background-color-input)", + "listbox": "var(--background-color-listbox)", + "listbox-hover": "var(--background-color-listbox-hover)", + "listbox-selected": "var(--background-color-listbox-selected)" }), textColor: ({ theme }) => ({ "button-primary": "var(--text-color-button-primary)", @@ -201,6 +204,9 @@ module.exports = { "valid": "var(--text-color-valid)", "disabled": "var(--text-color-disabled)", "required": "var(--text-color-required)", + "listbox": "var(--text-color-listbox)", + "listbox-hover": "var(--text-color-listbox-hover)", + "listbox-selected": "var(--text-color-listbox-selected)", }), borderColor: ({ theme }) => ({ "button-primary": "var(--border-color-button-primary)", @@ -224,6 +230,7 @@ module.exports = { "disabled": "var(--border-color-disabled)", "input": "var(--border-color-input)", "input-inverted": "var(--border-color-input-inverted)", + "listbox-option": "var(--border-color-listbox-option)" }), stroke: ({ theme }) => ({ "input": "var(--border-color-input)", From 209e2d983a16a6dac91250a043942b8b0c1e21c8 Mon Sep 17 00:00:00 2001 From: dcruvolo Date: Thu, 31 Oct 2024 16:51:37 +0100 Subject: [PATCH 02/46] initial listbox component --- .../components/input/Listbox.vue | 145 ++++++++++++++++++ .../pages/input/Listbox.story.vue | 30 ++++ 2 files changed, 175 insertions(+) create mode 100644 apps/tailwind-components/components/input/Listbox.vue create mode 100644 apps/tailwind-components/pages/input/Listbox.story.vue diff --git a/apps/tailwind-components/components/input/Listbox.vue b/apps/tailwind-components/components/input/Listbox.vue new file mode 100644 index 0000000000..a52a2da1fb --- /dev/null +++ b/apps/tailwind-components/components/input/Listbox.vue @@ -0,0 +1,145 @@ + + + diff --git a/apps/tailwind-components/pages/input/Listbox.story.vue b/apps/tailwind-components/pages/input/Listbox.story.vue new file mode 100644 index 0000000000..915a18d0f1 --- /dev/null +++ b/apps/tailwind-components/pages/input/Listbox.story.vue @@ -0,0 +1,30 @@ + + + From 4bf9393dbb796f78bce36018c488b669d3b22860 Mon Sep 17 00:00:00 2001 From: dcruvolo Date: Fri, 1 Nov 2024 15:08:27 +0100 Subject: [PATCH 03/46] revised listbox classes --- apps/tailwind-components/assets/css/main.css | 2 +- apps/tailwind-components/tailwind.config.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/tailwind-components/assets/css/main.css b/apps/tailwind-components/assets/css/main.css index 6b5787e37e..726739346a 100644 --- a/apps/tailwind-components/assets/css/main.css +++ b/apps/tailwind-components/assets/css/main.css @@ -149,7 +149,7 @@ --text-color-listbox: var(--color-black); --text-color-listbox-hover: var(--color-black); --text-color-listbox-selected: var(--color-blue-50); - + --text-color-button-input-toggle: var(--color-black); --text-color-invalid: var(--color-red-500); --text-color-valid: var(--color-green-800); diff --git a/apps/tailwind-components/tailwind.config.js b/apps/tailwind-components/tailwind.config.js index a3ca9dc531..72a5e81fab 100644 --- a/apps/tailwind-components/tailwind.config.js +++ b/apps/tailwind-components/tailwind.config.js @@ -207,6 +207,7 @@ module.exports = { "listbox": "var(--text-color-listbox)", "listbox-hover": "var(--text-color-listbox-hover)", "listbox-selected": "var(--text-color-listbox-selected)", + "button-input-toggle": "var(--text-color-button-input-toggle)", }), borderColor: ({ theme }) => ({ "button-primary": "var(--border-color-button-primary)", @@ -238,6 +239,7 @@ module.exports = { fill: ({ theme }) => ({ "input": "var(--background-color-input)", "input-checked": "var(--background-color-input-checked)", + "listbox-selected": "var(--text-color-listbox-selected)", }), borderRadius: { "3px": "var(--border-radius-3px)", From 42d7c8ea04fda44fe27d85d28e561fd4c6bacb1e Mon Sep 17 00:00:00 2001 From: dcruvolo Date: Fri, 1 Nov 2024 15:08:56 +0100 Subject: [PATCH 04/46] feat: separated elements into child components --- .../components/input/Listbox.vue | 133 +++++------------- .../components/input/Listbox/List.vue | 28 ++++ .../components/input/Listbox/ListItem.vue | 82 +++++++++++ .../components/input/Listbox/Toggle.vue | 54 +++++++ .../pages/input/Listbox.story.vue | 7 +- 5 files changed, 207 insertions(+), 97 deletions(-) create mode 100644 apps/tailwind-components/components/input/Listbox/List.vue create mode 100644 apps/tailwind-components/components/input/Listbox/ListItem.vue create mode 100644 apps/tailwind-components/components/input/Listbox/Toggle.vue diff --git a/apps/tailwind-components/components/input/Listbox.vue b/apps/tailwind-components/components/input/Listbox.vue index a52a2da1fb..45fe49b629 100644 --- a/apps/tailwind-components/components/input/Listbox.vue +++ b/apps/tailwind-components/components/input/Listbox.vue @@ -1,82 +1,40 @@ @@ -85,14 +43,16 @@ import { useTemplateRefsList } from "@vueuse/core"; import { ref } from "vue"; interface IListboxOption { + elemId?: string; value: string | number | boolean; label?: string; + selected?: boolean; } withDefaults( defineProps<{ id: string; - listboxLabel: string; + listboxLabelId: string; listboxOptions: IListboxOption[]; required?: boolean; hasError?: boolean; @@ -106,40 +66,23 @@ withDefaults( ); const modelValue = defineModel(); -const selectedElemId = ref(""); const hoveredOption = ref(); const focusedOption = ref(); const listboxIsExpanded = ref(false); const listboxOptionRefs = useTemplateRefsList(); -function onToggleClick() { - listboxIsExpanded.value = !listboxIsExpanded.value; - if (listboxIsExpanded.value) { - listboxOptionRefs.value[0].focus(); - focusedOption.value = { - value: listboxOptionRefs.value[0].getAttribute("data-value") as string, - label: listboxOptionRefs.value[0].getAttribute("data-label") as string, - }; - } -} - -function onListboxSelection(option: IListboxOption, elemId: string) { - modelValue.value = option; - selectedElemId.value = elemId; - listboxIsExpanded.value = false; +function openCloseListbox(value: boolean) { + listboxIsExpanded.value = value; + // if (listboxIsExpanded.value) { + // console.log(listboxOptionRefs.value[0]); + // } } -function onListboxHover(option: IListboxOption) { - hoveredOption.value = option; - focusedOption.value = null; -} +// onMounted(() => console.dir(listboxOptionRefs.value[0])) -function onListboxFocus(option: IListboxOption) { - focusedOption.value = option; +function onSelection (data: IListboxOption) { + modelValue.value = data; } -function onKeyboardEvent(key: string, option: IListboxOption | null) { - console.log(key); -} diff --git a/apps/tailwind-components/components/input/Listbox/List.vue b/apps/tailwind-components/components/input/Listbox/List.vue new file mode 100644 index 0000000000..ce04525d90 --- /dev/null +++ b/apps/tailwind-components/components/input/Listbox/List.vue @@ -0,0 +1,28 @@ + + + diff --git a/apps/tailwind-components/components/input/Listbox/ListItem.vue b/apps/tailwind-components/components/input/Listbox/ListItem.vue new file mode 100644 index 0000000000..2e764952f8 --- /dev/null +++ b/apps/tailwind-components/components/input/Listbox/ListItem.vue @@ -0,0 +1,82 @@ + + + diff --git a/apps/tailwind-components/components/input/Listbox/Toggle.vue b/apps/tailwind-components/components/input/Listbox/Toggle.vue new file mode 100644 index 0000000000..15c1c52212 --- /dev/null +++ b/apps/tailwind-components/components/input/Listbox/Toggle.vue @@ -0,0 +1,54 @@ + + + diff --git a/apps/tailwind-components/pages/input/Listbox.story.vue b/apps/tailwind-components/pages/input/Listbox.story.vue index 915a18d0f1..42754fd753 100644 --- a/apps/tailwind-components/pages/input/Listbox.story.vue +++ b/apps/tailwind-components/pages/input/Listbox.story.vue @@ -1,7 +1,10 @@ diff --git a/apps/tailwind-components/components/input/Listbox/List.vue b/apps/tailwind-components/components/input/Listbox/List.vue index ce04525d90..6c43d8ea9f 100644 --- a/apps/tailwind-components/components/input/Listbox/List.vue +++ b/apps/tailwind-components/components/input/Listbox/List.vue @@ -2,12 +2,12 @@
    @@ -24,5 +24,4 @@ interface IListbox { withDefaults(defineProps(), { expanded: false, }); - diff --git a/apps/tailwind-components/components/input/Listbox/ListItem.vue b/apps/tailwind-components/components/input/Listbox/ListItem.vue index 2e764952f8..e26297761f 100644 --- a/apps/tailwind-components/components/input/Listbox/ListItem.vue +++ b/apps/tailwind-components/components/input/Listbox/ListItem.vue @@ -1,16 +1,15 @@