@dative-gpi/foundation-shared-components 1.0.189-update-fs-card → 1.0.190-feat-time-normalization

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,7 +1,6 @@
1
1
  <template>
2
- <FSCard
2
+ <FSClickable
3
3
  v-if="$props.variant !== 'icon'"
4
- :clickable="true"
5
4
  :disabled="$props.disabled"
6
5
  :padding="padding"
7
6
  :variant="$props.variant"
@@ -9,6 +8,7 @@
9
8
  :load="$props.load"
10
9
  :href="$props.href"
11
10
  :to="$props.to"
11
+ :style="style"
12
12
  @click.stop="onClick"
13
13
  v-bind="$attrs"
14
14
  >
@@ -87,62 +87,93 @@
87
87
  </FSIcon>
88
88
  </slot>
89
89
  </FSCol>
90
- </FSCard>
91
- <FSRouterLink
90
+ </FSClickable>
91
+ <FSRow
92
92
  v-else
93
- :to="$props.to"
94
- :href="$props.href"
93
+ width="hug"
95
94
  :class="iconClasses"
95
+ :style="style"
96
96
  @click.stop="onClick"
97
+ v-bind="$attrs"
97
98
  >
98
- <FSRow
99
- width="hug"
100
- align="center-left"
101
- v-bind="$attrs"
99
+ <template
100
+ v-if="$props.load"
102
101
  >
103
- <template
104
- v-if="$props.load"
102
+ <v-progress-circular
103
+ class="fs-button-load"
104
+ width="2"
105
+ size="20"
106
+ :indeterminate="true"
107
+ :color="loadColor"
108
+ />
109
+ </template>
110
+ <template
111
+ v-else-if="$props.href"
112
+ >
113
+ <a
114
+ :href="$props.href"
105
115
  >
106
- <v-progress-circular
107
- class="fs-button-load"
108
- width="2"
109
- size="20"
110
- :indeterminate="true"
111
- :color="loadColor"
112
- />
113
- </template>
114
- <template
115
- v-else
116
+ <FSIcon
117
+ v-if="$props.icon"
118
+ :size="$props.iconSize"
119
+ >
120
+ {{ $props.icon }}
121
+ </FSIcon>
122
+ <FSSpan
123
+ v-if="$props.label"
124
+ >
125
+ {{ $props.label }}
126
+ </FSSpan>
127
+ </a>
128
+ </template>
129
+ <template
130
+ v-else-if="$props.to"
131
+ >
132
+ <FSRouterLink
133
+ :to="$props.to"
116
134
  >
117
135
  <FSIcon
118
136
  v-if="$props.icon"
119
- :color="iconVariantColor"
120
137
  :size="$props.iconSize"
121
138
  >
122
139
  {{ $props.icon }}
123
140
  </FSIcon>
124
- <FSText
141
+ <FSSpan
125
142
  v-if="$props.label"
126
- :color="iconVariantColor"
127
143
  >
128
144
  {{ $props.label }}
129
- </FSText>
130
- </template>
131
- </FSRow>
132
- </FSRouterLink>
145
+ </FSSpan>
146
+ </FSRouterLink>
147
+ </template>
148
+ <template
149
+ v-else
150
+ >
151
+ <FSIcon
152
+ v-if="$props.icon"
153
+ :size="$props.iconSize"
154
+ >
155
+ {{ $props.icon }}
156
+ </FSIcon>
157
+ <FSSpan
158
+ v-if="$props.label"
159
+ >
160
+ {{ $props.label }}
161
+ </FSSpan>
162
+ </template>
163
+ </FSRow>
133
164
  </template>
134
165
 
135
166
  <script lang="ts">
136
- import { computed, defineComponent, type PropType, useSlots } from "vue";
167
+ import { computed, defineComponent, type PropType, type StyleValue, useSlots } from "vue";
137
168
  import { type RouteLocation } from "vue-router";
138
169
 
139
170
  import { type ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
140
171
  import { useColors } from "@dative-gpi/foundation-shared-components/composables";
141
172
 
142
- import FSRouterLink from './FSRouterLink.vue';
143
- import FSText from "./FSText.vue";
173
+ import FSRouterLink from "./FSRouterLink.vue";
174
+ import FSClickable from "./FSClickable.vue";
175
+ import FSSpan from "./FSSpan.vue";
144
176
  import FSIcon from "./FSIcon.vue";
145
- import FSCard from './FSCard.vue';
146
177
  import FSCol from "./FSCol.vue";
147
178
  import FSRow from "./FSRow.vue";
148
179
 
@@ -156,8 +187,8 @@ export default defineComponent({
156
187
  name: "FSButton",
157
188
  components: {
158
189
  FSRouterLink,
159
- FSCard,
160
- FSText,
190
+ FSClickable,
191
+ FSSpan,
161
192
  FSIcon,
162
193
  FSCol,
163
194
  FSRow
@@ -234,17 +265,32 @@ export default defineComponent({
234
265
  const { getColors } = useColors();
235
266
 
236
267
  const colors = computed(() => getColors(props.color));
268
+ const lights = getColors(ColorEnum.Light);
237
269
  const darks = getColors(ColorEnum.Dark);
238
270
  const slots = useSlots();
239
271
 
240
- const iconVariantColor = computed((): string => {
272
+ const style = computed((): StyleValue => {
241
273
  if (props.disabled) {
242
- return ColorEnum.Light;
274
+ switch (props.variant) {
275
+ case "icon": return {
276
+ "--fs-button-color": lights.dark,
277
+ };
278
+ }
243
279
  }
244
- if (props.color === ColorEnum.Light) {
245
- return ColorEnum.Dark;
280
+ switch (props.variant) {
281
+ case "icon": switch (props.color) {
282
+ case ColorEnum.Dark:
283
+ case ColorEnum.Light: return {
284
+ "--fs-button-color" : darks.base,
285
+ "--fs-button-hover-color": darks.dark,
286
+ };
287
+ default: return {
288
+ "--fs-button-color" : colors.value.base,
289
+ "--fs-button-hover-color": colors.value.dark,
290
+ };
291
+ }
246
292
  }
247
- return props.color;
293
+ return {};
248
294
  });
249
295
 
250
296
  const iconClasses = computed((): string[] => {
@@ -291,11 +337,11 @@ export default defineComponent({
291
337
  };
292
338
 
293
339
  return {
340
+ iconClasses,
341
+ loadColor,
294
342
  colors,
343
+ style,
295
344
  padding,
296
- loadColor,
297
- iconClasses,
298
- iconVariantColor,
299
345
  onClick
300
346
  };
301
347
  }
@@ -1,187 +1,142 @@
1
1
  <template>
2
- <FSRouterLink
2
+ <div
3
+ :class="classes"
3
4
  :style="style"
4
- :to="$props.to"
5
- :href="$props.href"
6
- :type="actualWrapperType"
7
- :passive="actualClickable ? false : true"
8
- :class="['fs-card-wrapper', $props.class]"
9
- v-on="wrapperListeners"
10
5
  >
11
- <div
12
- :class="classes"
6
+ <slot>
7
+ <FSCol
8
+ :gap="$props.gap"
9
+ >
10
+ <FSRow
11
+ v-if="$slots.header"
12
+ >
13
+ <slot
14
+ name="header"
15
+ />
16
+ </FSRow>
17
+ <FSRow
18
+ v-if="$slots.body"
19
+ >
20
+ <slot
21
+ name="body"
22
+ />
23
+ </FSRow>
24
+ <FSRow
25
+ v-if="$slots.footer"
26
+ >
27
+ <slot
28
+ name="footer"
29
+ />
30
+ </FSRow>
31
+ </FSCol>
32
+ </slot>
33
+ <FSRow
34
+ v-if="$slots['top-right']"
35
+ class="fs-card-top-right"
13
36
  >
14
37
  <slot
15
- name="default"
16
- v-bind="{ contentVariant }"
17
- />
18
- <v-progress-circular
19
- v-if="$props.load"
20
- class="fs-card-load__spinner"
21
- width="2"
22
- size="24"
23
- :indeterminate="true"
24
- :color="loadColor"
38
+ name="top-right"
25
39
  />
26
- <FSRow
27
- v-if="$slots['top-right'] && !$props.load"
28
- class="fs-card-top-right"
29
- >
30
- <slot
31
- name="top-right"
32
- />
33
- </FSRow>
34
- </div>
35
- </FSRouterLink>
40
+ </FSRow>
41
+ </div>
36
42
  </template>
37
43
 
38
44
  <script lang="ts">
39
- import { computed, defineComponent, ref, type PropType, type StyleValue } from "vue";
40
- import { type RouteLocation } from "vue-router";
45
+ import { computed, defineComponent, type PropType, type StyleValue } from "vue";
41
46
 
42
- import { sizeToVar } from "@dative-gpi/foundation-shared-components/utils";
47
+ import { type ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
43
48
  import { useColors } from "@dative-gpi/foundation-shared-components/composables";
44
- import { type CardVariant, type ColorBase, ColorEnum, CardVariants, type ColorBaseVariations } from "@dative-gpi/foundation-shared-components/models";
49
+ import { sizeToVar } from "@dative-gpi/foundation-shared-components/utils";
45
50
 
51
+ import FSCol from "./FSCol.vue";
46
52
  import FSRow from "./FSRow.vue";
47
- import FSRouterLink from "./FSRouterLink.vue";
48
53
 
49
54
  export default defineComponent({
50
55
  name: "FSCard",
51
56
  components: {
52
- FSRouterLink,
57
+ FSCol,
53
58
  FSRow
54
59
  },
55
60
  props: {
56
61
  height: {
57
62
  type: [Array, String, Number] as PropType<string[] | number[] | string | number | null>,
63
+ required: false,
58
64
  default: null
59
65
  },
60
66
  width: {
61
67
  type: [Array, String, Number] as PropType<string[] | number[] | string | number | null>,
68
+ required: false,
62
69
  default: null
63
70
  },
64
71
  maxWidth: {
65
72
  type: [Array, String, Number] as PropType<string[] | number[] | string | number | null>,
73
+ required: false,
66
74
  default: null
67
75
  },
68
76
  padding: {
69
77
  type: [Array, String, Number] as PropType<string[] | number[] | string | number | null>,
78
+ required: false,
70
79
  default: "0"
71
80
  },
72
- class: {
73
- type: [String, Array] as PropType<string | string[] | null>,
74
- default: null
75
- },
76
- to: {
77
- type: Object as PropType<RouteLocation | null>,
78
- default: null
79
- },
80
- href: {
81
- type: String as PropType<string | null>,
82
- default: null
83
- },
84
- onClick: {
85
- type: Function as PropType<(event: MouseEvent) => void | null>,
81
+ gap: {
82
+ type: [Array, String, Number] as PropType<string[] | number[] | string | number | null>,
86
83
  required: false,
87
- default: null
84
+ default: "8px"
88
85
  },
89
86
  variant: {
90
- type: String as PropType<CardVariant>,
87
+ type: String as PropType<"background" | "standard" | "full" | "gradient">,
91
88
  required: false,
92
- default: CardVariants.Background
93
- },
94
- clickable: {
95
- type: Boolean as PropType<boolean | null>,
96
- default: null
89
+ default: "background"
97
90
  },
98
91
  color: {
99
92
  type: [Array, String] as PropType<ColorBase | ColorBase[]>,
93
+ required: false,
100
94
  default: ColorEnum.Background
101
95
  },
102
96
  border: {
103
97
  type: Boolean,
98
+ required: false,
104
99
  default: true
105
100
  },
106
101
  borderRadius: {
107
102
  type: [String, Number],
103
+ required: false,
108
104
  default: "4px"
109
105
  },
110
106
  borderStyle: {
111
107
  type: String as PropType<"solid" | "dashed" | "dotted" | "double" | "groove" | "ridge" | "inset" | "outset" | "none">,
108
+ required: false,
112
109
  default: "solid"
113
110
  },
114
111
  borderColor: {
115
112
  type: [Array, String] as PropType<ColorBase | null | string>,
113
+ required: false,
116
114
  default: null
117
115
  },
118
116
  elevation: {
119
117
  type: Boolean,
118
+ required: false,
120
119
  default: false
121
120
  },
122
121
  topRightPadding: {
123
122
  type: [String, Number],
123
+ required: false,
124
124
  default: "4px"
125
- },
126
- type: {
127
- type: String as PropType<"button" | "submit" | "reset" | null>,
128
- default: null
129
- },
130
- load: {
131
- type: Boolean,
132
- default: false
133
- },
134
- disabled: {
135
- type: Boolean,
136
- default: false
137
125
  }
138
126
  },
139
- setup(props, { emit }) {
127
+ setup(props) {
140
128
  const { getColors, getGradients } = useColors();
141
129
 
142
- const active = ref(false);
143
- const hover = ref(false);
144
-
145
- const backgrounds = getColors(ColorEnum.Background);
146
- const lights = getColors(ColorEnum.Light);
147
-
148
130
  const colors = computed(() => {
149
131
  if (Array.isArray(props.color)) {
150
132
  return getColors(props.color[0]);
151
133
  }
152
134
  return getColors(props.color);
153
135
  });
154
-
155
136
  const gradients = computed(() => getGradients(props.color, 135));
156
-
157
- const actualClickable = computed((): boolean => {
158
- if (props.clickable === false || props.disabled) {
159
- return false;
160
- }
161
- return props.clickable || !!props.to || !!props.href || !!props.onClick;
162
- });
163
-
164
- const actualWrapperType = computed(() => {
165
- if (props.type) {
166
- return props.type;
167
- }
168
- return "button";
169
- });
170
-
171
- const contentVariant = computed((): ColorBaseVariations => {
172
- if (active.value) {
173
- return "darkContrast";
174
- }
175
- if (hover.value) {
176
- return "baseContrast";
177
- }
178
- switch (props.variant) {
179
- case "standard" : return "lightContrast";
180
- case "background": return "base";
181
- case "full" : return "baseContrast";
182
- }
183
- return "base";
184
- });
137
+ const backgrounds = getColors(ColorEnum.Background);
138
+ const lights = getColors(ColorEnum.Light);
139
+ const darks = getColors(ColorEnum.Dark);
185
140
 
186
141
  const borderColor = computed((): ColorBase => {
187
142
  if (props.borderColor) {
@@ -204,76 +159,59 @@ export default defineComponent({
204
159
  }
205
160
  });
206
161
 
207
- const loadColor = computed((): string => {
208
- return colors.value[contentVariant.value] ?? colors.value.baseContrast!;
209
- });
210
-
211
162
  const style = computed((): StyleValue => {
212
- const baseStyle = {
213
- "--fs-card-border-size" : props.border ? "1px" : "0",
214
- "--fs-card-border-style" : props.borderStyle,
215
- "--fs-card-border-radius" : sizeToVar(props.borderRadius),
216
- "--fs-card-padding" : sizeToVar(props.padding),
217
- "--fs-card-height" : sizeToVar(props.height),
218
- "--fs-card-width" : sizeToVar(props.width),
219
- "--fs-card-max-width" : sizeToVar(props.maxWidth, "unset"),
220
- "--fs-card-top-right-padding": sizeToVar(props.topRightPadding)
221
- };
222
- if (props.disabled) {
223
- return {
224
- ...baseStyle,
225
- "--fs-card-background-color": lights.light,
226
- "--fs-card-border-color" : lights.dark,
227
- "--fs-card-color" : lights.lightContrast!
228
- };
229
- }
230
-
231
163
  switch (props.variant) {
232
164
  case "background": return {
233
- ...baseStyle,
165
+ "--fs-card-border-size" : props.border ? "1px" : "0",
166
+ "--fs-card-border-style" : props.borderStyle,
167
+ "--fs-card-border-radius" : sizeToVar(props.borderRadius),
168
+ "--fs-card-padding" : sizeToVar(props.padding),
169
+ "--fs-card-height" : sizeToVar(props.height),
170
+ "--fs-card-width" : sizeToVar(props.width),
171
+ "--fs-card-max-width" : sizeToVar(props.maxWidth, "unset"),
234
172
  "--fs-card-background-color": backgrounds.base,
235
173
  "--fs-card-border-color" : borderColor.value,
236
- "--fs-card-color" : backgrounds.baseContrast!,
237
- "--fs-card-hover-background-color" : colors.value.base,
238
- "--fs-card-hover-border-color" : colors.value.baseContrast!,
239
- "--fs-card-hover-color" : colors.value.baseContrast!
174
+ "--fs-card-color" : darks.base,
175
+ "--fs-card-top-right-padding": sizeToVar(props.topRightPadding)
240
176
  }
241
- case "standard": {
242
- if (actualClickable.value && !Array.isArray(props.color) && [ColorEnum.Light, ColorEnum.Dark].includes(props.color as ColorEnum)) {
243
- return {
244
- ...baseStyle,
245
- "--fs-card-background-color": backgrounds.base,
246
- "--fs-card-border-color" : lights.dark,
247
- "--fs-card-color" : backgrounds.baseContrast!,
248
- "--fs-card-hover-background-color" : lights.base,
249
- "--fs-card-hover-border-color" : lights.dark,
250
- "--fs-card-hover-color" : lights.baseContrast!
251
- };
252
- }
253
- return {
254
- ...baseStyle,
255
- "--fs-card-background-color": colors.value.light,
256
- "--fs-card-border-color" : borderColor.value,
257
- "--fs-card-color" : colors.value.lightContrast!,
258
- "--fs-card-hover-background-color" : colors.value.base,
259
- "--fs-card-hover-border-color" : colors.value.base,
260
- "--fs-card-hover-color" : colors.value.baseContrast!
261
- };
177
+ case "standard": return {
178
+ "--fs-card-border-size" : props.border ? "1px" : "0",
179
+ "--fs-card-border-style" : props.borderStyle,
180
+ "--fs-card-border-radius" : sizeToVar(props.borderRadius),
181
+ "--fs-card-padding" : sizeToVar(props.padding),
182
+ "--fs-card-height" : sizeToVar(props.height),
183
+ "--fs-card-width" : sizeToVar(props.width),
184
+ "--fs-card-max-width" : sizeToVar(props.maxWidth, "unset"),
185
+ "--fs-card-background-color": colors.value.light,
186
+ "--fs-card-border-color" : borderColor.value,
187
+ "--fs-card-color" : colors.value.lightContrast!,
188
+ "--fs-card-top-right-padding": sizeToVar(props.topRightPadding)
262
189
  }
263
190
  case "full": return {
264
- ...baseStyle,
191
+ "--fs-card-border-size" : props.border ? "1px" : "0",
192
+ "--fs-card-border-style" : props.borderStyle,
193
+ "--fs-card-border-radius" : sizeToVar(props.borderRadius),
194
+ "--fs-card-padding" : sizeToVar(props.padding),
195
+ "--fs-card-height" : sizeToVar(props.height),
196
+ "--fs-card-width" : sizeToVar(props.width),
197
+ "--fs-card-max-width" : sizeToVar(props.maxWidth, "unset"),
265
198
  "--fs-card-background-color": colors.value.base,
266
199
  "--fs-card-border-color" : borderColor.value,
267
200
  "--fs-card-color" : colors.value.baseContrast!,
268
- "--fs-card-hover-background-color" : colors.value.base,
269
- "--fs-card-hover-border-color" : colors.value.base,
270
- "--fs-card-hover-color" : colors.value.baseContrast!
201
+ "--fs-card-top-right-padding": sizeToVar(props.topRightPadding)
271
202
  }
272
203
  case "gradient": return {
273
- ...baseStyle,
204
+ "--fs-card-border-size" : props.border ? "1px" : "0",
205
+ "--fs-card-border-style" : props.borderStyle,
206
+ "--fs-card-border-radius" : sizeToVar(props.borderRadius),
207
+ "--fs-card-padding" : sizeToVar(props.padding),
208
+ "--fs-card-height" : sizeToVar(props.height),
209
+ "--fs-card-width" : sizeToVar(props.width),
210
+ "--fs-card-max-width" : sizeToVar(props.maxWidth, "unset"),
274
211
  "--fs-card-background-color": gradients.value.base,
275
212
  "--fs-card-border-color" : borderColor.value,
276
- "--fs-card-color" : colors.value.lightContrast!
213
+ "--fs-card-color" : colors.value.lightContrast!,
214
+ "--fs-card-top-right-padding": sizeToVar(props.topRightPadding)
277
215
  }
278
216
  }
279
217
  });
@@ -286,60 +224,21 @@ export default defineComponent({
286
224
  break;
287
225
  case "background":
288
226
  classNames.push("fs-card-background");
227
+ classNames.push("fs-card-clickable");
289
228
  break;
290
229
  default:
291
230
  classNames.push("fs-card-background");
292
231
  break;
293
232
  }
294
-
295
- if (actualClickable.value) {
296
- classNames.push("fs-card-clickable");
297
- }
298
- if (props.disabled) {
299
- classNames.push("fs-card-disabled");
300
- }
301
- if (props.load) {
302
- classNames.push("fs-card-load");
303
- }
304
233
  if (props.elevation) {
305
234
  classNames.push("fs-card-elevation");
306
235
  }
307
-
308
236
  return classNames;
309
237
  });
310
-
311
- const wrapperListeners = computed(() => {
312
- if (actualClickable.value && !props.disabled) {
313
- return {
314
- mouseover: () => { hover.value = true },
315
- mouseleave: () => { hover.value = false },
316
- mousedown: () => { active.value = true },
317
- mouseup: () => { active.value = false },
318
- "click": onClick
319
- };
320
- }
321
- return {};
322
- });
323
-
324
- const onClick = (event: MouseEvent) => {
325
- if (!actualClickable.value || props.disabled || props.load || props.href || props.to) {
326
- return;
327
- }
328
- emit("click", event);
329
- };
330
238
 
331
239
  return {
332
- actualWrapperType,
333
- actualClickable,
334
- contentVariant,
335
- FSRouterLink,
336
- loadColor,
337
240
  classes,
338
- active,
339
- hover,
340
- style,
341
- onClick,
342
- wrapperListeners
241
+ style
343
242
  };
344
243
  }
345
244
  });