From 28c561d16a4c3d904643162c1a833180343152e7 Mon Sep 17 00:00:00 2001 From: Ethan Davidson <31261035+EthanThatOneKid@users.noreply.github.com> Date: Wed, 6 Mar 2024 10:52:15 -0800 Subject: [PATCH 1/5] reorganize components again --- .../form/question_input/question_input.svelte | 59 ------------------- .../question_list_editor.svelte | 7 ++- .../{form => }/form_editor/form_editor.svelte | 0 src/lib/components/list_input/list_input.ts | 2 +- .../question_input/question_input.svelte | 53 +++++++++++++++++ .../availability_question_input.svelte | 2 +- .../availability_question_input_editor.svelte | 0 .../boolean/boolean_question_input.svelte | 2 +- .../boolean_question_input_editor.svelte | 0 .../color/color_question_input.svelte | 3 +- .../color/color_question_input_editor.svelte | 0 .../questions/date/date_question_input.svelte | 2 +- .../date/date_question_input_editor.svelte | 0 .../datetime/datetime_question_input.svelte} | 2 +- .../datetime_question_input_editor.svelte | 0 .../number/number_question_input.svelte | 2 +- .../number_question_input_editor.svelte | 0 .../radio_group_question_input.svelte | 2 +- .../radio_group_question_input_editor.svelte | 0 .../select/select_question_input.svelte | 2 +- .../select_question_input_editor.svelte | 0 .../questions/text/text_question_input.svelte | 2 +- .../text/text_question_input_editor.svelte | 0 .../textarea/adjustable_textarea_height.ts | 22 +++++++ .../textarea/textarea_question_input.svelte | 23 +------- .../textarea_question_input_editor.svelte | 0 .../questions/time/time_question_input.svelte | 2 +- .../time/time_question_input_editor.svelte | 0 .../timezone/timezone_question_input.svelte | 2 +- .../timezone_question_input_editor.svelte | 0 src/lib/form/submission.ts | 17 +----- 31 files changed, 97 insertions(+), 109 deletions(-) delete mode 100644 src/lib/components/form/question_input/question_input.svelte rename src/lib/components/{form => }/form_editor/form_editor.svelte (100%) create mode 100644 src/lib/components/question_input/question_input.svelte rename src/lib/components/{form => }/questions/availability/availability_question_input.svelte (95%) rename src/lib/components/{form => }/questions/availability/availability_question_input_editor.svelte (100%) rename src/lib/components/{form => }/questions/boolean/boolean_question_input.svelte (89%) rename src/lib/components/{form => }/questions/boolean/boolean_question_input_editor.svelte (100%) rename src/lib/components/{form => }/questions/color/color_question_input.svelte (84%) rename src/lib/components/{form => }/questions/color/color_question_input_editor.svelte (100%) rename src/lib/components/{form => }/questions/date/date_question_input.svelte (87%) rename src/lib/components/{form => }/questions/date/date_question_input_editor.svelte (100%) rename src/lib/components/{form/questions/datetime/datetime_question_imput.svelte => questions/datetime/datetime_question_input.svelte} (86%) rename src/lib/components/{form => }/questions/datetime/datetime_question_input_editor.svelte (100%) rename src/lib/components/{form => }/questions/number/number_question_input.svelte (88%) rename src/lib/components/{form => }/questions/number/number_question_input_editor.svelte (100%) rename src/lib/components/{form => }/questions/radio_group/radio_group_question_input.svelte (96%) rename src/lib/components/{form => }/questions/radio_group/radio_group_question_input_editor.svelte (100%) rename src/lib/components/{form => }/questions/select/select_question_input.svelte (88%) rename src/lib/components/{form => }/questions/select/select_question_input_editor.svelte (100%) rename src/lib/components/{form => }/questions/text/text_question_input.svelte (94%) rename src/lib/components/{form => }/questions/text/text_question_input_editor.svelte (100%) create mode 100644 src/lib/components/questions/textarea/adjustable_textarea_height.ts rename src/lib/components/{form => }/questions/textarea/textarea_question_input.svelte (58%) rename src/lib/components/{form => }/questions/textarea/textarea_question_input_editor.svelte (100%) rename src/lib/components/{form => }/questions/time/time_question_input.svelte (87%) rename src/lib/components/{form => }/questions/time/time_question_input_editor.svelte (100%) rename src/lib/components/{form => }/questions/timezone/timezone_question_input.svelte (92%) rename src/lib/components/{form => }/questions/timezone/timezone_question_input_editor.svelte (100%) diff --git a/src/lib/components/form/question_input/question_input.svelte b/src/lib/components/form/question_input/question_input.svelte deleted file mode 100644 index 17e49d9..0000000 --- a/src/lib/components/form/question_input/question_input.svelte +++ /dev/null @@ -1,59 +0,0 @@ - - -
- {#if data.type === QuestionType.BOOLEAN} - - {:else if data.type === QuestionType.TEXT} - - {:else if data.type === QuestionType.RADIO_GROUP} - - {:else if data.type === QuestionType.NUMBER} - - {:else if data.type === QuestionType.COLOR} - - {:else if data.type === QuestionType.TEXTAREA} - - {:else if data.type === QuestionType.DATE} - - {:else if data.type === QuestionType.AVAILABILITY} - - {:else if data.type === QuestionType.DATETIME} - - {:else if data.type === QuestionType.TIME} - - {:else if data.type === QuestionType.SELECT} - - {:else if data.type === QuestionType.TIMEZONE} - - {/if} -
- - diff --git a/src/lib/components/form/question_list_editor/question_list_editor.svelte b/src/lib/components/form/question_list_editor/question_list_editor.svelte index 1084c92..c5f9ff2 100644 --- a/src/lib/components/form/question_list_editor/question_list_editor.svelte +++ b/src/lib/components/form/question_list_editor/question_list_editor.svelte @@ -2,12 +2,12 @@ import type { QuestionList } from '$lib/form'; import { QuestionType } from '$lib/form'; import ListInput from '$lib/components/list_input/list_input.svelte'; - import QuestionInput from '$lib/components/form/question_input/question_input.svelte'; + import QuestionInput from '$lib/components/question_input/question_input.svelte'; import QuestionInputEditor from '$lib/components/form/question_input_editor/question_input_editor.svelte'; import AddItem from './add_item.svelte'; import DeleteItem from './delete_item.svelte'; - export let value: QuestionList; + export let data: QuestionList; ; +export type ItemProps = object; export interface AddItemProps { addAction(item: ItemProps): void; diff --git a/src/lib/components/question_input/question_input.svelte b/src/lib/components/question_input/question_input.svelte new file mode 100644 index 0000000..e5bf2bd --- /dev/null +++ b/src/lib/components/question_input/question_input.svelte @@ -0,0 +1,53 @@ + + +
+ {#if $$props.type === QuestionType.BOOLEAN} + + {:else if $$props.type === QuestionType.TEXT} + + {:else if $$props.type === QuestionType.RADIO_GROUP} + + {:else if $$props.type === QuestionType.NUMBER} + + {:else if $$props.type === QuestionType.COLOR} + + {:else if $$props.type === QuestionType.TEXTAREA} + + {:else if $$props.type === QuestionType.DATE} + + {:else if $$props.type === QuestionType.AVAILABILITY} + + {:else if $$props.type === QuestionType.DATETIME} + + {:else if $$props.type === QuestionType.TIME} + + {:else if $$props.type === QuestionType.SELECT} + + {/if} +
+ + diff --git a/src/lib/components/form/questions/availability/availability_question_input.svelte b/src/lib/components/questions/availability/availability_question_input.svelte similarity index 95% rename from src/lib/components/form/questions/availability/availability_question_input.svelte rename to src/lib/components/questions/availability/availability_question_input.svelte index 4cc1571..7203350 100644 --- a/src/lib/components/form/questions/availability/availability_question_input.svelte +++ b/src/lib/components/questions/availability/availability_question_input.svelte @@ -1,7 +1,7 @@
diff --git a/src/lib/components/form/questions/availability/availability_question_input_editor.svelte b/src/lib/components/questions/availability/availability_question_input_editor.svelte similarity index 100% rename from src/lib/components/form/questions/availability/availability_question_input_editor.svelte rename to src/lib/components/questions/availability/availability_question_input_editor.svelte diff --git a/src/lib/components/form/questions/boolean/boolean_question_input.svelte b/src/lib/components/questions/boolean/boolean_question_input.svelte similarity index 89% rename from src/lib/components/form/questions/boolean/boolean_question_input.svelte rename to src/lib/components/questions/boolean/boolean_question_input.svelte index 7df0a8b..dd7c933 100644 --- a/src/lib/components/form/questions/boolean/boolean_question_input.svelte +++ b/src/lib/components/questions/boolean/boolean_question_input.svelte @@ -1,7 +1,7 @@
diff --git a/src/lib/components/form/questions/boolean/boolean_question_input_editor.svelte b/src/lib/components/questions/boolean/boolean_question_input_editor.svelte similarity index 100% rename from src/lib/components/form/questions/boolean/boolean_question_input_editor.svelte rename to src/lib/components/questions/boolean/boolean_question_input_editor.svelte diff --git a/src/lib/components/form/questions/color/color_question_input.svelte b/src/lib/components/questions/color/color_question_input.svelte similarity index 84% rename from src/lib/components/form/questions/color/color_question_input.svelte rename to src/lib/components/questions/color/color_question_input.svelte index cdce196..427ef42 100644 --- a/src/lib/components/form/questions/color/color_question_input.svelte +++ b/src/lib/components/questions/color/color_question_input.svelte @@ -1,6 +1,7 @@
diff --git a/src/lib/components/form/questions/color/color_question_input_editor.svelte b/src/lib/components/questions/color/color_question_input_editor.svelte similarity index 100% rename from src/lib/components/form/questions/color/color_question_input_editor.svelte rename to src/lib/components/questions/color/color_question_input_editor.svelte diff --git a/src/lib/components/form/questions/date/date_question_input.svelte b/src/lib/components/questions/date/date_question_input.svelte similarity index 87% rename from src/lib/components/form/questions/date/date_question_input.svelte rename to src/lib/components/questions/date/date_question_input.svelte index 1d3043b..89b66cd 100644 --- a/src/lib/components/form/questions/date/date_question_input.svelte +++ b/src/lib/components/questions/date/date_question_input.svelte @@ -1,7 +1,7 @@
diff --git a/src/lib/components/form/questions/date/date_question_input_editor.svelte b/src/lib/components/questions/date/date_question_input_editor.svelte similarity index 100% rename from src/lib/components/form/questions/date/date_question_input_editor.svelte rename to src/lib/components/questions/date/date_question_input_editor.svelte diff --git a/src/lib/components/form/questions/datetime/datetime_question_imput.svelte b/src/lib/components/questions/datetime/datetime_question_input.svelte similarity index 86% rename from src/lib/components/form/questions/datetime/datetime_question_imput.svelte rename to src/lib/components/questions/datetime/datetime_question_input.svelte index a12dd94..49e0182 100644 --- a/src/lib/components/form/questions/datetime/datetime_question_imput.svelte +++ b/src/lib/components/questions/datetime/datetime_question_input.svelte @@ -1,7 +1,7 @@
diff --git a/src/lib/components/form/questions/datetime/datetime_question_input_editor.svelte b/src/lib/components/questions/datetime/datetime_question_input_editor.svelte similarity index 100% rename from src/lib/components/form/questions/datetime/datetime_question_input_editor.svelte rename to src/lib/components/questions/datetime/datetime_question_input_editor.svelte diff --git a/src/lib/components/form/questions/number/number_question_input.svelte b/src/lib/components/questions/number/number_question_input.svelte similarity index 88% rename from src/lib/components/form/questions/number/number_question_input.svelte rename to src/lib/components/questions/number/number_question_input.svelte index 69a2d9d..605ee60 100644 --- a/src/lib/components/form/questions/number/number_question_input.svelte +++ b/src/lib/components/questions/number/number_question_input.svelte @@ -1,7 +1,7 @@
diff --git a/src/lib/components/form/questions/number/number_question_input_editor.svelte b/src/lib/components/questions/number/number_question_input_editor.svelte similarity index 100% rename from src/lib/components/form/questions/number/number_question_input_editor.svelte rename to src/lib/components/questions/number/number_question_input_editor.svelte diff --git a/src/lib/components/form/questions/radio_group/radio_group_question_input.svelte b/src/lib/components/questions/radio_group/radio_group_question_input.svelte similarity index 96% rename from src/lib/components/form/questions/radio_group/radio_group_question_input.svelte rename to src/lib/components/questions/radio_group/radio_group_question_input.svelte index e38a33f..226fcb3 100644 --- a/src/lib/components/form/questions/radio_group/radio_group_question_input.svelte +++ b/src/lib/components/questions/radio_group/radio_group_question_input.svelte @@ -1,7 +1,7 @@
diff --git a/src/lib/components/form/questions/radio_group/radio_group_question_input_editor.svelte b/src/lib/components/questions/radio_group/radio_group_question_input_editor.svelte similarity index 100% rename from src/lib/components/form/questions/radio_group/radio_group_question_input_editor.svelte rename to src/lib/components/questions/radio_group/radio_group_question_input_editor.svelte diff --git a/src/lib/components/form/questions/select/select_question_input.svelte b/src/lib/components/questions/select/select_question_input.svelte similarity index 88% rename from src/lib/components/form/questions/select/select_question_input.svelte rename to src/lib/components/questions/select/select_question_input.svelte index b618e2e..33ebf02 100644 --- a/src/lib/components/form/questions/select/select_question_input.svelte +++ b/src/lib/components/questions/select/select_question_input.svelte @@ -1,7 +1,7 @@
diff --git a/src/lib/components/form/questions/select/select_question_input_editor.svelte b/src/lib/components/questions/select/select_question_input_editor.svelte similarity index 100% rename from src/lib/components/form/questions/select/select_question_input_editor.svelte rename to src/lib/components/questions/select/select_question_input_editor.svelte diff --git a/src/lib/components/form/questions/text/text_question_input.svelte b/src/lib/components/questions/text/text_question_input.svelte similarity index 94% rename from src/lib/components/form/questions/text/text_question_input.svelte rename to src/lib/components/questions/text/text_question_input.svelte index d94e733..82e2538 100644 --- a/src/lib/components/form/questions/text/text_question_input.svelte +++ b/src/lib/components/questions/text/text_question_input.svelte @@ -1,7 +1,7 @@
diff --git a/src/lib/components/form/questions/text/text_question_input_editor.svelte b/src/lib/components/questions/text/text_question_input_editor.svelte similarity index 100% rename from src/lib/components/form/questions/text/text_question_input_editor.svelte rename to src/lib/components/questions/text/text_question_input_editor.svelte diff --git a/src/lib/components/questions/textarea/adjustable_textarea_height.ts b/src/lib/components/questions/textarea/adjustable_textarea_height.ts new file mode 100644 index 0000000..0c4edf5 --- /dev/null +++ b/src/lib/components/questions/textarea/adjustable_textarea_height.ts @@ -0,0 +1,22 @@ +import type { Action } from 'svelte/action'; + +/** + * adjustableTextareaHeight is a progressive enhancement for adjusting height + * of textarea. + * + * @see https://svelte.dev/docs/svelte-action + */ +export const adjustableTextareaHeight: Action = (node) => { + function handleInput() { + node.style.height = 'auto'; + node.style.height = node.scrollHeight + 'px'; + } + + node.addEventListener('input', handleInput); + + return { + destroy() { + node.removeEventListener('input', handleInput); + } + }; +}; diff --git a/src/lib/components/form/questions/textarea/textarea_question_input.svelte b/src/lib/components/questions/textarea/textarea_question_input.svelte similarity index 58% rename from src/lib/components/form/questions/textarea/textarea_question_input.svelte rename to src/lib/components/questions/textarea/textarea_question_input.svelte index d172100..898bd15 100644 --- a/src/lib/components/form/questions/textarea/textarea_question_input.svelte +++ b/src/lib/components/questions/textarea/textarea_question_input.svelte @@ -1,31 +1,14 @@
{data.content}