@moltenship/calendar 1.0.0-rc.2 → 2.0.0-beta.1
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/README.md +24 -4
- package/dist/index.d.mts +2 -2
- package/docs/accessibility.md +304 -0
- package/docs/agents/changes.md +449 -0
- package/docs/agents/coding-agents.md +117 -0
- package/docs/agents/connect.md +435 -0
- package/docs/agents/deleting.md +296 -0
- package/docs/agents/reference.md +512 -0
- package/docs/agents/server.md +317 -0
- package/docs/agents/webmcp.md +153 -0
- package/docs/agents.md +353 -0
- package/docs/annotations.md +196 -0
- package/docs/api/changes.md +248 -0
- package/docs/api/dnd-kit.md +267 -0
- package/docs/api/events.md +152 -0
- package/docs/api/ics.md +524 -0
- package/docs/api/primitives.md +168 -0
- package/docs/api/react.md +236 -0
- package/docs/api/recurrence.md +586 -0
- package/docs/api/solid.md +460 -0
- package/docs/api/store.md +92 -0
- package/docs/api/temporal.md +172 -0
- package/docs/api.md +57 -0
- package/docs/availability.md +573 -0
- package/docs/comparison.md +279 -0
- package/docs/concepts/anatomy.md +73 -0
- package/docs/concepts/events.md +164 -0
- package/docs/concepts/how-it-works.md +95 -0
- package/docs/concepts/recurrence.md +127 -0
- package/docs/concepts/state.md +244 -0
- package/docs/concepts/time.md +170 -0
- package/docs/guides/dnd-kit.md +333 -0
- package/docs/guides/google-calendar-sync.md +1246 -0
- package/docs/guides/google-calendar.md +367 -0
- package/docs/guides/ics.md +486 -0
- package/docs/guides/motion.md +414 -0
- package/docs/guides/nextjs-app-router.md +630 -0
- package/docs/guides/nextjs.md +149 -0
- package/docs/guides/performance.md +103 -0
- package/docs/guides/recurring-events.md +583 -0
- package/docs/guides/tanstack-query.md +485 -0
- package/docs/index.md +118 -0
- package/docs/installation.md +194 -0
- package/docs/interactions.md +408 -0
- package/docs/llms.txt +86 -0
- package/docs/migrating-to-2.md +322 -0
- package/docs/quick-start.md +159 -0
- package/docs/stylex.md +265 -0
- package/docs/testing.md +581 -0
- package/docs/theme-builder.md +81 -0
- package/docs/theming.md +169 -0
- package/docs/undo-redo.md +339 -0
- package/docs/views/agenda.md +221 -0
- package/docs/views/custom-views.md +192 -0
- package/docs/views/month.md +109 -0
- package/docs/views/resource-columns.md +261 -0
- package/docs/views/resource-timeline.md +225 -0
- package/docs/views/scrolling.md +192 -0
- package/docs/views/week-and-day.md +257 -0
- package/docs/views/year.md +138 -0
- package/docs/views.md +69 -0
- package/package.json +41 -14
- package/skills/moltenship-time/SKILL.md +75 -0
- package/skills/moltenship-time/references/agent-ready.md +272 -0
- package/skills/moltenship-time/references/changes.md +188 -0
- package/skills/moltenship-time/references/compose.md +168 -0
- package/skills/moltenship-time/references/mistakes.md +98 -0
- package/skills/moltenship-time/references/solid.md +202 -0
- package/skills/moltenship-time/references/state.md +129 -0
- package/skills/moltenship-time/references/testing.md +176 -0
package/docs/stylex.md
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# StyleX
|
|
2
|
+
|
|
3
|
+
The calendar's views styled with StyleX and Astryx, for apps without Tailwind.
|
|
4
|
+
|
|
5
|
+
Source: https://time.molten.sh/docs/stylex
|
|
6
|
+
|
|
7
|
+
The registry's baseline is Tailwind and shadcn/ui. If your app styles with
|
|
8
|
+
[StyleX](https://stylexjs.com) and builds on [Astryx](https://astryx.atmeta.com), Meta's design
|
|
9
|
+
system, use the `stylex-*` items instead. They hold the same components with the same behaviour,
|
|
10
|
+
every view included: same file names, exports, `data-slot` attributes, roles and labels. Styles are
|
|
11
|
+
`stylex.create` rather than Tailwind classes, and buttons, tooltips and the like come from Astryx
|
|
12
|
+
rather than shadcn/ui. As with the baseline, you own the source you add.
|
|
13
|
+
|
|
14
|
+
See it running on the demo's [StyleX page](https://moltenship-time-demo.vercel.app/stylex/).
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @stylexjs/stylex @astryxdesign/core @astryxdesign/theme-neutral
|
|
20
|
+
npm install --save-dev @stylexjs/unplugin
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`@moltenship/calendar` comes with the items, as [UI source](./installation.md#ui-source-optional)
|
|
24
|
+
describes, and [Temporal](./installation.md#temporal) needs the same setup as in any app.
|
|
25
|
+
|
|
26
|
+
## Configure Vite
|
|
27
|
+
|
|
28
|
+
```ts title="vite.config.ts"
|
|
29
|
+
import { fileURLToPath } from "node:url";
|
|
30
|
+
|
|
31
|
+
import stylex from "@stylexjs/unplugin";
|
|
32
|
+
import react from "@vitejs/plugin-react";
|
|
33
|
+
import { defineConfig } from "vite";
|
|
34
|
+
|
|
35
|
+
const fromHere = (path: string) => fileURLToPath(new URL(path, import.meta.url));
|
|
36
|
+
|
|
37
|
+
export default defineConfig(({ command }) => ({
|
|
38
|
+
plugins: [
|
|
39
|
+
// Before React.
|
|
40
|
+
stylex.vite({
|
|
41
|
+
aliases: { "@/*": [fromHere("src/*")] },
|
|
42
|
+
dev: command === "serve",
|
|
43
|
+
lightningcssOptions: {
|
|
44
|
+
targets: { chrome: 123 << 16, firefox: 120 << 16, safari: (17 << 16) | (5 << 8) },
|
|
45
|
+
},
|
|
46
|
+
runtimeInjection: false,
|
|
47
|
+
unstable_moduleResolution: { rootDir: fromHere("."), type: "commonJS" },
|
|
48
|
+
}),
|
|
49
|
+
react(),
|
|
50
|
+
],
|
|
51
|
+
build: { cssTarget: ["chrome123", "firefox120", "safari17.5"] },
|
|
52
|
+
resolve: { alias: { "@": fromHere("src") } },
|
|
53
|
+
}));
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
- `aliases` and `unstable_moduleResolution` let StyleX find the tokens file. The items import it as
|
|
57
|
+
`@/components/calendar-stylex/calendar-tokens.stylex`, and StyleX reads it at compile time. Vite's
|
|
58
|
+
own alias doesn't reach the StyleX compiler, so it needs both.
|
|
59
|
+
- `lightningcssOptions.targets` and `build.cssTarget` name browsers that have `light-dark()`. Astryx
|
|
60
|
+
and the calendar's tokens rely on it for dark mode. With older targets it's lowered to a polyfill
|
|
61
|
+
that needs `color-scheme` in the same stylesheet, and dark colors break without an error.
|
|
62
|
+
|
|
63
|
+
## Add the global CSS
|
|
64
|
+
|
|
65
|
+
Declare the layers first, then import the stylesheets. `calendar-global.css` holds the few rules
|
|
66
|
+
StyleX can't write, such as those for drag previews, and arrives with the items.
|
|
67
|
+
|
|
68
|
+
```css title="styles.css"
|
|
69
|
+
@layer reset, astryx-base, astryx-theme;
|
|
70
|
+
@import "@astryxdesign/core/reset.css";
|
|
71
|
+
@import "@astryxdesign/core/astryx.css";
|
|
72
|
+
@import "@astryxdesign/theme-neutral/theme.css";
|
|
73
|
+
@import "@/components/calendar-stylex/calendar-global.css";
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Wrap your app in Astryx's `Theme`. It sets the root's `color-scheme`, which `light-dark()` follows:
|
|
77
|
+
|
|
78
|
+
```tsx title="main.tsx"
|
|
79
|
+
import { Theme } from "@astryxdesign/core/theme";
|
|
80
|
+
import { neutralTheme } from "@astryxdesign/theme-neutral/built";
|
|
81
|
+
|
|
82
|
+
import "./styles.css";
|
|
83
|
+
|
|
84
|
+
<Theme theme={neutralTheme}>
|
|
85
|
+
<App />
|
|
86
|
+
</Theme>;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Add the items
|
|
90
|
+
|
|
91
|
+
`shadcn add` needs a `components.json` to know your aliases, even in an app without Tailwind, and
|
|
92
|
+
your `tsconfig.json` needs the `@/*` path. The schema requires the `tailwind` block, but these items
|
|
93
|
+
don't read it, and adding them leaves your CSS as it is:
|
|
94
|
+
|
|
95
|
+
```json title="components.json"
|
|
96
|
+
{
|
|
97
|
+
"$schema": "https://ui.shadcn.com/schema.json",
|
|
98
|
+
"style": "base-nova",
|
|
99
|
+
"rsc": false,
|
|
100
|
+
"tsx": true,
|
|
101
|
+
"tailwind": { "css": "src/styles.css", "baseColor": "neutral", "cssVariables": true },
|
|
102
|
+
"aliases": {
|
|
103
|
+
"components": "@/components",
|
|
104
|
+
"utils": "@/lib/utils",
|
|
105
|
+
"ui": "@/components/ui",
|
|
106
|
+
"lib": "@/lib",
|
|
107
|
+
"hooks": "@/hooks"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`stylex-calendar-full` installs every view, the tokens and the parts they share:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
npx shadcn@latest add https://time.molten.sh/r/stylex-calendar-full.json
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Or add one view, which brings what it builds on. Every item in the
|
|
119
|
+
[table on Installation](./installation.md#ui-source-optional) has a `stylex-` version:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
npx shadcn@latest add https://time.molten.sh/r/stylex-month-view.json
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The files land in `calendar-stylex/` under your `components` alias, so they never overwrite the
|
|
126
|
+
Tailwind ones.
|
|
127
|
+
|
|
128
|
+
## Use the views
|
|
129
|
+
|
|
130
|
+
The API is the [Quick start](./quick-start.md)'s, with imports from `calendar-stylex`:
|
|
131
|
+
|
|
132
|
+
```tsx title="calendar.tsx"
|
|
133
|
+
import { createCalendar, defineEventAdapter } from "@moltenship/calendar";
|
|
134
|
+
import * as stylex from "@stylexjs/stylex";
|
|
135
|
+
|
|
136
|
+
import { CalendarToolbar } from "@/components/calendar-stylex/calendar-toolbar";
|
|
137
|
+
import { createMonthView } from "@/components/calendar-stylex/month-view/month-view";
|
|
138
|
+
import { createWeekView } from "@/components/calendar-stylex/time-grid-view/time-grid-view";
|
|
139
|
+
|
|
140
|
+
const eventAdapter = defineEventAdapter<Meeting>()({
|
|
141
|
+
getId: (meeting) => meeting.id,
|
|
142
|
+
getTitle: (meeting) => meeting.title,
|
|
143
|
+
getInterval: (meeting) => ({ kind: "timed", start: meeting.start, end: meeting.end }),
|
|
144
|
+
getResourceIds: () => [],
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const Calendar = createCalendar<Meeting>()({
|
|
148
|
+
eventAdapter,
|
|
149
|
+
views: [createWeekView<Meeting>(), createMonthView<Meeting>()],
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const styles = stylex.create({
|
|
153
|
+
frame: { display: "flex", flexDirection: "column", height: 640 },
|
|
154
|
+
viewport: { flexGrow: 1, minHeight: 0 },
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
export function TeamCalendar({ meetings }: { readonly meetings: readonly Meeting[] }) {
|
|
158
|
+
return (
|
|
159
|
+
<Calendar.Root
|
|
160
|
+
events={meetings}
|
|
161
|
+
defaultAnchorDate={Temporal.PlainDate.from("2026-10-08")}
|
|
162
|
+
defaultTimeZone="Europe/Berlin"
|
|
163
|
+
locale="en-US"
|
|
164
|
+
weekRules={{ firstDay: 1, minimalDays: 4, weekend: [6, 7] }}
|
|
165
|
+
>
|
|
166
|
+
<Calendar.Frame {...stylex.props(styles.frame)}>
|
|
167
|
+
<CalendarToolbar calendar={Calendar} />
|
|
168
|
+
<Calendar.Viewport {...stylex.props(styles.viewport)}>
|
|
169
|
+
<Calendar.ActiveView />
|
|
170
|
+
</Calendar.Viewport>
|
|
171
|
+
</Calendar.Frame>
|
|
172
|
+
</Calendar.Root>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Change the tokens
|
|
178
|
+
|
|
179
|
+
The tokens have the names in [Theming](./theming.md#tokens), as keys of `calendarVars`:
|
|
180
|
+
`calendarVars["--calendar-today"]` is `var(--calendar-today)`. Override them on a part of the page
|
|
181
|
+
with `stylex.createTheme`, and apply the theme on a wrapper. One value covers both modes through
|
|
182
|
+
`light-dark()`, which takes only colors:
|
|
183
|
+
|
|
184
|
+
```tsx
|
|
185
|
+
import * as stylex from "@stylexjs/stylex";
|
|
186
|
+
|
|
187
|
+
import { calendarVars } from "@/components/calendar-stylex/calendar-tokens.stylex";
|
|
188
|
+
|
|
189
|
+
const calendarTheme = stylex.createTheme(calendarVars, {
|
|
190
|
+
"--calendar-today": "light-dark(oklch(0.55 0.17 150), oklch(0.72 0.15 150))",
|
|
191
|
+
"--calendar-hour-height": "4rem",
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
<div {...stylex.props(calendarTheme)}>
|
|
195
|
+
<TeamCalendar meetings={meetings} />
|
|
196
|
+
</div>;
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
The base colors, such as `--background` and `--primary`, read the tokens of the root Astryx theme, so
|
|
200
|
+
a theme of yours flows in with no change here. They fall back to the values of `calendar-theme.css`
|
|
201
|
+
without one.
|
|
202
|
+
|
|
203
|
+
Tokens are resolved where they're declared, on `:root`. So a wrapper that overrides `--primary`
|
|
204
|
+
doesn't change `--calendar-event-border`, which reads `var(--primary)`: restate it in the same
|
|
205
|
+
theme. The [Theme builder](./theme-builder.md#use-the-stylex-theme) does this for you, and lets you
|
|
206
|
+
try a theme and copy it.
|
|
207
|
+
|
|
208
|
+
Popovers and tooltips open in a portal under `<body>`, outside a wrapper. To theme them too, put the
|
|
209
|
+
theme's class on `<body>`, or pass your wrapper to the portal's `container` in the source you own.
|
|
210
|
+
|
|
211
|
+
`--calendar-surface` is no token. It's unset, and the views read it through a constant, for a
|
|
212
|
+
container with its own background to set in an inline `style`, as on
|
|
213
|
+
[Theming](./theming.md#changing-tokens).
|
|
214
|
+
|
|
215
|
+
## Override a component's styles
|
|
216
|
+
|
|
217
|
+
The components take `xstyle` beside `className` and `style`, for styles of your own. They win over
|
|
218
|
+
the component's:
|
|
219
|
+
|
|
220
|
+
```tsx
|
|
221
|
+
const styles = stylex.create({
|
|
222
|
+
toolbar: { paddingBlock: "1rem" },
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
<CalendarToolbar calendar={Calendar} xstyle={styles.toolbar} />;
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Event colors
|
|
229
|
+
|
|
230
|
+
Views take `getEventColor`, and the names are the same nine, as in
|
|
231
|
+
[Choosing a color per event](./theming.md#choosing-a-color-per-event). Each color has three tokens
|
|
232
|
+
of its own, in place of the baseline's hue and chroma: `--calendar-event-blue`,
|
|
233
|
+
`--calendar-event-blue-foreground` and `--calendar-event-blue-border`. Override them with
|
|
234
|
+
`createTheme` like any other:
|
|
235
|
+
|
|
236
|
+
```tsx
|
|
237
|
+
const calendarTheme = stylex.createTheme(calendarVars, {
|
|
238
|
+
"--calendar-event-blue": "light-dark(oklch(0.92 0.06 240), oklch(0.35 0.08 240))",
|
|
239
|
+
});
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
`eventColorStyles` in `event-color-styles.ts` points an element's `--calendar-event` tokens at one
|
|
243
|
+
color, and `data-color` stays on the element as a hook for your own CSS. To add a color, add its
|
|
244
|
+
name to `event-colors.ts`, its tokens to `calendar-tokens.stylex.ts`, and an entry to
|
|
245
|
+
`eventColorStyles`.
|
|
246
|
+
|
|
247
|
+
## Next.js
|
|
248
|
+
|
|
249
|
+
The demo and CI exercise this flavour under Vite, and not under Next.js. Astryx's
|
|
250
|
+
[`example-nextjs-stylex`](https://github.com/meta/astryx/tree/main/apps/example-nextjs-stylex) shows
|
|
251
|
+
the setup for Next.js: `@stylexjs/babel-plugin` in `babel.config.js` with the `@/*` alias, and
|
|
252
|
+
`@stylexjs/postcss-plugin` with `useCSSLayers.before` naming Astryx's layers, with `@stylex;` at the
|
|
253
|
+
end of the global CSS.
|
|
254
|
+
|
|
255
|
+
## What's different from the baseline
|
|
256
|
+
|
|
257
|
+
- Base UI stays, unstyled, under the parts that need its focus handling or anchoring where Astryx has
|
|
258
|
+
no equal: the recurrence scope dialog, the undo toast, the year view's day popover, and some
|
|
259
|
+
tooltips and popovers in the views. An item lists `@base-ui/react` when it uses it.
|
|
260
|
+
- StyleX's classes have the same specificity as a global `[data-slot]` rule, and come after your
|
|
261
|
+
CSS. So a rule of yours that sets a property a view's styles also set, such as an
|
|
262
|
+
[Availability](./availability.md) recipe's background color, needs a stronger selector:
|
|
263
|
+
`[data-slot="time-grid-unavailable"][data-slot]`. Or use `xstyle` or the tokens.
|
|
264
|
+
- A fix to a view goes to both flavours. You get it the way you do for the baseline, by running
|
|
265
|
+
`shadcn add` for the item again, which asks before it replaces a file you changed.
|