@lightspeed/crane 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/app.d.mts +147 -10
  2. package/dist/app.d.ts +147 -10
  3. package/dist/app.mjs +1 -1
  4. package/dist/cli.mjs +22 -11
  5. package/package.json +5 -2
  6. package/template/footers/example-footer/ExampleFooter.vue +36 -2
  7. package/template/footers/example-footer/component/ReportAbuse.vue +18 -0
  8. package/template/footers/example-footer/entity/color.ts +4 -0
  9. package/template/footers/example-footer/settings/content.ts +3 -0
  10. package/template/footers/example-footer/settings/design.ts +11 -0
  11. package/template/footers/example-footer/settings/translations.ts +12 -0
  12. package/template/footers/example-footer/showcases/1.ts +2 -0
  13. package/template/footers/example-footer/showcases/translations.ts +9 -0
  14. package/template/footers/example-footer/type.ts +2 -2
  15. package/template/headers/example-header/ExampleHeader.vue +20 -7
  16. package/template/headers/example-header/assets/cart.svg +20 -0
  17. package/template/headers/example-header/assets/search.svg +13 -0
  18. package/template/headers/example-header/component/Cart.vue +64 -0
  19. package/template/headers/example-header/component/SearchForm.vue +89 -0
  20. package/template/headers/example-header/showcases/1.ts +11 -0
  21. package/template/headers/example-header/type.ts +2 -2
  22. package/template/package.json +3 -2
  23. package/template/sections/example-section/component/image/ImagesGrid.vue +18 -37
  24. package/template/sections/example-section/settings/content.ts +53 -55
  25. package/template/sections/example-section/settings/translations.ts +27 -24
  26. package/template/sections/example-section/showcases/1.ts +143 -103
  27. package/template/sections/example-section/showcases/2.ts +127 -103
  28. package/template/sections/example-section/showcases/translations.ts +4 -0
  29. package/template/templates/template.ts +143 -103
  30. package/types.d.ts +14 -1
  31. package/template/footers/example-footer/component/SampleComponent.vue +0 -11
  32. package/template/headers/settings/content.ts +0 -1
  33. package/template/headers/settings/design.ts +0 -1
  34. package/template/headers/settings/layout.ts +0 -1
  35. /package/template/{footers → headers/example-header}/settings/content.ts +0 -0
  36. /package/template/{footers → headers/example-header}/settings/design.ts +0 -0
  37. /package/template/{footers → headers/example-header}/settings/layout.ts +0 -0
  38. /package/template/{footers → headers/example-header}/settings/translations.ts +0 -0
  39. /package/template/headers/{settings → example-header/showcases}/translations.ts +0 -0
@@ -0,0 +1,64 @@
1
+ <template>
2
+ <div class="cart-icon">
3
+ <a href="/products/cart" role="button">
4
+ <img alt="cart" src="../assets/cart.svg">
5
+ <span
6
+ v-if="cartItemCount > 0"
7
+ class="item-count"
8
+ >
9
+ {{ cartItemCount > 99 ? '99+' : cartItemCount }}
10
+ </span>
11
+ </a>
12
+ </div>
13
+ </template>
14
+
15
+ <script setup>
16
+ import Ecommerce from '@ecwid/sdk';
17
+ import { ref } from 'vue';
18
+
19
+ const cartItemCount = ref(0);
20
+ const ecommerce = new Ecommerce({
21
+ storeId: window.Ecwid.getOwnerId(),
22
+ });
23
+
24
+ function setCartItemCount() {
25
+ ecommerce.cart.get().then((result) => {
26
+ cartItemCount.value = result?.productsQuantity ?? 0;
27
+ });
28
+ }
29
+
30
+ function subscribeOnCartChange() {
31
+ if (typeof document === 'undefined') {
32
+ return;
33
+ }
34
+
35
+ document.addEventListener('visibilitychange', () => {
36
+ if (document.visibilityState !== 'hidden') {
37
+ setCartItemCount();
38
+ }
39
+ }, false);
40
+
41
+ setCartItemCount();
42
+ }
43
+
44
+ subscribeOnCartChange();
45
+ </script>
46
+
47
+ <style scoped>
48
+ .cart-icon {
49
+ position: relative;
50
+ a:visited{
51
+ text-decoration: none;
52
+ color: black;
53
+ }
54
+ }
55
+ .item-count {
56
+ position: absolute;
57
+ top: 50%;
58
+ left: 50%;
59
+ transform: translate(-50%, -50%);
60
+ color: white;
61
+ font-weight: 400;
62
+ font-size: 13px;
63
+ }
64
+ </style>
@@ -0,0 +1,89 @@
1
+ <template>
2
+ <div class="search-form__wrapper">
3
+ <form
4
+ role="search"
5
+ class="search-form"
6
+ method="get"
7
+ @submit.prevent="openSearchPage"
8
+ >
9
+ <input
10
+ ref="searchInputRef"
11
+ class="search-form__input"
12
+ type="search"
13
+ enterkeyhint="search"
14
+ name="keyword"
15
+ value=""
16
+ autocomplete="off"
17
+ maxlength="2048"
18
+ aria-label="Search"
19
+ placeholder="Search"
20
+ >
21
+ <button
22
+ type="submit"
23
+ aria-label="Search the website"
24
+ class="search-form__button"
25
+ >
26
+ <img src="../assets/search.svg" alt="Search" />
27
+ </button>
28
+ </form>
29
+ </div>
30
+ </template>
31
+
32
+ <script setup lang="ts">
33
+ import { ref } from 'vue';
34
+ import { useInstantsiteJsApi } from '@lightspeed/crane';
35
+
36
+ const instantsiteJsApi = useInstantsiteJsApi();
37
+ const searchInputRef = ref<HTMLInputElement>();
38
+
39
+ function openSearchPage() {
40
+ const searchInput = searchInputRef.value;
41
+ instantsiteJsApi?.openSearchPage(searchInput?.value);
42
+ }
43
+ </script>
44
+
45
+ <style scoped>
46
+ .search-form {
47
+ position: relative;
48
+ }
49
+
50
+ .search-form__wrapper {
51
+ width: 250px;
52
+ margin-right: 10px;
53
+ margin-left: 10px;
54
+ }
55
+
56
+ .search-form__input {
57
+ background-color: #313132;
58
+ color: #f5faff;
59
+ font-size: 16px;
60
+ width: 100%;
61
+ height: 30px;
62
+ padding: 0 40px 0 10px;
63
+ border: 1px solid transparent;
64
+ border-radius: 20px;
65
+ outline: none;
66
+
67
+ &::-webkit-search-cancel-button {
68
+ appearance: none;
69
+ }
70
+ }
71
+
72
+ .search-form__button {
73
+ display: flex;
74
+ position: absolute;
75
+ top: 1px;
76
+ right: 8px;
77
+ align-items: center;
78
+ justify-content: center;
79
+ width: 30px;
80
+ height: 28px;
81
+ border: 0 none;
82
+ cursor: pointer;
83
+
84
+ img {
85
+ width: 20px;
86
+ height: 20px;
87
+ }
88
+ }
89
+ </style>
@@ -0,0 +1,11 @@
1
+ export default {
2
+ previewImage: {
3
+ set: {
4
+ ORIGINAL: {
5
+ url: 'example_header_showcase_1_preview.jpg',
6
+ },
7
+ },
8
+ },
9
+ content: {},
10
+ design: {},
11
+ } as const;
@@ -1,5 +1,5 @@
1
- import ContentSettings from '../settings/content.ts';
2
- import DesignSettings from '../settings/design.ts';
1
+ import ContentSettings from './settings/content.ts';
2
+ import DesignSettings from './settings/design.ts';
3
3
 
4
4
  export type Content = InferContentType<typeof ContentSettings>;
5
5
  export type Design = InferDesignType<typeof DesignSettings>;
@@ -7,9 +7,10 @@
7
7
  "deploy": "crane build && crane deploy"
8
8
  },
9
9
  "dependencies": {
10
- "@lightspeed/crane": "1.1.0",
10
+ "@lightspeed/crane": "1.1.1",
11
11
  "@lightspeed/eslint-config-crane": "1.0.2",
12
- "vue": "^3.4.0"
12
+ "vue": "^3.4.0",
13
+ "@ecwid/sdk": "^0.8.0"
13
14
  },
14
15
  "engines": {
15
16
  "node": ">=20"
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div
3
3
  v-if="size > 0"
4
- :class="`image-grid__${images.length}`"
4
+ :class="`image-grid__${images?.length}`"
5
5
  >
6
6
  <div
7
7
  v-for="(image, index) in images"
@@ -19,45 +19,26 @@
19
19
 
20
20
  <script setup lang="ts">
21
21
  import { computed, ref } from 'vue';
22
- import { useImageElementContent, useInputboxElementContent, useTextareaElementContent } from '@lightspeed/crane';
22
+ import {
23
+ useDeckElementContent,
24
+ Card,
25
+ EditorTypes,
26
+ ImageContent,
27
+ TextAreaContent,
28
+ InputBoxContent,
29
+ } from '@lightspeed/crane';
23
30
  import CustomSectionExampleImage from './Image.vue';
24
31
  import { Content } from '../../type.ts';
25
32
 
26
- const imageText1 = useTextareaElementContent<Content>('image_text_1');
27
- const imageText2 = useTextareaElementContent<Content>('image_text_2');
28
- const imageText3 = useTextareaElementContent<Content>('image_text_3');
29
- const imageText4 = useTextareaElementContent<Content>('image_text_4');
30
- const imageContent1 = useImageElementContent<Content>('image_content_1');
31
- const imageContent2 = useImageElementContent<Content>('image_content_2');
32
- const imageContent3 = useImageElementContent<Content>('image_content_3');
33
- const imageContent4 = useImageElementContent<Content>('image_content_4');
34
- const imageLink1 = useInputboxElementContent<Content>('image_link_1');
35
- const imageLink2 = useInputboxElementContent<Content>('image_link_2');
36
- const imageLink3 = useInputboxElementContent<Content>('image_link_3');
37
- const imageLink4 = useInputboxElementContent<Content>('image_link_4');
38
- const images = computed(() => ([
39
- {
40
- text: imageText1,
41
- content: imageContent1,
42
- link: imageLink1,
43
- },
44
- {
45
- text: imageText2,
46
- content: imageContent2,
47
- link: imageLink2,
48
- },
49
- {
50
- text: imageText3,
51
- content: imageContent3,
52
- link: imageLink3,
53
- },
54
- {
55
- text: imageText4,
56
- content: imageContent4,
57
- link: imageLink4,
58
- },
59
- ].filter((image) => image.content.hasContent)));
60
- const size = computed(() => images.value.length);
33
+ const imagesRaw = useDeckElementContent<Content>('images');
34
+ const images = computed(() => (
35
+ imagesRaw?.cards?.map((card: Card) => ({
36
+ text: imagesRaw.getReactiveRef(card, EditorTypes.TEXTAREA, 'image_text') as unknown as TextAreaContent | undefined,
37
+ content: imagesRaw.getReactiveRef(card, EditorTypes.IMAGE, 'image_content') as unknown as ImageContent | undefined,
38
+ link: imagesRaw.getReactiveRef(card, EditorTypes.INPUTBOX, 'image_link') as unknown as InputBoxContent | undefined,
39
+ })).filter((image) => (image.content !== undefined && image.content.hasContent))));
40
+
41
+ const size = computed(() => (images.value?.length ? images.value.length : 0));
61
42
 
62
43
  const windowWidth = ref(window.innerWidth);
63
44
  const onWidthChange = () => { windowWidth.value = window.innerWidth; };
@@ -9,60 +9,58 @@ export default {
9
9
  label: '$label.section_description.label',
10
10
  placeholder: '$label.section_description.placeholder',
11
11
  },
12
- image_content_1: {
13
- type: 'IMAGE',
14
- label: '$label.image_content_1.label',
15
- },
16
- image_text_1: {
17
- type: 'TEXTAREA',
18
- label: '$label.image_text_1.label',
19
- placeholder: '$label.image_text.placeholder',
20
- },
21
- image_link_1: {
22
- type: 'INPUTBOX',
23
- label: '$label.image_link_1.label',
24
- placeholder: '$label.image_link.placeholder',
25
- },
26
- image_content_2: {
27
- type: 'IMAGE',
28
- label: '$label.image_content_2.label',
29
- },
30
- image_text_2: {
31
- type: 'TEXTAREA',
32
- label: '$label.image_text_2.label',
33
- placeholder: '$label.image_text.placeholder',
34
- },
35
- image_link_2: {
36
- type: 'INPUTBOX',
37
- label: '$label.image_link_2.label',
38
- placeholder: '$label.image_link.placeholder',
39
- },
40
- image_content_3: {
41
- type: 'IMAGE',
42
- label: '$label.image_content_3.label',
43
- },
44
- image_text_3: {
45
- type: 'TEXTAREA',
46
- label: '$label.image_text_3.label',
47
- placeholder: '$label.image_text.placeholder',
48
- },
49
- image_link_3: {
50
- type: 'INPUTBOX',
51
- label: '$label.image_link_3.label',
52
- placeholder: '$label.image_link.placeholder',
53
- },
54
- image_content_4: {
55
- type: 'IMAGE',
56
- label: '$label.image_content_4.label',
57
- },
58
- image_text_4: {
59
- type: 'TEXTAREA',
60
- label: '$label.image_text_4.label',
61
- placeholder: '$label.image_text.placeholder',
62
- },
63
- image_link_4: {
64
- type: 'INPUTBOX',
65
- label: '$label.image_link_4.label',
66
- placeholder: '$label.image_link.placeholder',
12
+
13
+ images: {
14
+ type: 'DECK',
15
+ label: '$label.images.deck_title',
16
+ addButtonLabel: '$label.images.add_card_button',
17
+ maxCards: 5,
18
+ cards: {
19
+ defaultCardContent: {
20
+ label: '$label.images.card_title',
21
+ settings: {
22
+ image_content: {
23
+ type: 'IMAGE',
24
+ label: '$label.image_content_1.label',
25
+ defaults: {
26
+ set: {
27
+ LOW_RES: {
28
+ url: 'new_arrivals_mobile_low.jpeg',
29
+ },
30
+ MOBILE_WEBP_LOW_RES: {
31
+ url: 'new_arrivals_mobile_low.jpeg',
32
+ },
33
+ MOBILE_WEBP_HI_RES: {
34
+ url: 'new_arrivals_mobile_high.jpeg',
35
+ },
36
+ WEBP_LOW_RES: {
37
+ url: 'new_arrivals_pc_low.jpeg',
38
+ },
39
+ WEBP_HI_2X_RES: {
40
+ url: 'new_arrivals_pc_high.jpeg',
41
+ },
42
+ },
43
+ borderInfo: {},
44
+ },
45
+ },
46
+ image_text: {
47
+ type: 'TEXTAREA',
48
+ label: '$label.image_text_1.label',
49
+ placeholder: '$label.image_text.placeholder',
50
+ defaults: {
51
+ text: '$label.images.default.image_text',
52
+ },
53
+ },
54
+ image_link: {
55
+ type: 'INPUTBOX',
56
+ label: '$label.image_link_1.label',
57
+ placeholder: '$label.image_link.placeholder',
58
+ defaults: {
59
+ text: '$label.images.default.image_link.text',
60
+ },
61
+ },
62
+ },
63
+ },
64
+ },
67
65
  },
68
66
  } as const;
@@ -5,22 +5,29 @@ export default {
5
5
  '$label.section_description.label': 'Long description',
6
6
  '$label.section_description.placeholder': 'This description will be displayed below the title',
7
7
  '$label.image_text.label': 'Image Caption',
8
- '$label.image_text_1.label': 'Image 1 caption',
9
- '$label.image_text_2.label': 'Image 2 caption',
10
- '$label.image_text_3.label': 'Image 3 caption',
11
- '$label.image_text_4.label': 'Image 4 caption',
8
+
12
9
  '$label.image_text.placeholder': 'This caption will be displayed on or below the image',
13
10
  '$label.image_content.label': 'Image Content',
14
- '$label.image_content_1.label': 'Image 1',
15
- '$label.image_content_2.label': 'Image 2',
16
- '$label.image_content_3.label': 'Image 3',
17
- '$label.image_content_4.label': 'Image 4',
18
- '$label.image_link_1.label': 'Image 1 link',
19
- '$label.image_link_2.label': 'Image 2 link',
20
- '$label.image_link_3.label': 'Image 3 link',
21
- '$label.image_link_4.label': 'Image 4 link',
22
11
  '$label.image_link.placeholder': 'Enter an optional URL for the image',
23
12
  '$label.background.label': 'Background',
13
+
14
+ '$label.image_text_1.label': 'Content.ts: Image caption',
15
+ '$label.image_content_1.label': 'Content.ts: Image',
16
+ '$label.image_link_1.label': 'Content.ts: Image link',
17
+
18
+ '$label.images.deck_title': 'Content.ts: Image settings',
19
+ '$label.images.add_card_button': 'Content.ts: Add new image settings',
20
+ '$label.images.card_title': 'Content.ts: Image settings',
21
+
22
+ '$label.images.default.image_text': 'Default of Content.ts: Default image text',
23
+ '$label.images.default.image_link.text': 'Default of Content.ts: Default image link text',
24
+ '$label.images.default.button_title': 'Default of Content.ts: Default button title',
25
+
26
+ '$label.images.toggle.label': 'Content.ts: Image toggle',
27
+ '$label.images.selectbox.label': 'Content.ts: Image select',
28
+ '$label.images.selectbox_option_1.label': 'Content.ts: Image select option 1',
29
+ '$label.images.selectbox_option_2.label': 'Content.ts: Image select option 2',
30
+ '$label.images.button.label': 'Content.ts: Image button label',
24
31
  },
25
32
 
26
33
  nl: {
@@ -29,21 +36,17 @@ export default {
29
36
  '$label.section_description.label': 'Lange beschrijving',
30
37
  '$label.section_description.placeholder': 'Deze beschrijving wordt onder de titel weergegeven',
31
38
  '$label.image_text.label': 'Bijschrift afbeelding',
32
- '$label.image_text_1.label': 'Onderschrift afbeelding 1',
33
- '$label.image_text_2.label': 'Bijschrift afbeelding 2',
34
- '$label.image_text_3.label': 'Bijschrift afbeelding 3',
35
- '$label.image_text_4.label': 'Bijschrift afbeelding 4',
39
+ '$label.image_text_1.label': 'Onderschrift afbeelding',
36
40
  '$label.image_text.placeholder': 'Dit bijschrift wordt op of onder de afbeelding weergegeven',
37
41
  '$label.image_content.label': 'Afbeeldingsinhoud',
38
- '$label.image_content_1.label': 'Afbeelding 1',
39
- '$label.image_content_2.label': 'Afbeelding 2',
40
- '$label.image_content_3.label': 'Afbeelding 3',
41
- '$label.image_content_4.label': 'Afbeelding 4',
42
- '$label.image_link_1.label': 'Afbeelding 1 link',
43
- '$label.image_link_2.label': 'Afbeelding 2 link',
44
- '$label.image_link_3.label': 'Afbeelding 3 link',
45
- '$label.image_link_4.label': 'Afbeelding 4 link',
42
+ '$label.image_content_1.label': 'Afbeelding',
43
+ '$label.image_link_1.label': 'Afbeelding link',
46
44
  '$label.image_link.placeholder': 'Voer een optionele URL in voor de afbeelding',
47
45
  '$label.background.label': 'Achtergrond',
46
+
47
+ '$label.images.deck_title': 'Afbeeldingsinstellingen',
48
+ '$label.images.add_card_button': 'Afbeeldingsinstellingen toevoegen',
49
+ '$label.images.card_title': 'Afbeeldingsinstellingen',
50
+ '$label.images.image_text_default': 'Standaardtekst',
48
51
  },
49
52
  } as const;