@eldrajs/theme-cli 0.2.9 → 0.2.11
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.
- package/CHANGELOG.md +12 -1
- package/package.json +3 -3
- package/template/.eldra/block-types.d.ts +4 -6
- package/template/.eldra/manifest.json +228 -246
- package/template/.eldra/previews.json +35 -35
- package/template/.storybook/eldra.ts +7 -2
- package/template/app/assets/main.css +5 -0
- package/template/app/composables/useBlockData.ts +9 -2
- package/template/app/composables/usePriceTokens.ts +150 -0
- package/template/app/composables/useQuickAdd.ts +95 -0
- package/template/app/composables/useRegionalFormat.ts +94 -0
- package/template/app/icons.ts +4 -0
- package/template/app/plugins/eldra-storefront.ts +2 -0
- package/template/app/plugins/eldra-ui-messages.ts +22 -8
- package/template/app/storefront/demo.ts +188 -16
- package/template/app/storefront/gateway.ts +19 -0
- package/template/app/storefront/productCardLook.ts +76 -0
- package/template/app/storefront/productReference.ts +17 -0
- package/template/app/storefront/toProductCard.ts +12 -8
- package/template/app/storefront/types.ts +17 -0
- package/template/blocks/announcement-bar/__tests__/Block.spec.ts +19 -7
- package/template/blocks/announcement-bar/block.json +2 -1
- package/template/blocks/announcement-bar/mock.json +1 -1
- package/template/blocks/announcement-bar/preview.png +0 -0
- package/template/blocks/article/Block.vue +8 -18
- package/template/blocks/article/block.json +3 -1
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/block.json +10 -1
- package/template/blocks/article-list/preview.png +0 -0
- package/template/blocks/breadcrumbs/Block.vue +15 -3
- package/template/blocks/breadcrumbs/__tests__/Block.spec.ts +13 -0
- package/template/blocks/breadcrumbs/block.json +1 -0
- package/template/blocks/breadcrumbs/preview.png +0 -0
- package/template/blocks/cart/Block.vue +15 -5
- package/template/blocks/cart/__tests__/Block.spec.ts +53 -10
- package/template/blocks/cart/__tests__/ShippingBar.spec.ts +10 -8
- package/template/blocks/cart/block.json +8 -5
- package/template/blocks/cart/mock.json +2 -2
- package/template/blocks/cart/parts/ShippingBar.vue +24 -30
- package/template/blocks/cart/parts/notSold.ts +4 -3
- package/template/blocks/collection-grid/Block.vue +168 -85
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +101 -23
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/Block.vue +51 -17
- package/template/blocks/collection-header/__tests__/Block.spec.ts +80 -4
- package/template/blocks/collection-header/block.json +2 -0
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/block.json +4 -0
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/block.json +2 -0
- package/template/blocks/faq/Block.vue +5 -10
- package/template/blocks/faq/block.json +2 -1
- package/template/blocks/faq/mock.json +12 -1
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/__tests__/Block.spec.ts +30 -7
- package/template/blocks/feature-grid/block.json +3 -2
- package/template/blocks/feature-grid/mock.json +1 -1
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +64 -21
- package/template/blocks/footer/__tests__/Block.spec.ts +97 -1
- package/template/blocks/footer/block.json +5 -2
- package/template/blocks/footer/mock.json +1 -1
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/form/block.json +1 -0
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/Block.vue +38 -9
- package/template/blocks/hero/__tests__/Block.spec.ts +71 -19
- package/template/blocks/hero/block.json +16 -22
- package/template/blocks/hero/preview.json +1 -3
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/block.json +2 -1
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/block.json +1 -0
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +405 -159
- package/template/blocks/navigation/__tests__/Block.spec.ts +816 -172
- package/template/blocks/navigation/__tests__/currentItem.spec.ts +90 -0
- package/template/blocks/navigation/block.json +2 -11
- package/template/blocks/navigation/mock.json +3 -3
- package/template/blocks/navigation/parts/LocalePicker.vue +103 -0
- package/template/blocks/navigation/parts/currentItem.ts +82 -0
- package/template/blocks/navigation/preview.json +7 -1
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/newsletter/Block.vue +6 -2
- package/template/blocks/newsletter/block.json +2 -0
- package/template/blocks/newsletter/preview.png +0 -0
- package/template/blocks/order-status/Block.vue +8 -17
- package/template/blocks/order-status/block.json +3 -0
- package/template/blocks/order-status/preview.png +0 -0
- package/template/blocks/pricing-table/__tests__/Block.spec.ts +12 -4
- package/template/blocks/pricing-table/block.json +2 -0
- package/template/blocks/pricing-table/mock.json +6 -6
- package/template/blocks/pricing-table/preview.png +0 -0
- package/template/blocks/product-carousel/Block.vue +36 -126
- package/template/blocks/product-carousel/__tests__/Block.spec.ts +88 -0
- package/template/blocks/product-carousel/block.json +1 -0
- package/template/blocks/product-carousel/preview.png +0 -0
- package/template/blocks/product-detail/Block.vue +84 -31
- package/template/blocks/product-detail/__tests__/Block.spec.ts +86 -0
- package/template/blocks/product-detail/__tests__/specs.spec.ts +79 -0
- package/template/blocks/product-detail/block.json +3 -1
- package/template/blocks/product-detail/mock.json +54 -4
- package/template/blocks/product-detail/parts/Gallery.vue +8 -2
- package/template/blocks/product-detail/preview.png +0 -0
- package/template/blocks/product-detail/specs.ts +75 -0
- package/template/blocks/quote/block.json +1 -0
- package/template/blocks/rich-text/preview.png +0 -0
- package/template/blocks/search/Block.vue +6 -1
- package/template/blocks/search/TypeSection.vue +8 -1
- package/template/blocks/search/__tests__/Block.spec.ts +24 -1
- package/template/blocks/search/block.json +1 -0
- package/template/blocks/search/preview.png +0 -0
- package/template/blocks/split-content/Block.vue +12 -5
- package/template/blocks/split-content/__tests__/Block.spec.ts +13 -0
- package/template/blocks/split-content/block.json +4 -2
- package/template/blocks/split-content/preview.png +0 -0
- package/template/blocks/stats/preview.png +0 -0
- package/template/blocks/tabs/Block.vue +3 -4
- package/template/blocks/tabs/block.json +1 -1
- package/template/blocks/tabs/preview.png +0 -0
- package/template/blocks/team/block.json +3 -1
- package/template/blocks/team/preview.png +0 -0
- package/template/blocks/testimonials/block.json +2 -0
- package/template/blocks/testimonials/preview.png +0 -0
- package/template/blocks/timeline/block.json +2 -1
- package/template/blocks/timeline/preview.png +0 -0
- package/template/blocks/trust-strip/Block.vue +2 -2
- package/template/blocks/trust-strip/__tests__/Block.spec.ts +38 -9
- package/template/blocks/trust-strip/block.json +1 -1
- package/template/blocks/trust-strip/mock.json +1 -1
- package/template/blocks/trust-strip/preview.json +1 -1
- package/template/blocks/trust-strip/preview.png +0 -0
- package/template/blocks/video-embed/block.json +2 -0
- package/template/blocks/video-embed/preview.png +0 -0
- package/template/blocks/wishlist/Block.vue +2 -2
- package/template/blocks/wishlist/preview.png +0 -0
- package/template/i18n/en-US.json +13 -5
- package/template/i18n/is-IS.json +12 -4
- package/template/pages/article.page.json +1 -3
- package/template/pages/cart.page.json +1 -3
- package/template/pages/category.page.json +2 -4
- package/template/pages/collection.page.json +1 -3
- package/template/pages/home.page.json +7 -18
- package/template/pages/product.page.json +62 -131
- package/template/pages/products.page.json +1 -3
- package/template/pages/search.page.json +1 -3
- package/template/pages/wishlist.page.json +1 -3
- package/template/stories/generated/footer.stories.ts +6 -0
- package/template/stories/generated/navigation.stories.ts +0 -18
- package/template/test/inlineEditable.spec.ts +10 -2
- package/template/test/localePrefix.spec.ts +2 -19
- package/template/test/pages/article.spec.ts +0 -2
- package/template/test/pages/category.spec.ts +35 -13
- package/template/test/pages/home.spec.ts +33 -17
- package/template/test/pages/product.spec.ts +64 -44
- package/template/test/pages/ssr.spec.ts +3 -1
- package/template/test/prerenderRefresh.browser.spec.ts +30 -25
- package/template/test/previewParity.browser.spec.ts +36 -2
- package/template/test/priceTokens.spec.ts +309 -0
- package/template/test/regionalFormat.spec.ts +80 -0
- package/template/test/starter.spec.ts +23 -7
- package/template/test/storefront/demo.spec.ts +19 -18
- package/template/test/storefront/toProductCard.spec.ts +17 -2
- package/template/test/structuredData.generate.spec.ts +4 -2
- package/template/test/support/mockGateway.ts +21 -1
- package/template/test/support/mountBlock.ts +25 -4
- package/template/test/support/priceTokens.ts +20 -0
- package/template/test/uiMessagesPlugin.spec.ts +34 -1
- package/template/tokens.json +8 -8
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
2
|
import { mount } from '@vue/test-utils';
|
|
3
3
|
import { h, nextTick } from 'vue';
|
|
4
|
+
import { flushPromises } from '@vue/test-utils';
|
|
4
5
|
import { axe } from '../../../test/support/axe';
|
|
5
6
|
import { describe, expect, it } from 'vitest';
|
|
6
7
|
import Block from '../Block.vue';
|
|
@@ -89,37 +90,88 @@ describe('hero block', () => {
|
|
|
89
90
|
expect(frame.classes()).toContain('@min-[68.8125rem]:aspect-[21/9]!');
|
|
90
91
|
});
|
|
91
92
|
|
|
92
|
-
|
|
93
|
+
/**
|
|
94
|
+
* WS-1277: the caption was three typed fields, its price a string ("ISK 4,790") that ignored the
|
|
95
|
+
* regional format and the shopper's currency and went stale with the catalog. It is the picked
|
|
96
|
+
* product now, its name, price and link all read from the storefront.
|
|
97
|
+
*/
|
|
98
|
+
it('names the picked product and its price from the catalog, and links to it', async () => {
|
|
93
99
|
const wrapper = mount(Block, mountOptions({ entry: { id: 'e1', data: card } }));
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
expect(caption).
|
|
98
|
-
expect(caption
|
|
99
|
-
expect(caption!.attributes('href')).toBe(withImage.captionHref);
|
|
100
|
+
await flushPromises();
|
|
101
|
+
const caption = wrapper.get('[data-eldra-hero-caption]');
|
|
102
|
+
expect(caption.text()).toContain('Glazed milk jug');
|
|
103
|
+
expect(caption.attributes('href')).toBe('/products/glazed-milk-jug');
|
|
104
|
+
expect(caption.text()).toContain('$34');
|
|
100
105
|
});
|
|
101
106
|
|
|
102
|
-
it('
|
|
103
|
-
const
|
|
104
|
-
Block,
|
|
105
|
-
mountOptions({ entry: { id: 'e1', data: { ...card, captionHref: '' } } })
|
|
106
|
-
);
|
|
107
|
-
expect(noHref.text()).not.toContain(withImage.captionLabel);
|
|
108
|
-
const imageRight = mount(
|
|
107
|
+
it('writes the price in the regional format and the store currency', async () => {
|
|
108
|
+
const wrapper = mount(
|
|
109
109
|
Block,
|
|
110
|
-
mountOptions(
|
|
110
|
+
mountOptions(
|
|
111
|
+
{ entry: { id: 'e1', data: card } },
|
|
112
|
+
{
|
|
113
|
+
locale: 'en-US',
|
|
114
|
+
commerce: { currency: 'ISK', taxInclusivePricing: true, defaultTaxRate: 0.24 },
|
|
115
|
+
region: { countryCode: 'IS', formatLocale: 'is-IS', timeZone: 'Atlantic/Reykjavik' },
|
|
116
|
+
}
|
|
117
|
+
)
|
|
111
118
|
);
|
|
112
|
-
|
|
119
|
+
await flushPromises();
|
|
120
|
+
const caption = wrapper.get('[data-eldra-hero-caption]');
|
|
121
|
+
// `is-IS` writes a no-break space before the currency.
|
|
122
|
+
expect(caption.text()).toMatch(/34\u00a0kr\./);
|
|
123
|
+
expect(caption.text()).not.toContain('ISK');
|
|
113
124
|
});
|
|
114
125
|
|
|
115
|
-
it('
|
|
126
|
+
it('takes its own text in place of the product name, keeping the price and link', async () => {
|
|
116
127
|
const wrapper = mount(
|
|
117
128
|
Block,
|
|
118
129
|
mountOptions({
|
|
119
|
-
entry: { id: 'e1', data: { ...card,
|
|
130
|
+
entry: { id: 'e1', data: { ...card, captionLabel: 'Our bestselling jug' } },
|
|
131
|
+
})
|
|
132
|
+
);
|
|
133
|
+
await flushPromises();
|
|
134
|
+
const caption = wrapper.get('[data-eldra-hero-caption]');
|
|
135
|
+
expect(caption.text()).toContain('Our bestselling jug');
|
|
136
|
+
expect(caption.text()).not.toContain('Glazed milk jug');
|
|
137
|
+
expect(caption.attributes('href')).toBe('/products/glazed-milk-jug');
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('draws the caption as a pill whose words are never underlined, at rest, hovered or pressed', async () => {
|
|
141
|
+
// The design's shoppable pill (`.nw-shoppable`): the pill is the affordance. `Link`'s
|
|
142
|
+
// `underline: false` still underlines on hover and press, so the caption turns both off.
|
|
143
|
+
const wrapper = mount(Block, mountOptions({ entry: { id: 'e1', data: card } }));
|
|
144
|
+
await flushPromises();
|
|
145
|
+
const caption = wrapper.get('[data-eldra-hero-caption]');
|
|
146
|
+
for (const token of [
|
|
147
|
+
'no-underline',
|
|
148
|
+
'hover:no-underline',
|
|
149
|
+
'active:no-underline',
|
|
150
|
+
'rounded-full',
|
|
151
|
+
]) {
|
|
152
|
+
expect(caption.classes()).toContain(token);
|
|
153
|
+
}
|
|
154
|
+
expect(caption.classes()).toContain('eldra:hover:underline');
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('shows no caption without a product, for a sold-out one, or outside the card variant', async () => {
|
|
158
|
+
const caption = async (data: Record<string, unknown>) => {
|
|
159
|
+
const wrapper = mount(Block, mountOptions({ entry: { id: 'e1', data } }));
|
|
160
|
+
await flushPromises();
|
|
161
|
+
return wrapper.find('[data-eldra-hero-caption]').exists();
|
|
162
|
+
};
|
|
163
|
+
expect(await caption({ ...card, captionProduct: null })).toBe(false);
|
|
164
|
+
expect(
|
|
165
|
+
await caption({
|
|
166
|
+
...card,
|
|
167
|
+
captionProduct: { _type: 'product', slug: 'enamel-camp-cups-set-of-6' },
|
|
120
168
|
})
|
|
169
|
+
).toBe(false);
|
|
170
|
+
// A draft's bare stub names no slug yet: nothing to look up until it is published.
|
|
171
|
+
expect(await caption({ ...card, captionProduct: { _type: 'product', id: 'abc' } })).toBe(
|
|
172
|
+
false
|
|
121
173
|
);
|
|
122
|
-
expect(
|
|
174
|
+
expect(await caption({ ...card, variant: 'image-right' })).toBe(false);
|
|
123
175
|
});
|
|
124
176
|
});
|
|
125
177
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"description": "Top-of-page banner with heading, supporting text, image and calls to action.",
|
|
5
5
|
"icon": "layout-dashboard",
|
|
6
6
|
"category": "marketing",
|
|
7
|
-
"version":
|
|
7
|
+
"version": 3,
|
|
8
8
|
"migrations": [
|
|
9
9
|
{
|
|
10
10
|
"version": 2,
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
{ "from": "ctaLabel", "to": "primaryCtaLabel" },
|
|
13
13
|
{ "from": "ctaHref", "to": "primaryCtaHref" }
|
|
14
14
|
]
|
|
15
|
-
}
|
|
15
|
+
},
|
|
16
|
+
{ "version": 3, "renames": [] }
|
|
16
17
|
],
|
|
17
18
|
"groups": [
|
|
18
19
|
{ "groupId": "content", "name": "Content", "defaultOpen": true },
|
|
@@ -101,39 +102,30 @@
|
|
|
101
102
|
"type": "string",
|
|
102
103
|
"localized": true
|
|
103
104
|
},
|
|
104
|
-
{ "fieldId": "href", "name": "Link", "type": "string" }
|
|
105
|
+
{ "fieldId": "href", "name": "Link", "type": "string", "allowPrices": false }
|
|
105
106
|
]
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
},
|
|
110
111
|
{
|
|
111
|
-
"fieldId": "
|
|
112
|
-
"name": "Image caption",
|
|
113
|
-
"type": "
|
|
112
|
+
"fieldId": "captionProduct",
|
|
113
|
+
"name": "Image caption product",
|
|
114
|
+
"type": "reference",
|
|
114
115
|
"groupId": "content",
|
|
115
|
-
"
|
|
116
|
-
"helpText": "
|
|
117
|
-
"showWhen": { "field": "variant", "in": ["card"] }
|
|
118
|
-
"validators": { "maxLength": 60 }
|
|
116
|
+
"relation": { "allowProducts": true },
|
|
117
|
+
"helpText": "The product in the photo. The caption shows its name and price and links to it, and hides while it is sold out. Card variant only.",
|
|
118
|
+
"showWhen": { "field": "variant", "in": ["card"] }
|
|
119
119
|
},
|
|
120
120
|
{
|
|
121
|
-
"fieldId": "
|
|
122
|
-
"name": "Image caption
|
|
121
|
+
"fieldId": "captionLabel",
|
|
122
|
+
"name": "Image caption text",
|
|
123
123
|
"type": "string",
|
|
124
124
|
"groupId": "content",
|
|
125
125
|
"localized": true,
|
|
126
|
-
"helpText": "
|
|
126
|
+
"helpText": "Leave empty to use the product's name.",
|
|
127
127
|
"showWhen": { "field": "variant", "in": ["card"] },
|
|
128
|
-
"validators": { "maxLength":
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
"fieldId": "captionHref",
|
|
132
|
-
"name": "Image caption link",
|
|
133
|
-
"type": "string",
|
|
134
|
-
"groupId": "content",
|
|
135
|
-
"helpText": "Where the caption goes, usually the product in the photo. No link, no caption.",
|
|
136
|
-
"showWhen": { "field": "variant", "in": ["card"] }
|
|
128
|
+
"validators": { "maxLength": 60 }
|
|
137
129
|
},
|
|
138
130
|
{
|
|
139
131
|
"fieldId": "spacing",
|
|
@@ -153,6 +145,7 @@
|
|
|
153
145
|
"fieldId": "primaryCtaHref",
|
|
154
146
|
"name": "Button link",
|
|
155
147
|
"type": "string",
|
|
148
|
+
"allowPrices": false,
|
|
156
149
|
"groupId": "action"
|
|
157
150
|
},
|
|
158
151
|
{
|
|
@@ -166,6 +159,7 @@
|
|
|
166
159
|
"fieldId": "secondaryCtaHref",
|
|
167
160
|
"name": "Secondary button link",
|
|
168
161
|
"type": "string",
|
|
162
|
+
"allowPrices": false,
|
|
169
163
|
"groupId": "action"
|
|
170
164
|
}
|
|
171
165
|
],
|
|
@@ -52,9 +52,7 @@
|
|
|
52
52
|
"href": "/products/dinner-plates"
|
|
53
53
|
}
|
|
54
54
|
],
|
|
55
|
-
"
|
|
56
|
-
"captionDetail": "$34",
|
|
57
|
-
"captionHref": "/products/glazed-milk-jug",
|
|
55
|
+
"captionProduct": { "_type": "product", "slug": "glazed-milk-jug" },
|
|
58
56
|
"primaryCtaHref": "/collections/the-winter-edit",
|
|
59
57
|
"secondaryCtaLabel": "Meet the makers",
|
|
60
58
|
"secondaryCtaHref": "/pages/makers",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|