@nexxtmove/ui 2.6.0 → 2.8.0
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/editor/molecules/EditorColor/EditorColor.vue.d.ts +7 -5
- package/dist/components/editor/molecules/EditorColor/_ColorField.vue.d.ts +4 -1
- package/dist/components/organisms/ColorPicker/ColorPicker.vue.d.ts +3 -1
- package/dist/index.js +95 -172
- package/dist/nuxt.js +0 -1
- package/package.json +38 -36
- package/src/attribute-contract.test.ts +151 -0
- package/src/components/atoms/AnimatedNumber/AnimatedNumber.stories.ts +36 -0
- package/src/components/atoms/AnimatedNumber/AnimatedNumber.test.ts +21 -0
- package/src/components/atoms/Avatar/Avatar.stories.ts +122 -0
- package/src/components/atoms/Avatar/Avatar.test.ts +134 -0
- package/src/components/atoms/Button/Button.stories.ts +290 -0
- package/src/components/atoms/Button/Button.test.ts +406 -0
- package/src/components/atoms/Card/Card.stories.ts +45 -0
- package/src/components/atoms/Card/Card.test.ts +46 -0
- package/src/components/atoms/Checkbox/Checkbox.stories.ts +35 -0
- package/src/components/atoms/Checkbox/Checkbox.test.ts +55 -0
- package/src/components/atoms/Chip/Chip.stories.ts +274 -0
- package/src/components/atoms/Chip/Chip.test.ts +230 -0
- package/src/components/atoms/EnergyLabel/EnergyLabel.stories.ts +189 -0
- package/src/components/atoms/EnergyLabel/EnergyLabel.test.ts +100 -0
- package/src/components/atoms/FloatingPanel/FloatingPanel.stories.ts +677 -0
- package/src/components/atoms/FloatingPanel/FloatingPanel.test.ts +864 -0
- package/src/components/atoms/Icon/Icon.stories.ts +63 -0
- package/src/components/atoms/Icon/Icon.test.ts +89 -0
- package/src/components/atoms/Loader/Loader.stories.ts +36 -0
- package/src/components/atoms/Loader/Loader.test.ts +40 -0
- package/src/components/atoms/PickerItem/PickerItem.stories.ts +172 -0
- package/src/components/atoms/PickerItem/PickerItem.test.ts +142 -0
- package/src/components/atoms/PickerPreview/PickerPreview.stories.ts +183 -0
- package/src/components/atoms/PickerPreview/PickerPreview.test.ts +137 -0
- package/src/components/atoms/PresenceIndicator/PresenceIndicator.stories.ts +21 -0
- package/src/components/atoms/PropertyListing/PropertyListing.stories.ts +38 -0
- package/src/components/atoms/PropertyListing/PropertyListing.test.ts +46 -0
- package/src/components/atoms/SelectableOption/SelectableOption.stories.ts +131 -0
- package/src/components/atoms/SelectableOption/SelectableOption.test.ts +96 -0
- package/src/components/atoms/Skeleton/Skeleton.stories.ts +27 -0
- package/src/components/atoms/Skeleton/Skeleton.test.ts +28 -0
- package/src/components/atoms/Slider/Slider.stories.ts +151 -0
- package/src/components/atoms/Slider/Slider.test.ts +191 -0
- package/src/components/atoms/Squircle/Squircle.stories.ts +114 -0
- package/src/components/atoms/Squircle/Squircle.test.ts +70 -0
- package/src/components/atoms/Switch/Switch.stories.ts +91 -0
- package/src/components/atoms/Switch/Switch.test.ts +183 -0
- package/src/components/atoms/Tooltip/Tooltip.stories.ts +158 -0
- package/src/components/atoms/Tooltip/Tooltip.test.ts +134 -0
- package/src/components/editor/atoms/EditorDimensionField/EditorDimensionField.stories.ts +124 -0
- package/src/components/editor/atoms/EditorDimensionField/EditorDimensionField.test.ts +464 -0
- package/src/components/editor/atoms/EditorSettingsBlock/EditorSettingsBlock.stories.ts +266 -0
- package/src/components/editor/atoms/EditorSettingsBlock/EditorSettingsBlock.test.ts +421 -0
- package/src/components/editor/atoms/EditorSettingsGroup/EditorSettingsGroup.stories.ts +365 -0
- package/src/components/editor/atoms/EditorSettingsGroup/EditorSettingsGroup.test.ts +484 -0
- package/src/components/editor/composables/useRadioGrid.test.ts +261 -0
- package/src/components/editor/molecules/EditorAlignItems/EditorAlignItems.stories.ts +73 -0
- package/src/components/editor/molecules/EditorAlignItems/EditorAlignItems.test.ts +189 -0
- package/src/components/editor/molecules/EditorAlignmentGrid/EditorAlignmentGrid.stories.ts +309 -0
- package/src/components/editor/molecules/EditorAlignmentGrid/EditorAlignmentGrid.test.ts +359 -0
- package/src/components/editor/molecules/EditorAnchor/EditorAnchor.stories.ts +138 -0
- package/src/components/editor/molecules/EditorAnchor/EditorAnchor.test.ts +344 -0
- package/src/components/editor/molecules/EditorBackgroundSize/EditorBackgroundSize.stories.ts +87 -0
- package/src/components/editor/molecules/EditorBackgroundSize/EditorBackgroundSize.test.ts +262 -0
- package/src/components/editor/molecules/EditorBlur/EditorBlur.stories.ts +115 -0
- package/src/components/editor/molecules/EditorBlur/EditorBlur.test.ts +243 -0
- package/src/components/editor/molecules/EditorBorder/EditorBorder.stories.ts +187 -0
- package/src/components/editor/molecules/EditorBorder/EditorBorder.test.ts +456 -0
- package/src/components/editor/molecules/EditorColor/EditorColor.stories.ts +633 -0
- package/src/components/editor/molecules/EditorColor/EditorColor.test.ts +776 -0
- package/src/components/editor/molecules/EditorColor/EditorColor.vue +7 -5
- package/src/components/editor/molecules/EditorColor/EditorColorGradient.test.ts +832 -0
- package/src/components/editor/molecules/EditorColor/_ColorField.vue +20 -15
- package/src/components/editor/molecules/EditorColor/gradientClass.test.ts +303 -0
- package/src/components/editor/molecules/EditorDashPattern/EditorDashPattern.stories.ts +72 -0
- package/src/components/editor/molecules/EditorDashPattern/EditorDashPattern.test.ts +124 -0
- package/src/components/editor/molecules/EditorFlexDirection/EditorFlexDirection.stories.ts +46 -0
- package/src/components/editor/molecules/EditorFlexDirection/EditorFlexDirection.test.ts +97 -0
- package/src/components/editor/molecules/EditorFontSize/EditorFontSize.stories.ts +248 -0
- package/src/components/editor/molecules/EditorFontSize/EditorFontSize.test.ts +288 -0
- package/src/components/editor/molecules/EditorGap/EditorGap.stories.ts +129 -0
- package/src/components/editor/molecules/EditorGap/EditorGap.test.ts +253 -0
- package/src/components/editor/molecules/EditorHeadingType/EditorHeadingType.stories.ts +68 -0
- package/src/components/editor/molecules/EditorHeadingType/EditorHeadingType.test.ts +150 -0
- package/src/components/editor/molecules/EditorJustifyContent/EditorJustifyContent.stories.ts +71 -0
- package/src/components/editor/molecules/EditorJustifyContent/EditorJustifyContent.test.ts +161 -0
- package/src/components/editor/molecules/EditorLetterSpacing/EditorLetterSpacing.stories.ts +204 -0
- package/src/components/editor/molecules/EditorLetterSpacing/EditorLetterSpacing.test.ts +238 -0
- package/src/components/editor/molecules/EditorLineHeight/EditorLineHeight.stories.ts +257 -0
- package/src/components/editor/molecules/EditorLineHeight/EditorLineHeight.test.ts +286 -0
- package/src/components/editor/molecules/EditorLineStyle/EditorLineStyle.stories.ts +135 -0
- package/src/components/editor/molecules/EditorLineStyle/EditorLineStyle.test.ts +230 -0
- package/src/components/editor/molecules/EditorMaxWidth/EditorMaxWidth.stories.ts +154 -0
- package/src/components/editor/molecules/EditorMaxWidth/EditorMaxWidth.test.ts +112 -0
- package/src/components/editor/molecules/EditorOverrideStatus/EditorOverrideStatus.stories.ts +206 -0
- package/src/components/editor/molecules/EditorOverrideStatus/EditorOverrideStatus.test.ts +332 -0
- package/src/components/editor/molecules/EditorPadding/EditorPadding.stories.ts +374 -0
- package/src/components/editor/molecules/EditorPadding/EditorPadding.test.ts +712 -0
- package/src/components/editor/molecules/EditorRadius/EditorRadius.stories.ts +64 -0
- package/src/components/editor/molecules/EditorRadius/EditorRadius.test.ts +137 -0
- package/src/components/editor/molecules/EditorShadow/EditorShadow.stories.ts +103 -0
- package/src/components/editor/molecules/EditorShadow/EditorShadow.test.ts +168 -0
- package/src/components/editor/molecules/EditorSize/EditorSize.stories.ts +84 -0
- package/src/components/editor/molecules/EditorSize/EditorSize.test.ts +253 -0
- package/src/components/editor/molecules/EditorSizeLimit/EditorSizeLimit.stories.ts +49 -0
- package/src/components/editor/molecules/EditorSizeLimit/EditorSizeLimit.test.ts +43 -0
- package/src/components/editor/molecules/EditorTextAlign/EditorTextAlign.stories.ts +69 -0
- package/src/components/editor/molecules/EditorTextAlign/EditorTextAlign.test.ts +155 -0
- package/src/components/molecules/Announcement/Announcement.stories.ts +224 -0
- package/src/components/molecules/Announcement/Announcement.test.ts +161 -0
- package/src/components/molecules/ContactInfoCard/ContactInfoCard.stories.ts +99 -0
- package/src/components/molecules/ContactInfoCard/ContactInfoCard.test.ts +70 -0
- package/src/components/molecules/CustomerJourneyTile/CustomerJourneyTile.stories.ts +148 -0
- package/src/components/molecules/CustomerJourneyTile/CustomerJourneyTile.test.ts +271 -0
- package/src/components/molecules/DoughnutChart/DoughnutChart.stories.ts +45 -0
- package/src/components/molecules/DoughnutChart/DoughnutChart.test.ts +205 -0
- package/src/components/molecules/InfoBlock/InfoBlock.stories.ts +84 -0
- package/src/components/molecules/InfoBlock/InfoBlock.test.ts +101 -0
- package/src/components/molecules/InputField/InputField.stories.ts +117 -0
- package/src/components/molecules/InputField/InputField.test.ts +138 -0
- package/src/components/molecules/InputSelect/InputSelect.stories.ts +116 -0
- package/src/components/molecules/InputSelect/InputSelect.test.ts +127 -0
- package/src/components/molecules/ModalFooter/ModalFooter.stories.ts +204 -0
- package/src/components/molecules/ModalFooter/ModalFooter.test.ts +276 -0
- package/src/components/molecules/PageCard/PageCard.stories.ts +100 -0
- package/src/components/molecules/PageCard/PageCard.test.ts +91 -0
- package/src/components/molecules/PageContainer/PageContainer.stories.ts +90 -0
- package/src/components/molecules/PageContainer/PageContainer.test.ts +50 -0
- package/src/components/molecules/PageMockup/PageMockup.stories.ts +38 -0
- package/src/components/molecules/PageMockup/PageMockup.test.ts +20 -0
- package/src/components/molecules/PageTypeTile/PageTypeTile.stories.ts +63 -0
- package/src/components/molecules/PageTypeTile/PageTypeTile.test.ts +41 -0
- package/src/components/molecules/Pagination/Pagination.stories.ts +72 -0
- package/src/components/molecules/Pagination/Pagination.test.ts +130 -0
- package/src/components/molecules/PickerGroup/PickerGroup.stories.ts +90 -0
- package/src/components/molecules/PickerGroup/PickerGroup.test.ts +145 -0
- package/src/components/molecules/PickerList/PickerList.stories.ts +436 -0
- package/src/components/molecules/PickerList/PickerList.test.ts +870 -0
- package/src/components/molecules/PlaceholderInput/PlaceholderInput.stories.ts +48 -0
- package/src/components/molecules/PlaceholderInput/PlaceholderInput.test.ts +107 -0
- package/src/components/molecules/PropertyCard/PropertyCard.stories.ts +46 -0
- package/src/components/molecules/PropertyCard/PropertyCard.test.ts +59 -0
- package/src/components/molecules/Select/Select.stories.ts +264 -0
- package/src/components/molecules/Select/Select.test.ts +315 -0
- package/src/components/molecules/SidebarMenuItem/SidebarMenuItem.stories.ts +84 -0
- package/src/components/molecules/SidebarMenuItem/SidebarMenuItem.test.ts +103 -0
- package/src/components/molecules/SkeletonPropertyCard/SkeletonPropertyCard.stories.ts +11 -0
- package/src/components/molecules/SkeletonPropertyCard/SkeletonPropertyCard.test.ts +38 -0
- package/src/components/molecules/SocialIcons/SocialIcons.stories.ts +28 -0
- package/src/components/molecules/SocialIcons/SocialIcons.test.ts +58 -0
- package/src/components/molecules/SocialMediaCustomTemplate/SocialMediaCustomTemplate.stories.ts +11 -0
- package/src/components/molecules/SocialMediaCustomTemplate/SocialMediaCustomTemplate.test.ts +116 -0
- package/src/components/molecules/SocialMediaType/SocialMediaType.stories.ts +37 -0
- package/src/components/molecules/SocialMediaType/SocialMediaType.test.ts +126 -0
- package/src/components/molecules/Source/Source.stories.ts +35 -0
- package/src/components/molecules/Source/Source.test.ts +45 -0
- package/src/components/molecules/TabbedContent/TabbedContent.stories.ts +96 -0
- package/src/components/molecules/TabbedContent/TabbedContent.test.ts +109 -0
- package/src/components/molecules/Tabs/Tabs.stories.ts +230 -0
- package/src/components/molecules/Tabs/Tabs.test.ts +280 -0
- package/src/components/molecules/TemplateCard/TemplateCard.stories.ts +327 -0
- package/src/components/molecules/TemplateCard/TemplateCard.test.ts +339 -0
- package/src/components/molecules/Textarea/Textarea.stories.ts +216 -0
- package/src/components/molecules/Textarea/Textarea.test.ts +191 -0
- package/src/components/molecules/TimelineEvent/TimelineEvent.stories.ts +319 -0
- package/src/components/molecules/TimelineEvent/TimelineEvent.test.ts +224 -0
- package/src/components/molecules/TimelineLanes/TimelineLanes.stories.ts +29 -0
- package/src/components/molecules/TimelineLanes/TimelineLanes.test.ts +30 -0
- package/src/components/molecules/Toast/Toast.stories.ts +110 -0
- package/src/components/molecules/Toast/Toast.test.ts +103 -0
- package/src/components/molecules/ToggleGroup/ToggleGroup.stories.ts +297 -0
- package/src/components/molecules/ToggleGroup/ToggleGroup.test.ts +578 -0
- package/src/components/molecules/Tree/Tree.stories.ts +884 -0
- package/src/components/molecules/Tree/Tree.test.ts +1247 -0
- package/src/components/molecules/Tree/tree-drop.test.ts +223 -0
- package/src/components/organisms/Calendar/Calendar.stories.ts +108 -0
- package/src/components/organisms/Calendar/Calendar.test.ts +279 -0
- package/src/components/organisms/Calendar/_CalendarDayView.test.ts +104 -0
- package/src/components/organisms/Calendar/_CalendarHeader.test.ts +86 -0
- package/src/components/organisms/Calendar/_CalendarMonthView.test.ts +52 -0
- package/src/components/organisms/Calendar/_CalendarTimePicker.test.ts +89 -0
- package/src/components/organisms/Calendar/_CalendarYearView.test.ts +56 -0
- package/src/components/organisms/ColorPicker/ColorPicker.stories.ts +229 -0
- package/src/components/organisms/ColorPicker/ColorPicker.test.ts +696 -0
- package/src/components/organisms/ColorPicker/ColorPicker.vue +12 -3
- package/src/components/organisms/ColorPicker/gradient.test.ts +67 -0
- package/src/components/organisms/ColorPicker/gradientGeometry.test.ts +206 -0
- package/src/components/organisms/Combobox/Combobox.stories.ts +234 -0
- package/src/components/organisms/Combobox/Combobox.test.ts +512 -0
- package/src/components/organisms/Combobox/Combobox.vue +1 -1
- package/src/components/organisms/ComboboxPanel/ComboboxPanel.stories.ts +158 -0
- package/src/components/organisms/ComboboxPanel/ComboboxPanel.test.ts +524 -0
- package/src/components/organisms/ComboboxPanel/ComboboxPanel.vue +1 -1
- package/src/components/organisms/CountrySelect/CountrySelect.stories.ts +139 -0
- package/src/components/organisms/CountrySelect/CountrySelect.test.ts +149 -0
- package/src/components/organisms/DatePicker/DatePicker.stories.ts +163 -0
- package/src/components/organisms/DatePicker/DatePicker.test.ts +214 -0
- package/src/components/organisms/DropdownButton/DropdownButton.stories.ts +123 -0
- package/src/components/organisms/DropdownButton/DropdownButton.test.ts +379 -0
- package/src/components/organisms/FontPicker/FontPicker.stories.ts +476 -0
- package/src/components/organisms/FontPicker/FontPicker.test.ts +873 -0
- package/src/components/organisms/Header/Header.stories.ts +75 -0
- package/src/components/organisms/Header/Header.test.ts +233 -0
- package/src/components/organisms/IconPicker/IconPicker.stories.ts +734 -0
- package/src/components/organisms/IconPicker/IconPicker.test.ts +669 -0
- package/src/components/organisms/IconPicker/_IconPickerGrid.test.ts +184 -0
- package/src/components/organisms/IconPicker/_IconPickerRail.test.ts +102 -0
- package/src/components/organisms/IconPicker/useIconPickerNavigation.test.ts +215 -0
- package/src/components/organisms/Modal/Modal.stories.ts +350 -0
- package/src/components/organisms/Modal/Modal.test.ts +275 -0
- package/src/components/organisms/PickerPanel/PickerPanel.stories.ts +452 -0
- package/src/components/organisms/PickerPanel/PickerPanel.test.ts +358 -0
- package/src/components/organisms/ProgressBar/ProgressBar.stories.ts +100 -0
- package/src/components/organisms/ProgressBar/ProgressBar.test.ts +417 -0
- package/src/components/organisms/ReferenceCard/ReferenceCard.stories.ts +191 -0
- package/src/components/organisms/ReferenceCard/ReferenceCard.test.ts +165 -0
- package/src/components/organisms/SocialMediaTemplate/SocialMediaTemplate.stories.ts +65 -0
- package/src/components/organisms/SocialMediaTemplate/SocialMediaTemplate.test.ts +466 -0
- package/src/components/organisms/StepperHeader/StepperHeader.stories.ts +91 -0
- package/src/components/organisms/StepperHeader/StepperHeader.test.ts +279 -0
- package/src/components/organisms/Table/Table.stories.ts +332 -0
- package/src/components/organisms/Table/Table.test.ts +320 -0
- package/src/components/organisms/TimelinePhaseblock/TimelinePhaseblock.stories.ts +198 -0
- package/src/components/organisms/TimelinePhaseblock/TimelinePhaseblock.test.ts +283 -0
- package/src/components/organisms/TimelineTrack/TimelineTrack.stories.ts +120 -0
- package/src/components/organisms/TimelineTrack/TimelineTrack.test.ts +91 -0
- package/src/components/organisms/Toaster/Toaster.stories.ts +51 -0
- package/src/components/organisms/Toaster/Toaster.test.ts +75 -0
- package/src/components/organisms/VideoControls/VideoControls.stories.ts +792 -0
- package/src/components/organisms/VideoControls/VideoControls.test.ts +1056 -0
- package/src/components/organisms/VideoPlayer/VideoPlayer.stories.ts +327 -0
- package/src/components/organisms/VideoPlayer/VideoPlayer.test.ts +439 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite'
|
|
2
|
+
import { expect } from 'storybook/test'
|
|
3
|
+
import EnergyLabel, { ENERGY_LABEL_COLORS, type EnergyLabelLetter } from './EnergyLabel.vue'
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Components/Atoms/Energy Label',
|
|
7
|
+
component: EnergyLabel,
|
|
8
|
+
argTypes: {
|
|
9
|
+
label: {
|
|
10
|
+
control: 'select',
|
|
11
|
+
options: ['A++++', 'A+++', 'A++', 'A+', 'A', 'B', 'C', 'D', 'E', 'F', 'G'],
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
} satisfies Meta<typeof EnergyLabel>
|
|
15
|
+
|
|
16
|
+
type Story = StoryObj<typeof EnergyLabel>
|
|
17
|
+
|
|
18
|
+
export const AQuadruplePlus: Story = {
|
|
19
|
+
name: 'A++++',
|
|
20
|
+
args: { label: 'A++++' },
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const ATriplePlus: Story = {
|
|
24
|
+
name: 'A+++',
|
|
25
|
+
args: { label: 'A+++' },
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const ADoublePlus: Story = {
|
|
29
|
+
name: 'A++',
|
|
30
|
+
args: { label: 'A++' },
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const ASinglePlus: Story = {
|
|
34
|
+
name: 'A+',
|
|
35
|
+
args: { label: 'A+' },
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const A: Story = {
|
|
39
|
+
args: { label: 'A' },
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const B: Story = {
|
|
43
|
+
args: { label: 'B' },
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const C: Story = {
|
|
47
|
+
args: { label: 'C' },
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const D: Story = {
|
|
51
|
+
args: { label: 'D' },
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const E: Story = {
|
|
55
|
+
args: { label: 'E' },
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const F: Story = {
|
|
59
|
+
args: { label: 'F' },
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const G: Story = {
|
|
63
|
+
args: { label: 'G' },
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const Lowercase: Story = {
|
|
67
|
+
args: { label: 'a++' },
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const LETTERS = Object.keys(ENERGY_LABEL_COLORS) as EnergyLabelLetter[]
|
|
71
|
+
|
|
72
|
+
const SIZES = [
|
|
73
|
+
{ name: 'Klein', class: 'text-[0.625rem]' },
|
|
74
|
+
{ name: 'Standaard', class: '' },
|
|
75
|
+
{ name: 'Groot', class: 'text-xl' },
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
// The arrow is a square of 17/24 of the label's height, turned 45 degrees.
|
|
79
|
+
const ARROW_RATIO = 17 / 24
|
|
80
|
+
|
|
81
|
+
const measureRow = (row: HTMLElement) =>
|
|
82
|
+
[...row.querySelectorAll<HTMLElement>('[role="img"]')].map((el) => {
|
|
83
|
+
const box = el.getBoundingClientRect()
|
|
84
|
+
const after = getComputedStyle(el, '::after')
|
|
85
|
+
const style = getComputedStyle(el)
|
|
86
|
+
const side = parseFloat(after.height)
|
|
87
|
+
return {
|
|
88
|
+
fontSize: parseFloat(style.fontSize),
|
|
89
|
+
lineHeight: parseFloat(style.lineHeight),
|
|
90
|
+
marginRight: parseFloat(style.marginRight),
|
|
91
|
+
box,
|
|
92
|
+
text: (el.firstElementChild as HTMLElement).getBoundingClientRect(),
|
|
93
|
+
side,
|
|
94
|
+
centerY: box.top + parseFloat(after.top),
|
|
95
|
+
tip: box.right + (side * Math.SQRT2) / 2,
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Size comes from classes on the component: a font-size class scales the whole
|
|
101
|
+
* label, arrow and margin included. The play checks every letter at every size:
|
|
102
|
+
* the arrow keeps its proportion and centre, covers the full height, stays clear
|
|
103
|
+
* of the next label, and the text fits inside the label.
|
|
104
|
+
*/
|
|
105
|
+
export const Sizes: Story = {
|
|
106
|
+
render: () => ({
|
|
107
|
+
components: { EnergyLabel },
|
|
108
|
+
setup: () => ({ letters: LETTERS, sizes: SIZES }),
|
|
109
|
+
template: `
|
|
110
|
+
<div class="flex flex-col gap-6">
|
|
111
|
+
<div v-for="size in sizes" :key="size.name" class="flex flex-col gap-2">
|
|
112
|
+
<span class="small-normal text-gray-700">{{ size.name }}</span>
|
|
113
|
+
<div :data-size="size.name" class="flex flex-wrap items-center gap-y-2">
|
|
114
|
+
<EnergyLabel v-for="letter in letters" :key="letter" :label="letter" :class="size.class" />
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
<div data-size="Stretched" class="flex h-12">
|
|
118
|
+
<EnergyLabel label="B" />
|
|
119
|
+
</div>
|
|
120
|
+
</div>`,
|
|
121
|
+
}),
|
|
122
|
+
play: async ({ canvasElement }) => {
|
|
123
|
+
const fontSizes: Record<string, number> = {}
|
|
124
|
+
|
|
125
|
+
for (const { name } of SIZES) {
|
|
126
|
+
const labels = measureRow(canvasElement.querySelector(`[data-size="${name}"]`) as HTMLElement)
|
|
127
|
+
await expect(labels).toHaveLength(LETTERS.length)
|
|
128
|
+
fontSizes[name] = labels[0].fontSize
|
|
129
|
+
|
|
130
|
+
for (const [index, label] of labels.entries()) {
|
|
131
|
+
const { box, text, side, centerY, tip } = label
|
|
132
|
+
// The height follows from line-height plus a third of an em on each side,
|
|
133
|
+
// and the margin is half of it: the room the arrow tip takes.
|
|
134
|
+
await expect(box.height).toBeCloseTo(label.lineHeight + (label.fontSize * 2) / 3, 1)
|
|
135
|
+
await expect(label.marginRight).toBeCloseTo(box.height / 2, 1)
|
|
136
|
+
await expect(side / box.height).toBeCloseTo(ARROW_RATIO, 2)
|
|
137
|
+
await expect(side * Math.SQRT2).toBeGreaterThanOrEqual(box.height)
|
|
138
|
+
await expect(centerY).toBeCloseTo(box.top + box.height / 2, 1)
|
|
139
|
+
await expect(tip - box.right).toBeCloseTo(box.height / 2, 0)
|
|
140
|
+
|
|
141
|
+
const next = labels[index + 1]
|
|
142
|
+
if (next && next.box.top === box.top) {
|
|
143
|
+
await expect(tip).toBeLessThanOrEqual(next.box.left + 0.5)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
await expect(text.left).toBeGreaterThanOrEqual(box.left)
|
|
147
|
+
await expect(text.right).toBeLessThanOrEqual(box.right)
|
|
148
|
+
await expect(text.top).toBeGreaterThanOrEqual(box.top)
|
|
149
|
+
await expect(text.bottom).toBeLessThanOrEqual(box.bottom)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
await expect(fontSizes).toEqual({ Klein: 10, Standaard: 12, Groot: 20 })
|
|
154
|
+
|
|
155
|
+
const [standard] = measureRow(
|
|
156
|
+
canvasElement.querySelector('[data-size="Standaard"]') as HTMLElement,
|
|
157
|
+
)
|
|
158
|
+
await expect(standard.box.height).toBe(24)
|
|
159
|
+
|
|
160
|
+
const [stretched] = measureRow(
|
|
161
|
+
canvasElement.querySelector('[data-size="Stretched"]') as HTMLElement,
|
|
162
|
+
)
|
|
163
|
+
await expect(stretched.box.height).toBe(24)
|
|
164
|
+
},
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Padding, typography and margin classes override the defaults. Raising the
|
|
169
|
+
* vertical padding needs the same raise on the right margin, so the arrow keeps
|
|
170
|
+
* its room: `py-2` and `mr-5` give a 40px label with 20px for the arrow.
|
|
171
|
+
*/
|
|
172
|
+
export const CustomStyling: Story = {
|
|
173
|
+
render: () => ({
|
|
174
|
+
components: { EnergyLabel },
|
|
175
|
+
template: `
|
|
176
|
+
<div class="flex items-center">
|
|
177
|
+
<EnergyLabel label="A+" class="mr-5 px-4 py-2 body-semibold-serif" />
|
|
178
|
+
<span data-neighbour class="small-normal text-gray-700">Buur</span>
|
|
179
|
+
</div>`,
|
|
180
|
+
}),
|
|
181
|
+
play: async ({ canvasElement }) => {
|
|
182
|
+
const [label] = measureRow(canvasElement)
|
|
183
|
+
const neighbour = (
|
|
184
|
+
canvasElement.querySelector('[data-neighbour]') as HTMLElement
|
|
185
|
+
).getBoundingClientRect()
|
|
186
|
+
await expect(label.side / label.box.height).toBeCloseTo(ARROW_RATIO, 2)
|
|
187
|
+
await expect(label.tip).toBeLessThanOrEqual(neighbour.left + 0.5)
|
|
188
|
+
},
|
|
189
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import EnergyLabel from './EnergyLabel.vue'
|
|
4
|
+
import { ENERGY_LABEL_COLORS, type EnergyLabelLetter } from '../../../index'
|
|
5
|
+
|
|
6
|
+
describe('EnergyLabel', () => {
|
|
7
|
+
it.each([
|
|
8
|
+
{ label: 'A++++' as const, color: 'rgb(0, 149, 63)' },
|
|
9
|
+
{ label: 'A+++' as const, color: 'rgb(0, 149, 63)' },
|
|
10
|
+
{ label: 'A++' as const, color: 'rgb(0, 149, 63)' },
|
|
11
|
+
{ label: 'A+' as const, color: 'rgb(0, 149, 63)' },
|
|
12
|
+
{ label: 'A' as const, color: 'rgb(0, 149, 63)' },
|
|
13
|
+
{ label: 'B' as const, color: 'rgb(82, 174, 50)' },
|
|
14
|
+
{ label: 'C' as const, color: 'rgb(165, 206, 109)' },
|
|
15
|
+
{ label: 'D' as const, color: 'rgb(255, 204, 0)' },
|
|
16
|
+
{ label: 'E' as const, color: 'rgb(249, 169, 60)' },
|
|
17
|
+
{ label: 'F' as const, color: 'rgb(239, 125, 52)' },
|
|
18
|
+
{ label: 'G' as const, color: 'rgb(230, 51, 41)' },
|
|
19
|
+
])('renders "$label" with its swatch colour as background', ({ label, color }) => {
|
|
20
|
+
const wrapper = mount(EnergyLabel, { props: { label } })
|
|
21
|
+
expect(wrapper.text()).toBe(label)
|
|
22
|
+
expect(wrapper.attributes('style')).toContain(`background-color: ${color}`)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('exposes the colour to the arrow via a custom property', () => {
|
|
26
|
+
const wrapper = mount(EnergyLabel, { props: { label: 'G' } })
|
|
27
|
+
expect(wrapper.attributes('style')).toContain('--energy-label-color: #E63329')
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it.each([
|
|
31
|
+
{ label: 'a++++' as const, expected: 'A++++' },
|
|
32
|
+
{ label: 'a+' as const, expected: 'A+' },
|
|
33
|
+
{ label: 'c' as const, expected: 'C' },
|
|
34
|
+
{ label: 'g' as const, expected: 'G' },
|
|
35
|
+
])('uppercases lowercase input "$label"', ({ label, expected }) => {
|
|
36
|
+
const wrapper = mount(EnergyLabel, { props: { label } })
|
|
37
|
+
expect(wrapper.text()).toBe(expected)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('renders lowercase input with the same colour as its uppercase equivalent', () => {
|
|
41
|
+
const lower = mount(EnergyLabel, { props: { label: 'd' } })
|
|
42
|
+
const upper = mount(EnergyLabel, { props: { label: 'D' } })
|
|
43
|
+
expect(lower.attributes('style')).toBe(upper.attributes('style'))
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('renders white text on the label', () => {
|
|
47
|
+
const wrapper = mount(EnergyLabel, { props: { label: 'A' } })
|
|
48
|
+
expect(wrapper.classes()).toContain('text-white')
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('is announced as an energy label with its grade', () => {
|
|
52
|
+
const wrapper = mount(EnergyLabel, { props: { label: 'a++' } })
|
|
53
|
+
expect(wrapper.attributes('role')).toBe('img')
|
|
54
|
+
expect(wrapper.attributes('aria-label')).toBe('Energielabel A++')
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('hides the visible text from screen readers to avoid a double announcement', () => {
|
|
58
|
+
const wrapper = mount(EnergyLabel, { props: { label: 'A' } })
|
|
59
|
+
expect(wrapper.find('span > span').attributes('aria-hidden')).toBe('true')
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('updates colour and label when the prop changes', async () => {
|
|
63
|
+
const wrapper = mount(EnergyLabel, { props: { label: 'A' } })
|
|
64
|
+
await wrapper.setProps({ label: 'G' })
|
|
65
|
+
expect(wrapper.text()).toBe('G')
|
|
66
|
+
expect(wrapper.attributes('style')).toContain('rgb(230, 51, 41)')
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('exports the colour table from the package entry, one swatch per grade', () => {
|
|
70
|
+
const letters: EnergyLabelLetter[] = [
|
|
71
|
+
'A++++',
|
|
72
|
+
'A+++',
|
|
73
|
+
'A++',
|
|
74
|
+
'A+',
|
|
75
|
+
'A',
|
|
76
|
+
'B',
|
|
77
|
+
'C',
|
|
78
|
+
'D',
|
|
79
|
+
'E',
|
|
80
|
+
'F',
|
|
81
|
+
'G',
|
|
82
|
+
]
|
|
83
|
+
expect(Object.keys(ENERGY_LABEL_COLORS)).toEqual(letters)
|
|
84
|
+
expect(ENERGY_LABEL_COLORS.G).toBe('#E63329')
|
|
85
|
+
expect(Object.isFrozen(ENERGY_LABEL_COLORS)).toBe(true)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('paints each grade in the colour the exported table gives it', () => {
|
|
89
|
+
for (const [label, color] of Object.entries(ENERGY_LABEL_COLORS)) {
|
|
90
|
+
const wrapper = mount(EnergyLabel, { props: { label: label as EnergyLabelLetter } })
|
|
91
|
+
expect(wrapper.attributes('style')).toContain(`--energy-label-color: ${color}`)
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('passes a class through to the label, next to its own classes', () => {
|
|
96
|
+
const wrapper = mount(EnergyLabel, { props: { label: 'B' }, attrs: { class: 'px-4 text-xl' } })
|
|
97
|
+
expect(wrapper.classes()).toEqual(expect.arrayContaining(['px-4', 'text-xl', 'inline-flex']))
|
|
98
|
+
expect(wrapper.attributes('role')).toBe('img')
|
|
99
|
+
})
|
|
100
|
+
})
|