@htmlbricks/hb-dashboard-card1 0.71.34 → 0.71.36

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.
Files changed (3) hide show
  1. package/README.md +170 -23
  2. package/manifest.json +12 -8
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,45 +1,192 @@
1
- ## `hb-dashboard-card1` — dashboard-card1
1
+ # `hb-dashboard-card1`
2
2
 
3
- **Category:** data | **Tags:** data, dashboard
3
+ **Package:** `@htmlbricks/hb-dashboard-card1`
4
+ **Category:** data · **Tags:** data, dashboard
4
5
 
5
- ### What it does
6
+ ## Purpose
6
7
 
7
- Bulma card shell for dashboards: JSON `header` supplies optional Bootstrap Icon name, title label, and right-aligned tag; JSON `body` can remove inner padding with `noborder`. Slots let you inject markup (`header_content`, `content`). Bootstrap Icons are loaded from the CDN in `svelte:head` for `bi` classes on the optional header icon.
8
+ `hb-dashboard-card1` is a compact **Bulma card** layout for dashboards and admin shells. You configure the **header** (optional Bootstrap Icon, title, optional right-aligned tag) and **body** (optional removal of inner padding) via **JSON strings** on attributes. Use the **`header_content`** and **`content`** slots when you need full control over markup inside the card header and body regions.
8
9
 
9
- ### Custom element
10
+ The component applies Bulma’s **light theme** tokens on `:host` and loads **Bootstrap Icons** for the optional header icon (`bi-*` classes).
10
11
 
11
- `hb-dashboard-card1`
12
+ ---
12
13
 
13
- ### Attributes / props (snake_case)
14
+ ## Registration and usage
14
15
 
15
- | Property | Type | Notes |
16
+ Load your built script (or bundle) so the custom element is defined, then use the tag in HTML or in any framework that renders real DOM. Attribute names are **`snake_case`**. From HTML, **structured props are JSON strings** (see [Attributes](#attributes)).
17
+
18
+ ---
19
+
20
+ ## Custom element
21
+
22
+ | Tag |
23
+ | --- |
24
+ | `hb-dashboard-card1` |
25
+
26
+ ---
27
+
28
+ ## Attributes
29
+
30
+ All reflected / declarative inputs are **strings** at the DOM boundary (HTML `attributes` or `setAttribute`). Pass **objects as JSON**.
31
+
32
+ | Attribute | Required | Description |
33
+ | --- | --- | --- |
34
+ | `id` | No | Passed through for identification / testing (host element `id`). |
35
+ | `header` | No | JSON object describing the header row. If omitted, invalid, or empty after parse, the default header chrome still renders but **title and icon stay empty** unless you use the `header_content` slot. |
36
+ | `body` | No | JSON object for body options. If omitted or invalid, defaults to `{ "noborder": false }`. |
37
+
38
+ ### `header` JSON shape
39
+
40
+ | Field | Type | Description |
41
+ | --- | --- | --- |
42
+ | `label` | string | Main title text (truncates with ellipsis when space is tight). |
43
+ | `icon` | string | Optional Bootstrap Icons **glyph name only** (no `bi-` prefix), e.g. `"graph-up"`, `"bell"`. |
44
+ | `badge` | string | Optional text for a Bulma **`tag`** on the right (status, delta, count). |
45
+
46
+ Example:
47
+
48
+ ```json
49
+ { "label": "Revenue", "icon": "graph-up", "badge": "+12%" }
50
+ ```
51
+
52
+ ### `body` JSON shape
53
+
54
+ | Field | Type | Description |
16
55
  | --- | --- | --- |
17
- | `id` | string (optional) | Element identifier. |
18
- | `style` | string (optional) | Inline style string. |
19
- | `header` | object (optional) | JSON `{ icon?: string; label: string; badge?: string }`. |
20
- | `body` | object (optional) | JSON `{ noborder?: boolean }`. |
56
+ | `noborder` | boolean | When `true`, the main **`card-content`** area uses **no padding** (`p-0`), useful for charts or tables that should bleed to the card edges. |
21
57
 
22
- **Bulma `--bulma-*` theme vars** (see `extra/docs.ts`). **Parts:** `text_placeholder`, `badge`, `card`. **Slots:** `header_content`, `content`.
58
+ Example:
23
59
 
24
- ### Events (`CustomEvent` names)
60
+ ```json
61
+ { "noborder": true }
62
+ ```
63
+
64
+ ### Parsing behavior
65
+
66
+ - **`header` and `body`** accept either a **string** (parsed with `JSON.parse`) or an object when set from JavaScript on the custom element’s property layer.
67
+ - **Invalid JSON** or non-object values for `body` fall back to **`{ noborder: false }`**.
68
+ - **Invalid or empty `header` JSON** yields **no parsed header**; the component does not throw.
69
+
70
+ ### `style` (TypeScript only)
71
+
72
+ The authoring type `Component` includes an optional **`style`** field for wrappers and tooling. The current Svelte implementation does **not** destructure or apply that prop inside the component; use normal **host** `style` / CSS if you need outer layout tweaks.
73
+
74
+ ---
75
+
76
+ ## Slots
77
+
78
+ Shadow slots let you replace the default fragments Bulma would otherwise own.
25
79
 
26
- None declared in types (`Events` is an empty object).
80
+ | Slot | Default | When you use it |
81
+ | --- | --- | --- |
82
+ | `header_content` | Built-in **`card-header-title`** row: optional icon, `label`, optional `badge`. | Supplying **children with `slot="header_content"` replaces the entire default title row**. Use this for fully custom header markup. |
83
+ | `content` | Empty (reserved for your body markup). | Main **`card-content`** area: charts, tables, metrics, etc. |
84
+
85
+ ---
86
+
87
+ ## Custom events
88
+
89
+ None. The `Events` contract for this component is **empty**—there are no documented `CustomEvent` outputs from the host.
27
90
 
28
- ### Styling (Bulma)
91
+ ---
29
92
 
30
- The component uses Bulma `card`, `card-header`, `card-header-title`, `card-content`, and `tag`. Theme defaults are applied on `:host` via Bulma’s light theme and `setup-theme`. Override card look with public `--bulma-*` properties (for example `--bulma-card-background-color`, `--bulma-card-shadow`, `--bulma-card-header-color`). Bootstrap Icons remain a separate stylesheet for `header.icon`.
93
+ ## Styling
31
94
 
32
- ### Usage notes
95
+ ### Bulma CSS variables (`:host`)
33
96
 
34
- - `header.icon` should be a bootstrap-icons icon name string (without the `bi-` prefix).
35
- - Use `::part(card)` and related parts for host-level theming inside shadow root.
36
- - No i18n in `docs.ts`.
97
+ Set **`--bulma-*`** variables on the host or an ancestor; they flow into the shadow tree with this component’s Bulma setup.
37
98
 
38
- ### Minimal HTML example
99
+ | Variable | Role |
100
+ | --- | --- |
101
+ | `--bulma-card-background-color` | Card panel background. |
102
+ | `--bulma-card-shadow` | Elevation / shadow around the card. |
103
+ | `--bulma-card-header-color` | Header title text color. |
104
+ | `--bulma-text-strong` | Strong text context used with header styling. |
105
+
106
+ Defaults and longer descriptions are listed in `extra/docs.ts` (`styleSetup.vars`) for catalog and design tools.
107
+
108
+ ### CSS parts
109
+
110
+ | Part | Element | Use |
111
+ | --- | --- | --- |
112
+ | `card` | Root `.card` container | Host-level tweaks to the whole widget (radius, border, background overrides complementary to variables). |
113
+
114
+ ### Icons
115
+
116
+ - **In-component icon:** `header.icon` uses classes `bi bi-{icon}`; names match [Bootstrap Icons](https://icons.getbootstrap.com/).
117
+ - **Stylesheets:** Icons are loaded from a CDN in the component (`svelte:head`) and the shared stylesheet also references Bootstrap Icons for consistent font loading—integrators typically do not need to add another icon link unless they strip shadow assets.
118
+
119
+ ---
120
+
121
+ ## Markup structure (Bulma)
122
+
123
+ The implementation uses Bulma **`card`**, **`card-header`**, **`card-header-title`**, **`card-content`**, and **`tag`**. Header layout uses flex helpers so long **labels truncate** and the **badge stays right-aligned**.
124
+
125
+ ---
126
+
127
+ ## Internationalization
128
+
129
+ No built-in i18n strings; all visible text comes from your **`header`** JSON, slot content, or slotted children.
130
+
131
+ ---
132
+
133
+ ## Examples
134
+
135
+ ### Minimal header with icon and badge
39
136
 
40
137
  ```html
41
138
  <hb-dashboard-card1
42
139
  header='{"label":"Revenue","icon":"graph-up","badge":"+12%"}'
43
- body='{"noborder":false}'
44
140
  ></hb-dashboard-card1>
45
141
  ```
142
+
143
+ ### Title only, padded body
144
+
145
+ ```html
146
+ <hb-dashboard-card1 header='{"label":"Active users"}'></hb-dashboard-card1>
147
+ ```
148
+
149
+ ### Tight body for a chart or table
150
+
151
+ ```html
152
+ <hb-dashboard-card1
153
+ header='{"label":"Metrics","icon":"graph-up","badge":"live"}'
154
+ body='{"noborder":true}'
155
+ >
156
+ <div slot="content" style="height: 200px; background: linear-gradient(...)"></div>
157
+ </hb-dashboard-card1>
158
+ ```
159
+
160
+ ### Custom header via slot
161
+
162
+ Replacing the default row removes the built-in icon/label/badge layout; style slotted nodes from **your** stylesheet (shadow Bulma rules do not target slotted light DOM unless the component exposes `::slotted(...)` rules).
163
+
164
+ ```html
165
+ <hb-dashboard-card1 body='{"noborder":true}'>
166
+ <div slot="header_content" style="display:flex;align-items:center;gap:0.5rem;width:100%;">
167
+ <strong>Custom</strong>
168
+ <span style="margin-left:auto;">meta</span>
169
+ </div>
170
+ <p slot="content">Body from slot.</p>
171
+ </hb-dashboard-card1>
172
+ ```
173
+
174
+ ### JavaScript: set properties
175
+
176
+ ```js
177
+ const el = document.querySelector("hb-dashboard-card1");
178
+ el.header = { label: "Alerts", icon: "bell", badge: "3" };
179
+ el.body = { noborder: false };
180
+ ```
181
+
182
+ ---
183
+
184
+ ## Files in this package (for contributors)
185
+
186
+ | File | Role |
187
+ | --- | --- |
188
+ | `component.wc.svelte` | Custom element implementation |
189
+ | `types/webcomponent.type.d.ts` | `Component` / `Events` authoring types |
190
+ | `extra/docs.ts` | Catalog metadata, CSS vars, parts, slots, Storybook args |
191
+ | `styles/bulma.scss` | Bulma modules + theme on `:host` |
192
+ | `styles/webcomponent.scss` | Layout tweaks, icon import |
package/manifest.json CHANGED
@@ -75,19 +75,19 @@
75
75
  "name": "--bulma-card-background-color",
76
76
  "valueType": "color",
77
77
  "defaultValue": "#ffffff",
78
- "description": "Card surface."
78
+ "description": "Controls the visible card panel background so dashboard widgets match your shell while keeping inner content contrast clear for readers."
79
79
  },
80
80
  {
81
81
  "name": "--bulma-card-shadow",
82
82
  "valueType": "other",
83
83
  "defaultValue": "0 0.5em 1em -0.125em rgba(10, 10, 10, 0.1)",
84
- "description": "Card elevation."
84
+ "description": "Defines the drop shadow around the whole card, letting you tune depth against flat dashboards or dense grids without editing shadow markup."
85
85
  },
86
86
  {
87
87
  "name": "--bulma-card-header-color",
88
88
  "valueType": "color",
89
89
  "defaultValue": "#363636",
90
- "description": "Header title color."
90
+ "description": "Sets the header title ink color so the metric label stays legible when you customize the card background or embed it on dark sections."
91
91
  },
92
92
  {
93
93
  "name": "--bulma-text-strong",
@@ -99,23 +99,27 @@
99
99
  "parts": [
100
100
  {
101
101
  "name": "text_placeholder",
102
- "description": "Text placeholder css div element part"
102
+ "description": "Header title text node wrapper; use for typography, truncation, or color without replacing the whole header slot."
103
103
  },
104
104
  {
105
105
  "name": "badge",
106
- "description": "badge"
106
+ "description": "Right-aligned Bulma `tag` in the card header (e.g. status or delta); style pill colors from the host."
107
107
  },
108
108
  {
109
109
  "name": "card",
110
- "description": "main container"
110
+ "description": "Root Bulma `card` element; use for elevation, border, or background on the whole widget."
111
111
  }
112
112
  ]
113
113
  },
114
114
  "contributors": [],
115
115
  "htmlSlots": [
116
+ {
117
+ "name": "header_content",
118
+ "description": "Optional markup between the icon/title row and the end of `card-header` (extra controls or meta)."
119
+ },
116
120
  {
117
121
  "name": "content",
118
- "description": ""
122
+ "description": "Main `card-content` body; replaces or augments the default padded content area."
119
123
  }
120
124
  ],
121
125
  "i18n": [],
@@ -188,5 +192,5 @@
188
192
  "size": {},
189
193
  "iifePath": "main.iife.js",
190
194
  "repoName": "@htmlbricks/hb-dashboard-card1",
191
- "version": "0.71.34"
195
+ "version": "0.71.36"
192
196
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htmlbricks/hb-dashboard-card1",
3
- "version": "0.71.34",
3
+ "version": "0.71.36",
4
4
  "contributors": [],
5
5
  "description": "Bulma card shell for dashboards: JSON `header` supplies optional Bootstrap Icon name, title label, and right-aligned tag; JSON `body` can remove inner padding with `noborder`. Default slots `header_content` and `content` let you inject arbitrary markup between the standard header row and body.",
6
6
  "licenses": [