@smartsoft001/claude-plugins 2.194.0 → 2.196.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/.claude-plugin/marketplace.json +14 -3
- package/README.md +19 -4
- package/package.json +3 -3
- package/plugins/smart-angular/.claude-plugin/plugin.json +6 -0
- package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/SKILL.md +1 -1
- package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/base-claude-config.md +13 -9
- package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/patch-delta.md +1 -1
- package/plugins/{smart → smart-core}/.claude-plugin/README.md +31 -16
- package/plugins/{smart → smart-core}/.claude-plugin/merge-permissions.js +7 -6
- package/plugins/smart-core/.claude-plugin/plugin.json +5 -0
- package/plugins/{smart → smart-core}/.claude-plugin/settings.template.json +2 -2
- package/plugins/{smart → smart-core}/hooks/README.md +1 -1
- package/plugins/{smart → smart-core}/skills/audit-log/SKILL.md +2 -2
- package/plugins/{smart → smart-core}/skills/format-code/SKILL.md +1 -1
- package/plugins/smart-react/.claude-plugin/plugin.json +6 -0
- package/plugins/smart-react/agents/react-components.md +260 -0
- package/plugins/smart-react/skills/react-components-accordion/SKILL.md +204 -0
- package/plugins/smart-react/skills/react-components-action-panel/SKILL.md +191 -0
- package/plugins/smart-react/skills/react-components-alert/SKILL.md +244 -0
- package/plugins/smart-react/skills/react-components-app/SKILL.md +236 -0
- package/plugins/smart-react/skills/react-components-avatar/SKILL.md +176 -0
- package/plugins/smart-react/skills/react-components-badge/SKILL.md +165 -0
- package/plugins/smart-react/skills/react-components-breadcrumbs/SKILL.md +183 -0
- package/plugins/smart-react/skills/react-components-button/SKILL.md +239 -0
- package/plugins/smart-react/skills/react-components-button-group/SKILL.md +187 -0
- package/plugins/smart-react/skills/react-components-calendar/SKILL.md +270 -0
- package/plugins/smart-react/skills/react-components-card/SKILL.md +201 -0
- package/plugins/smart-react/skills/react-components-card-heading/SKILL.md +133 -0
- package/plugins/smart-react/skills/react-components-command-palette/SKILL.md +228 -0
- package/plugins/smart-react/skills/react-components-container/SKILL.md +134 -0
- package/plugins/smart-react/skills/react-components-date-edit/SKILL.md +186 -0
- package/plugins/smart-react/skills/react-components-date-range/SKILL.md +259 -0
- package/plugins/smart-react/skills/react-components-description-list/SKILL.md +144 -0
- package/plugins/smart-react/skills/react-components-detail/SKILL.md +272 -0
- package/plugins/smart-react/skills/react-components-details/SKILL.md +250 -0
- package/plugins/smart-react/skills/react-components-divider/SKILL.md +128 -0
- package/plugins/smart-react/skills/react-components-drawer/SKILL.md +165 -0
- package/plugins/smart-react/skills/react-components-dropdown/SKILL.md +194 -0
- package/plugins/smart-react/skills/react-components-empty-state/SKILL.md +202 -0
- package/plugins/smart-react/skills/react-components-export/SKILL.md +120 -0
- package/plugins/smart-react/skills/react-components-feed/SKILL.md +171 -0
- package/plugins/smart-react/skills/react-components-form/SKILL.md +319 -0
- package/plugins/smart-react/skills/react-components-grid-list/SKILL.md +172 -0
- package/plugins/smart-react/skills/react-components-icon/SKILL.md +117 -0
- package/plugins/smart-react/skills/react-components-import/SKILL.md +113 -0
- package/plugins/smart-react/skills/react-components-info/SKILL.md +147 -0
- package/plugins/smart-react/skills/react-components-input/SKILL.md +406 -0
- package/plugins/smart-react/skills/react-components-list/SKILL.md +384 -0
- package/plugins/smart-react/skills/react-components-list-container/SKILL.md +105 -0
- package/plugins/smart-react/skills/react-components-loader/SKILL.md +126 -0
- package/plugins/smart-react/skills/react-components-media-object/SKILL.md +130 -0
- package/plugins/smart-react/skills/react-components-modal/SKILL.md +266 -0
- package/plugins/smart-react/skills/react-components-multi-column-layout/SKILL.md +155 -0
- package/plugins/smart-react/skills/react-components-navbar/SKILL.md +211 -0
- package/plugins/smart-react/skills/react-components-notification/SKILL.md +223 -0
- package/plugins/smart-react/skills/react-components-overlays/SKILL.md +182 -0
- package/plugins/smart-react/skills/react-components-page/SKILL.md +224 -0
- package/plugins/smart-react/skills/react-components-page-heading/SKILL.md +155 -0
- package/plugins/smart-react/skills/react-components-paging/SKILL.md +183 -0
- package/plugins/smart-react/skills/react-components-password-strength/SKILL.md +149 -0
- package/plugins/smart-react/skills/react-components-progress-bars/SKILL.md +195 -0
- package/plugins/smart-react/skills/react-components-searchbar/SKILL.md +150 -0
- package/plugins/smart-react/skills/react-components-section-heading/SKILL.md +138 -0
- package/plugins/smart-react/skills/react-components-select-menu/SKILL.md +168 -0
- package/plugins/smart-react/skills/react-components-sidebar-layout/SKILL.md +155 -0
- package/plugins/smart-react/skills/react-components-sidebar-navigation/SKILL.md +277 -0
- package/plugins/smart-react/skills/react-components-sign-in-form/SKILL.md +228 -0
- package/plugins/smart-react/skills/react-components-stacked-layout/SKILL.md +146 -0
- package/plugins/smart-react/skills/react-components-stacked-list/SKILL.md +156 -0
- package/plugins/smart-react/skills/react-components-stats/SKILL.md +149 -0
- package/plugins/smart-react/skills/react-components-table/SKILL.md +222 -0
- package/plugins/smart-react/skills/react-components-tabs/SKILL.md +189 -0
- package/plugins/smart-react/skills/react-components-textarea/SKILL.md +202 -0
- package/plugins/smart-react/skills/react-components-toggle/SKILL.md +157 -0
- package/plugins/smart-react/skills/react-components-vertical-navigation/SKILL.md +212 -0
- package/plugins/smart-react/skills/react-forms/SKILL.md +272 -0
- package/plugins/smart-react/skills/react-provider/SKILL.md +368 -0
- package/plugins/smart-react/skills/smart-crud-react/SKILL.md +410 -0
- package/plugins/smart/.claude-plugin/plugin.json +0 -5
- /package/plugins/{smart/agents/angular-components/AGENT.md → smart-angular/agents/angular-components.md} +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-accordion/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-action-panel/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-alert/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-avatar/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-badge/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-breadcrumbs/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-button/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-button-group/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-calendar/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-card/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-card-heading/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-command-palette/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-container/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-date-edit/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-date-range/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-description-list/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-detail/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-details/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-divider/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-drawer/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-dropdown/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-empty-state/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-feed/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-form/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-grid-list/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-icon/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-info/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-input/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-list/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-list-container/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-media-object/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-modal/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-multi-column-layout/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-navbar/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-notification/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-page/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-page-heading/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-paging/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-password-strength/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-progress-bars/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-searchbar/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-section-heading/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-select-menu/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-sidebar-layout/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-sidebar-navigation/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-sign-in-form/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-stacked-layout/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-stacked-list/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-stats/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-table/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-tabs/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-textarea/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-toggle/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-vertical-navigation/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/base-app.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/base-shared-lib.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/version-resolution.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/scripts/derive-prefix.sh +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/scripts/verify-scaffold.sh +0 -0
- /package/plugins/{smart → smart-angular}/skills/smart-crud/SKILL.md +0 -0
- /package/plugins/{smart → smart-core}/hooks/CONFIG.md +0 -0
- /package/plugins/{smart → smart-core}/hooks/audit_logger.py +0 -0
- /package/plugins/{smart → smart-core}/hooks/auto_format.sh +0 -0
- /package/plugins/{smart → smart-core}/hooks/hooks.json +0 -0
- /package/plugins/{smart → smart-core}/hooks/safety_validator.py +0 -0
- /package/plugins/{smart → smart-core}/hooks/sensitive_file_blocker.py +0 -0
- /package/plugins/{smart → smart-core}/hooks/skill_validator.py +0 -0
- /package/plugins/{smart → smart-core}/skills/project-conventions/SKILL.md +0 -0
- /package/plugins/{smart → smart-core}/skills/safety-check/SKILL.md +0 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-components-calendar
|
|
3
|
+
description: SmartCalendar React component API (@smartsoft001/react) — month calendar with day selection (controlled value/onValueChange or uncontrolled defaultValue), events per day, dayCellTpl render function, toolbar navigation, the 'calendar' registry key, SmartCalendarPreset and useCalendar.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Calendar (`SmartCalendar`)
|
|
8
|
+
|
|
9
|
+
`SmartCalendar` renders a month grid (6 x 7 days) with a toolbar to move between periods, lets the user select a day, and marks the days that have `events`. The selection is controlled (`value` + `onValueChange`) or kept inside (`defaultValue`). `options.dayCellTpl` is a **render function** called for every day with `{ cell, events }`. `SmartCalendarStandard` is barebones native HTML; `SmartCalendarPreset` is a styled single date picker.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- Picking a single day from a month view
|
|
14
|
+
- Showing which days have events and rendering custom day cells (`options.dayCellTpl`)
|
|
15
|
+
- Starting the calendar on a given month (`referenceDate`)
|
|
16
|
+
- Restyling every calendar (the `calendar` registry key) or building one on `useCalendar`
|
|
17
|
+
|
|
18
|
+
## Exports
|
|
19
|
+
|
|
20
|
+
All from `@smartsoft001/react`.
|
|
21
|
+
|
|
22
|
+
| Export | Kind | What it is |
|
|
23
|
+
| ----------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
24
|
+
| `SmartCalendar` | component | Renders the implementation registered as `components.calendar` on `SmartProvider`, `SmartCalendarStandard` by default. |
|
|
25
|
+
| `SmartCalendarPreset` | component | Styled calendar variation (preset) — a single date picker. |
|
|
26
|
+
| `SmartCalendarStandard` | component | Barebones native-HTML month calendar. |
|
|
27
|
+
| `useCalendar` | hook | The behaviour every calendar variant shares: the options with their defaults (month view, Monday week start, toolbar shown), the selected day (`value`, controlled or uncontrolled), the navigated reference date with its 6 x 7 `monthGrid`, the events of a day and the day's accessible name. |
|
|
28
|
+
| `buildMonthGrid` | function | The 6 x 7 day grid of the month of `reference`, starting on `weekStart` (0 = Sunday, 1 = Monday), with the leading / trailing days of the neighbouring months. |
|
|
29
|
+
|
|
30
|
+
The preset's class helpers (`getCalendarPresetDayClasses`, `CALENDAR_PRESET_CONTAINER`, `CALENDAR_PRESET_INNER`, `CALENDAR_PRESET_HEADER`, `CALENDAR_PRESET_NAV_BUTTON`, `CALENDAR_PRESET_MONTH_LABEL`, `CALENDAR_PRESET_WEEK_ROW`, `CALENDAR_PRESET_DAY_ROW`, `CALENDAR_PRESET_WEEKDAY`, `CALENDAR_PRESET_EVENT_DOT`) are exported too, for a custom implementation that wants the preset look.
|
|
31
|
+
|
|
32
|
+
## Props and Types
|
|
33
|
+
|
|
34
|
+
### `SmartCalendarProps`
|
|
35
|
+
|
|
36
|
+
| Prop | Type | Default | Description |
|
|
37
|
+
| ---------------- | ------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
38
|
+
| `options?` | `SmartCalendarOptions` | — | View, week start, toolbar and the custom templates. |
|
|
39
|
+
| `className?` | `string` | — | Classes on the root element. |
|
|
40
|
+
| `value?` | `Date \| null` | — | The selected day. Controlled when defined (`null` = nothing selected); leave it `undefined` to let the calendar keep the selection itself, starting from `defaultValue`. |
|
|
41
|
+
| `defaultValue?` | `Date \| null` | `null` | The initial selection of an uncontrolled calendar. |
|
|
42
|
+
| `onValueChange?` | `(value: Date \| null) => void` | — | Called with the day the user selects. |
|
|
43
|
+
| `referenceDate?` | `Date` | `today` | The day whose month is shown first; the calendar navigates from there and jumps back to it whenever it changes. Today when omitted. |
|
|
44
|
+
| `events?` | `ICalendarEvent[]` | `[]` | Events to mark; a day lists the events whose `start` falls on it. |
|
|
45
|
+
|
|
46
|
+
### `SmartCalendarOptions`
|
|
47
|
+
|
|
48
|
+
`ICalendarOptions` with `dayCellTpl` as a render function, called for every day with `SmartCalendarDayCellContext`. `toolbarActionsTpl` has no context, so it stays a `ReactNode`. `eventListTpl`, `sidePanelTpl`, `eventTpl` and `monthsCount` are accepted, but no variant renders them. Extends `Omit< ICalendarOptions`, `'dayCellTpl' >`.
|
|
49
|
+
|
|
50
|
+
| Field | Type | Default | Description |
|
|
51
|
+
| ------------- | ----------------------------------------------------- | ------- | -------------------------------------- |
|
|
52
|
+
| `dayCellTpl?` | `(context: SmartCalendarDayCellContext) => ReactNode` | — | Renders the content of every day cell. |
|
|
53
|
+
|
|
54
|
+
### `ICalendarOptions`
|
|
55
|
+
|
|
56
|
+
The base options; `SmartCalendarOptions` replaces its `dayCellTpl` with a render function.
|
|
57
|
+
|
|
58
|
+
| Field | Type | Default | Description |
|
|
59
|
+
| -------------------- | ------------------- | --------- | ----------------------------------------------------------------------------------------- |
|
|
60
|
+
| `view?` | `SmartCalendarView` | `'month'` | The period Prev / Next move by (month, week, day, year). The grid is always a month grid. |
|
|
61
|
+
| `monthsCount?` | `1 \| 2 \| 12` | — | Accepted, not rendered by any variant. |
|
|
62
|
+
| `weekStart?` | `0 \| 1` | `1` | `1` Monday, `0` Sunday. |
|
|
63
|
+
| `showToolbar?` | `boolean` | `true` | Shows the Prev / Today / Next toolbar. |
|
|
64
|
+
| `toolbarActionsTpl?` | `ReactNode` | — | Extra content in the toolbar of the standard calendar (the preset does not render it). |
|
|
65
|
+
| `eventListTpl?` | `ReactNode` | — | Accepted, not rendered by any variant. |
|
|
66
|
+
| `sidePanelTpl?` | `ReactNode` | — | Accepted, not rendered by any variant. |
|
|
67
|
+
| `dayCellTpl?` | `ReactNode` | — | Overridden by `SmartCalendarOptions.dayCellTpl` (a render function). |
|
|
68
|
+
| `eventTpl?` | `ReactNode` | — | Accepted, not rendered by any variant. |
|
|
69
|
+
|
|
70
|
+
### `SmartCalendarDayCellContext`
|
|
71
|
+
|
|
72
|
+
The context `dayCellTpl` renders with: the day `cell` and its `events`.
|
|
73
|
+
|
|
74
|
+
| Field | Type | Default | Description |
|
|
75
|
+
| -------- | ------------------ | -------- | --------------------------------------------------------------- |
|
|
76
|
+
| `cell` | `ICalendarDayCell` | required | The day: `date`, `isCurrentMonth`, `isToday`, `isSelected`. |
|
|
77
|
+
| `events` | `ICalendarEvent[]` | required | The events starting on `cell.date` (`eventsForDay(cell.date)`). |
|
|
78
|
+
|
|
79
|
+
### `ICalendarDayCell`
|
|
80
|
+
|
|
81
|
+
One day of the month grid.
|
|
82
|
+
|
|
83
|
+
| Field | Type | Default | Description |
|
|
84
|
+
| ---------------- | --------- | -------- | ------------------------------------------------------------------- |
|
|
85
|
+
| `date` | `Date` | required | The day. |
|
|
86
|
+
| `isCurrentMonth` | `boolean` | required | `false` for the leading / trailing days of the neighbouring months. |
|
|
87
|
+
| `isToday` | `boolean` | required | The day is today. |
|
|
88
|
+
| `isSelected` | `boolean` | required | The day is the selected `value`. |
|
|
89
|
+
|
|
90
|
+
### `ICalendarEvent`
|
|
91
|
+
|
|
92
|
+
An event shown on the day of its `start`.
|
|
93
|
+
|
|
94
|
+
| Field | Type | Default | Description |
|
|
95
|
+
| -------- | ------------------------- | -------- | ---------------------------------------------- |
|
|
96
|
+
| `id` | `string \| number` | required | Identifies the event. |
|
|
97
|
+
| `start` | `Date` | required | Start; decides the day the event is listed on. |
|
|
98
|
+
| `end?` | `Date` | — | End (informational). |
|
|
99
|
+
| `title?` | `string` | — | Title, used in the day's accessible name. |
|
|
100
|
+
| `meta?` | `Record<string, unknown>` | — | Free data for your `dayCellTpl`. |
|
|
101
|
+
|
|
102
|
+
### Related types
|
|
103
|
+
|
|
104
|
+
- `SmartCalendarView`: `'month' \| 'week' \| 'day' \| 'year'`
|
|
105
|
+
|
|
106
|
+
## Behaviour
|
|
107
|
+
|
|
108
|
+
- `SmartCalendar` replaces a missing `referenceDate` with the date it was mounted, so a registered implementation always gets one. When `referenceDate` changes to another day, the calendar jumps back to it.
|
|
109
|
+
- The toolbar labels (Prev / Today / Next) of the standard calendar and the English month and weekday names of the preset are not translated.
|
|
110
|
+
- `SmartCalendarPreset` disables days outside the shown month; the standard grid marks days with events with `data-events="<count>"`.
|
|
111
|
+
|
|
112
|
+
## Usage
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
import { useState } from 'react';
|
|
116
|
+
|
|
117
|
+
import {
|
|
118
|
+
ICalendarEvent,
|
|
119
|
+
SmartCalendar,
|
|
120
|
+
SmartCalendarPreset,
|
|
121
|
+
} from '@smartsoft001/react';
|
|
122
|
+
|
|
123
|
+
const events: ICalendarEvent[] = [
|
|
124
|
+
{ id: 1, start: new Date(2026, 9, 12, 10), title: 'Sprint review' },
|
|
125
|
+
{ id: 2, start: new Date(2026, 9, 12, 14), title: 'Retro' },
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
export function MeetingCalendar() {
|
|
129
|
+
const [day, setDay] = useState<Date | null>(null);
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<>
|
|
133
|
+
<SmartCalendar
|
|
134
|
+
value={day}
|
|
135
|
+
onValueChange={setDay}
|
|
136
|
+
events={events}
|
|
137
|
+
referenceDate={new Date(2026, 9, 1)}
|
|
138
|
+
options={{
|
|
139
|
+
weekStart: 1,
|
|
140
|
+
dayCellTpl: ({ cell, events: dayEvents }) => (
|
|
141
|
+
<span>
|
|
142
|
+
{cell.date.getDate()}
|
|
143
|
+
{dayEvents.length > 0 && <small> ({dayEvents.length})</small>}
|
|
144
|
+
</span>
|
|
145
|
+
),
|
|
146
|
+
}}
|
|
147
|
+
/>
|
|
148
|
+
|
|
149
|
+
{/* A styled single date picker, uncontrolled. */}
|
|
150
|
+
<SmartCalendarPreset
|
|
151
|
+
defaultValue={new Date()}
|
|
152
|
+
onValueChange={(value) => console.log(value)}
|
|
153
|
+
/>
|
|
154
|
+
</>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Replacing the Implementation
|
|
160
|
+
|
|
161
|
+
`SmartCalendar` renders the component registered under the `'calendar'` key of `SmartProvider`'s `components`, and `SmartCalendarStandard` when nothing is registered there. Every `SmartCalendar` below the provider then renders the registered component, which receives the same props.
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
import type { ReactNode } from 'react';
|
|
165
|
+
|
|
166
|
+
import { SmartProvider, SmartCalendarPreset } from '@smartsoft001/react';
|
|
167
|
+
|
|
168
|
+
// A module constant: a new object on every render would change the context.
|
|
169
|
+
const components = { calendar: SmartCalendarPreset };
|
|
170
|
+
|
|
171
|
+
export function AppProviders({ children }: { children: ReactNode }) {
|
|
172
|
+
return <SmartProvider components={components}>{children}</SmartProvider>;
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
`SmartCalendarPreset` is the styled (preset) implementation: register it as above, render it directly in place of `SmartCalendar`, or spread `SMART_PRESET_COMPONENTS` on the provider to register every preset at once (see the `react-provider` skill). Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
177
|
+
|
|
178
|
+
### The `useCalendar` hook
|
|
179
|
+
|
|
180
|
+
The behaviour every calendar variant shares: the options with their defaults (month view, Monday week start, toolbar shown), the selected day (`value`, controlled or uncontrolled), the navigated reference date with its 6 x 7 `monthGrid`, the events of a day and the day's accessible name. The reference starts at `referenceDate` (today when omitted), moves with `prevPeriod` / `nextPeriod` / `goToToday`, and jumps back to `referenceDate` whenever that prop changes to another point in time.
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
function useCalendar({
|
|
184
|
+
options,
|
|
185
|
+
value: valueProp,
|
|
186
|
+
defaultValue = null,
|
|
187
|
+
onValueChange,
|
|
188
|
+
referenceDate,
|
|
189
|
+
events = NO_EVENTS,
|
|
190
|
+
}: SmartCalendarProps);
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
| Returns | Type | Description |
|
|
194
|
+
| -------------- | --------------------------------- | --------------------------------------------------------- |
|
|
195
|
+
| `view` | `SmartCalendarView` | `options.view ?? 'month'`. |
|
|
196
|
+
| `weekStart` | `0 \| 1` | `options.weekStart ?? 1`. |
|
|
197
|
+
| `showToolbar` | `boolean` | `options.showToolbar ?? true`. |
|
|
198
|
+
| `value` | `Date \| null` | The selected day (controlled or internal). |
|
|
199
|
+
| `reference` | `Date` | The navigated reference date (the shown month). |
|
|
200
|
+
| `monthGrid` | `ICalendarDayCell[][]` | The 6 x 7 grid of the reference month (`buildMonthGrid`). |
|
|
201
|
+
| `eventsForDay` | `(day: Date) => ICalendarEvent[]` | The events starting on a day. |
|
|
202
|
+
| `dayAriaLabel` | `(day: Date) => string` | The accessible name of a day (with the event count). |
|
|
203
|
+
| `selectDay` | `(date: Date) => void` | Selects a day and calls `onValueChange`. |
|
|
204
|
+
| `goToToday` | `() => void` | Moves the reference to today. |
|
|
205
|
+
| `prevPeriod` | `() => void` | Moves the reference one `view` period back. |
|
|
206
|
+
| `nextPeriod` | `() => void` | Moves the reference one `view` period forward. |
|
|
207
|
+
|
|
208
|
+
```tsx
|
|
209
|
+
import { SmartCalendarProps, useCalendar } from '@smartsoft001/react';
|
|
210
|
+
|
|
211
|
+
export function CompactCalendar(props: SmartCalendarProps) {
|
|
212
|
+
const {
|
|
213
|
+
monthGrid,
|
|
214
|
+
reference,
|
|
215
|
+
selectDay,
|
|
216
|
+
prevPeriod,
|
|
217
|
+
nextPeriod,
|
|
218
|
+
dayAriaLabel,
|
|
219
|
+
} = useCalendar(props);
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<div className={props.className}>
|
|
223
|
+
<button type="button" onClick={prevPeriod}>
|
|
224
|
+
‹
|
|
225
|
+
</button>
|
|
226
|
+
<span>
|
|
227
|
+
{reference.toLocaleDateString(undefined, {
|
|
228
|
+
month: 'long',
|
|
229
|
+
year: 'numeric',
|
|
230
|
+
})}
|
|
231
|
+
</span>
|
|
232
|
+
<button type="button" onClick={nextPeriod}>
|
|
233
|
+
›
|
|
234
|
+
</button>
|
|
235
|
+
{monthGrid.map((week, index) => (
|
|
236
|
+
<div key={index}>
|
|
237
|
+
{week.map((cell) => (
|
|
238
|
+
<button
|
|
239
|
+
key={cell.date.toISOString()}
|
|
240
|
+
type="button"
|
|
241
|
+
aria-label={dayAriaLabel(cell.date)}
|
|
242
|
+
aria-pressed={cell.isSelected}
|
|
243
|
+
disabled={!cell.isCurrentMonth}
|
|
244
|
+
onClick={() => selectDay(cell.date)}
|
|
245
|
+
>
|
|
246
|
+
{cell.date.getDate()}
|
|
247
|
+
</button>
|
|
248
|
+
))}
|
|
249
|
+
</div>
|
|
250
|
+
))}
|
|
251
|
+
</div>
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Styling
|
|
257
|
+
|
|
258
|
+
- `SmartCalendarStandard` is unstyled native HTML (`.calendar`, `data-view`, `data-events`); `SmartCalendarPreset` carries the date-picker look with `smart:dark:` variants.
|
|
259
|
+
- `className` is appended to the root element.
|
|
260
|
+
|
|
261
|
+
## File Locations
|
|
262
|
+
|
|
263
|
+
Source: `packages/shared/react/src/lib/components/calendar/` in the smartsoft001 repository.
|
|
264
|
+
|
|
265
|
+
- `calendar.tsx`: `SmartCalendar`
|
|
266
|
+
- `calendar.types.ts`: `SmartCalendarDayCellContext`, `SmartCalendarOptions`, `SmartCalendarProps`
|
|
267
|
+
- `preset/calendar-preset.tsx`: `SmartCalendarPreset`
|
|
268
|
+
- `standard/calendar-standard.tsx`: `SmartCalendarStandard`
|
|
269
|
+
- `use-calendar.ts`: `useCalendar`, `buildMonthGrid`
|
|
270
|
+
- `calendar.stories.tsx`: Storybook stories
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-components-card
|
|
3
|
+
description: SmartCard React component API (@smartsoft001/react) — panel with header, body and footer slots (header/footer/children), title, gray body/footer, the 'card' registry key with SmartCardVariantProps, SmartCardPreset and useCard.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Card (`SmartCard`)
|
|
8
|
+
|
|
9
|
+
`SmartCard` is a panel with three sections: an optional header (`header`, plus `options.title`), the body (`children`) and an optional footer (`footer`). A section is rendered when its content is given, unless `hasHeader` / `hasFooter` force it. The wrapper hands the slots to the registered implementation as `headerTpl` / `bodyTpl` / `footerTpl` (`SmartCardVariantProps`), so a custom card receives nodes, not `children`.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- Grouping content in a bordered/raised panel with a title and actions
|
|
14
|
+
- Putting actions in the header or footer (`header`, `footer` nodes)
|
|
15
|
+
- Restyling every card (the `card` registry key; implementations take `SmartCardVariantProps`)
|
|
16
|
+
|
|
17
|
+
## Exports
|
|
18
|
+
|
|
19
|
+
All from `@smartsoft001/react`.
|
|
20
|
+
|
|
21
|
+
| Export | Kind | What it is |
|
|
22
|
+
| -------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
23
|
+
| `SmartCard` | component | Renders the implementation registered as `components.card` on `SmartProvider`, `SmartCardStandard` by default. |
|
|
24
|
+
| `SmartCardPreset` | component | Styled card variation (preset). |
|
|
25
|
+
| `SmartCardStandard` | component | The default card rendering: a white panel with an optional header (with `options.title`), the body and an optional footer. |
|
|
26
|
+
| `useCard` | hook | The behaviour every card variant shares: which sections are shown, and the classes of the container and the header, body and footer sections. |
|
|
27
|
+
| `isCardSectionShown` | function | Whether a card section is rendered: `flag` when set, otherwise whether `content` renders anything (`null`, `undefined`, booleans and `''` do not). |
|
|
28
|
+
|
|
29
|
+
The preset's class helpers (`getCardContainerClasses`, `getCardHeaderClasses`, `getCardBodyClasses`, `getCardFooterClasses`) are exported too, for a custom implementation that wants the preset look.
|
|
30
|
+
|
|
31
|
+
## Props and Types
|
|
32
|
+
|
|
33
|
+
### `SmartCardProps`
|
|
34
|
+
|
|
35
|
+
Props of `<SmartCard>`.
|
|
36
|
+
|
|
37
|
+
| Prop | Type | Default | Description |
|
|
38
|
+
| ------------ | -------------- | ------- | --------------------------------------------------------------- |
|
|
39
|
+
| `options?` | `ICardOptions` | — | Title and the gray body / footer flags. |
|
|
40
|
+
| `hasHeader?` | `boolean` | — | Renders the header section; by default, when `header` is given. |
|
|
41
|
+
| `hasFooter?` | `boolean` | — | Renders the footer section; by default, when `footer` is given. |
|
|
42
|
+
| `className?` | `string` | — | Classes on the card container. |
|
|
43
|
+
| `header?` | `ReactNode` | — | The header content. |
|
|
44
|
+
| `footer?` | `ReactNode` | — | The footer content. |
|
|
45
|
+
| `children?` | `ReactNode` | — | The body content. |
|
|
46
|
+
|
|
47
|
+
### `SmartCardVariantProps`
|
|
48
|
+
|
|
49
|
+
Props of a card implementation (`SmartCardStandard`, `SmartCardPreset` or one registered as `components.card`): the wrapper passes `header` / `children` / `footer` as `headerTpl` / `bodyTpl` / `footerTpl`.
|
|
50
|
+
|
|
51
|
+
| Prop | Type | Default | Description |
|
|
52
|
+
| ------------ | -------------- | ------- | ------------------------------------------------------------------ |
|
|
53
|
+
| `options?` | `ICardOptions` | — | Title and the gray body / footer flags. |
|
|
54
|
+
| `hasHeader?` | `boolean` | — | Renders the header section; by default, when `headerTpl` is given. |
|
|
55
|
+
| `hasFooter?` | `boolean` | — | Renders the footer section; by default, when `footerTpl` is given. |
|
|
56
|
+
| `className?` | `string` | — | Classes on the card container. |
|
|
57
|
+
| `headerTpl?` | `ReactNode` | — | The header content (`SmartCard`'s `header`). |
|
|
58
|
+
| `bodyTpl?` | `ReactNode` | — | The body content (`SmartCard`'s `children`). |
|
|
59
|
+
| `footerTpl?` | `ReactNode` | — | The footer content (`SmartCard`'s `footer`). |
|
|
60
|
+
|
|
61
|
+
### `ICardOptions`
|
|
62
|
+
|
|
63
|
+
| Field | Type | Default | Description |
|
|
64
|
+
| ------------- | --------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
65
|
+
| `title?` | `string` | — | Rendered in the header (the header is shown for it when `hasHeader` is set). |
|
|
66
|
+
| `buttons?` | `Array<IIconButtonOptions>` | — | @deprecated Has never been rendered by any card variant (standard or preset). Put actions in the header or footer instead: pass them as the `header` / `footer` of `SmartCard`, which reach the variant as `headerTpl` / `footerTpl`. |
|
|
67
|
+
| `grayFooter?` | `boolean` | — | Gray background on the footer. |
|
|
68
|
+
| `grayBody?` | `boolean` | — | Gray background on the body. |
|
|
69
|
+
|
|
70
|
+
### `IIconButtonOptions`
|
|
71
|
+
|
|
72
|
+
An icon button description (used by `ICardOptions.buttons`, deprecated here, and by page buttons).
|
|
73
|
+
|
|
74
|
+
| Field | Type | Default | Description |
|
|
75
|
+
| ------------ | ------------------------ | -------- | ----------------------------------------------------------------------------------------------- |
|
|
76
|
+
| `icon` | `string` | required | Identifier of the button (page renderings use it as the React key; it is not drawn as an icon). |
|
|
77
|
+
| `text?` | `string` | — | Label. |
|
|
78
|
+
| `handler?` | `() => void` | — | Click handler. |
|
|
79
|
+
| `component?` | `any` | — | Carried for implementations of your own; the library's renderings do not read it. |
|
|
80
|
+
| `type?` | `'default' \| 'popover'` | — | Carried for implementations of your own; the library's renderings do not read it. |
|
|
81
|
+
| `disabled?` | `boolean` | — | Disables the button. |
|
|
82
|
+
| `number?` | `number` | — | A count badge on the button. |
|
|
83
|
+
|
|
84
|
+
## Sections
|
|
85
|
+
|
|
86
|
+
- The header is rendered when `header` is given, or when `hasHeader` is `true` (for example to show only `options.title`).
|
|
87
|
+
- The footer is rendered when `footer` is given, or when `hasFooter` is `true`.
|
|
88
|
+
- `hasHeader={false}` / `hasFooter={false}` hide a section even when content is given. `isCardSectionShown(flag, content)` is the rule (`null`, `undefined`, booleans and `''` count as no content).
|
|
89
|
+
- `options.buttons` is deprecated and never rendered: put actions into `header` or `footer`.
|
|
90
|
+
|
|
91
|
+
## Usage
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import { SmartButton, SmartCard, SmartCardPreset } from '@smartsoft001/react';
|
|
95
|
+
|
|
96
|
+
export function ProfileCard({ onEdit }: { onEdit: () => void }) {
|
|
97
|
+
return (
|
|
98
|
+
<div className="grid gap-6 md:grid-cols-2">
|
|
99
|
+
<SmartCard
|
|
100
|
+
options={{ title: 'Profile', grayFooter: true }}
|
|
101
|
+
hasHeader
|
|
102
|
+
footer={
|
|
103
|
+
<SmartButton options={{ click: onEdit, size: 'sm' }}>
|
|
104
|
+
Edit
|
|
105
|
+
</SmartButton>
|
|
106
|
+
}
|
|
107
|
+
>
|
|
108
|
+
<p>Anna Kowalska, product designer.</p>
|
|
109
|
+
</SmartCard>
|
|
110
|
+
|
|
111
|
+
{/* The preset takes the variant props: headerTpl / bodyTpl / footerTpl. */}
|
|
112
|
+
<SmartCardPreset
|
|
113
|
+
options={{ title: 'Usage' }}
|
|
114
|
+
hasHeader
|
|
115
|
+
bodyTpl={<p>12 of 20 seats used.</p>}
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Replacing the Implementation
|
|
123
|
+
|
|
124
|
+
`SmartCard` renders the component registered under the `'card'` key of `SmartProvider`'s `components`, and `SmartCardStandard` when nothing is registered there. Every `SmartCard` below the provider then renders the registered component, which receives the same props.
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
import type { ReactNode } from 'react';
|
|
128
|
+
|
|
129
|
+
import { SmartProvider, SmartCardPreset } from '@smartsoft001/react';
|
|
130
|
+
|
|
131
|
+
// A module constant: a new object on every render would change the context.
|
|
132
|
+
const components = { card: SmartCardPreset };
|
|
133
|
+
|
|
134
|
+
export function AppProviders({ children }: { children: ReactNode }) {
|
|
135
|
+
return <SmartProvider components={components}>{children}</SmartProvider>;
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`SmartCardPreset` is the styled (preset) implementation: register it as above, render it directly in place of `SmartCard`, or spread `SMART_PRESET_COMPONENTS` on the provider to register every preset at once (see the `react-provider` skill). Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
140
|
+
|
|
141
|
+
### The `useCard` hook
|
|
142
|
+
|
|
143
|
+
The behaviour every card variant shares: which sections are shown, and the classes of the container and the header, body and footer sections.
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
function useCard({
|
|
147
|
+
options,
|
|
148
|
+
hasHeader,
|
|
149
|
+
hasFooter,
|
|
150
|
+
headerTpl,
|
|
151
|
+
footerTpl,
|
|
152
|
+
}: SmartCardVariantProps);
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
| Returns | Type | Description |
|
|
156
|
+
| ------------------------ | ---------- | --------------------------------------------------------------- |
|
|
157
|
+
| `showHeader` | `boolean` | Whether the header section is rendered. |
|
|
158
|
+
| `showFooter` | `boolean` | Whether the footer section is rendered. |
|
|
159
|
+
| `sharedContainerClasses` | `string[]` | Classes of the card container. |
|
|
160
|
+
| `headerClasses` | `string` | Classes of the header section. |
|
|
161
|
+
| `bodyClasses` | `string` | Classes of the body section (gray with `options.grayBody`). |
|
|
162
|
+
| `footerClasses` | `string` | Classes of the footer section (gray with `options.grayFooter`). |
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
import { SmartCardVariantProps, useCard } from '@smartsoft001/react';
|
|
166
|
+
|
|
167
|
+
export function FlatCard(props: SmartCardVariantProps) {
|
|
168
|
+
const { showHeader, showFooter } = useCard(props);
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<article className={props.className}>
|
|
172
|
+
{showHeader && (
|
|
173
|
+
<header>
|
|
174
|
+
{props.options?.title && <h3>{props.options.title}</h3>}
|
|
175
|
+
{props.headerTpl}
|
|
176
|
+
</header>
|
|
177
|
+
)}
|
|
178
|
+
<div>{props.bodyTpl}</div>
|
|
179
|
+
{showFooter && <footer>{props.footerTpl}</footer>}
|
|
180
|
+
</article>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Register it as `components={{ card: FlatCard }}`: `SmartCard` keeps taking `header` / `children` / `footer` and passes them on as `headerTpl` / `bodyTpl` / `footerTpl`.
|
|
186
|
+
|
|
187
|
+
## Styling
|
|
188
|
+
|
|
189
|
+
- `SmartCardStandard` is a white panel with dark-mode variants; `SmartCardPreset` adds the rounded `shadow-2xs` surface with bordered header and footer.
|
|
190
|
+
- `className` is appended to the container.
|
|
191
|
+
|
|
192
|
+
## File Locations
|
|
193
|
+
|
|
194
|
+
Source: `packages/shared/react/src/lib/components/card/` in the smartsoft001 repository.
|
|
195
|
+
|
|
196
|
+
- `card.tsx`: `SmartCard`
|
|
197
|
+
- `card.types.ts`: `SmartCardProps`, `SmartCardVariantProps`
|
|
198
|
+
- `preset/card-preset.tsx`: `SmartCardPreset`
|
|
199
|
+
- `standard/card-standard.tsx`: `SmartCardStandard`
|
|
200
|
+
- `use-card.ts`: `isCardSectionShown`, `useCard`
|
|
201
|
+
- `card.stories.tsx`: Storybook stories
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-components-card-heading
|
|
3
|
+
description: SmartCardHeading React component API (@smartsoft001/react) — card header block with title, description, avatar, meta and actions slots and author/stacked/overlay/outline presentations, the 'card-heading' registry key and SmartCardHeadingPreset.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Card Heading (`SmartCardHeading`)
|
|
8
|
+
|
|
9
|
+
`SmartCardHeading` renders the heading block of a card: a title and description, plus `ReactNode` slots for an avatar, meta information and actions, each rendered only when given. `SmartCardHeadingStandard` is unstyled and ignores `options.presentation`; `SmartCardHeadingPreset` renders one of four looks chosen by `options.presentation.variant` (`author`, the default, `stacked`, `overlay`, `outline`).
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- The top of a card or article teaser: author avatar, title, description, meta (date, read time) and actions
|
|
14
|
+
- Choosing a card-heading presentation (`author`, `stacked`, `overlay`, `outline`) through the preset
|
|
15
|
+
- Restyling every card heading (the `card-heading` registry key)
|
|
16
|
+
|
|
17
|
+
## Exports
|
|
18
|
+
|
|
19
|
+
All from `@smartsoft001/react`.
|
|
20
|
+
|
|
21
|
+
| Export | Kind | What it is |
|
|
22
|
+
| -------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
23
|
+
| `SmartCardHeading` | component | Renders the implementation registered as `components['card-heading']` on `SmartProvider`, `SmartCardHeadingStandard` by default. |
|
|
24
|
+
| `SmartCardHeadingPreset` | component | HyperUI-styled card heading variation (preset). |
|
|
25
|
+
| `SmartCardHeadingStandard` | component | The default card heading rendering: the avatar, the title, description and meta, and the actions of `options`, each only when given. |
|
|
26
|
+
|
|
27
|
+
The preset's class helpers (`getCardHeadingContainerClasses`) are exported too, for a custom implementation that wants the preset look.
|
|
28
|
+
|
|
29
|
+
## Props and Types
|
|
30
|
+
|
|
31
|
+
### `SmartCardHeadingProps`
|
|
32
|
+
|
|
33
|
+
| Prop | Type | Default | Description |
|
|
34
|
+
| ------------ | --------------------- | ------- | --------------------------------------- |
|
|
35
|
+
| `options?` | `ICardHeadingOptions` | — | The content slots and the presentation. |
|
|
36
|
+
| `className?` | `string` | — | Classes on the root element. |
|
|
37
|
+
|
|
38
|
+
### `ICardHeadingOptions`
|
|
39
|
+
|
|
40
|
+
| Field | Type | Default | Description |
|
|
41
|
+
| --------------- | ---------------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------- |
|
|
42
|
+
| `title?` | `string` | — | The heading text. |
|
|
43
|
+
| `description?` | `string` | — | Text under the title. |
|
|
44
|
+
| `avatarTpl?` | `ReactNode` | — | An avatar or image node. |
|
|
45
|
+
| `actionsTpl?` | `ReactNode` | — | Buttons or a menu. |
|
|
46
|
+
| `metaTpl?` | `ReactNode` | — | Meta information (date, tags, read time). |
|
|
47
|
+
| `presentation?` | `{ variant?: 'author' \| 'stacked' \| 'overlay' \| 'outline'; }` | — | `variant` picks the preset look (`'author'` by default); ignored by the standard rendering. |
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import {
|
|
53
|
+
SmartAvatarPreset,
|
|
54
|
+
SmartButton,
|
|
55
|
+
SmartCardHeadingPreset,
|
|
56
|
+
} from '@smartsoft001/react';
|
|
57
|
+
|
|
58
|
+
export function ArticleHeading({ onFollow }: { onFollow: () => void }) {
|
|
59
|
+
return (
|
|
60
|
+
<SmartCardHeadingPreset
|
|
61
|
+
options={{
|
|
62
|
+
title: 'Designing for dark mode',
|
|
63
|
+
description: 'How we picked colours that work at night.',
|
|
64
|
+
presentation: { variant: 'author' },
|
|
65
|
+
avatarTpl: <SmartAvatarPreset initials="AK" size="sm" />,
|
|
66
|
+
metaTpl: <span>12 Mar 2026 · 6 min read</span>,
|
|
67
|
+
actionsTpl: (
|
|
68
|
+
<SmartButton
|
|
69
|
+
options={{ click: onFollow, size: 'sm', variant: 'secondary' }}
|
|
70
|
+
>
|
|
71
|
+
Follow
|
|
72
|
+
</SmartButton>
|
|
73
|
+
),
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Replacing the Implementation
|
|
81
|
+
|
|
82
|
+
`SmartCardHeading` renders the component registered under the `'card-heading'` key of `SmartProvider`'s `components`, and `SmartCardHeadingStandard` when nothing is registered there. Every `SmartCardHeading` below the provider then renders the registered component, which receives the same props.
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import type { ReactNode } from 'react';
|
|
86
|
+
|
|
87
|
+
import { SmartProvider, SmartCardHeadingPreset } from '@smartsoft001/react';
|
|
88
|
+
|
|
89
|
+
// A module constant: a new object on every render would change the context.
|
|
90
|
+
const components = { 'card-heading': SmartCardHeadingPreset };
|
|
91
|
+
|
|
92
|
+
export function AppProviders({ children }: { children: ReactNode }) {
|
|
93
|
+
return <SmartProvider components={components}>{children}</SmartProvider>;
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`SmartCardHeadingPreset` is the styled (preset) implementation: register it as above, render it directly in place of `SmartCardHeading`, or spread `SMART_PRESET_COMPONENTS` on the provider to register every preset at once (see the `react-provider` skill). Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import { SmartCardHeadingProps } from '@smartsoft001/react';
|
|
101
|
+
|
|
102
|
+
export function SimpleCardHeading({
|
|
103
|
+
options,
|
|
104
|
+
className,
|
|
105
|
+
}: SmartCardHeadingProps) {
|
|
106
|
+
return (
|
|
107
|
+
<div className={className}>
|
|
108
|
+
{options?.avatarTpl}
|
|
109
|
+
<div>
|
|
110
|
+
<h3>{options?.title}</h3>
|
|
111
|
+
{options?.description && <p>{options.description}</p>}
|
|
112
|
+
{options?.metaTpl}
|
|
113
|
+
</div>
|
|
114
|
+
{options?.actionsTpl}
|
|
115
|
+
</div>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Styling
|
|
121
|
+
|
|
122
|
+
- `SmartCardHeadingStandard` is unstyled markup; `SmartCardHeadingPreset` carries the four presentations with `smart:dark:` variants (`overlay` places the text over the avatar image, so give that slot an image).
|
|
123
|
+
- `className` is appended to the root element.
|
|
124
|
+
|
|
125
|
+
## File Locations
|
|
126
|
+
|
|
127
|
+
Source: `packages/shared/react/src/lib/components/card-heading/` in the smartsoft001 repository.
|
|
128
|
+
|
|
129
|
+
- `card-heading.tsx`: `SmartCardHeading`
|
|
130
|
+
- `card-heading.types.ts`: `SmartCardHeadingProps`
|
|
131
|
+
- `preset/card-heading-preset.tsx`: `SmartCardHeadingPreset`
|
|
132
|
+
- `standard/card-heading-standard.tsx`: `SmartCardHeadingStandard`
|
|
133
|
+
- `card-heading.stories.tsx`: Storybook stories
|