@dative-gpi/foundation-shared-components 0.0.2 → 0.0.5

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.
Files changed (37) hide show
  1. package/components/FSBreadcrumbs.vue +10 -7
  2. package/components/FSButton.vue +85 -27
  3. package/components/FSCheckbox.vue +21 -17
  4. package/components/FSCol.vue +56 -16
  5. package/components/FSFadeOut.vue +7 -2
  6. package/components/FSNumberField.vue +65 -0
  7. package/components/FSPasswordField.vue +108 -0
  8. package/components/FSRadio.vue +21 -17
  9. package/components/FSRadioGroup.vue +1 -1
  10. package/components/FSRow.vue +57 -17
  11. package/components/FSSlideGroup.vue +2 -2
  12. package/components/FSSpan.vue +2 -3
  13. package/components/FSSwitch.vue +22 -18
  14. package/components/FSTab.vue +32 -25
  15. package/components/FSTabs.vue +6 -5
  16. package/components/FSTag.vue +21 -18
  17. package/components/FSTextField.vue +64 -11
  18. package/components/FSWrapGroup.vue +2 -2
  19. package/composables/useColors.ts +7 -25
  20. package/defaults/FSButtons.ts +45 -15
  21. package/package.json +4 -4
  22. package/styles/components/fs_breadcrumbs.scss +23 -10
  23. package/styles/components/fs_button.scss +26 -0
  24. package/styles/components/fs_col.scss +87 -2
  25. package/styles/components/fs_icon.scss +4 -4
  26. package/styles/components/fs_password_field.scss +5 -0
  27. package/styles/components/fs_row.scss +86 -1
  28. package/styles/components/fs_span.scss +1 -1
  29. package/styles/components/fs_tabs.scss +0 -1
  30. package/styles/components/fs_text_field.scss +34 -16
  31. package/styles/components/index.scss +15 -14
  32. package/styles/globals/fixes.scss +5 -0
  33. package/styles/globals/index.scss +4 -1
  34. package/styles/globals/overrides.scss +13 -0
  35. package/styles/globals/text_fonts.scss +44 -24
  36. package/importMap.json +0 -59
  37. package/importsGenerator.py +0 -39
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div
3
- class="fs-row"
4
3
  :style="style"
4
+ :class="classes"
5
5
  v-bind="$attrs"
6
6
  >
7
7
  <slot />
@@ -22,7 +22,12 @@ export default defineComponent({
22
22
  height: {
23
23
  type: String as PropType<"hug" | "fill" | string>,
24
24
  required: false,
25
- default: "fill"
25
+ default: "hug"
26
+ },
27
+ align: {
28
+ type: String as PropType<"top-left" | "top-center" | "top-right" | "center-left" | "center-center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right">,
29
+ required: false,
30
+ default: "top-left"
26
31
  },
27
32
  wrap: {
28
33
  type: Boolean,
@@ -36,39 +41,74 @@ export default defineComponent({
36
41
  }
37
42
  },
38
43
  setup(props) {
39
- const { width, height, wrap, gap } = toRefs(props);
44
+ const { width, height, align, wrap, gap } = toRefs(props);
40
45
 
41
- const style = computed(() => {
42
- const style = {
43
- "--fs-row-flex-wrap": wrap.value ? "wrap" : "nowrap",
44
- "--fs-row-gap": `${gap.value}px`
45
- };
46
+ const style = computed((): {[code: string]: string} & Partial<CSSStyleDeclaration> => ({
47
+ "--fs-row-flex-wrap": wrap.value ? "wrap" : "nowrap",
48
+ "--fs-row-gap": `${gap.value}px`,
49
+ "--fs-row-width": width.value,
50
+ "--fs-row-height": height.value
51
+ }));
52
+
53
+ const classes = computed((): string => {
54
+ let classes = "fs-row";
46
55
  switch (width.value) {
47
56
  case "hug":
57
+ classes += " fs-row-width-hug";
48
58
  break;
49
59
  case "fill":
50
- style["flex"] = "1 0 0";
60
+ classes += " fs-row-width-fill";
51
61
  break;
52
- default:
53
- style["width"] = width.value;
62
+ default:
63
+ classes += " fs-row-width-fixed";
54
64
  break;
55
65
  }
56
66
  switch (height.value) {
57
67
  case "hug":
68
+ classes += " fs-row-height-hug";
58
69
  break;
59
70
  case "fill":
60
- style["align-self"] = "stretch";
71
+ classes += " fs-row-height-fill";
72
+ break;
73
+ default:
74
+ classes += " fs-row-height-fixed";
75
+ break;
76
+ }
77
+ switch (align.value) {
78
+ case "top-left":
79
+ classes += " fs-row-top-left";
80
+ break;
81
+ case "top-center":
82
+ classes += " fs-row-top-center";
83
+ break;
84
+ case "top-right":
85
+ classes += " fs-row-top-right";
86
+ break;
87
+ case "center-left":
88
+ classes += " fs-row-center-left";
89
+ break;
90
+ case "center-center":
91
+ classes += " fs-row-center-center";
92
+ break;
93
+ case "center-right":
94
+ classes += " fs-row-center-right";
95
+ break;
96
+ case "bottom-left":
97
+ classes += " fs-row-bottom-left";
98
+ break;
99
+ case "bottom-center":
100
+ classes += " fs-row-bottom-center";
61
101
  break;
62
- default:
63
- style["height"] = height.value;
64
- style["flex-shrink"] = "0";
102
+ case "bottom-right":
103
+ classes += " fs-row-bottom-right";
65
104
  break;
66
105
  }
67
- return style;
106
+ return classes;
68
107
  });
69
108
 
70
109
  return {
71
- style
110
+ style,
111
+ classes
72
112
  };
73
113
  }
74
114
  });
@@ -5,7 +5,7 @@
5
5
  :style="style"
6
6
  v-bind="$attrs"
7
7
  >
8
- <FSRow height="hug">
8
+ <FSRow>
9
9
  <v-slide-group-item v-for="(component, index) in $slots.default()" :key="index">
10
10
  <component :is="component" v-bind="{ color }" />
11
11
  </v-slide-group-item>
@@ -37,7 +37,7 @@ export default defineComponent({
37
37
  const { color } = toRefs(props);
38
38
 
39
39
  const colors = useColors().getVariants(color.value);
40
- const dark = useColors().getDark();
40
+ const dark = useColors().getVariants(ColorBase.Dark);
41
41
 
42
42
  const style = {
43
43
  "--fs-group-light-color" : colors.light,
@@ -1,7 +1,6 @@
1
1
  <template>
2
2
  <span
3
- class="fs-span"
4
- :class="$props.font"
3
+ :class="'fs-span ' + $props.font"
5
4
  v-bind="$attrs"
6
5
  >
7
6
  <slot />
@@ -15,7 +14,7 @@ export default defineComponent({
15
14
  name: "FSSpan",
16
15
  props: {
17
16
  font: {
18
- type: String as PropType<"text-h1" | "text-h2" | "text-h3" | "text-body" | "text-button" | "text-overline">,
17
+ type: String as PropType<"text-h1" | "text-h2" | "text-h3" | "text-body" | "text-button" | "text-overline" | "text-underline">,
19
18
  required: false,
20
19
  default: "text-body"
21
20
  }
@@ -1,6 +1,6 @@
1
1
  <template>
2
- <FSCol width="hug" height="hug">
3
- <FSRow width="hug" height="hug">
2
+ <FSCol width="hug">
3
+ <FSRow width="hug" align="center-left">
4
4
  <v-switch
5
5
  class="fs-switch"
6
6
  hide-details
@@ -11,24 +11,28 @@
11
11
  @update:modelValue="onToggle"
12
12
  v-bind="$attrs"
13
13
  />
14
+ <slot name="default">
15
+ <FSSpan
16
+ v-if="$props.label"
17
+ class="fs-switch-label"
18
+ :style="style"
19
+ :font="font"
20
+ @click="onToggle"
21
+ >
22
+ {{ $props.label }}
23
+ </FSSpan>
24
+ </slot>
25
+ </FSRow>
26
+ <slot name="description">
14
27
  <FSSpan
15
- v-if="$props.label"
16
- class="fs-switch-label"
28
+ v-if="$props.description"
29
+ class="fs-switch-description"
30
+ font="text-underline"
17
31
  :style="style"
18
- :font="font"
19
- @click="onToggle"
20
32
  >
21
- {{ $props.label }}
33
+ {{ $props.description }}
22
34
  </FSSpan>
23
- </FSRow>
24
- <FSSpan
25
- v-if="$props.description"
26
- class="fs-switch-description"
27
- font="text-overline"
28
- :style="style"
29
- >
30
- {{ $props.description }}
31
- </FSSpan>
35
+ </slot>
32
36
  </FSCol>
33
37
  </template>
34
38
 
@@ -80,9 +84,9 @@ export default defineComponent({
80
84
  setup(props, { emit }) {
81
85
  const { value, color, editable } = toRefs(props);
82
86
 
83
- const colors = useColors().getVariants(color.value);
84
87
  const background = useColors().getBackground();
85
- const dark = useColors().getDark();
88
+ const colors = useColors().getVariants(color.value);
89
+ const dark = useColors().getVariants(ColorBase.Dark);
86
90
 
87
91
  const style = computed(() => ({
88
92
  "--fs-switch-cursor" : editable.value ? "pointer" : "default",
@@ -2,39 +2,56 @@
2
2
  <v-tab
3
3
  class="fs-tab"
4
4
  :ripple="false"
5
- :slider-color="sliderColor"
6
5
  v-bind="$attrs"
7
6
  >
8
7
  <slot>
9
- <FSRow>
10
- <FSSpan v-if="label" class="fs-tab-label" font="text-button">
11
- {{ label }}
12
- </FSSpan>
8
+ <FSRow align="center-left">
9
+ <slot name="prepend">
10
+ <FSIcon v-if="$props.prependIcon" size="m">
11
+ {{ $props.prependIcon }}
12
+ </FSIcon>
13
+ </slot>
14
+ <slot name="default">
15
+ <FSSpan v-if="$props.label" font="text-button">
16
+ {{ $props.label }}
17
+ </FSSpan>
18
+ </slot>
13
19
  <v-spacer />
14
- <FSSpan v-if="tag" class="fs-tab-tag">
15
- {{ tag }}
16
- </FSSpan>
20
+ <slot name="tag">
21
+ <FSSpan v-if="$props.tag" class="fs-tab-tag">
22
+ {{ $props.tag }}
23
+ </FSSpan>
24
+ </slot>
25
+ <slot name="append">
26
+ <FSIcon v-if="$props.appendIcon" size="m">
27
+ {{ $props.appendIcon }}
28
+ </FSIcon>
29
+ </slot>
17
30
  </FSRow>
18
31
  </slot>
19
32
  </v-tab>
20
33
  </template>
21
34
 
22
35
  <script lang="ts">
23
- import { defineComponent, PropType, toRefs } from "vue";
24
-
25
- import { useColors } from "@dative-gpi/foundation-shared-components/composables";
26
- import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
36
+ import { defineComponent } from "vue";
27
37
 
28
38
  import FSSpan from "./FSSpan.vue";
39
+ import FSIcon from "./FSIcon.vue";
29
40
  import FSRow from "./FSRow.vue";
30
41
 
31
42
  export default defineComponent({
32
43
  name: "FSTab",
33
44
  components: {
34
45
  FSSpan,
46
+ FSIcon,
35
47
  FSRow
36
48
  },
37
49
  props: {
50
+ prependIcon: {
51
+ type: String,
52
+ required: false,
53
+ default: null
54
+ },
38
55
  label: {
39
56
  type: String,
40
57
  required: false,
@@ -45,21 +62,11 @@ export default defineComponent({
45
62
  required: false,
46
63
  default: null
47
64
  },
48
- color: {
49
- type: String as PropType<ColorBase>,
65
+ appendIcon: {
66
+ type: String,
50
67
  required: false,
51
- default: ColorBase.Primary
68
+ default: null
52
69
  }
53
- },
54
- setup(props) {
55
- const { label, color } = toRefs(props);
56
-
57
- const colors = useColors().getVariants(color.value);
58
-
59
- return {
60
- label,
61
- sliderColor: colors.base
62
- };
63
70
  }
64
71
  });
65
72
  </script>
@@ -6,10 +6,13 @@
6
6
  grow
7
7
  :style="style"
8
8
  :modelValue="tab"
9
+ :slider-color="colors.base"
9
10
  @update:modelValue="(v) => emit('update:tab', v)"
10
11
  v-bind="$attrs"
11
12
  >
12
- <slot v-bind="{ color }" />
13
+ <template v-for="(component, index) in $slots.default()" :key="index">
14
+ <component :is="component" />
15
+ </template>
13
16
  </v-tabs>
14
17
  </template>
15
18
 
@@ -38,20 +41,18 @@ export default defineComponent({
38
41
  const { tab, color } = toRefs(props);
39
42
 
40
43
  const colors = useColors().getVariants(color.value);
41
- const dark = useColors().getDark();
44
+ const dark = useColors().getVariants(ColorBase.Dark);
42
45
 
43
46
  const style = {
44
47
  "--fs-group-light-color" : colors.light,
45
48
  "--fs-group-base-color" : colors.base,
46
- "--fs-group-dark-color" : colors.dark,
47
49
  "--fs-group-light-text" : dark.base,
48
- "--fs-group-base-text" : dark.base,
49
50
  "--fs-group-dark-text" : dark.dark
50
51
  };
51
52
 
52
53
  return {
53
54
  tab,
54
- color,
55
+ colors,
55
56
  style,
56
57
  emit
57
58
  };
@@ -2,22 +2,27 @@
2
2
  <FSRow
3
3
  class="fs-tag"
4
4
  width="hug"
5
+ align="center-left"
5
6
  :style="style"
6
7
  v-bind="$attrs"
7
8
  >
8
- <FSSpan>
9
- {{ label }}
10
- </FSSpan>
11
- <v-btn
12
- v-if="editable"
13
- class="fs-tag-button"
14
- :ripple="false"
15
- @click="emit('remove')"
16
- >
17
- <FSIcon size="s">
18
- mdi-close
19
- </FSIcon>
20
- </v-btn>
9
+ <slot name="default">
10
+ <FSSpan class="fs-tag-label">
11
+ {{ $props.label }}
12
+ </FSSpan>
13
+ </slot>
14
+ <slot name="button">
15
+ <v-btn
16
+ v-if="editable"
17
+ class="fs-tag-button"
18
+ :ripple="false"
19
+ @click="$emit('remove')"
20
+ >
21
+ <FSIcon size="s">
22
+ mdi-close
23
+ </FSIcon>
24
+ </v-btn>
25
+ </slot>
21
26
  </FSRow>
22
27
  </template>
23
28
 
@@ -60,8 +65,8 @@ export default defineComponent({
60
65
  }
61
66
  },
62
67
  emits: ["remove"],
63
- setup(props, { emit }) {
64
- const { label, full, color, editable } = toRefs(props);
68
+ setup(props) {
69
+ const { full, color, editable } = toRefs(props);
65
70
 
66
71
  const colors = useColors().getVariants(color.value);
67
72
 
@@ -75,10 +80,8 @@ export default defineComponent({
75
80
  }));
76
81
 
77
82
  return {
78
- label,
79
83
  editable,
80
- style,
81
- emit
84
+ style
82
85
  };
83
86
  }
84
87
  });
@@ -1,11 +1,41 @@
1
1
  <template>
2
- <v-text-field
3
- class="fs-text-field"
4
- variant="outlined"
5
- hide-details
6
- v-bind="$attrs"
7
- >
8
- </v-text-field>
2
+ <FSCol>
3
+ <slot name="label">
4
+ <FSSpan
5
+ v-if="$props.label"
6
+ class="fs-text-field-label"
7
+ font="text-overline"
8
+ :style="style"
9
+ >
10
+ {{ $props.label }}{{ $props.required ? "*" : "" }}
11
+ </FSSpan>
12
+ </slot>
13
+ <v-text-field
14
+ class="fs-text-field"
15
+ variant="outlined"
16
+ hide-details
17
+ :style="style"
18
+ :type="$props.type"
19
+ :readonly="!$props.editable"
20
+ :modelValue="$props.value"
21
+ @update:modelValue="(value) => $emit('update:value', value)"
22
+ v-bind="$attrs"
23
+ >
24
+ <template v-for="(_, name) in $slots" v-slot:[name]="slotData">
25
+ <slot :name="name" v-bind="slotData" />
26
+ </template>
27
+ </v-text-field>
28
+ <slot name="description">
29
+ <FSSpan
30
+ v-if="$props.description"
31
+ class="fs-text-field-description"
32
+ font="text-underline"
33
+ :style="style"
34
+ >
35
+ {{ $props.description }}
36
+ </FSSpan>
37
+ </slot>
38
+ </FSCol>
9
39
  </template>
10
40
 
11
41
  <script lang="ts">
@@ -15,16 +45,15 @@ import { useColors } from "@dative-gpi/foundation-shared-components/composables"
15
45
  import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
16
46
 
17
47
  import FSSpan from "./FSSpan.vue";
18
- import FSRow from "./FSRow.vue";
19
48
  import FSCol from "./FSCol.vue";
20
49
 
21
50
  export default defineComponent({
22
51
  name: "FSTextField",
23
52
  components: {
24
53
  FSSpan,
25
- FSRow,
26
54
  FSCol
27
55
  },
56
+ inheritAttrs: false,
28
57
  props: {
29
58
  label: {
30
59
  type: String,
@@ -36,6 +65,11 @@ export default defineComponent({
36
65
  required: false,
37
66
  default: null
38
67
  },
68
+ type: {
69
+ type: String as PropType<"text" | "password" | "number">,
70
+ required: false,
71
+ default: "text"
72
+ },
39
73
  value: {
40
74
  type: String,
41
75
  required: false,
@@ -44,7 +78,12 @@ export default defineComponent({
44
78
  color: {
45
79
  type: String as PropType<ColorBase>,
46
80
  required: false,
47
- default: null
81
+ default: ColorBase.Dark
82
+ },
83
+ required: {
84
+ type: Boolean,
85
+ required: false,
86
+ default: false
48
87
  },
49
88
  editable: {
50
89
  type: Boolean,
@@ -52,8 +91,22 @@ export default defineComponent({
52
91
  default: true
53
92
  }
54
93
  },
55
- setup(props, { emit }) {
94
+ emits: ["update:value"],
95
+ setup(props) {
96
+ const { color, editable } = toRefs(props);
97
+
98
+ const colors = useColors().getVariants(color.value);
99
+ const dark = useColors().getVariants(ColorBase.Dark);
100
+
101
+ const style = computed(() => ({
102
+ "--fs-text-field-cursor" : editable.value ? "text" : "default",
103
+ "--fs-text-field-base-color": editable.value ? dark.base : dark.light,
104
+ "--fs-text-field-dark-color": editable.value ? colors.dark: dark.light,
105
+ "--fs-text-field-base-text" : editable.value ? dark.base : dark.light
106
+ }));
107
+
56
108
  return {
109
+ style
57
110
  };
58
111
  }
59
112
  });
@@ -4,7 +4,7 @@
4
4
  :style="style"
5
5
  v-bind="$attrs"
6
6
  >
7
- <FSRow height="hug">
7
+ <FSRow>
8
8
  <v-slide-group-item v-for="(component, index) in $slots.default()" :key="index">
9
9
  <component :is="component" v-bind="{ color }" />
10
10
  </v-slide-group-item>
@@ -36,7 +36,7 @@ export default defineComponent({
36
36
  const { color } = toRefs(props);
37
37
 
38
38
  const colors = useColors().getVariants(color.value);
39
- const dark = useColors().getDark();
39
+ const dark = useColors().getVariants(ColorBase.Dark);
40
40
 
41
41
  const style = {
42
42
  "--fs-group-light-color" : colors.light,
@@ -19,33 +19,17 @@ export const useColors = () => {
19
19
  };
20
20
  }
21
21
 
22
- const getLight = () => {
23
- const base = new Color(theme.colors[ColorBase.Light]);
24
- const light = base.value(Math.max(base.value() - 20, 0));
25
- const dark = darken(base);
26
-
27
- return {
28
- light: light.hex(),
29
- base: base.hex(),
30
- dark: dark.hex()
31
- };
32
- };
33
-
34
- const getDark = () => {
35
- const base = new Color(theme.colors[ColorBase.Dark]);
36
- const light = base.saturationv(Math.max(base.saturationv() - 80, 0)).value(Math.min(base.value() + 40, 100));
37
- const dark = darken(base);
38
-
39
- return {
40
- light: light.hex(),
41
- base: base.hex(),
42
- dark: dark.hex()
43
- };
22
+ const getLight = (color: ColorBase, base: Color): Color => {
23
+ switch (color) {
24
+ case ColorBase.Light: return base.value(Math.max(base.value() - 20, 0));
25
+ case ColorBase.Dark: return base.saturationv(Math.max(base.saturationv() - 80, 0)).value(Math.min(base.value() + 40, 100));
26
+ default: return lighten(base);
27
+ }
44
28
  };
45
29
 
46
30
  const getVariants = (color: ColorBase) => {
47
31
  const base = new Color(theme.colors[color]);
48
- const light = lighten(base);
32
+ const light = getLight(color, base);
49
33
  const dark = darken(base);
50
34
 
51
35
  return {
@@ -57,8 +41,6 @@ export const useColors = () => {
57
41
 
58
42
  return {
59
43
  getBackground,
60
- getLight,
61
- getDark,
62
44
  getVariants
63
45
  };
64
46
  }