@dative-gpi/foundation-shared-components 1.0.5 → 1.0.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.
@@ -128,13 +128,11 @@
128
128
  </template>
129
129
 
130
130
  <script lang="ts">
131
- import type { PropType } from "vue";
132
- import { computed, defineComponent } from "vue";
133
- import type { RouteLocation } from "vue-router";
131
+ import { computed, defineComponent, type PropType } from "vue";
132
+ import { type RouteLocation } from "vue-router";
134
133
 
134
+ import { type ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
135
135
  import { useColors, useSlots } from "@dative-gpi/foundation-shared-components/composables";
136
- import type { ColorBase} from "@dative-gpi/foundation-shared-components/models";
137
- import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
138
136
 
139
137
  import FSClickable from "./FSClickable.vue";
140
138
  import FSSpan from "./FSSpan.vue";
@@ -34,11 +34,9 @@
34
34
  </template>
35
35
 
36
36
  <script lang="ts">
37
- import type { PropType } from "vue";
38
- import { computed, defineComponent } from "vue";
37
+ import { computed, defineComponent, type PropType } from "vue";
39
38
 
40
- import type { ColorBase} from "@dative-gpi/foundation-shared-components/models";
41
- import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
39
+ import { type ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
42
40
  import { useColors } from "@dative-gpi/foundation-shared-components/composables";
43
41
  import { sizeToVar } from "@dative-gpi/foundation-shared-components/utils";
44
42
 
@@ -73,7 +71,7 @@ export default defineComponent({
73
71
  default: "8px"
74
72
  },
75
73
  variant: {
76
- type: String as PropType<"background" | "standard" | "gradient">,
74
+ type: String as PropType<"background" | "standard" | "full" | "gradient">,
77
75
  required: false,
78
76
  default: "background"
79
77
  },
@@ -119,6 +117,17 @@ export default defineComponent({
119
117
 
120
118
  const style = computed((): { [key: string] : string | null | undefined } => {
121
119
  switch (props.variant) {
120
+ case "background": return {
121
+ "--fs-card-border-size" : props.border ? "1px" : "0",
122
+ "--fs-card-border-style" : props.borderStyle,
123
+ "--fs-card-border-radius" : sizeToVar(props.borderRadius),
124
+ "--fs-card-padding" : sizeToVar(props.padding),
125
+ "--fs-card-height" : sizeToVar(props.height),
126
+ "--fs-card-width" : sizeToVar(props.width),
127
+ "--fs-card-background-color": backgrounds.base,
128
+ "--fs-card-border-color" : lights.dark,
129
+ "--fs-card-color" : darks.base
130
+ }
122
131
  case "standard": return {
123
132
  "--fs-card-border-size" : props.border ? "1px" : "0",
124
133
  "--fs-card-border-style" : props.borderStyle,
@@ -130,16 +139,16 @@ export default defineComponent({
130
139
  "--fs-card-border-color" : colors.value.lightContrast,
131
140
  "--fs-card-color" : colors.value.lightContrast
132
141
  }
133
- case "background": return {
142
+ case "full": return {
134
143
  "--fs-card-border-size" : props.border ? "1px" : "0",
135
144
  "--fs-card-border-style" : props.borderStyle,
136
145
  "--fs-card-border-radius" : sizeToVar(props.borderRadius),
137
146
  "--fs-card-padding" : sizeToVar(props.padding),
138
147
  "--fs-card-height" : sizeToVar(props.height),
139
148
  "--fs-card-width" : sizeToVar(props.width),
140
- "--fs-card-background-color": backgrounds.base,
141
- "--fs-card-border-color" : lights.dark,
142
- "--fs-card-color" : darks.base
149
+ "--fs-card-background-color": colors.value.base,
150
+ "--fs-card-border-color" : colors.value.base,
151
+ "--fs-card-color" : colors.value.baseContrast
143
152
  }
144
153
  case "gradient": return {
145
154
  "--fs-card-border-size" : props.border ? "1px" : "0",
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <FSCard
3
+ :variant="$props.variant"
3
4
  :border="$props.border"
4
- :class="classes"
5
- :style="style"
5
+ :color="$props.color"
6
6
  v-bind="$attrs"
7
7
  >
8
8
  <slot
@@ -12,11 +12,9 @@
12
12
  </template>
13
13
 
14
14
  <script lang="ts">
15
- import type { PropType } from "vue";
16
- import { computed, defineComponent } from "vue";
15
+ import { computed, defineComponent, type PropType } from "vue";
17
16
 
18
- import type { ColorBase} from "@dative-gpi/foundation-shared-components/models";
19
- import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
17
+ import { type ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
20
18
  import { useColors } from "@dative-gpi/foundation-shared-components/composables";
21
19
 
22
20
  import FSCard from "./FSCard.vue";
@@ -27,15 +25,20 @@ export default defineComponent({
27
25
  FSCard
28
26
  },
29
27
  props: {
30
- border: {
31
- type: Boolean,
28
+ variant: {
29
+ type: String as PropType<"standard" | "full">,
32
30
  required: false,
33
- default: true
31
+ default: "standard"
34
32
  },
35
33
  color: {
36
34
  type: String as PropType<ColorBase>,
37
35
  required: false,
38
36
  default: ColorEnum.Primary
37
+ },
38
+ border: {
39
+ type: Boolean,
40
+ required: false,
41
+ default: true
39
42
  }
40
43
  },
41
44
  setup(props) {
@@ -43,29 +46,8 @@ export default defineComponent({
43
46
 
44
47
  const colors = computed(() => getColors(props.color));
45
48
 
46
- const style = computed((): { [key: string] : string | null | undefined } => {
47
- return {
48
- "--fs-color-background-color": colors.value.light,
49
- "--fs-color-border-color" : colors.value.lightContrast,
50
- "--fs-color-color" : colors.value.lightContrast,
51
- "--fs-color-light" : colors.value.light,
52
- "--fs-color-base" : colors.value.base,
53
- "--fs-color-dark" : colors.value.dark
54
- };
55
- });
56
-
57
- const classes = computed((): string[] => {
58
- const classNames = ["fs-color"];
59
- if (props.border) {
60
- classNames.push("fs-color-border");
61
- }
62
- return classNames;
63
- });
64
-
65
49
  return {
66
- classes,
67
- colors,
68
- style
50
+ colors
69
51
  };
70
52
  }
71
53
  });
@@ -112,7 +112,7 @@ export default defineComponent({
112
112
  default: null
113
113
  },
114
114
  modelValue: {
115
- type: String,
115
+ type: String as PropType<string | null>,
116
116
  required: false,
117
117
  default: "#000000"
118
118
  },
@@ -164,9 +164,9 @@ export default defineComponent({
164
164
 
165
165
  const menu = ref(false);
166
166
 
167
- const innerColor = ref(getColors(props.modelValue).base);
168
- const innerOpacity = ref(getHexFromPercentage(props.opacityValue));
169
- const fullColor = ref(innerColor.value + innerOpacity.value);
167
+ const innerColor = ref("#000000");
168
+ const innerOpacity = ref("00");
169
+ const fullColor = ref("#00000000");
170
170
 
171
171
  const style = computed((): { [key: string]: string | undefined } => {
172
172
  if (!props.editable) {
@@ -185,7 +185,6 @@ export default defineComponent({
185
185
  };
186
186
  });
187
187
 
188
-
189
188
  const onSubmit = (value: string) => {
190
189
  innerColor.value = value.substring(0, 7);
191
190
  innerOpacity.value = value.length === 9 ? value.substring(7, 9) : "FF";
@@ -195,14 +194,21 @@ export default defineComponent({
195
194
  };
196
195
 
197
196
  const reset = (): void => {
198
- innerColor.value = getColors(props.modelValue)['base'];
199
- innerOpacity.value = getHexFromPercentage(props.opacityValue);
200
- fullColor.value = innerColor.value + innerOpacity.value;
197
+ if (props.modelValue) {
198
+ innerColor.value = getColors(props.modelValue)['base'];
199
+ innerOpacity.value = getHexFromPercentage(props.opacityValue);
200
+ fullColor.value = innerColor.value + innerOpacity.value;
201
+ }
202
+ else {
203
+ innerColor.value = "#000000";
204
+ innerOpacity.value = "00";
205
+ fullColor.value = "#00000000";
206
+ }
201
207
  };
202
208
 
203
209
  watch(() => props.modelValue, () => {
204
210
  reset();
205
- });
211
+ }, { immediate: true });
206
212
 
207
213
  return {
208
214
  getPercentageFromHex,
@@ -56,11 +56,20 @@ export const useColors = () => {
56
56
  return color.lighten(color.value() / 50);
57
57
  }
58
58
 
59
- const getColors = (color: ColorBase): ColorVariations => {
59
+ const parseColor = (color: ColorBase): Color => {
60
60
  const themed = (Object as any).values(ColorEnum).includes(color);
61
+
62
+ try {
63
+ return themed ? new Color(theme.colors[color as ColorEnum]) : new Color(color);
64
+ }
65
+ catch {
66
+ return new Color("#000000");
67
+ }
68
+ }
61
69
 
62
- const base = themed ? new Color(theme.colors[color as ColorEnum]) : new Color(color);
63
-
70
+ const getColors = (color: ColorBase): ColorVariations => {
71
+ const base = parseColor(color);
72
+
64
73
  const light = getLight(base);
65
74
  const soft = getSoft(base);
66
75
  const dark = getDark(base);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dative-gpi/foundation-shared-components",
3
3
  "sideEffects": false,
4
- "version": "1.0.5",
4
+ "version": "1.0.6",
5
5
  "description": "",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -10,8 +10,8 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@dative-gpi/foundation-shared-domain": "1.0.5",
14
- "@dative-gpi/foundation-shared-services": "1.0.5"
13
+ "@dative-gpi/foundation-shared-domain": "1.0.6",
14
+ "@dative-gpi/foundation-shared-services": "1.0.6"
15
15
  },
16
16
  "peerDependencies": {
17
17
  "@dative-gpi/bones-ui": "^0.0.75",
@@ -35,5 +35,5 @@
35
35
  "sass": "1.71.1",
36
36
  "sass-loader": "13.3.2"
37
37
  },
38
- "gitHead": "23b56d709ccee80d14efeadd00136e6c5c7f52b8"
38
+ "gitHead": "b2bbdea22792b7454a5234d8a6b8bb43553f3202"
39
39
  }