@dative-gpi/foundation-shared-components 0.0.19 → 0.0.21

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.
@@ -78,6 +78,7 @@ input[type=number]::-webkit-outer-spin-button {
78
78
  margin: 0;
79
79
  }
80
80
 
81
+ // Set the right z-index in overlays
81
82
  $nthOverlay: 25;
82
83
  @for $i from 1 through $nthOverlay {
83
84
  .v-overlay-container > :nth-child(#{$i}) {
@@ -96,8 +97,8 @@ $nthOverlay: 25;
96
97
  .v-slide-group__prev,
97
98
  .v-slide-group__next {
98
99
  color: var(--fs-group-color);
99
- min-width: 24px !important;
100
- width: 24px !important;
100
+ min-width: var(--fs-group-arrows-width) !important;
101
+ width: var(--fs-group-arrows-width) !important;
101
102
  flex: 1 1 0 !important;
102
103
 
103
104
  @include touchscreen {
package/utils/css.ts CHANGED
@@ -1,8 +1,22 @@
1
- export const sizeToVar = (value: string | number | null, nullValue: string = "fit-content", unit: "px" | "%" | "em"| "vw" | "vh" = "px"): string => {
1
+ import { useBreakpoints } from "../composables/useBreakpoints";
2
+
3
+ const { isMobileSized, isExtraSmall } = useBreakpoints();
4
+
5
+ export const sizeToVar = (value: string[] | number[] | string | number | null, nullValue: string = "fit-content", unit: "px" | "%" | "em"| "vw" | "vh" = "px"): string => {
2
6
  if (value == null) {
3
7
  return nullValue;
4
8
  }
5
-
9
+ if (Array.isArray(value)) {
10
+ if (isExtraSmall.value) {
11
+ const extraSmallValue = value[2] ?? value[1] ?? value[0];
12
+ return typeof extraSmallValue === 'string' && isNaN(+extraSmallValue) ? extraSmallValue : `${extraSmallValue}${unit}`;
13
+ }
14
+ if (isMobileSized.value) {
15
+ const mobileValue = value[1] ?? value[0];
16
+ return typeof mobileValue === 'string' && isNaN(+mobileValue) ? mobileValue : `${mobileValue}${unit}`;
17
+ }
18
+ return typeof value[0] === 'string' && isNaN(+value[0]) ? value[0] : `${value[0]}${unit}`;
19
+ }
6
20
  return typeof value === 'string' && isNaN(+value) ? value : `${value}${unit}`;
7
21
  };
8
22
 
@@ -1,246 +0,0 @@
1
- <template>
2
- <div>
3
- <v-btn
4
- v-if="!['icon'].includes($props.variant)"
5
- :ripple="false"
6
- :style="style"
7
- :class="classes"
8
- :disabled="!$props.editable"
9
- @click="onClick"
10
- v-bind="$attrs"
11
- >
12
- <FSRow
13
- align="center-center"
14
- :wrap="false"
15
- >
16
- <slot name="prepend" v-bind="{ color: $props.color, colors }">
17
- <FSIcon
18
- v-if="$props.prependIcon"
19
- size="l"
20
- >
21
- {{ $props.prependIcon }}
22
- </FSIcon>
23
- </slot>
24
- <slot v-bind="{ color: $props.color, colors }">
25
- <FSSpan
26
- v-if="$props.label"
27
- font="text-body"
28
- >
29
- {{ $props.label }}
30
- </FSSpan>
31
- </slot>
32
- <slot name="append" v-bind="{ color: $props.color, colors }">
33
- <FSIcon
34
- v-if="$props.appendIcon"
35
- size="l"
36
- >
37
- {{ $props.appendIcon }}
38
- </FSIcon>
39
- </slot>
40
- </FSRow>
41
- </v-btn>
42
- <FSRow
43
- v-else-if="$props.icon"
44
- width="hug"
45
- :style="style"
46
- :class="classes"
47
- v-bind="$attrs"
48
- >
49
- <FSIcon
50
- size="l"
51
- >
52
- {{ $props.icon }}
53
- </FSIcon>
54
- </FSRow>
55
- <form>
56
- <input
57
- v-show="false"
58
- type="file"
59
- ref="input"
60
- :accept="$props.accept"
61
- @input="onInput"
62
- />
63
- </form>
64
- </div>
65
- </template>
66
-
67
- <script lang="ts">
68
- import { computed, defineComponent, PropType, ref } from "vue";
69
-
70
- import { useColors, useSlots } from "@dative-gpi/foundation-shared-components/composables";
71
- import { ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
72
-
73
- import FSSpan from "./FSSpan.vue";
74
- import FSIcon from "./FSIcon.vue";
75
- import FSRow from "./FSRow.vue";
76
-
77
- export default defineComponent({
78
- name: "FSButtonFile",
79
- components: {
80
- FSSpan,
81
- FSIcon,
82
- FSRow
83
- },
84
- props: {
85
- accept: {
86
- type: String,
87
- required: false,
88
- default: "",
89
- },
90
- readFile: {
91
- type: Boolean,
92
- required: false,
93
- default: true,
94
- },
95
- prependIcon: {
96
- type: String,
97
- required: false,
98
- default: null
99
- },
100
- label: {
101
- type: String,
102
- required: false,
103
- default: null
104
- },
105
- appendIcon: {
106
- type: String,
107
- required: false,
108
- default: null
109
- },
110
- icon: {
111
- type: String,
112
- required: false,
113
- default: null
114
- },
115
- variant: {
116
- type: String as PropType<"standard" | "full" | "icon">,
117
- required: false,
118
- default: "standard"
119
- },
120
- color: {
121
- type: String as PropType<ColorBase>,
122
- required: false,
123
- default: ColorEnum.Dark
124
- },
125
- editable: {
126
- type: Boolean,
127
- required: false,
128
- default: true
129
- }
130
- },
131
- emits: ["update:modelValue"],
132
- setup(props, { emit }) {
133
- const { getColors, getContrasts } = useColors();
134
- const { slots } = useSlots();
135
-
136
- const textColors = computed(() => getContrasts(props.color));
137
- const colors = computed(() => getColors(props.color));
138
- const lights = getColors(ColorEnum.Light);
139
-
140
- const input = ref(null);
141
-
142
- const isEmpty = computed(() => {
143
- return !slots.default && !props.label;
144
- });
145
-
146
- const style = computed((): {[code: string]: string} & Partial<CSSStyleDeclaration> => {
147
- if (!props.editable) {
148
- switch (props.variant) {
149
- case "standard":
150
- case "full": return {
151
- "--fs-button-padding": !isEmpty.value ? "0 16px" : "0",
152
- "--fs-button-background-color": lights.base,
153
- "--fs-button-border-color": lights.dark,
154
- "--fs-button-color": lights.dark
155
- }
156
- case "icon": return {
157
- "--fs-button-color": lights.dark
158
- }
159
- }
160
- }
161
- switch (props.variant) {
162
- case "standard": return {
163
- "--fs-button-padding" : !isEmpty.value ? "0 16px" : "0",
164
- "--fs-button-background-color" : colors.value.light,
165
- "--fs-button-border-color" : colors.value.base,
166
- "--fs-button-color" : textColors.value.base,
167
- "--fs-button-hover-background-color" : colors.value.base,
168
- "--fs-button-hover-border-color" : colors.value.base,
169
- "--fs-button-hover-color" : textColors.value.light,
170
- "--fs-button-active-background-color": colors.value.dark,
171
- "--fs-button-active-border-color" : colors.value.dark,
172
- "--fs-button-active-color" : textColors.value.light
173
- };
174
- case "full": return {
175
- "--fs-button-padding" : !isEmpty.value ? "0 16px" : "0",
176
- "--fs-button-background-color" : colors.value.base,
177
- "--fs-button-border-color" : colors.value.base,
178
- "--fs-button-color" : textColors.value.light,
179
- "--fs-button-hover-background-color" : colors.value.base,
180
- "--fs-button-hover-border-color" : colors.value.base,
181
- "--fs-button-hover-color" : textColors.value.light,
182
- "--fs-button-active-background-color": colors.value.dark,
183
- "--fs-button-active-border-color" : colors.value.dark,
184
- "--fs-button-active-color" : textColors.value.light
185
- };
186
- case "icon": return {
187
- "--fs-button-color" : textColors.value.base,
188
- "--fs-button-hover-color": textColors.value.dark
189
- };
190
- }
191
- });
192
-
193
- const classes = computed((): string[] => {
194
- const classNames = [];
195
- if (!props.editable) {
196
- classNames.push("fs-button--disabled");
197
- }
198
- switch (props.variant) {
199
- case "icon":
200
- classNames.push("fs-button-icon");
201
- break;
202
- default:
203
- classNames.push("fs-button");
204
- break;
205
- }
206
- return classNames;
207
- });
208
-
209
- const clear = () => {
210
- input.value!.form && input.value!.form.reset();
211
- };
212
-
213
- const onClick = () => {
214
- input.value!.click();
215
- }
216
-
217
- const onInput = () => {
218
- const file = input.value!.files && input.value!.files[0];
219
- if (!file) {
220
- return;
221
- }
222
- if (!props.readFile) {
223
- emit("update:modelValue", file);
224
- clear();
225
- }
226
- else {
227
- const reader = new FileReader();
228
- reader.addEventListener("load", (fileEv) => {
229
- emit("update:modelValue", fileEv.target && fileEv.target.result);
230
- clear();
231
- });
232
- reader.readAsDataURL(file);
233
- }
234
- };
235
-
236
- return {
237
- colors,
238
- style,
239
- classes,
240
- input,
241
- onClick,
242
- onInput
243
- };
244
- }
245
- });
246
- </script>