From 3cefad871e9b5ca5884e635079ff4e710b5a951e Mon Sep 17 00:00:00 2001 From: kaaps Date: Wed, 14 Feb 2024 17:11:22 +0000 Subject: [PATCH 1/9] fix: estimations --- src/components/blocks/estimation.svelte | 145 ++++++++++-------------- src/lib/estimations.ts | 80 ++++++++++--- 2 files changed, 129 insertions(+), 96 deletions(-) diff --git a/src/components/blocks/estimation.svelte b/src/components/blocks/estimation.svelte index fd7783f6..1072e3e3 100644 --- a/src/components/blocks/estimation.svelte +++ b/src/components/blocks/estimation.svelte @@ -2,49 +2,40 @@ import type { EstimationStoryblok } from '$types/bloks'; import IllustrationEmply from '../illustrations/assets/illustration-emply.webp'; import IllustrationEmplyLight from '../illustrations/assets/illustration-emply-light.webp'; - import ArrowLight from '../illustrations/assets/arrow-estimations-white.webp'; - import ArrowDark from '../illustrations/assets/arrow-estimations.webp'; import { theme } from '$lib/stores/theme'; - import { Icon, MultiSelect } from '@significa/svelte-ui'; + import { Radio } from '@significa/svelte-ui'; import clsx from 'clsx'; import ContactForm from '$components/contact-form.svelte'; import { estimations } from '$lib/estimations'; - import type { ListboxOption } from '@melt-ui/svelte/dist/builders/listbox/types'; + import HandAsset from '../illustrations/assets/hand.webp'; - import PreFooterAsset from '../illustrations/assets/pre-footer.webp'; - import PreFooterAssetLight from '../illustrations/assets/pre-footer-light.webp'; + import { t } from '$lib/i18n'; export let block: EstimationStoryblok; let open = false; - $: src = $theme === 'dark' ? IllustrationEmply : IllustrationEmplyLight; - $: srcArrow = $theme === 'dark' ? ArrowDark : ArrowLight; - - let selected: Record[]> = {}; + let selected: Array = []; - $: selectedMap = Object.entries(selected).map(([key, value]) => ({ key, value })); - - $: selectedKeyValues = selectedMap.map(({ value }) => value.map((v) => v.value)).flat(); + $: src = $theme === 'dark' ? IllustrationEmply : IllustrationEmplyLight; - let estimationsMap = estimations.map((v) => v.options.filter((o) => o.name)).flat(); + $: estimationsMap = estimations + .map((v, i) => v.options.filter((o) => o.name === selected[i])) + .flat(); - $: combinedBudgetPower = estimationsMap - .filter((r) => selectedKeyValues.includes(r.name)) - .reduce( - (a, b) => { - return { - lowBudget: a.lowBudget + Number(b['low-bud-point']), - highBudget: a.highBudget + Number(b['high-bud-point']), - lowPower: a.lowPower + Number(b['low-est-point']), - highPower: a.highPower + Number(b['high-est-point']) - }; - }, - { lowBudget: 0, highBudget: 0, lowPower: 0, highPower: 0 } - ); + $: combinedBudgetPower = estimationsMap.reduce( + (a, b) => { + return { + lowBudget: a.lowBudget + Number(b['low-est-point']) * 14500, + highBudget: a.highBudget + Number(b['high-est-point']) * 14500, + lowPower: a.lowPower + Number(b['low-est-point']), + highPower: a.highPower + Number(b['high-est-point']) + }; + }, + { lowBudget: 0, highBudget: 0, lowPower: 0, highPower: 0 } + ); - // open / close form $: Object.values(combinedBudgetPower).every((val) => val !== 0) ? (open = true) : (open = false); @@ -60,25 +51,16 @@
-
-
-
+
+

{block.title} @@ -86,48 +68,38 @@

{block.description}

-
- - {#each estimations as { name, options }} - o.name)} - bind:selected={selected[name]} - selectedLabel={name} - icon="plus" - class="w-full xs:w-fit" - /> - {/each} -
- -
- {#each selectedMap as option} - {#each option.value as op} +
+
+ {#each estimations as options, i}
- {op.label} - +

+ {options.name} +

+ + {#each options.options as opt} + + {/each}
{/each} - {/each} +
@@ -152,11 +124,18 @@ open ? 'xl:hidden xl:opacity-0' : 'right-0 opacity-100' )} > - +

-
+

{block.form_title} @@ -167,7 +146,7 @@

- +
diff --git a/src/lib/estimations.ts b/src/lib/estimations.ts index 3c904348..6384716d 100644 --- a/src/lib/estimations.ts +++ b/src/lib/estimations.ts @@ -1,27 +1,81 @@ export const estimations = [ { - name: 'Strategy', + name: 'Website', options: [ { - name: 'UX Research', + name: 'Design', 'low-est-point': '1', - 'high-est-point': '2', - 'low-bud-point': '10000', - 'high-bud-point': '20000' + 'high-est-point': '2' }, { - name: 'MVP build', + name: 'Design and development', + 'low-est-point': '2', + 'high-est-point': '4' + } + ] + }, + { + name: 'E-commerce', + options: [ + { + name: 'Design', + 'low-est-point': '2', + 'high-est-point': '3' + }, + { + name: 'Design and development', + 'low-est-point': '5', + 'high-est-point': '8' + } + ] + }, + { + name: 'Web app', + options: [ + { + name: 'Design', 'low-est-point': '1', - 'high-est-point': '2', - 'low-bud-point': '10000', - 'high-bud-point': '20000' + 'high-est-point': '3' }, { - name: 'Website', + name: 'Design and development', + 'low-est-point': '3', + 'high-est-point': '6' + } + ] + }, + { + name: 'Mobile app', + options: [ + { + name: 'Design', 'low-est-point': '1', - 'high-est-point': '2', - 'low-bud-point': '10000', - 'high-bud-point': '20000' + 'high-est-point': '3' + }, + { + name: 'Design and development', + 'low-est-point': '3', + 'high-est-point': '6' + } + ] + }, + { + name: 'Others (design and development)', + options: [ + { + name: 'TV App', + 'low-est-point': '2', + 'high-est-point': '5' + }, + { + name: 'Desktop App', + 'low-est-point': '3', + 'high-est-point': '6' + }, + { + name: 'Watch App', + 'low-est-point': '2', + 'high-est-point': '4' } ] } From 564746af8b608f459c75ec3e406b6c84edc63fc8 Mon Sep 17 00:00:00 2001 From: kaaps Date: Fri, 23 Feb 2024 11:34:31 +0000 Subject: [PATCH 2/9] fix: checkbox --- src/components/blocks/estimation.svelte | 70 ++++++++++++++++++------- 1 file changed, 50 insertions(+), 20 deletions(-) diff --git a/src/components/blocks/estimation.svelte b/src/components/blocks/estimation.svelte index 1072e3e3..3b385459 100644 --- a/src/components/blocks/estimation.svelte +++ b/src/components/blocks/estimation.svelte @@ -3,7 +3,7 @@ import IllustrationEmply from '../illustrations/assets/illustration-emply.webp'; import IllustrationEmplyLight from '../illustrations/assets/illustration-emply-light.webp'; import { theme } from '$lib/stores/theme'; - import { Radio } from '@significa/svelte-ui'; + import { CheckboxGroup, Radio } from '@significa/svelte-ui'; import clsx from 'clsx'; import ContactForm from '$components/contact-form.svelte'; import { estimations } from '$lib/estimations'; @@ -15,15 +15,25 @@ export let block: EstimationStoryblok; let open = false; + $: src = $theme === 'dark' ? IllustrationEmply : IllustrationEmplyLight; let selected: Array = []; - $: src = $theme === 'dark' ? IllustrationEmply : IllustrationEmplyLight; + $: selectedValuesToNotion = estimations + .map((estimation, index) => { + return estimation.options + .filter((option) => option.name === selected[index]) + .map((option) => `${estimation.name} / ${option.name}`); + }) + .flat() + .join(' , '); $: estimationsMap = estimations .map((v, i) => v.options.filter((o) => o.name === selected[i])) .flat(); + $: console.log(selectedValuesToNotion); + $: combinedBudgetPower = estimationsMap.reduce( (a, b) => { return { @@ -71,6 +81,7 @@
{#each estimations as options, i} + {@const isLast = estimations.length === i + 1}
@@ -79,23 +90,42 @@

{#each options.options as opt} - + {#if isLast} + + {:else} + + {/if} {/each}
{/each} @@ -146,7 +176,7 @@
- +
From d01787d66317325f4f9cac965382d70abcbe4fe2 Mon Sep 17 00:00:00 2001 From: kaaps Date: Tue, 27 Feb 2024 14:59:40 +0000 Subject: [PATCH 3/9] refactor: estimations --- src/components/blocks/estimation.svelte | 119 +++++++++++++----------- src/lib/estimations.ts | 5 +- 2 files changed, 70 insertions(+), 54 deletions(-) diff --git a/src/components/blocks/estimation.svelte b/src/components/blocks/estimation.svelte index 3b385459..e168013a 100644 --- a/src/components/blocks/estimation.svelte +++ b/src/components/blocks/estimation.svelte @@ -6,7 +6,7 @@ import { CheckboxGroup, Radio } from '@significa/svelte-ui'; import clsx from 'clsx'; import ContactForm from '$components/contact-form.svelte'; - import { estimations } from '$lib/estimations'; + import { estimations, estimationsCheckbox } from '$lib/estimations'; import HandAsset from '../illustrations/assets/hand.webp'; @@ -17,24 +17,31 @@ let open = false; $: src = $theme === 'dark' ? IllustrationEmply : IllustrationEmplyLight; - let selected: Array = []; + let selectedRadio: Array = []; + let selectedCheckbox: Array = []; - $: selectedValuesToNotion = estimations - .map((estimation, index) => { - return estimation.options - .filter((option) => option.name === selected[index]) - .map((option) => `${estimation.name} / ${option.name}`); - }) - .flat() - .join(' , '); + $: selectedValuesToNotion = [ + ...estimations.flatMap((estimation, index) => + estimation.options + .filter((option) => option.name === selectedRadio[index]) + .map((option) => `${estimation.name} / ${option.name}`) + ), + ...estimationsCheckbox.flatMap((estimation) => + estimation.options + .filter((option) => selectedCheckbox.includes(option.name)) + .map((option) => `${estimation.name} / ${option.name}`) + ) + ].join(' , '); - $: estimationsMap = estimations - .map((v, i) => v.options.filter((o) => o.name === selected[i])) + $: estimationsMapRadio = estimations + .map((v, i) => v.options.filter((o) => o.name === selectedRadio[i])) .flat(); - $: console.log(selectedValuesToNotion); + $: estimationsMapCheckbox = estimationsCheckbox + .map((v) => v.options.filter((v) => selectedCheckbox.includes(v.name))) + .flat(); - $: combinedBudgetPower = estimationsMap.reduce( + $: combinedBudgetPower = [...estimationsMapRadio, ...estimationsMapCheckbox].reduce( (a, b) => { return { lowBudget: a.lowBudget + Number(b['low-est-point']) * 14500, @@ -46,7 +53,7 @@ { lowBudget: 0, highBudget: 0, lowPower: 0, highPower: 0 } ); - $: Object.values(combinedBudgetPower).every((val) => val !== 0) ? (open = true) : (open = false); + $: open = Object.values(combinedBudgetPower).every((val) => val !== 0);
@@ -81,51 +88,57 @@
{#each estimations as options, i} - {@const isLast = estimations.length === i + 1} +
+

+ {options.name} +

+ + {#each options.options as opt} + + {/each} +
+ {/each} + {#each estimationsCheckbox as options}

{options.name}

{#each options.options as opt} - {#if isLast} - - {:else} - - {/if} + {/each}
{/each} diff --git a/src/lib/estimations.ts b/src/lib/estimations.ts index 6384716d..8f7e2bce 100644 --- a/src/lib/estimations.ts +++ b/src/lib/estimations.ts @@ -58,7 +58,10 @@ export const estimations = [ 'high-est-point': '6' } ] - }, + } +]; + +export const estimationsCheckbox = [ { name: 'Others (design and development)', options: [ From 74645a93f1a3de981ae3ba7762d94ea44fac6c59 Mon Sep 17 00:00:00 2001 From: kaaps Date: Tue, 27 Feb 2024 17:07:47 +0000 Subject: [PATCH 4/9] fix: mobile --- src/components/blocks/estimation.svelte | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/blocks/estimation.svelte b/src/components/blocks/estimation.svelte index e168013a..048c4181 100644 --- a/src/components/blocks/estimation.svelte +++ b/src/components/blocks/estimation.svelte @@ -72,8 +72,8 @@ >
@@ -85,8 +85,10 @@

{block.description}

-
-
+
+
{#each estimations as options, i}

@@ -116,7 +118,7 @@ {/each} {#each estimationsCheckbox as options}

{options.name} @@ -173,10 +175,10 @@