spoko-design-system 1.8.1 → 1.9.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.
@@ -1,240 +0,0 @@
1
- <script lang="ts" setup>
2
- import { ref, onMounted, onUnmounted } from 'vue';
3
- import type { PropType } from 'vue';
4
- import tippy, { type Instance } from 'tippy.js';
5
- import 'tippy.js/dist/tippy.css';
6
- import '../../styles/tippy-theme.css';
7
-
8
- /*
9
- VAG group (VW/Audi/Skoda/Seat/Porsche/Bentley/Lamborghini/Ducati/Cupra/Scania/MAN) manufacturer Engine Code
10
- Displays engine code with detailed tooltip showing: name, power, displacement, dates, etc.
11
- */
12
-
13
- interface Engine {
14
- id?: number;
15
- code: string;
16
- name?: string;
17
- info?: string | null;
18
- serie?: {
19
- value: string;
20
- label: string;
21
- };
22
- type?: {
23
- value: string;
24
- translated: string;
25
- label: string;
26
- };
27
- power?: {
28
- kw: number;
29
- ps: number;
30
- ps_label: string;
31
- label: string;
32
- };
33
- date?: {
34
- value: string;
35
- label: string;
36
- };
37
- displacement?: {
38
- value: number;
39
- label: string;
40
- };
41
- compression_ratio?: {
42
- value: string | null;
43
- label: string;
44
- };
45
- valves?: {
46
- value: number | null;
47
- label: string;
48
- };
49
- euro?: {
50
- value: number;
51
- label: string;
52
- };
53
- pivot?: any;
54
-
55
- // Backward compatibility - old flat structure
56
- kw?: number;
57
- ps?: number;
58
- cc?: number;
59
- c_ratio?: string | null;
60
- }
61
-
62
- const props = defineProps({
63
- engine: {
64
- type: Object as PropType<Engine>,
65
- required: true,
66
- },
67
- showComma: {
68
- type: Boolean,
69
- default: false,
70
- required: false,
71
- },
72
- translations: {
73
- type: Object as PropType<{
74
- power?: string;
75
- cc?: string;
76
- compressionRatio?: string;
77
- valves?: string;
78
- euro?: string;
79
- horsepowerUnit?: string; // 'PS' for German, 'KM' for Polish, 'HP' for English
80
- }>,
81
- default: () => ({
82
- power: 'Power',
83
- cc: 'CC',
84
- compressionRatio: 'C. Ratio',
85
- valves: 'Valves',
86
- euro: 'Euro',
87
- horsepowerUnit: 'PS',
88
- }),
89
- required: false,
90
- },
91
- });
92
-
93
- const engineRef = ref<HTMLElement | null>(null);
94
- let tippyInstance: Instance | null = null;
95
-
96
- // Helper to get series value (supports both old and new API)
97
- const getSerieValue = (): string => {
98
- if (props.engine.serie && typeof props.engine.serie === 'object') {
99
- return props.engine.serie.value;
100
- }
101
- // Backward compatibility - old API
102
- const serie = props.engine.serie as any;
103
- if (!serie) return '';
104
- return serie === 3 ? 'EA288' : serie === 2 ? 'EA189' : `Serie ${serie}`;
105
- };
106
-
107
- // Generate tooltip HTML content
108
- const getTooltipContent = () => {
109
- // Header section
110
- let headerContent = `<strong>${props.engine.name || props.engine.code}</strong>`;
111
- if (props.engine.info) {
112
- headerContent += ` <span class="info">${props.engine.info}</span>`;
113
- }
114
- const serieValue = getSerieValue();
115
- if (serieValue) {
116
- headerContent += `<div class="series-badge">${serieValue}</div>`;
117
- }
118
-
119
- const header = `<div class="tooltip-header">${headerContent}</div>`;
120
-
121
- // Specs rows
122
- const rows = [];
123
-
124
- // Power (supports both new and old API structure)
125
- const power = props.engine.power;
126
- const oldKw = props.engine.kw;
127
- const oldPs = props.engine.ps;
128
-
129
- if (power || oldKw || oldPs) {
130
- const powerValues = [];
131
- const kw = power?.kw || oldKw;
132
- const ps = power?.ps || oldPs;
133
- const psLabel = power?.ps_label || props.translations.horsepowerUnit;
134
- const powerLabel = power?.label || props.translations.power;
135
-
136
- if (kw) powerValues.push(`${kw} kW`);
137
- if (ps) powerValues.push(`${ps} ${psLabel}`);
138
-
139
- if (powerValues.length) {
140
- rows.push(`<div class="tooltip-row"><span class="tooltip-label">${powerLabel}:</span><span class="tooltip-value">${powerValues.join(' / ')}</span></div>`);
141
- }
142
- }
143
-
144
- // Displacement (CC)
145
- const displacement = props.engine.displacement;
146
- const oldCc = props.engine.cc;
147
-
148
- if (displacement || oldCc) {
149
- const ccValue = displacement?.value || oldCc;
150
- const ccLabel = displacement?.label || props.translations.cc;
151
-
152
- if (ccValue) {
153
- rows.push(`<div class="tooltip-row"><span class="tooltip-label">${ccLabel}:</span><span class="tooltip-value">${ccValue} cm³</span></div>`);
154
- }
155
- }
156
-
157
- // Euro standard
158
- const euro = props.engine.euro;
159
-
160
- if (euro && typeof euro === 'object') {
161
- if (euro.value) {
162
- rows.push(`<div class="tooltip-row"><span class="tooltip-label">${euro.label}:</span><span class="tooltip-value">Euro ${euro.value}</span></div>`);
163
- }
164
- } else if (euro) {
165
- // Backward compatibility - old API
166
- rows.push(`<div class="tooltip-row"><span class="tooltip-label">${props.translations.euro}:</span><span class="tooltip-value">Euro ${euro}</span></div>`);
167
- }
168
-
169
- const specsContent = rows.length
170
- ? `<div class="tooltip-specs">${rows.join('')}</div>`
171
- : '';
172
-
173
- return header + specsContent;
174
- };
175
-
176
- onMounted(() => {
177
- if (engineRef.value) {
178
- tippyInstance = tippy(engineRef.value, {
179
- content: getTooltipContent(),
180
- allowHTML: true,
181
- theme: 'sds',
182
- placement: 'top',
183
- arrow: true,
184
- animation: 'shift-away',
185
- duration: [200, 150],
186
- maxWidth: 280,
187
- });
188
- }
189
- });
190
-
191
- onUnmounted(() => {
192
- if (tippyInstance) {
193
- tippyInstance.destroy();
194
- }
195
- });
196
- </script>
197
-
198
- <template>
199
- <span
200
- ref="engineRef"
201
- class="engine-code"
202
- :class="`engine-code-${engine.code}`"
203
- >
204
- {{ engine.code }}<span v-if="showComma">,</span>
205
- </span>
206
- </template>
207
-
208
- <style scoped>
209
- /* Engine Code Styles */
210
- .engine-code {
211
- @apply inline-block mr-1;
212
- @apply underline decoration-dotted underline-offset-4 py-0.5;
213
- @apply decoration-neutral-light cursor-default;
214
- @apply transition-colors duration-200;
215
- }
216
-
217
- .engine-code:hover {
218
- @apply decoration-blue-darker dark:decoration-blue-light;
219
- }
220
-
221
- /* Semantic Engine Code Colors */
222
- /* GTI Engines - Red */
223
- .engine-code-CAVE,
224
- .engine-code-CTHE,
225
- .engine-code-DAJA,
226
- .engine-code-DAYB {
227
- @apply text-red-600 dark:text-red-500;
228
- }
229
-
230
- /* WRC R Engine - Blue */
231
- .engine-code-CDLJ {
232
- @apply text-blue-600 dark:text-blue-500;
233
- }
234
-
235
- /* Special Blue Engines */
236
- .engine-code-CPTA,
237
- .engine-code-CZEA {
238
- @apply text-blue-700 dark:text-blue-600;
239
- }
240
- </style>
@@ -1,116 +0,0 @@
1
- <script lang="ts" setup>
2
- import { computed } from 'vue';
3
- import type { PropType } from 'vue';
4
- import ProductEngine from './ProductEngine.vue';
5
-
6
- /*
7
- ProductEngines wrapper component
8
- Displays a list of engine codes with tooltips
9
- */
10
-
11
- interface Engine {
12
- id?: number;
13
- code: string;
14
- name?: string;
15
- info?: string | null;
16
- serie?: {
17
- value: string;
18
- label: string;
19
- } | number;
20
- type?: {
21
- value: string;
22
- translated: string;
23
- label: string;
24
- };
25
- power?: {
26
- kw: number;
27
- ps: number;
28
- ps_label: string;
29
- label: string;
30
- };
31
- date?: {
32
- value: string;
33
- label: string;
34
- };
35
- displacement?: {
36
- value: number;
37
- label: string;
38
- };
39
- compression_ratio?: {
40
- value: string | null;
41
- label: string;
42
- };
43
- valves?: {
44
- value: number | null;
45
- label: string;
46
- };
47
- euro?: {
48
- value: number;
49
- label: string;
50
- } | number;
51
- pivot?: any;
52
-
53
- // Backward compatibility
54
- kw?: number;
55
- ps?: number;
56
- cc?: number;
57
- }
58
-
59
- const props = defineProps({
60
- engines: {
61
- type: Array as PropType<Engine[]>,
62
- default: () => [],
63
- required: true,
64
- },
65
- isPdp: {
66
- type: Boolean,
67
- default: false,
68
- required: false,
69
- },
70
- translations: {
71
- type: Object as PropType<{
72
- power?: string;
73
- cc?: string;
74
- compressionRatio?: string;
75
- valves?: string;
76
- euro?: string;
77
- horsepowerUnit?: string;
78
- }>,
79
- default: () => ({
80
- power: 'Power',
81
- cc: 'CC',
82
- compressionRatio: 'C. Ratio',
83
- valves: 'Valves',
84
- euro: 'Euro',
85
- horsepowerUnit: 'PS',
86
- }),
87
- required: false,
88
- },
89
- });
90
-
91
- // Sort engines by code
92
- const sortedEngines = computed(() => {
93
- if (!props.engines || !props.engines.length) return [];
94
- return [...props.engines].sort((a, b) => {
95
- return (a.code || '').localeCompare(b.code || '');
96
- });
97
- });
98
- </script>
99
-
100
- <template>
101
- <div v-if="sortedEngines.length" class="engines-list inline-flex flex-wrap items-center gap-x-0.5">
102
- <ProductEngine
103
- v-for="(engine, index) in sortedEngines"
104
- :key="engine.id || index"
105
- :engine="engine"
106
- :show-comma="index !== sortedEngines.length - 1"
107
- :translations="translations"
108
- />
109
- </div>
110
- </template>
111
-
112
- <style scoped>
113
- .engines-list {
114
- @apply leading-none;
115
- }
116
- </style>