@citizenplane/pimp 18.23.4 → 18.23.6
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/dist/components/CpBasket.vue.d.ts +6 -6
- package/dist/components/CpBasket.vue.d.ts.map +1 -1
- package/dist/pimp.es.js +9283 -9280
- package/dist/pimp.umd.js +60 -60
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/CpBasket.spec.ts +4 -4
- package/src/components/CpBasket.vue +5 -7
- package/src/components/CpQuantityCounter.vue +1 -1
- package/src/components/__snapshots__/CpBasket.spec.ts.snap +3 -7
- package/src/stories/CpBasket.stories.ts +57 -1
package/package.json
CHANGED
|
@@ -21,14 +21,14 @@ const promoRows: CpBasketRow[] = [{ label: 'Promo SUMMER25 applied', value: '-10
|
|
|
21
21
|
const defaultProps = { total: '47,00 €', totalLabel: 'Total' }
|
|
22
22
|
|
|
23
23
|
describe('CpBasket', () => {
|
|
24
|
-
it('renders text-only rows as two
|
|
24
|
+
it('renders text-only rows as two morphing spans', () => {
|
|
25
25
|
const wrapper = mount(CpBasket, { props: { ...defaultProps, rows: textOnlyRows } })
|
|
26
26
|
|
|
27
27
|
const renderedRows = wrapper.findAll('.cpBasket__row')
|
|
28
28
|
|
|
29
29
|
expect(renderedRows).toHaveLength(2)
|
|
30
|
-
expect(renderedRows[0].element.innerHTML).toBe('<span>Seat 12A</span><span>12,00 €</span>')
|
|
31
|
-
expect(renderedRows[1].element.innerHTML).toBe('<span>Carbon offset</span><span>3,00 €</span>')
|
|
30
|
+
expect(renderedRows[0].element.innerHTML).toBe('<span class="">Seat 12A</span><span class="">12,00 €</span>')
|
|
31
|
+
expect(renderedRows[1].element.innerHTML).toBe('<span class="">Carbon offset</span><span class="">3,00 €</span>')
|
|
32
32
|
expect(wrapper.html()).toMatchSnapshot()
|
|
33
33
|
})
|
|
34
34
|
|
|
@@ -41,7 +41,7 @@ describe('CpBasket', () => {
|
|
|
41
41
|
const renderedRow = wrapper.get('.cpBasket__row')
|
|
42
42
|
|
|
43
43
|
expect(renderedRow.element.children).toHaveLength(2)
|
|
44
|
-
expect(renderedRow.element.children[0].outerHTML).toBe('<span>Promo SUMMER25 applied</span>')
|
|
44
|
+
expect(renderedRow.element.children[0].outerHTML).toBe('<span class="">Promo SUMMER25 applied</span>')
|
|
45
45
|
expect(renderedRow.get('.promoValue').text()).toBe('-10,00 €')
|
|
46
46
|
})
|
|
47
47
|
|
|
@@ -16,12 +16,10 @@
|
|
|
16
16
|
<cp-transition-list-items>
|
|
17
17
|
<div v-for="group in category.groups" :key="group.id" class="cpBasket__group">
|
|
18
18
|
<p v-if="group.label" class="cpBasket__route">{{ group.label }}</p>
|
|
19
|
-
<
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
</div>
|
|
24
|
-
</cp-transition-list-items>
|
|
19
|
+
<div v-for="row in group.rows" :key="row.key" :class="group.rowClass">
|
|
20
|
+
<slot name="rowLabel" :row="row"><cp-text-morph :text="row.label" as="span" /></slot>
|
|
21
|
+
<slot name="rowValue" :row="row"><cp-text-morph :text="row.value" as="span" /></slot>
|
|
22
|
+
</div>
|
|
25
23
|
</div>
|
|
26
24
|
</cp-transition-list-items>
|
|
27
25
|
</div>
|
|
@@ -46,6 +44,7 @@ import { computed, useSlots } from 'vue'
|
|
|
46
44
|
|
|
47
45
|
import type { CpBasketCategory, CpBasketRow } from '@/constants/CpBasketTypes'
|
|
48
46
|
|
|
47
|
+
import CpTextMorph from '@/components/CpTextMorph.vue'
|
|
49
48
|
import CpTransitionExpand from '@/components/CpTransitionExpand.vue'
|
|
50
49
|
import CpTransitionListItems from '@/components/CpTransitionListItems.vue'
|
|
51
50
|
|
|
@@ -192,7 +191,6 @@ const hasSections = computed(() => visibleCategories.value.length > 0)
|
|
|
192
191
|
|
|
193
192
|
& + & {
|
|
194
193
|
padding-top: var(--cp-spacing-sm-md);
|
|
195
|
-
border-top: fn.px-to-rem(1) solid var(--cp-border-soft);
|
|
196
194
|
}
|
|
197
195
|
}
|
|
198
196
|
|
|
@@ -64,7 +64,7 @@ const increment = () => {
|
|
|
64
64
|
align-items: center;
|
|
65
65
|
padding: var(--cp-spacing-xs);
|
|
66
66
|
border-radius: var(--cp-radius-md-lg);
|
|
67
|
-
background: var(--cp-background-
|
|
67
|
+
background: var(--cp-background-secondary);
|
|
68
68
|
gap: var(--cp-spacing-sm);
|
|
69
69
|
|
|
70
70
|
&__button {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
-
exports[`CpBasket > renders text-only rows as two
|
|
3
|
+
exports[`CpBasket > renders text-only rows as two morphing spans 1`] = `
|
|
4
4
|
"<div class="cpBasket">
|
|
5
5
|
<!--v-if-->
|
|
6
6
|
<transition-stub data-v-19d824c7="" name="expand" appear="false" persisted="false" css="true">
|
|
@@ -15,15 +15,11 @@ exports[`CpBasket > renders text-only rows as two plain spans 1`] = `
|
|
|
15
15
|
<transition-group-stub name="list-items" appear="false" persisted="false" css="true">
|
|
16
16
|
<div class="cpBasket__group">
|
|
17
17
|
<p class="cpBasket__route">CDG → ORY</p>
|
|
18
|
-
<
|
|
19
|
-
<div class="cpBasket__row cpBasket__row--isIndented"><span>Seat 12A</span><span>12,00 €</span></div>
|
|
20
|
-
</transition-group-stub>
|
|
18
|
+
<div class="cpBasket__row cpBasket__row--isIndented"><span class="">Seat 12A</span><span class="">12,00 €</span></div>
|
|
21
19
|
</div>
|
|
22
20
|
<div class="cpBasket__group">
|
|
23
21
|
<!--v-if-->
|
|
24
|
-
<
|
|
25
|
-
<div class="cpBasket__row"><span>Carbon offset</span><span>3,00 €</span></div>
|
|
26
|
-
</transition-group-stub>
|
|
22
|
+
<div class="cpBasket__row"><span class="">Carbon offset</span><span class="">3,00 €</span></div>
|
|
27
23
|
</div>
|
|
28
24
|
</transition-group-stub>
|
|
29
25
|
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Args, Meta, StoryObj } from '@storybook/vue3-vite'
|
|
2
|
-
import { ref } from 'vue'
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
3
|
|
|
4
4
|
import type { CpBasketRow } from '@/constants/CpBasketTypes'
|
|
5
5
|
|
|
@@ -99,6 +99,28 @@ const fakeRowPool: CpBasketRow[] = [
|
|
|
99
99
|
{ label: 'Priority boarding', value: '8,00 €', category: extrasCategory, group: null },
|
|
100
100
|
]
|
|
101
101
|
|
|
102
|
+
const morphBaseRows: CpBasketRow[] = [
|
|
103
|
+
{ label: 'Seat 12A', value: '12,00 €', category: { ...seatsCategory, subtotal: '12,00 €' }, group: outboundGroup },
|
|
104
|
+
{
|
|
105
|
+
label: 'Cabin baggage 10kg',
|
|
106
|
+
value: '20,00 €',
|
|
107
|
+
category: { ...baggageCategory, subtotal: '20,00 €' },
|
|
108
|
+
group: outboundGroup,
|
|
109
|
+
},
|
|
110
|
+
{ label: 'Carbon offset', value: '3,00 €', category: { ...extrasCategory, subtotal: '3,00 €' } },
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
const morphDoubledRows: CpBasketRow[] = [
|
|
114
|
+
{ label: 'Seat 12A', value: '24,00 €', category: { ...seatsCategory, subtotal: '24,00 €' }, group: outboundGroup },
|
|
115
|
+
{
|
|
116
|
+
label: 'Cabin baggage 10kg',
|
|
117
|
+
value: '40,00 €',
|
|
118
|
+
category: { ...baggageCategory, subtotal: '40,00 €' },
|
|
119
|
+
group: outboundGroup,
|
|
120
|
+
},
|
|
121
|
+
{ label: 'Carbon offset', value: '6,00 €', category: { ...extrasCategory, subtotal: '6,00 €' } },
|
|
122
|
+
]
|
|
123
|
+
|
|
102
124
|
const promoCategory = { id: 'promo', label: 'Promo code', subtotal: '-10,00 €' }
|
|
103
125
|
|
|
104
126
|
const promoRows: CpBasketRow[] = [
|
|
@@ -330,6 +352,40 @@ export const TrailingSlot: Story = {
|
|
|
330
352
|
}),
|
|
331
353
|
}
|
|
332
354
|
|
|
355
|
+
/**
|
|
356
|
+
* The rows keep their identity while their amounts change: clicking "Double
|
|
357
|
+
* the quantities" only swaps `row.value`, so each value morphs in place
|
|
358
|
+
* through `cp-text-morph` instead of the row re-entering the list.
|
|
359
|
+
*/
|
|
360
|
+
export const MorphingRowValues: Story = {
|
|
361
|
+
args: {
|
|
362
|
+
rows: morphBaseRows,
|
|
363
|
+
total: '35,00 €',
|
|
364
|
+
totalLabel: 'Total',
|
|
365
|
+
},
|
|
366
|
+
render: (args: Args) => ({
|
|
367
|
+
components: { CpBasket, CpButton },
|
|
368
|
+
setup() {
|
|
369
|
+
const isDoubled = ref(false)
|
|
370
|
+
|
|
371
|
+
const storyRows = computed<CpBasketRow[]>(() => (isDoubled.value ? morphDoubledRows : morphBaseRows))
|
|
372
|
+
const storyTotal = computed<string>(() => (isDoubled.value ? '70,00 €' : '35,00 €'))
|
|
373
|
+
|
|
374
|
+
const toggleQuantities = () => {
|
|
375
|
+
isDoubled.value = !isDoubled.value
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
return { args, storyRows, storyTotal, toggleQuantities }
|
|
379
|
+
},
|
|
380
|
+
template: `
|
|
381
|
+
<div style="display: flex; flex-direction: column; gap: 16px; max-width: 415px;">
|
|
382
|
+
<CpButton @click="toggleQuantities">Double the quantities</CpButton>
|
|
383
|
+
<CpBasket v-bind="args" :rows="storyRows" :total="storyTotal" />
|
|
384
|
+
</div>
|
|
385
|
+
`,
|
|
386
|
+
}),
|
|
387
|
+
}
|
|
388
|
+
|
|
333
389
|
/**
|
|
334
390
|
* `#rowLabel` and `#rowValue` let the consumer own one cell of a row while the
|
|
335
391
|
* rest of the basket keeps its default text rendering. Here the promo row
|