@fiscozen/card 0.1.1 → 0.1.3

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.1",
3
+ "version": "0.1.3",
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.3",
11
- "@fiscozen/button": "^0.1.2"
10
+ "@fiscozen/icons": "^0.1.5",
11
+ "@fiscozen/button": "^0.1.4"
12
12
  },
13
13
  "peerDependencies": {
14
14
  "tailwindcss": "^3.4.1",
@@ -33,8 +33,8 @@
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/prettier-config": "^0.1.0",
37
36
  "@fiscozen/eslint-config": "^0.1.0",
37
+ "@fiscozen/prettier-config": "^0.1.0",
38
38
  "@fiscozen/tsconfig": "^0.1.0"
39
39
  },
40
40
  "license": "MIT",
package/src/FzCard.vue CHANGED
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <section :class="[sectionStaticClass, backgroundColor]">
3
- <header :class="[headerContainerComputedClass, borderColor]">
3
+ <header :class="[headerContainerComputedClass, borderColor]" @click="toggleOpen">
4
4
  <div :class="headerStaticClass">
5
5
  <div class="flex flex-row gap-12 items-center">
6
6
  <h2
@@ -15,37 +15,34 @@
15
15
  <FzIconButton
16
16
  v-if="collapsible"
17
17
  :iconName="isOpen ? 'chevron-up' : 'chevron-down'"
18
- @click="isOpen = !isOpen"
19
18
  variant="invisible"
20
19
  />
21
20
  </div>
22
21
  <slot name="header-content"></slot>
23
22
  </header>
24
- <template v-if="showContent">
25
- <article :class="['p-20', contentClass]">
26
- <slot></slot>
27
- </article>
28
- <footer v-if="atLeastOneButton" :class="[footerStaticClass, borderColor]">
29
- <FzIconButton
30
- v-if="tertiaryAction"
31
- @click="$emit('fztertiary:click')"
32
- :iconName="tertiaryAction.icon"
33
- variant="invisible"
34
- />
35
- <FzButton
36
- v-if="secondaryAction"
37
- @click="$emit('fzsecondary:click')"
38
- :label="secondaryAction.label"
39
- variant="secondary"
40
- />
41
- <FzButton
42
- v-if="primaryAction"
43
- @click="$emit('fzprimary:click')"
44
- :label="primaryAction.label"
45
- variant="primary"
46
- />
47
- </footer>
48
- </template>
23
+ <article v-if="isAlive" :class="['p-20', contentClass]" v-show="showContent">
24
+ <slot></slot>
25
+ </article>
26
+ <footer v-if="atLeastOneButton && isAlive" :class="[footerStaticClass, borderColor]" v-show="showContent">
27
+ <FzIconButton
28
+ v-if="tertiaryAction"
29
+ @click="$emit('fztertiary:click')"
30
+ :iconName="tertiaryAction.icon"
31
+ variant="invisible"
32
+ />
33
+ <FzButton
34
+ v-if="secondaryAction"
35
+ @click="$emit('fzsecondary:click')"
36
+ :label="secondaryAction.label"
37
+ variant="secondary"
38
+ />
39
+ <FzButton
40
+ v-if="primaryAction"
41
+ @click="$emit('fzprimary:click')"
42
+ :label="primaryAction.label"
43
+ variant="primary"
44
+ />
45
+ </footer>
49
46
  </section>
50
47
  </template>
51
48
 
@@ -65,8 +62,10 @@ const footerStaticClass =
65
62
  "h-64 border-t-1 border-solid p-16 flex justify-end gap-8 items-center";
66
63
 
67
64
  const showContent = computed(() => isOpen.value || !props.collapsible);
65
+ const isAlive = computed(() => props.alwaysAlive || showContent.value);
68
66
  const headerContainerComputedClass = computed(() => [
69
67
  showContent.value ? "border-b-1" : "border-b-0",
68
+ props.collapsible ? "cursor-pointer" : "",
70
69
  ]);
71
70
 
72
71
  const backgroundColor = computed(() => {
@@ -102,6 +101,11 @@ const atLeastOneButton = computed(
102
101
  props.tertiaryAction !== undefined,
103
102
  );
104
103
 
104
+ function toggleOpen() {
105
+ if (props.collapsible)
106
+ isOpen.value = !isOpen.value;
107
+ }
108
+
105
109
  onMounted(() => {
106
110
  if (props.tertiaryAction && !props.secondaryAction && !props.primaryAction)
107
111
  console.warn(
@@ -112,4 +116,6 @@ onMounted(() => {
112
116
  "[Fiscozen Design System]: You should set primaryAction if you want to set secondaryAction",
113
117
  );
114
118
  });
119
+
120
+ defineExpose({ toggleOpen });
115
121
  </script>
package/src/types.ts CHANGED
@@ -7,6 +7,7 @@ export type FzCardProps = {
7
7
  contentClass?: string;
8
8
  collapsible?: boolean;
9
9
  defaultExpanded?: boolean;
10
+ alwaysAlive?: boolean;
10
11
  };
11
12
 
12
13
  type FzCardButton = {