@appscode/design-system 2.4.30 → 2.5.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appscode/design-system",
3
- "version": "2.4.30",
3
+ "version": "2.5.0",
4
4
  "description": "A design system for Appscode websites and dashboards made using Bulma",
5
5
  "main": "main.scss",
6
6
  "scripts": {
@@ -0,0 +1 @@
1
+ export * from "./v3";
@@ -237,3 +237,9 @@
237
237
  }
238
238
  }
239
239
  }
240
+
241
+ .details-with-checkradio-wrapper {
242
+ display: grid;
243
+ gap: 16px;
244
+ grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
245
+ }
@@ -1,27 +1,54 @@
1
1
  <script setup lang="ts">
2
+ import { computed } from "vue";
3
+
2
4
  interface Props {
3
5
  options: Array<{
4
6
  value: unknown;
5
7
  label: string;
8
+ description?: string;
6
9
  }>;
7
10
  name: string;
8
11
  modifierClasses?: string;
9
12
  errorMsg?: string;
10
13
  isRow?: boolean;
14
+ hasDescription?: boolean;
11
15
  }
12
16
 
13
- withDefaults(defineProps<Props>(), {
17
+ const props = withDefaults(defineProps<Props>(), {
14
18
  modifierClasses: "",
15
19
  name: "radio",
16
20
  errorMsg: "",
17
21
  isRow: false,
22
+ hasDescription: false,
18
23
  });
24
+ const includeSelectedClass = (optionValue: unknown) => {
25
+ return props.hasDescription && JSON.stringify(model.value) === JSON.stringify(optionValue);
26
+ };
27
+ const handleClick = (optionValue: unknown) => {
28
+ model.value = optionValue;
29
+ };
19
30
  const model = defineModel();
31
+
32
+ const bodyClass = computed(() => {
33
+ if (props.hasDescription) return "gap-16 details-with-checkradio-wrapper";
34
+ else if (!props.isRow) return "is-flex is-flex-wrap-wrap is-flex-direction-column";
35
+ else return "gap-24";
36
+ });
20
37
  </script>
21
38
 
22
39
  <template>
23
- <div class="is-flex" :class="!isRow ? 'is-flex-direction-column' : 'gap-8'" data-testid="check-radio-element">
24
- <div class="ac-radio mr-16" v-for="option in options" :key="name + option.label" data-testid="check-radio-option">
40
+ <div :class="bodyClass" data-testid="check-radio-element">
41
+ <div
42
+ class="ac-radio"
43
+ v-for="option in options"
44
+ :key="name + option.label"
45
+ :class="{
46
+ 'card-select is-clickable': hasDescription,
47
+ 'is-selected': includeSelectedClass(option.value),
48
+ }"
49
+ data-testid="check-radio-option"
50
+ @click.prevent="handleClick(option.value)"
51
+ >
25
52
  <input
26
53
  v-model="model"
27
54
  :class="modifierClasses"
@@ -34,6 +61,9 @@ const model = defineModel();
34
61
  <p v-show="errorMsg" class="has-text-danger">
35
62
  <slot name="message" />
36
63
  </p>
64
+ <p v-if="hasDescription" class="is-ellipsis-2 mt-8" :title="option.description">
65
+ {{ option.description }}
66
+ </p>
37
67
  <p v-show="errorMsg" class="has-text-danger mb-16">
38
68
  {{ errorMsg }}
39
69
  </p>
@@ -0,0 +1,9 @@
1
+ import AcAccordion from "./accordion/Accordion.vue";
2
+ import AcAlert from "./alert/Alert.vue";
3
+ import AcAlertMessage from "./alert/AlertMessage.vue";
4
+ import AcToast from "./alert/Toast.vue";
5
+ import AcAvatar from "./avatar/Avatar.vue";
6
+ import AcBadge from "./badge-tags/Badge.vue";
7
+ import AcTag from "./badge-tags/Tag.vue";
8
+
9
+ export { AcAccordion, AcAlert, AcAlertMessage, AcToast, AcAvatar, AcBadge, AcTag };