Skip to content

Commit

Permalink
feat: typescript config (SWF-310) (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdanilowicz authored May 24, 2023
1 parent e0a452f commit 4c3ec0e
Show file tree
Hide file tree
Showing 59 changed files with 468 additions and 383 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-candles-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vue-demo-store": minor
---

Fix types for `ProductVariantConfigurator.vue`
5 changes: 5 additions & 0 deletions .changeset/slimy-tables-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vue-demo-store": minor
---

Fix closing sidebar for mobile view search
5 changes: 5 additions & 0 deletions .changeset/sour-glasses-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vue-demo-store": minor
---

Upgrade vue-tsc and fix type checks
82 changes: 42 additions & 40 deletions packages/cms-base/components/SwContactForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,37 @@ import {
useNavigationContext,
} from "@shopware-pwa/composables-next";
import { ClientApiError } from "@shopware-pwa/types";
import deepMerge from '../helpers/deepMerge'
import deepMerge from "../helpers/deepMerge";
import getTranslations from "../helpers/getTranslations";
const props = defineProps<{
content: CmsElementForm;
}>()
content: CmsElementForm;
}>();
type Translations = {
form: {
salutation: string
salutationPlaceholder: string,
firstName: string
firstNamePlaceholder: string
lastName: string
lastNamePlaceholder: string
email: string
emailPlaceholder: string
phone: string
phonePlaceholder: string
subject: string
subjectPlaceholder: string
comment: string
commentPlaceholder: string
privacy: string
dataProtection: string
submit: string
salutation: string;
salutationPlaceholder: string;
firstName: string;
firstNamePlaceholder: string;
lastName: string;
lastNamePlaceholder: string;
email: string;
emailPlaceholder: string;
phone: string;
phonePlaceholder: string;
subject: string;
subjectPlaceholder: string;
comment: string;
commentPlaceholder: string;
privacy: string;
dataProtection: string;
submit: string;
messages: {
contactFormSuccess: string
}
}
}
contactFormSuccess: string;
};
};
};
let translations: Translations = {
form: {
Expand All @@ -59,14 +59,14 @@ let translations: Translations = {
dataProtection: "I have read the data protection information.",
submit: "Submit",
messages: {
contactFormSuccess: "We have received your contact request and will process it as soon as possible."
}
}
}
const globalTranslations = getTranslations()
translations = deepMerge(translations, globalTranslations) as Translations
contactFormSuccess:
"We have received your contact request and will process it as soon as possible.",
},
},
};
const globalTranslations = getTranslations();
translations = deepMerge(translations, globalTranslations) as Translations;
const loading = ref<boolean>();
const formSent = ref<boolean>(false);
Expand Down Expand Up @@ -166,7 +166,7 @@ const invokeSubmit = async () => {
<template v-if="!formSent">
<div class="grid grid-cols-12 gap-5">
<div class="col-span-4">
<label for="salutation">{{translations.form.salutation}} *</label>
<label for="salutation">{{ translations.form.salutation }} *</label>
<select
id="salutation"
name="salutation"
Expand All @@ -179,7 +179,9 @@ const invokeSubmit = async () => {
v-model="state.salutationId"
@blur="$v.salutationId.$touch()"
>
<option disabled selected value="">{{translations.form.salutationPlaceholder}}</option>
<option disabled selected value="">
{{ translations.form.salutationPlaceholder }}
</option>
<option
v-for="salutation in getSalutations"
:key="salutation.id"
Expand Down Expand Up @@ -220,7 +222,7 @@ const invokeSubmit = async () => {
</span>
</div>
<div class="col-span-4">
<label for="last-name">{{translations.form.lastName}} *</label>
<label for="last-name">{{ translations.form.lastName }} *</label>
<input
id="last-name"
name="last-name"
Expand Down Expand Up @@ -268,7 +270,7 @@ const invokeSubmit = async () => {
</span>
</div>
<div class="col-span-6">
<label for="phone">{{translations.form.phone}} *</label>
<label for="phone">{{ translations.form.phone }} *</label>
<input
id="phone"
name="phone"
Expand All @@ -292,7 +294,7 @@ const invokeSubmit = async () => {
</span>
</div>
<div class="col-span-12">
<label for="subject">{{translations.form.subject}} *</label>
<label for="subject">{{ translations.form.subject }} *</label>
<input
id="subject"
name="subject"
Expand All @@ -316,7 +318,7 @@ const invokeSubmit = async () => {
</span>
</div>
<div class="col-span-12">
<label for="comment">{{translations.form.comment}} *</label>
<label for="comment">{{ translations.form.comment }} *</label>
<textarea
id="comment"
name="comment"
Expand All @@ -341,7 +343,7 @@ const invokeSubmit = async () => {
</span>
</div>
<div class="col-span-12">
<label>{{translations.form.privacy }} *</label>
<label>{{ translations.form.privacy }} *</label>
<div class="flex gap-3 items-start">
<input
id="privacy"
Expand All @@ -358,7 +360,7 @@ const invokeSubmit = async () => {
:class="[$v.checkbox.$error ? 'text-red-600' : '']"
for="privacy"
>
{{translations.form.dataProtection}}
{{ translations.form.dataProtection }}
</label>
</div>
</div>
Expand All @@ -370,7 +372,7 @@ const invokeSubmit = async () => {
type="submit"
:disabled="loading"
>
{{translations.form.submit }}
{{ translations.form.submit }}
</button>
</div>
</template>
Expand Down
70 changes: 36 additions & 34 deletions packages/cms-base/components/SwNewsletterForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,35 @@ import { useVuelidate } from "@vuelidate/core";
import { required, email } from "@vuelidate/validators";
import { CmsElementForm } from "@shopware-pwa/composables-next";
import { ClientApiError } from "@shopware-pwa/types";
import deepMerge from '../helpers/deepMerge'
import deepMerge from "../helpers/deepMerge";
import getTranslations from "../helpers/getTranslations";
const props =
defineProps<{
content: CmsElementForm;
}>()
const props = defineProps<{
content: CmsElementForm;
}>();
type Translations = {
form: {
subscribeLabel: string
unsubscribeLabel: string
action: string
email: string
emailPlaceholder: string
salutation: string
salutationPlaceholder: string
firstName: string
firstNamePlaceholder: string
lastName: string
lastNamePlaceholder: string
privacy: string
privacyLabel: string
submit: string
newsletterBenefits: string
}
}
subscribeLabel: string;
unsubscribeLabel: string;
action: string;
email: string;
emailPlaceholder: string;
salutation: string;
salutationPlaceholder: string;
firstName: string;
firstNamePlaceholder: string;
lastName: string;
lastNamePlaceholder: string;
privacy: string;
privacyLabel: string;
submit: string;
newsletterBenefits: string;
};
};
let translations: Translations = {
form: {
form: {
subscribeLabel: "Subscribe to newsletter",
unsubscribeLabel: "Unsubscribe from newsletter",
action: "Action",
Expand All @@ -47,12 +46,13 @@ let translations: Translations = {
privacy: "Privacy",
privacyLabel: "I have read the data protection information.",
submit: "Submit",
newsletterBenefits: "Be aware of upcoming sales and events.Receive gifts and special offers!"
}
}
newsletterBenefits:
"Be aware of upcoming sales and events.Receive gifts and special offers!",
},
};
const globalTranslations = getTranslations()
translations = deepMerge(translations, globalTranslations) as Translations
const globalTranslations = getTranslations();
translations = deepMerge(translations, globalTranslations) as Translations;
const loading = ref<boolean>();
const formSent = ref<boolean>(false);
Expand Down Expand Up @@ -159,7 +159,7 @@ const invokeSubmit = async () => {
<template v-if="!formSent">
<div class="grid grid-cols-12 gap-5">
<div class="col-span-12">
<label for="option">{{translations.form.action}} *</label>
<label for="option">{{ translations.form.action }} *</label>
<select
id="option"
name="option"
Expand All @@ -176,7 +176,7 @@ const invokeSubmit = async () => {
</select>
</div>
<div class="col-span-12">
<label for="email-address">{{translations.form.email}} *</label>
<label for="email-address">{{ translations.form.email }} *</label>
<input
id="email-address"
name="email"
Expand All @@ -200,7 +200,7 @@ const invokeSubmit = async () => {
</span>
</div>
<div v-if="state.option === 'subscribe'" class="col-span-4">
<label for="salutation">{{translations.form.salutation}} *</label>
<label for="salutation">{{ translations.form.salutation }} *</label>
<select
id="salutation"
name="salutation"
Expand All @@ -213,7 +213,9 @@ const invokeSubmit = async () => {
v-model="state.salutationId"
@blur="$v.salutationId.$touch()"
>
<option disabled selected value="">{{ translations.form.salutationPlaceholder }}</option>
<option disabled selected value="">
{{ translations.form.salutationPlaceholder }}
</option>
<option
v-for="salutation in getSalutations"
:key="salutation.id"
Expand Down Expand Up @@ -295,7 +297,7 @@ const invokeSubmit = async () => {
:class="[$v.checkbox.$error ? 'text-red-600' : '']"
for="privacy"
>
{{translations.form.privacyLabel }}
{{ translations.form.privacyLabel }}
</label>
</div>
</div>
Expand All @@ -307,7 +309,7 @@ const invokeSubmit = async () => {
type="submit"
:disabled="loading"
>
{{translations.form.submit }}
{{ translations.form.submit }}
</button>
</div>
</template>
Expand Down
34 changes: 16 additions & 18 deletions packages/cms-base/components/SwPagination.vue
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
<script setup lang="ts">
import deepMerge from '../helpers/deepMerge'
import deepMerge from "../helpers/deepMerge";
import getTranslations from "../helpers/getTranslations";
const props =
defineProps<{
total: number;
current: number;
}>()
const props = defineProps<{
total: number;
current: number;
}>();
type Translations = {
listing: {
previous: string
next: string
}
}
previous: string;
next: string;
};
};
let translations: Translations = {
listing: {
previous: "Previous",
next: "Next"
}
}
next: "Next",
},
};
const globalTranslations = getTranslations()
translations = deepMerge(translations, globalTranslations) as Translations
const globalTranslations = getTranslations();
translations = deepMerge(translations, globalTranslations) as Translations;
defineEmits<{
(e: "changePage", page: number): void;
Expand All @@ -45,7 +43,7 @@ defineEmits<{
class="relative inline-flex items-center px-2 py-2 rounded-l-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50"
>
<span class="w-10 h-10 i-carbon-chevron-left text-blue-700"></span>
<span class="sr-only">{{translations.listing.previous}}</span>
<span class="sr-only">{{ translations.listing.previous }}</span>
</button>
<button
v-if="current > 2"
Expand Down Expand Up @@ -101,7 +99,7 @@ defineEmits<{
@click="$emit('changePage', total)"
class="relative inline-flex items-center px-2 py-2 rounded-r-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50"
>
<span class="sr-only">{{translations.listing.next}}</span>
<span class="sr-only">{{ translations.listing.next }}</span>
<span class="w-10 h-10 i-carbon-chevron-right text-blue-700"></span>
</button>
</nav>
Expand Down
Loading

1 comment on commit 4c3ec0e

@vercel
Copy link

@vercel vercel bot commented on 4c3ec0e May 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.