@fiscozen/card 0.1.4 → 0.1.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.
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@fiscozen/card",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
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.19",
11
- "@fiscozen/button": "^0.1.9"
10
+ "@fiscozen/button": "^0.1.9",
11
+ "@fiscozen/icons": "^0.1.19"
12
12
  },
13
13
  "peerDependencies": {
14
14
  "tailwindcss": "^3.4.1",
@@ -34,8 +34,8 @@
34
34
  "@fortawesome/fontawesome-svg-core": "^6.5.1",
35
35
  "@fortawesome/vue-fontawesome": "^3.0.6",
36
36
  "@fiscozen/eslint-config": "^0.1.0",
37
- "@fiscozen/tsconfig": "^0.1.0",
38
- "@fiscozen/prettier-config": "^0.1.0"
37
+ "@fiscozen/prettier-config": "^0.1.0",
38
+ "@fiscozen/tsconfig": "^0.1.0"
39
39
  },
40
40
  "license": "MIT",
41
41
  "scripts": {
package/src/FzCard.vue CHANGED
@@ -1,6 +1,10 @@
1
1
  <template>
2
2
  <section :class="[sectionStaticClass, backgroundColor]">
3
- <header :class="[headerContainerComputedClass, borderColor]" @click="toggleOpen">
3
+ <header
4
+ v-if="existHeader"
5
+ :class="[headerContainerComputedClass, borderColor]"
6
+ @click="toggleOpen"
7
+ >
4
8
  <div :class="headerStaticClass">
5
9
  <div class="flex flex-row gap-12 items-center">
6
10
  <h2
@@ -20,10 +24,18 @@
20
24
  </div>
21
25
  <slot name="header-content"></slot>
22
26
  </header>
23
- <article v-if="isAlive" :class="['p-20', contentClass]" v-show="showContent">
27
+ <article
28
+ v-if="isAlive"
29
+ :class="['p-20', contentClass]"
30
+ v-show="showContent"
31
+ >
24
32
  <slot></slot>
25
33
  </article>
26
- <footer v-if="(slots.footer || atLeastOneButton) && isAlive" :class="[footerStaticClass, borderColor]" v-show="showContent">
34
+ <footer
35
+ v-if="(slots.footer || atLeastOneButton) && isAlive"
36
+ :class="[footerStaticClass, borderColor]"
37
+ v-show="showContent"
38
+ >
27
39
  <slot name="footer">
28
40
  <FzIconButton
29
41
  v-if="tertiaryAction"
@@ -67,6 +79,9 @@ const footerStaticClass =
67
79
 
68
80
  const showContent = computed(() => isOpen.value || !props.collapsible);
69
81
  const isAlive = computed(() => props.alwaysAlive || showContent.value);
82
+ const existHeader = computed(
83
+ () => props.title || slots["header"] || slots["header-content"],
84
+ );
70
85
  const headerContainerComputedClass = computed(() => [
71
86
  showContent.value ? "border-b-1" : "border-b-0",
72
87
  props.collapsible ? "cursor-pointer" : "",
@@ -106,8 +121,7 @@ const atLeastOneButton = computed(
106
121
  );
107
122
 
108
123
  function toggleOpen() {
109
- if (props.collapsible)
110
- isOpen.value = !isOpen.value;
124
+ if (props.collapsible) isOpen.value = !isOpen.value;
111
125
  }
112
126
 
113
127
  onMounted(() => {
@@ -121,10 +135,10 @@ onMounted(() => {
121
135
  );
122
136
  });
123
137
 
124
- defineExpose({
138
+ defineExpose({
125
139
  /**
126
140
  * Method to toggle the card open/closed state
127
141
  */
128
- toggleOpen
142
+ toggleOpen,
129
143
  });
130
144
  </script>
@@ -159,4 +159,35 @@ describe("FzCard", () => {
159
159
  await wrapper.find("header").find("button").trigger("click");
160
160
  expect(wrapper.find("article").exists()).toBeTruthy();
161
161
  });
162
+
163
+ it("should hide the header when no title is defined", async () => {
164
+ const wrapper = mount(FzCard, {
165
+ props: {},
166
+ });
167
+ await wrapper.vm.$nextTick();
168
+
169
+ expect(wrapper.find("header").exists()).toBeFalsy();
170
+ });
171
+
172
+ it("should show the header when no title is defined but header slot is", async () => {
173
+ const wrapper = mount(FzCard, {
174
+ slots: {
175
+ header: "<div>Header</div>",
176
+ },
177
+ });
178
+ await wrapper.vm.$nextTick();
179
+
180
+ expect(wrapper.find("header").exists()).toBeTruthy();
181
+ });
182
+
183
+ it("should show the header when no title is defined but header-content slot is", async () => {
184
+ const wrapper = mount(FzCard, {
185
+ slots: {
186
+ "header-content": "<div>Header</div>",
187
+ },
188
+ });
189
+ await wrapper.vm.$nextTick();
190
+
191
+ expect(wrapper.find("header").exists()).toBeTruthy();
192
+ });
162
193
  });
package/src/types.ts CHANGED
@@ -2,7 +2,7 @@ export type FzCardProps = {
2
2
  /**
3
3
  * The title of the card
4
4
  */
5
- title: string;
5
+ title?: string;
6
6
  /**
7
7
  * The background color of the card
8
8
  */
@@ -52,34 +52,34 @@ export interface FzCardEvents {
52
52
  * Event emitted when the primary action is clicked
53
53
  * @type {() => void}
54
54
  */
55
- (event: 'fzprimary:click'): void
55
+ (event: "fzprimary:click"): void;
56
56
  /**
57
57
  * Event emitted when the secondary action is clicked
58
58
  * @type {() => void}
59
59
  */
60
- (event:'fzsecondary:click'): void,
60
+ (event: "fzsecondary:click"): void;
61
61
  /**
62
62
  * Event emitted when the tertiary action is clicked
63
63
  * @type {() => void}
64
64
  */
65
- (event:'fztertiary:click'): void,
65
+ (event: "fztertiary:click"): void;
66
66
  }
67
67
 
68
68
  export interface FzCardSlots {
69
69
  /**
70
70
  * Slot for the content of the card
71
71
  */
72
- default(props:{}): any;
72
+ default(props: {}): any;
73
73
  /**
74
74
  * Slot for the header, it will be displayed on the left of the title
75
75
  */
76
- header(props:{}): any;
76
+ header(props: {}): any;
77
77
  /**
78
78
  * Slot for the header content, it will be displayed below the title
79
79
  */
80
- 'header-content'(props:{}): any;
80
+ "header-content"(props: {}): any;
81
81
  /**
82
82
  * Slot for the footer of the card
83
83
  */
84
- footer(props:{}): any;
84
+ footer(props: {}): any;
85
85
  }