@fiscozen/card 0.1.3 → 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 CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@fiscozen/card",
3
- "version": "0.1.3",
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.5",
11
- "@fiscozen/button": "^0.1.4"
10
+ "@fiscozen/icons": "^0.1.19",
11
+ "@fiscozen/button": "^0.1.9"
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/prettier-config": "^0.1.0",
38
- "@fiscozen/tsconfig": "^0.1.0"
37
+ "@fiscozen/tsconfig": "^0.1.0",
38
+ "@fiscozen/prettier-config": "^0.1.0"
39
39
  },
40
40
  "license": "MIT",
41
41
  "scripts": {
package/src/FzCard.vue CHANGED
@@ -23,35 +23,39 @@
23
23
  <article v-if="isAlive" :class="['p-20', contentClass]" v-show="showContent">
24
24
  <slot></slot>
25
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
- />
26
+ <footer v-if="(slots.footer || atLeastOneButton) && isAlive" :class="[footerStaticClass, borderColor]" v-show="showContent">
27
+ <slot name="footer">
28
+ <FzIconButton
29
+ v-if="tertiaryAction"
30
+ @click="emit('fztertiary:click')"
31
+ :iconName="tertiaryAction.icon"
32
+ variant="invisible"
33
+ />
34
+ <FzButton
35
+ v-if="secondaryAction"
36
+ @click="emit('fzsecondary:click')"
37
+ :label="secondaryAction.label"
38
+ variant="secondary"
39
+ />
40
+ <FzButton
41
+ v-if="primaryAction"
42
+ @click="emit('fzprimary:click')"
43
+ :label="primaryAction.label"
44
+ variant="primary"
45
+ />
46
+ </slot>
45
47
  </footer>
46
48
  </section>
47
49
  </template>
48
50
 
49
51
  <script setup lang="ts">
50
52
  import { computed, onMounted, ref } from "vue";
51
- import { FzCardProps } from "./types";
53
+ import { FzCardEvents, FzCardProps, FzCardSlots } from "./types";
52
54
  import { FzButton, FzIconButton } from "@fiscozen/button";
53
55
 
54
56
  const props = defineProps<FzCardProps>();
57
+ const emit = defineEmits<FzCardEvents>();
58
+ const slots = defineSlots<FzCardSlots>();
55
59
  const isOpen = ref(props.defaultExpanded ?? false);
56
60
 
57
61
  const sectionStaticClass =
@@ -117,5 +121,10 @@ onMounted(() => {
117
121
  );
118
122
  });
119
123
 
120
- defineExpose({ toggleOpen });
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,39 @@
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
+ */
10
37
  alwaysAlive?: boolean;
11
38
  };
12
39
 
@@ -19,3 +46,40 @@ type FzCardIconButton = {
19
46
  };
20
47
 
21
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
+ }