@fiscozen/card 0.1.2 → 0.1.4
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 +5 -5
- package/src/FzCard.vue +21 -12
- package/src/types.ts +65 -0
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiscozen/card",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Design System Card component",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"keywords": [],
|
|
8
8
|
"author": "Cristian Barraco",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@fiscozen/icons": "^0.1.
|
|
11
|
-
"@fiscozen/button": "^0.1.
|
|
10
|
+
"@fiscozen/icons": "^0.1.19",
|
|
11
|
+
"@fiscozen/button": "^0.1.9"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
14
|
"tailwindcss": "^3.4.1",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"@awesome.me/kit-8137893ad3": "^1.0.65",
|
|
34
34
|
"@fortawesome/fontawesome-svg-core": "^6.5.1",
|
|
35
35
|
"@fortawesome/vue-fontawesome": "^3.0.6",
|
|
36
|
+
"@fiscozen/eslint-config": "^0.1.0",
|
|
36
37
|
"@fiscozen/tsconfig": "^0.1.0",
|
|
37
|
-
"@fiscozen/prettier-config": "^0.1.0"
|
|
38
|
-
"@fiscozen/eslint-config": "^0.1.0"
|
|
38
|
+
"@fiscozen/prettier-config": "^0.1.0"
|
|
39
39
|
},
|
|
40
40
|
"license": "MIT",
|
|
41
41
|
"scripts": {
|
package/src/FzCard.vue
CHANGED
|
@@ -20,40 +20,42 @@
|
|
|
20
20
|
</div>
|
|
21
21
|
<slot name="header-content"></slot>
|
|
22
22
|
</header>
|
|
23
|
-
<
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<
|
|
23
|
+
<article v-if="isAlive" :class="['p-20', contentClass]" v-show="showContent">
|
|
24
|
+
<slot></slot>
|
|
25
|
+
</article>
|
|
26
|
+
<footer v-if="(slots.footer || atLeastOneButton) && isAlive" :class="[footerStaticClass, borderColor]" v-show="showContent">
|
|
27
|
+
<slot name="footer">
|
|
28
28
|
<FzIconButton
|
|
29
29
|
v-if="tertiaryAction"
|
|
30
|
-
@click="
|
|
30
|
+
@click="emit('fztertiary:click')"
|
|
31
31
|
:iconName="tertiaryAction.icon"
|
|
32
32
|
variant="invisible"
|
|
33
33
|
/>
|
|
34
34
|
<FzButton
|
|
35
35
|
v-if="secondaryAction"
|
|
36
|
-
@click="
|
|
36
|
+
@click="emit('fzsecondary:click')"
|
|
37
37
|
:label="secondaryAction.label"
|
|
38
38
|
variant="secondary"
|
|
39
39
|
/>
|
|
40
40
|
<FzButton
|
|
41
41
|
v-if="primaryAction"
|
|
42
|
-
@click="
|
|
42
|
+
@click="emit('fzprimary:click')"
|
|
43
43
|
:label="primaryAction.label"
|
|
44
44
|
variant="primary"
|
|
45
45
|
/>
|
|
46
|
-
</
|
|
47
|
-
</
|
|
46
|
+
</slot>
|
|
47
|
+
</footer>
|
|
48
48
|
</section>
|
|
49
49
|
</template>
|
|
50
50
|
|
|
51
51
|
<script setup lang="ts">
|
|
52
52
|
import { computed, onMounted, ref } from "vue";
|
|
53
|
-
import { FzCardProps } from "./types";
|
|
53
|
+
import { FzCardEvents, FzCardProps, FzCardSlots } from "./types";
|
|
54
54
|
import { FzButton, FzIconButton } from "@fiscozen/button";
|
|
55
55
|
|
|
56
56
|
const props = defineProps<FzCardProps>();
|
|
57
|
+
const emit = defineEmits<FzCardEvents>();
|
|
58
|
+
const slots = defineSlots<FzCardSlots>();
|
|
57
59
|
const isOpen = ref(props.defaultExpanded ?? false);
|
|
58
60
|
|
|
59
61
|
const sectionStaticClass =
|
|
@@ -64,8 +66,10 @@ const footerStaticClass =
|
|
|
64
66
|
"h-64 border-t-1 border-solid p-16 flex justify-end gap-8 items-center";
|
|
65
67
|
|
|
66
68
|
const showContent = computed(() => isOpen.value || !props.collapsible);
|
|
69
|
+
const isAlive = computed(() => props.alwaysAlive || showContent.value);
|
|
67
70
|
const headerContainerComputedClass = computed(() => [
|
|
68
71
|
showContent.value ? "border-b-1" : "border-b-0",
|
|
72
|
+
props.collapsible ? "cursor-pointer" : "",
|
|
69
73
|
]);
|
|
70
74
|
|
|
71
75
|
const backgroundColor = computed(() => {
|
|
@@ -117,5 +121,10 @@ onMounted(() => {
|
|
|
117
121
|
);
|
|
118
122
|
});
|
|
119
123
|
|
|
120
|
-
defineExpose({
|
|
124
|
+
defineExpose({
|
|
125
|
+
/**
|
|
126
|
+
* Method to toggle the card open/closed state
|
|
127
|
+
*/
|
|
128
|
+
toggleOpen
|
|
129
|
+
});
|
|
121
130
|
</script>
|
package/src/types.ts
CHANGED
|
@@ -1,12 +1,40 @@
|
|
|
1
1
|
export type FzCardProps = {
|
|
2
|
+
/**
|
|
3
|
+
* The title of the card
|
|
4
|
+
*/
|
|
2
5
|
title: string;
|
|
6
|
+
/**
|
|
7
|
+
* The background color of the card
|
|
8
|
+
*/
|
|
3
9
|
color?: FzCardColor;
|
|
10
|
+
/**
|
|
11
|
+
* The primary action button
|
|
12
|
+
*/
|
|
4
13
|
primaryAction?: FzCardButton;
|
|
14
|
+
/**
|
|
15
|
+
* The secondary action button
|
|
16
|
+
*/
|
|
5
17
|
secondaryAction?: FzCardButton;
|
|
18
|
+
/**
|
|
19
|
+
* The tertiary action button
|
|
20
|
+
*/
|
|
6
21
|
tertiaryAction?: FzCardIconButton;
|
|
22
|
+
/**
|
|
23
|
+
* Custom css class to apply to the content
|
|
24
|
+
*/
|
|
7
25
|
contentClass?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the card is collapsible
|
|
28
|
+
*/
|
|
8
29
|
collapsible?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the card is expanded by default (only if collapsible)
|
|
32
|
+
*/
|
|
9
33
|
defaultExpanded?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the card content is always alive (never destroyed) when collapsed
|
|
36
|
+
*/
|
|
37
|
+
alwaysAlive?: boolean;
|
|
10
38
|
};
|
|
11
39
|
|
|
12
40
|
type FzCardButton = {
|
|
@@ -18,3 +46,40 @@ type FzCardIconButton = {
|
|
|
18
46
|
};
|
|
19
47
|
|
|
20
48
|
export type FzCardColor = "purple" | "orange" | "blue";
|
|
49
|
+
|
|
50
|
+
export interface FzCardEvents {
|
|
51
|
+
/**
|
|
52
|
+
* Event emitted when the primary action is clicked
|
|
53
|
+
* @type {() => void}
|
|
54
|
+
*/
|
|
55
|
+
(event: 'fzprimary:click'): void
|
|
56
|
+
/**
|
|
57
|
+
* Event emitted when the secondary action is clicked
|
|
58
|
+
* @type {() => void}
|
|
59
|
+
*/
|
|
60
|
+
(event:'fzsecondary:click'): void,
|
|
61
|
+
/**
|
|
62
|
+
* Event emitted when the tertiary action is clicked
|
|
63
|
+
* @type {() => void}
|
|
64
|
+
*/
|
|
65
|
+
(event:'fztertiary:click'): void,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface FzCardSlots {
|
|
69
|
+
/**
|
|
70
|
+
* Slot for the content of the card
|
|
71
|
+
*/
|
|
72
|
+
default(props:{}): any;
|
|
73
|
+
/**
|
|
74
|
+
* Slot for the header, it will be displayed on the left of the title
|
|
75
|
+
*/
|
|
76
|
+
header(props:{}): any;
|
|
77
|
+
/**
|
|
78
|
+
* Slot for the header content, it will be displayed below the title
|
|
79
|
+
*/
|
|
80
|
+
'header-content'(props:{}): any;
|
|
81
|
+
/**
|
|
82
|
+
* Slot for the footer of the card
|
|
83
|
+
*/
|
|
84
|
+
footer(props:{}): any;
|
|
85
|
+
}
|