classcard-ui 0.2.876 → 0.2.877

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": "classcard-ui",
3
- "version": "0.2.876",
3
+ "version": "0.2.877",
4
4
  "main": "dist/classcard-ui.umd.min.js",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -0,0 +1,133 @@
1
+ <template>
2
+ <div>
3
+ <slot></slot>
4
+ <div
5
+ :class="[isDisabled ? 'opacity-50' : '']"
6
+ class="relative inline-block text-left"
7
+ >
8
+ <button
9
+ :type="type"
10
+ :class="classes"
11
+ class="focus:outline-none inline-flex w-full justify-center border border-transparent px-4 py-2 text-sm font-medium shadow-sm"
12
+ aria-haspopup="listbox"
13
+ aria-expanded="true"
14
+ aria-labelledby="listbox-label"
15
+ :disabled="isDisabled"
16
+ @click="toggleDropdown = !toggleDropdown"
17
+ @blur="close()"
18
+ >
19
+ <c-icon v-if="isLoading" class="mr-2 h-5 w-5" name="loader"></c-icon>
20
+ {{ label }}
21
+ <c-icon name="chevron-down" type="solid" class="ml-2 h-5 w-5"></c-icon>
22
+ </button>
23
+
24
+ <div
25
+ v-if="toggleDropdown"
26
+ :class="dropdownPositionClass"
27
+ class="absolute z-10 mt-2 -mr-1 w-56 rounded-md bg-white shadow-lg ring-1 ring-gray-900 ring-opacity-5"
28
+ >
29
+ <ul
30
+ class="py-1"
31
+ tabindex="-1"
32
+ role="listbox"
33
+ aria-labelledby="listbox-label"
34
+ >
35
+ <div v-for="(item, index) in items" :key="index">
36
+ <!-- to have a border pass a object { hasNoData: true } after the object
37
+ below which the border is required -->
38
+ <hr
39
+ v-if="item.hasNoData"
40
+ class="border-1 mt-1 h-1 w-full border-gray-200 pt-1"
41
+ />
42
+ <!-- item.isDisabled will make the list item unclickable and reduce the opacity -->
43
+ <li
44
+ v-else
45
+ :class="[
46
+ item.isDisabled ? 'pointer-events-none opacity-50 ' : '',
47
+ ]"
48
+ class="flex cursor-pointer px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900"
49
+ @mousedown="emitOption(item)"
50
+ >
51
+ <c-icon
52
+ v-if="item.icon"
53
+ :type="item.iconType"
54
+ class="mr-2 h-5 w-5 text-gray-500"
55
+ :name="item.icon"
56
+ ></c-icon>
57
+ <slot name="customIcon" v-if="item.customIcon"></slot>
58
+ {{ item.text }}
59
+ </li>
60
+ </div>
61
+ </ul>
62
+ </div>
63
+ </div>
64
+ </div>
65
+ </template>
66
+
67
+ <script>
68
+ import CIcon from "../CIcon/CIcon.vue";
69
+ export default {
70
+ name: "CButtonSelectBorder",
71
+ components: { CIcon },
72
+ props: {
73
+ label: {
74
+ type: String,
75
+ required: true,
76
+ },
77
+ type: {
78
+ type: String,
79
+ default: "primary",
80
+ },
81
+ items: {
82
+ type: Array,
83
+ required: true,
84
+ },
85
+ isLoading: {
86
+ type: Boolean,
87
+ default: false,
88
+ },
89
+ dropdownPositionClass: {
90
+ type: String,
91
+ },
92
+ isDisabled: {
93
+ type: Boolean,
94
+ default: false,
95
+ },
96
+ },
97
+ data() {
98
+ return {
99
+ toggleDropdown: false,
100
+ };
101
+ },
102
+
103
+ computed: {
104
+ classes() {
105
+ return {
106
+ "text-gray-700 border-gray-300 rounded-md hover:bg-gray-50 focus:ring-indigo-600":
107
+ this.type == "secondary",
108
+ "text-white rounded-md hover:bg-indigo-800 bg-indigo-700 focus:ring-indigo-600":
109
+ this.type == "primary",
110
+ "text-white rounded-md hover:bg-red-800 bg-red-700 focus:ring-red-600":
111
+ this.type == "danger",
112
+ "text-white rounded-md hover:bg-green-800 bg-green-700 focus:ring-green-600":
113
+ this.type == "success",
114
+ "cursor-default rounded-md pointer-events-none": this.isLoading,
115
+ //the type-white property contains the class rounded-r-md that would only round the button corner in the right direction
116
+ //while the other type property will round the button corners for all 4 direction
117
+ "text-gray-700 border-gray-300 rounded-r-md hover:bg-gray-50 focus:ring-indigo-600 bg-white":
118
+ this.type == "white-rounded-right",
119
+ };
120
+ },
121
+ },
122
+ methods: {
123
+ emitOption(item) {
124
+ this.$emit("buttonActions", item);
125
+ },
126
+ close() {
127
+ this.toggleDropdown = false;
128
+ },
129
+ },
130
+ };
131
+ </script>
132
+
133
+ <style></style>
@@ -0,0 +1,3 @@
1
+ import CButtonSelectBorder from "./CButtonSelectBorder.vue";
2
+
3
+ export default CButtonSelectBorder;
@@ -46,3 +46,4 @@ export { default as CTimeline } from "./CTimeline";
46
46
  export { default as CUpload } from "./CUpload";
47
47
  export { default as CConfirmActionModal } from "./CConfirmActionModal";
48
48
  export { default as CCalendar } from "./CCalendar";
49
+ export { default as CButtonSelectBorder } from "./CButtonSelectBorder";
@@ -0,0 +1,48 @@
1
+ import CButtonSelectBorder from "../components/CButtonSelectBorder";
2
+ import CIcon from "../components/CIcon/CIcon.vue";
3
+ import "./utils.css";
4
+
5
+ export default {
6
+ title: "CButtonSelectBorder",
7
+ component: CButtonSelectBorder,
8
+ subcomponents: { CIcon },
9
+ argTypes: {
10
+ type: {
11
+ control: {
12
+ type: "select",
13
+ options: [
14
+ "primary",
15
+ "secondary",
16
+ "success",
17
+ "danger",
18
+ "white-rounded-right",
19
+ ],
20
+ },
21
+ },
22
+ items: { control: { type: "object" } },
23
+ },
24
+ };
25
+
26
+ const Template = (args, { argTypes }) => ({
27
+ props: Object.keys(argTypes),
28
+ components: { CButtonSelectBorder },
29
+ template: '<c-button-select-border v-bind="$props" />',
30
+ });
31
+
32
+ export const Default = Template.bind({});
33
+ Default.args = {
34
+ items: [
35
+ { icon: "check", text: "one", action: "first", iconType: "solid" },
36
+ { icon: "check", text: "one", action: "first", iconType: "solid" },
37
+ { hasNoData: true },
38
+ { icon: "check", text: "one", action: "first", iconType: "solid" },
39
+ { hasNoData: true },
40
+ { icon: "check", text: "two", action: "second", iconType: "solid" },
41
+ { hasNoData: true },
42
+ { icon: "check", text: "two", action: "second", iconType: "solid" },
43
+ { icon: "check", text: "two", action: "second", iconType: "solid" },
44
+ ],
45
+ type: "primary",
46
+ label: "Button",
47
+ isLoading: false,
48
+ };