@fiscozen/card 1.0.1 → 1.1.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,30 @@
1
+ # @fiscozen/card
2
+
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 2cc511a: Add yellow and red color variants
8
+
9
+ ### Patch Changes
10
+
11
+ - 1a2df8c: Move @fiscozen/icons from dependencies to peerDependencies. Consumers now need to install @fiscozen/icons explicitly. This decouples icon updates from component version bumps.
12
+ - Updated dependencies [1a2df8c]
13
+ - @fiscozen/button@1.0.2
14
+
15
+ ## 1.0.2
16
+
17
+ ### Minor Changes
18
+
19
+ - **LIB-1889: Aggiornamento di FzCard al design 1.0.0.** Nuovo layout, gestione dello stile e rimozione di IconButton.
20
+
21
+ ### Patch Changes
22
+
23
+ - Aggiunta possibilità di disabilitare i pulsanti nelle card (SQA-2250)
24
+ - Rimozione della dipendenza da IconButton (LIB-1889)
25
+ - Aggiornamento dello stile e del padding dell'articolo principale (LIB-1889)
26
+ - Updated dependencies
27
+ - @fiscozen/button@1.0.1
28
+ - @fiscozen/style@0.2.0
29
+ - @fiscozen/composables@1.0.1
30
+ - @fiscozen/container@0.4.1
package/README.md CHANGED
@@ -1 +1,100 @@
1
1
  # @fiscozen/card
2
+
3
+ > For usage documentation, see [Storybook Documentation](https://storybook-url/Documentation/Panel/FzCard)
4
+
5
+ ## Development
6
+
7
+ ### Architecture
8
+
9
+ The `FzCard` component is a layout container that groups related content and actions. It provides a consistent structure: optional header (title + slots), main content area, and optional footer (default action buttons or custom slot). It supports multiple background color variants, collapsible content with configurable default state, and optional info icon. All action buttons and the info icon use the same `environment` prop for visual context (backoffice vs frontoffice).
10
+
11
+ **Key state:**
12
+ - `isOpen`: Ref controlling expanded/collapsed state when `collapsible` is true; initial value from `defaultExpanded ?? false`
13
+ - `normalizedColor`: Computed mapping deprecated color values (e.g. `aliceblue` → `blue`) for internal styling
14
+ - `showContent`: Computed — true when not collapsible or when expanded
15
+ - `isAlive`: Computed — true when `alwaysAlive` or `showContent`; drives whether article/footer are in DOM (v-if)
16
+ - `existHeader`: Computed — true when title or header/header-content slots are provided
17
+ - `atLeastOneButton`: Computed — true when any of primary/secondary/tertiary action is set
18
+
19
+ **Color and styling flow:**
20
+ - `normalizedColor` feeds `backgroundColor` and `borderColor` computed properties
21
+ - Background/border use Tailwind classes: design tokens for default/blue/orange/purple/grey; semantic tokens for yellow (`--semantic-warning-50`) and red (`--semantic-error-50`)
22
+ - Text color is always `text-core-black` for all variants
23
+
24
+ ### Code Organization
25
+
26
+ - `src/FzCard.vue`: Single-file component; all logic and template in one place
27
+ - `src/types.ts`: `FzCardProps`, `FzCardColor`, `FzCardEnvironment`, `FzCardEvents`, `FzCardSlots`, and internal action types
28
+ - `src/index.ts`: Exports component and types
29
+
30
+ No subcomponents or `utils`/`common` modules; color mapping and layout logic live in the main component.
31
+
32
+ ### Key Concepts
33
+
34
+ #### Color Variants and Normalization
35
+
36
+ The `color` prop accepts: `default`, `blue`, `orange`, `purple`, `grey`, `yellow`, `red`, and deprecated `aliceblue`. All styling uses `normalizedColor` so that:
37
+ - `aliceblue` is mapped to `blue` (same visual result)
38
+ - A `watch` with `immediate: true` logs a deprecation warning when `color === 'aliceblue'`
39
+
40
+ Background and border classes are resolved in two computed properties (`backgroundColor`, `borderColor`) with a `switch (normalizedColor.value)` over the normalized value. Adding a new color requires adding a case in both computeds and extending `FzCardColor` in `types.ts`.
41
+
42
+ #### Collapsible and Content Visibility
43
+
44
+ - When `collapsible` is false: content and footer are always visible; `isAlive` and `showContent` are true
45
+ - When `collapsible` is true: header click toggles `isOpen`; `showContent` follows `isOpen`; article uses `v-show="showContent"` so it can be hidden without destroy
46
+ - `isAlive`: When true, article and footer are rendered (v-if). When false (collapsible and collapsed and not `alwaysAlive`), article is not in DOM. So: `alwaysAlive` keeps content in DOM when collapsed; otherwise collapsed state removes article (and footer when no actions/slot)
47
+
48
+ Footer is shown only when `(slots.footer || atLeastOneButton) && isAlive` and `v-show="showContent"`, so it hides with content when collapsed unless overridden by slot usage.
49
+
50
+ #### Action Buttons and Warnings
51
+
52
+ Primary, secondary, and tertiary actions are rendered in the default footer slot via `FzContainer` + `FzButton` / `FzIconButton`. Order in template: tertiary (icon), secondary, primary. On mount, the component warns if:
53
+ - `tertiaryAction` is set without both `primaryAction` and `secondaryAction`
54
+ - `secondaryAction` is set without `primaryAction`
55
+
56
+ These are guidance only; rendering still proceeds.
57
+
58
+ #### Responsive Footer
59
+
60
+ `useMediaQuery` from `@fiscozen/composables` and `breakpoints` from `@fiscozen/style` drive `smOrSmaller`. When true, footer has `w-full` on the container and `flex-grow` on secondary/primary buttons; footer layout uses `justify-end` when not `smOrSmaller`.
61
+
62
+ ### Internal Logic
63
+
64
+ #### Color Class Mapping
65
+
66
+ - `backgroundColor`: `default` → `bg-core-white`; `blue` → `bg-background-alice-blue`; `orange` → `bg-background-seashell`; `purple` → `bg-background-pale-purple`; `grey` → `bg-background-white-smoke`; `yellow` → `bg-semantic-warning-50`; `red` → `bg-semantic-error-50`
67
+ - `borderColor`: same keys → `border-grey-100` (default), `border-background-alice-blue`, `border-background-seashell`, `border-background-pale-purple`, `border-background-white-smoke`, `border-semantic-warning-50`, `border-semantic-error-50`
68
+
69
+ All other colors (e.g. future tokens) require adding a case in both computeds and ensuring the Tailwind/semantic token exists in the design system.
70
+
71
+ #### Footer Visibility
72
+
73
+ Footer is rendered (v-if) when there is something to show and content is “alive”:
74
+ - Condition: `(slots.footer || atLeastOneButton) && isAlive`
75
+ - Visibility: `v-show="showContent"` so it hides when collapsible and collapsed
76
+ - When only actions exist, default footer slot renders `FzContainer` with tertiary (FzIconButton), secondary (FzButton), primary (FzButton). Custom footer replaces this entirely via `#footer`.
77
+
78
+ #### defineExpose
79
+
80
+ Only `toggleOpen` is exposed; used for programmatic expand/collapse when `collapsible` is true.
81
+
82
+ ### Design Decisions
83
+
84
+ #### Why Normalize Color Instead of Removing aliceblue?
85
+
86
+ Keeping `aliceblue` in the type and normalizing to `blue` preserves backward compatibility. Consumers can migrate at their own pace while receiving a single deprecation warning. Removing it would be a breaking change.
87
+
88
+ #### Why v-if for Article/Footer and v-show for Visibility?
89
+
90
+ `v-if="isAlive"` controls whether the content block exists at all (e.g. when collapsed and not `alwaysAlive`). `v-show="showContent"` only hides the block visually when collapsible and collapsed but still “alive”. This allows optional DOM removal for performance while supporting `alwaysAlive` for stateful content that must stay mounted.
91
+
92
+ #### Why Action Warnings on Mount?
93
+
94
+ Tertiary/secondary without primary are allowed by the type system but are considered poor UX. The onMounted warnings guide consumers toward recommended usage without breaking existing code.
95
+
96
+ ### Known Limitations
97
+
98
+ - **No built-in loading/error state**: Card does not provide loading or error UI; consumers can use slots or contentClass
99
+ - **Action order fixed**: Tertiary, secondary, primary order is not configurable via prop
100
+ - **Single expand state**: No accordion/group behavior; each card manages its own `isOpen`