@dative-gpi/foundation-shared-components 0.0.4 → 0.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.
Files changed (52) hide show
  1. package/components/FSBreadcrumbs.vue +23 -18
  2. package/components/FSButton.vue +138 -30
  3. package/components/FSCheckbox.vue +41 -26
  4. package/components/FSCol.vue +56 -16
  5. package/components/FSColor.vue +80 -0
  6. package/components/FSFadeOut.vue +11 -6
  7. package/components/FSIcon.vue +5 -3
  8. package/components/FSNumberField.vue +65 -0
  9. package/components/FSPasswordField.vue +119 -0
  10. package/components/FSRadio.vue +40 -26
  11. package/components/FSRadioGroup.vue +6 -8
  12. package/components/FSRow.vue +57 -17
  13. package/components/FSSearchField.vue +122 -0
  14. package/components/FSSlideGroup.vue +17 -13
  15. package/components/FSSpan.vue +28 -4
  16. package/components/FSSwitch.vue +45 -28
  17. package/components/FSTab.vue +36 -22
  18. package/components/FSTabs.vue +21 -12
  19. package/components/FSTag.vue +48 -31
  20. package/components/FSTagField.vue +152 -0
  21. package/components/FSTagGroup.vue +60 -0
  22. package/components/FSText.vue +78 -0
  23. package/components/FSTextField.vue +122 -13
  24. package/components/FSWrapGroup.vue +16 -13
  25. package/composables/useColors.ts +31 -39
  26. package/models/FSButtons.ts +111 -0
  27. package/models/FSTags.ts +8 -0
  28. package/models/FSTextFields.ts +17 -0
  29. package/package.json +5 -4
  30. package/styles/components/fs_breadcrumbs.scss +29 -11
  31. package/styles/components/fs_button.scss +36 -9
  32. package/styles/components/fs_checkbox.scss +3 -4
  33. package/styles/components/fs_col.scss +87 -2
  34. package/styles/components/fs_color.scss +5 -0
  35. package/styles/components/fs_icon.scss +4 -4
  36. package/styles/components/fs_password_field.scss +10 -0
  37. package/styles/components/fs_radio.scss +3 -4
  38. package/styles/components/fs_row.scss +86 -1
  39. package/styles/components/fs_span.scss +8 -3
  40. package/styles/components/fs_switch.scss +4 -4
  41. package/styles/components/fs_tabs.scss +8 -9
  42. package/styles/components/fs_tag.scss +8 -8
  43. package/styles/components/fs_tag_field.scss +10 -0
  44. package/styles/components/fs_text.scss +5 -0
  45. package/styles/components/fs_text_field.scss +46 -17
  46. package/styles/components/index.scss +18 -14
  47. package/styles/globals/fixes.scss +5 -0
  48. package/styles/globals/index.scss +4 -1
  49. package/styles/globals/overrides.scss +26 -4
  50. package/styles/globals/text_fonts.scss +48 -24
  51. package/themes/default.ts +6 -6
  52. package/defaults/FSButtons.ts +0 -63
@@ -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,21 +84,34 @@ 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
- const background = useColors().getBackground();
85
- const dark = useColors().getDark();
87
+ const colors = useColors().getColors(color.value);
88
+
89
+ const backgrounds = useColors().getColors(ColorBase.Background);
90
+ const lights = useColors().getColors(ColorBase.Light);
91
+ const darks = useColors().getColors(ColorBase.Dark);
86
92
 
87
- const style = computed(() => ({
88
- "--fs-switch-cursor" : editable.value ? "pointer" : "default",
89
- "--fs-switch-translate-x" : value.value ? "8px" : "-8px",
90
- "--fs-switch-base-color" : value.value ? colors.base : editable.value ? dark.base : dark.light,
91
- "--fs-switch-base-text" : editable.value ? dark.base : dark.light,
92
- "--fs-switch-base-background": background.base
93
- }));
93
+ const style = computed((): { [code: string]: string } & Partial<CSSStyleDeclaration> => {
94
+ if (!editable.value) {
95
+ return {
96
+ "--fs-switch-translate-x": value.value ? "8px" : "-8px",
97
+ "--fs-switch-cursor": "default",
98
+ "--fs-switch-track-color": lights.dark,
99
+ "--fs-switch-thumb-color": backgrounds.base,
100
+ "--fs-switch-color": lights.dark
101
+ };
102
+ }
103
+ return {
104
+ "--fs-switch-translate-x": value.value ? "8px" : "-8px",
105
+ "--fs-switch-cursor": "pointer",
106
+ "--fs-switch-track-color": value.value ? colors.base : darks.base,
107
+ "--fs-switch-thumb-color": backgrounds.base,
108
+ "--fs-switch-color": darks.base
109
+ };
110
+ });
94
111
 
95
- const font = computed(() => value.value ? "text-button" : "text-body");
112
+ const font = computed((): string => value.value ? "text-button" : "text-body");
96
113
 
97
- const onToggle = () => {
114
+ const onToggle = (): void => {
98
115
  if (!editable.value) {
99
116
  return;
100
117
  }
@@ -2,39 +2,58 @@
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>
13
- <v-spacer />
14
- <FSSpan v-if="tag" class="fs-tab-tag">
15
- {{ tag }}
16
- </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>
19
+ <v-spacer v-if="$props.tag" />
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";
36
+ import { defineComponent, PropType } from "vue";
24
37
 
25
- import { useColors } from "@dative-gpi/foundation-shared-components/composables";
26
38
  import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
27
39
 
28
40
  import FSSpan from "./FSSpan.vue";
41
+ import FSIcon from "./FSIcon.vue";
29
42
  import FSRow from "./FSRow.vue";
30
43
 
31
44
  export default defineComponent({
32
45
  name: "FSTab",
33
46
  components: {
34
47
  FSSpan,
48
+ FSIcon,
35
49
  FSRow
36
50
  },
37
51
  props: {
52
+ prependIcon: {
53
+ type: String,
54
+ required: false,
55
+ default: null
56
+ },
38
57
  label: {
39
58
  type: String,
40
59
  required: false,
@@ -45,21 +64,16 @@ export default defineComponent({
45
64
  required: false,
46
65
  default: null
47
66
  },
67
+ appendIcon: {
68
+ type: String,
69
+ required: false,
70
+ default: null
71
+ },
48
72
  color: {
49
73
  type: String as PropType<ColorBase>,
50
74
  required: false,
51
- default: ColorBase.Primary
75
+ default: ColorBase.Dark
52
76
  }
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
77
  }
64
78
  });
65
79
  </script>
@@ -6,15 +6,18 @@
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" v-bind="{ color, colors, style }" />
15
+ </template>
13
16
  </v-tabs>
14
17
  </template>
15
18
 
16
19
  <script lang="ts">
17
- import { defineComponent, PropType, toRefs } from "vue";
20
+ import { defineComponent, PropType, Ref, ref, toRefs } from "vue";
18
21
 
19
22
  import { useColors } from "@dative-gpi/foundation-shared-components/composables";
20
23
  import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
@@ -37,21 +40,27 @@ export default defineComponent({
37
40
  setup(props, { emit }) {
38
41
  const { tab, color } = toRefs(props);
39
42
 
40
- const colors = useColors().getVariants(color.value);
41
- const dark = useColors().getDark();
43
+ const textColors = useColors().getContrasts(color.value);
44
+ const colors = useColors().getColors(color.value);
42
45
 
43
- const style = {
44
- "--fs-group-light-color" : colors.light,
45
- "--fs-group-base-color" : colors.base,
46
- "--fs-group-dark-color" : colors.dark,
47
- "--fs-group-light-text" : dark.base,
48
- "--fs-group-base-text" : dark.base,
49
- "--fs-group-dark-text" : dark.dark
50
- };
46
+ const darks = useColors().getColors(ColorBase.Dark);
47
+
48
+ const style: Ref<{ [code: string]: string } & Partial<CSSStyleDeclaration>> = ref({
49
+ "--fs-group-color": darks.base,
50
+ "--fs-group-hover-background-color": colors.light,
51
+ "--fs-group-hover-color": darks.dark,
52
+ "--fs-group-disabled-color": darks.light,
53
+ "--fs-group-light": colors.light,
54
+ "--fs-group-base": colors.base,
55
+ "--fs-group-dark": colors.dark,
56
+ "--fs-tab-tag-background-color": colors.base,
57
+ "--fs-tab-tag-color": textColors.light
58
+ });
51
59
 
52
60
  return {
53
61
  tab,
54
62
  color,
63
+ colors,
55
64
  style,
56
65
  emit
57
66
  };
@@ -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" v-bind="{ color, colors }">
10
+ <FSSpan class="fs-tag-label">
11
+ {{ $props.label }}
12
+ </FSSpan>
13
+ </slot>
14
+ <slot name="button" v-bind="{ color, colors }">
15
+ <v-btn
16
+ v-if="$props.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
 
@@ -43,10 +48,10 @@ export default defineComponent({
43
48
  type: String,
44
49
  required: true
45
50
  },
46
- full: {
47
- type: Boolean,
51
+ variant: {
52
+ type: String as PropType<"standard" | "full">,
48
53
  required: false,
49
- default: true
54
+ default: "full"
50
55
  },
51
56
  color: {
52
57
  type: String as PropType<ColorBase>,
@@ -60,25 +65,37 @@ 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 { variant, color } = toRefs(props);
65
70
 
66
- const colors = useColors().getVariants(color.value);
71
+ const textColors = useColors().getContrasts(color.value);
72
+ const colors = useColors().getColors(color.value);
67
73
 
68
- const style = computed(() => ({
69
- "--fs-tag-light-color": full.value ? colors.base : colors.light,
70
- "--fs-tag-base-color" : colors.base,
71
- "--fs-tag-dark-color" : colors.dark,
72
- "--fs-tag-light-text" : full.value ? colors.light : colors.base,
73
- "--fs-tag-base-text" : colors.light,
74
- "--fs-tag-dark-text" : colors.light
75
- }));
74
+ const style = computed((): { [code: string]: string } & Partial<CSSStyleDeclaration> => {
75
+ switch (variant.value) {
76
+ case "standard": return {
77
+ "--fs-tag-background-color": colors.light,
78
+ "--fs-tag-color": textColors.base,
79
+ "--fs-tag-hover-background-color": colors.base,
80
+ "--fs-tag-hover-color": textColors.light,
81
+ "--fs-tag-active-background-color": colors.dark,
82
+ "--fs-tag-active-color": textColors.light
83
+ };
84
+ case "full": return {
85
+ "--fs-tag-background-color": colors.base,
86
+ "--fs-tag-color": textColors.light,
87
+ "--fs-tag-hover-background-color": colors.base,
88
+ "--fs-tag-hover-color": textColors.light,
89
+ "--fs-tag-active-background-color": colors.dark,
90
+ "--fs-tag-active-color": textColors.light
91
+ };
92
+ }
93
+ });
76
94
 
77
95
  return {
78
- label,
79
- editable,
80
- style,
81
- emit
96
+ colors,
97
+ color,
98
+ style
82
99
  };
83
100
  }
84
101
  });
@@ -0,0 +1,152 @@
1
+ <template>
2
+ <FSCol>
3
+ <FSTextField
4
+ :label="$props.label"
5
+ :description="$props.description"
6
+ :type="type"
7
+ :color="$props.color"
8
+ :required="$props.required"
9
+ :editable="$props.editable"
10
+ :value="innerValue"
11
+ @update:value="(value) => innerValue = value"
12
+ @keydown.enter="onAdd"
13
+ v-bind="$attrs"
14
+ >
15
+ <template #append-inner>
16
+ <FSIcon
17
+ class="fs-tag-field-icon"
18
+ size="m"
19
+ :style="style"
20
+ @click="onAdd"
21
+ >
22
+ mdi-tag-outline
23
+ </FSIcon>
24
+ </template>
25
+ <template v-for="(_, name) in $slots" v-slot:[name]="slotData">
26
+ <slot :name="name" v-bind="slotData" />
27
+ </template>
28
+ </FSTextField>
29
+ <FSTagGroup
30
+ :tags="$props.value"
31
+ :variant="$props.variant"
32
+ :color="$props.tagColor"
33
+ :editable="$props.editable"
34
+ @remove="onRemove"
35
+ />
36
+ </FSCol>
37
+ </template>
38
+
39
+ <script lang="ts">
40
+ import { computed, defineComponent, PropType, ref, toRefs } from "vue";
41
+
42
+ import { useColors } from "@dative-gpi/foundation-shared-components/composables";
43
+ import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
44
+
45
+ import FSTextField from "./FSTextField.vue";
46
+ import FSTagGroup from "./FSTagGroup.vue";
47
+ import FSCol from "./FSCol.vue"
48
+
49
+ export default defineComponent({
50
+ name: "FSTagField",
51
+ components: {
52
+ FSTextField,
53
+ FSTagGroup,
54
+ FSCol
55
+ },
56
+ props: {
57
+ label: {
58
+ type: String,
59
+ required: false,
60
+ default: null
61
+ },
62
+ description: {
63
+ type: String,
64
+ required: false,
65
+ default: null
66
+ },
67
+ value: {
68
+ type: Array as PropType<string[]>,
69
+ required: false,
70
+ default: () => []
71
+ },
72
+ variant: {
73
+ type: String as PropType<"standard" | "full">,
74
+ required: false,
75
+ default: "full"
76
+ },
77
+ color: {
78
+ type: String as PropType<ColorBase>,
79
+ required: false,
80
+ default: ColorBase.Primary
81
+ },
82
+ tagColor: {
83
+ type: String as PropType<ColorBase>,
84
+ required: false,
85
+ default: ColorBase.Primary
86
+ },
87
+ required: {
88
+ type: Boolean,
89
+ required: false,
90
+ default: false
91
+ },
92
+ editable: {
93
+ type: Boolean,
94
+ required: false,
95
+ default: true
96
+ }
97
+ },
98
+ emits: ["update:value"],
99
+ setup(props, { emit }) {
100
+ const { value, editable } = toRefs(props);
101
+
102
+ const innerValue = ref("");
103
+
104
+ const darks = useColors().getColors(ColorBase.Dark);
105
+
106
+ const style = computed((): {[code: string]: string} & Partial<CSSStyleDeclaration> => {
107
+ if (!editable.value) {
108
+ return {
109
+ "--fs-tag-field-cursor" : "default",
110
+ "--fs-tag-field-base-text": darks.light,
111
+ "--fs-tag-field-dark-text": darks.light
112
+ };
113
+ }
114
+ return {
115
+ "--fs-tag-field-cursor" : "pointer",
116
+ "--fs-tag-field-base-text": darks.base,
117
+ "--fs-tag-field-dark-text": darks.dark
118
+ };
119
+ });
120
+
121
+ const onAdd = (): void => {
122
+ if (!editable.value) {
123
+ return;
124
+ }
125
+ const tags = value.value ?? [];
126
+ if (!innerValue.value.length || tags.includes(innerValue.value)) {
127
+ return;
128
+ }
129
+ emit("update:value", tags.concat(innerValue.value));
130
+ innerValue.value = "";
131
+ }
132
+
133
+ const onRemove = (label: string): void => {
134
+ if (!editable.value) {
135
+ return;
136
+ }
137
+ const tags = value.value ?? [];
138
+ if (!tags.length || !tags.includes(label)) {
139
+ return;
140
+ }
141
+ emit("update:value", tags.filter(t => t !== label));
142
+ }
143
+
144
+ return {
145
+ innerValue,
146
+ style,
147
+ onAdd,
148
+ onRemove
149
+ };
150
+ }
151
+ });
152
+ </script>
@@ -0,0 +1,60 @@
1
+ <template>
2
+ <FSWrapGroup v-bind="$attrs">
3
+ <FSTag
4
+ v-for="(tag, index) in $props.tags"
5
+ :key="index"
6
+ :label="tag"
7
+ :variant="$props.variant"
8
+ :color="$props.color"
9
+ :editable="$props.editable"
10
+ @remove="() => $emit('remove', tag)"
11
+ />
12
+ <slot name="default" />
13
+ </FSWrapGroup>
14
+ </template>
15
+
16
+ <script lang="ts">
17
+ import { defineComponent, PropType } from "vue";
18
+
19
+ import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
20
+
21
+ import FSWrapGroup from "./FSWrapGroup.vue";
22
+ import FSTag from "./FSTag.vue";
23
+
24
+ export interface FSTagItem {
25
+ label: string,
26
+ variant: "standard" | "full",
27
+ color: ColorBase,
28
+ editable: boolean
29
+ }
30
+
31
+ export default defineComponent({
32
+ name: "FSTagGroup",
33
+ components: {
34
+ FSWrapGroup,
35
+ FSTag
36
+ },
37
+ props: {
38
+ tags: {
39
+ type: Array as PropType<Array<String>>,
40
+ required: false,
41
+ default: () => []
42
+ },
43
+ variant: {
44
+ type: String as PropType<"standard" | "full">,
45
+ required: false,
46
+ default: "full"
47
+ },
48
+ color: {
49
+ type: String as PropType<ColorBase>,
50
+ required: false,
51
+ default: ColorBase.Primary
52
+ },
53
+ editable: {
54
+ type: Boolean,
55
+ required: false,
56
+ default: true
57
+ }
58
+ }
59
+ });
60
+ </script>
@@ -0,0 +1,78 @@
1
+ <template>
2
+ <span
3
+ :class="classes"
4
+ :style="style"
5
+ v-bind="$attrs"
6
+ >
7
+ <slot />
8
+ </span>
9
+ </template>
10
+
11
+ <script lang="ts">
12
+ import { computed, defineComponent, PropType, toRefs, useSlots } from "vue";
13
+
14
+ import { useColors } from "@dative-gpi/foundation-shared-components/composables";
15
+ import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
16
+
17
+ export default defineComponent({
18
+ name: "FSText",
19
+ props: {
20
+ font: {
21
+ type: String as PropType<"text-h1" | "text-h2" | "text-h3" | "text-body" | "text-button" | "text-overline" | "text-underline">,
22
+ required: false,
23
+ default: "text-body"
24
+ },
25
+ color: {
26
+ type: String as PropType<ColorBase>,
27
+ required: false,
28
+ default: ColorBase.Dark
29
+ },
30
+ variant: {
31
+ type: String as PropType<"base" | "light" | "dark">,
32
+ required: false,
33
+ default: "dark"
34
+ },
35
+ ellipsis: {
36
+ type: Boolean,
37
+ required: false,
38
+ default: true
39
+ }
40
+ },
41
+ setup(props) {
42
+ const { color, font, variant } = toRefs(props);
43
+
44
+ const colors = useColors().getColors(color.value);
45
+ const slots = useSlots();
46
+
47
+ const style = computed((): { [code: string]: string } & Partial<CSSStyleDeclaration> => {
48
+ switch (variant.value) {
49
+ case "base": return {
50
+ "--fs-text-color": colors.base
51
+ };
52
+ case "light": return {
53
+ "--fs-text-color": colors.light
54
+ };
55
+ case "dark": return {
56
+ "--fs-text-color": colors.dark
57
+ };
58
+ }
59
+ });
60
+
61
+ const classes = computed((): string[] => {
62
+ const classes = ["fs-text", font.value];
63
+ if (props.ellipsis) {
64
+ classes.push("fs-span-ellipsis");
65
+ }
66
+ if (!slots.default) {
67
+ classes.push("fs-span-pre-wrap");
68
+ }
69
+ return classes;
70
+ });
71
+
72
+ return {
73
+ classes,
74
+ style
75
+ };
76
+ }
77
+ });
78
+ </script>