diff --git a/.changeset/calendar-today-hydration.md b/.changeset/calendar-today-hydration.md new file mode 100644 index 000000000..b46ea28f1 --- /dev/null +++ b/.changeset/calendar-today-hydration.md @@ -0,0 +1,5 @@ +--- +"@javaabu/onu": patch +--- + +Server-rendered `DateCalendar` and `HijriCalendar` now mark the browser's today once hydrated. Before, a server in another time zone (UTC against the Maldives between 00:00 and 05:00) could leave yesterday marked. diff --git a/.changeset/full-calendar-mobile-hydration.md b/.changeset/full-calendar-mobile-hydration.md new file mode 100644 index 000000000..f7ad9378c --- /dev/null +++ b/.changeset/full-calendar-mobile-hydration.md @@ -0,0 +1,5 @@ +--- +"@javaabu/onu": patch +--- + +A server-rendered `FullCalendar` without `view` or `defaultView` now opens on the agenda on phones once hydrated; before, it stayed on the month view. diff --git a/.changeset/nextjs-fixture-hydration-cases.md b/.changeset/nextjs-fixture-hydration-cases.md new file mode 100644 index 000000000..85ea99819 --- /dev/null +++ b/.changeset/nextjs-fixture-hydration-cases.md @@ -0,0 +1,4 @@ +--- +--- + +The Next.js server-rendering check now covers a stored theme, `ShareButtons` without a `url` and a phone-width `FullCalendar` (test fixture only, no release). diff --git a/.changeset/share-buttons-hydration.md b/.changeset/share-buttons-hydration.md new file mode 100644 index 000000000..1094eeb29 --- /dev/null +++ b/.changeset/share-buttons-hydration.md @@ -0,0 +1,5 @@ +--- +"@javaabu/onu": patch +--- + +Server-rendered `ShareButtons` without a `url` now get the current page's URL after hydration; before, their share links kept the server's empty URL. diff --git a/.changeset/theme-provider-hydration.md b/.changeset/theme-provider-hydration.md new file mode 100644 index 000000000..6619439a0 --- /dev/null +++ b/.changeset/theme-provider-hydration.md @@ -0,0 +1,5 @@ +--- +"@javaabu/onu": patch +--- + +`ThemeProvider` no longer causes a hydration mismatch when a theme is stored: it hydrates with `defaultTheme` and switches to the stored theme right after, so a server-rendered `ThemeToggle` shows the stored choice. It also follows a theme chosen in another tab. diff --git a/.changeset/theme-script-options.md b/.changeset/theme-script-options.md new file mode 100644 index 000000000..0016dc0c7 --- /dev/null +++ b/.changeset/theme-script-options.md @@ -0,0 +1,5 @@ +--- +"@javaabu/onu": patch +--- + +`themeScript` now takes the provider's options as an object, `themeScript({ defaultTheme, forcedTheme, storageKey })`, applies `forcedTheme`, and falls back to `defaultTheme` for a stored value that isn't a theme, so the first paint matches `ThemeProvider`. diff --git a/.changeset/use-client-only-where-needed.md b/.changeset/use-client-only-where-needed.md new file mode 100644 index 000000000..4bf19bbbf --- /dev/null +++ b/.changeset/use-client-only-where-needed.md @@ -0,0 +1,5 @@ +--- +"@javaabu/onu": patch +--- + +The build now marks only modules that need the browser with `"use client"`, so Server Components can call pure helpers such as `cn`, `themeScript`, `createTranslator`, `mergeMessages`, the `/thaana` conversion functions and the `/export` builders. `themeScript` no longer needs a client-component wrapper in Next.js. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cc24c14c5..033e7a90f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -40,6 +40,7 @@ A component is done only when it meets REQUIREMENTS §21: light/dark, LTR/RTL, ` - Use `` (from `src/icons/icon`) with semantic names, so `OnuProvider icons` overrides apply. Never render a Lucide component directly. When a component always shows the same glyph (a spinner, a close button, a chevron), also pass that Lucide icon as `fallback`, e.g. ``: overrides still win, and the component keeps its glyph outside `OnuProvider`. - Never import `src/icons/lucide-map` in a component. `OnuProvider` loads the default set on demand, so neither a single component nor the provider ships ~250 icons. ESLint and `src/icons/icon-imports.test.ts` enforce this, and `pnpm --filter @javaabu/onu size` checks the bundle budgets. - Built-in strings: a module that uses `t("form.…")` registers the English namespaces it uses at the top level, e.g. `registerEnglish({ form: en_form })` with `import { form as en_form } from "../../locales/en/form"`. Never import the whole locale (`src/locales`, `locales/en/messages`) in a component, so a bundle carries only the English text of the components it uses. `src/i18n/english-registry.test.ts` checks this. +- Start a module with `"use client"` when it uses state, effects or context (its own hooks or Onu's, such as `useTranslation`). The build keeps the directive only on those modules, so pure helpers (`cn`, `themeScript`, `/thaana` conversion, `/export`) stay callable from React Server Components. `src/use-client.test.ts` checks this. - Every `package.json` export has a `size-limit` budget (`pnpm --filter @javaabu/onu size`, run in CI). When a change grows an entry on purpose, raise its budget in the same PR and say why; keep budgets a little above the measured size. - Prefer shadcn/ui or an approved library (REQUIREMENTS §4) before building from scratch. Record new dependencies in `DEPENDENCIES.md`. - Add a changeset: `pnpm changeset`. diff --git a/docs/date-and-time/date-calendar.md b/docs/date-and-time/date-calendar.md index 883f9915d..89d2ef01a 100644 --- a/docs/date-and-time/date-calendar.md +++ b/docs/date-and-time/date-calendar.md @@ -62,6 +62,8 @@ import { DateCalendar } from "@javaabu/onu" `DEFAULT_WEEKEND_DAYS` (`[5, 6]`, Friday and Saturday) is exported. +Without `today`, "today" is the browser's date. When server-rendered, no day is marked as today until hydration (a server in another time zone can be on a different day); pass `today` to have it in the server's HTML. + ## Accessibility See the [DatePicker keyboard table](./date-picker#accessibility). The caption is a button ("March 2026: choose a month"); page changes are announced through a polite live region; the current month/year/range has `aria-current="date"`. diff --git a/docs/date-and-time/full-calendar.md b/docs/date-and-time/full-calendar.md index acb3fed3d..2fdf1351b 100644 --- a/docs/date-and-time/full-calendar.md +++ b/docs/date-and-time/full-calendar.md @@ -30,7 +30,7 @@ const events: CalendarEvent[] = [ ``` - `color` takes a theme colour (`primary`, `success`, `warning`, `destructive`, `info`, `secondary`, `chart-1`…`chart-8`), so events follow dark mode and `--onu-primary`. Any other FullCalendar event field (`backgroundColor`, `extendedProps`, `url`, …) passes through. -- The toolbar (‹ Today › · title · view switch) wraps on narrow containers; on phones the calendar opens on the agenda. No view scrolls the page sideways at 375px, in LTR or RTL: the agenda's screen-reader header is hidden in place (FullCalendar's `left: -10000px` would otherwise add 10,000px of overflow in RTL) and month events clip inside their day cell. +- The toolbar (‹ Today › · title · view switch) wraps on narrow containers; on phones the calendar opens on the agenda (also when server-rendered: it switches once hydrated), until a view is picked. No view scrolls the page sideways at 375px, in LTR or RTL: the agenda's screen-reader header is hidden in place (FullCalendar's `left: -10000px` would otherwise add 10,000px of overflow in RTL) and month events clip inside their day cell. - Weekend days (Friday and Saturday by default) are shaded; today is marked. - `apiRef` gives FullCalendar's `CalendarApi`; `options` passes any other FullCalendar option (Onu's props win); `hideToolbar` lets you build your own. diff --git a/docs/date-and-time/hijri-date-picker.md b/docs/date-and-time/hijri-date-picker.md index ffe4e5459..d04416ebe 100644 --- a/docs/date-and-time/hijri-date-picker.md +++ b/docs/date-and-time/hijri-date-picker.md @@ -36,6 +36,8 @@ Plus the shared picker field props. `selected`, `onSelect`, `min`, `max`, `weekStartsOn`, `weekendDays`, `showGregorian` (default `true`), `today`, `initialFocus`, `className`, `ref`. +As with `DateCalendar`, without `today` the browser's date is marked once hydrated, not the server's. + ## Accessibility The days view is an in-house APG grid (react-day-picker has no Hijri support). Day buttons are named with both calendars ("Today, 23 Ramadan 1447 AH, Thursday, March 12th, 2026"); today has `aria-current="date"`; days outside `min`/`max` are `aria-disabled`. diff --git a/docs/display-and-feedback/share-buttons.md b/docs/display-and-feedback/share-buttons.md index 4992ecc4f..5a2508d7f 100644 --- a/docs/display-and-feedback/share-buttons.md +++ b/docs/display-and-feedback/share-buttons.md @@ -30,6 +30,8 @@ import { ShareButtons } from "@javaabu/onu" `shareUrl(network, url, title?, text?)` builds the share links. +When server-rendered without `url`, the links start without a URL (the server doesn't know the page's address) and get the current page's URL straight after hydration. Pass `url` to have it in the server's HTML too. + :::info Brand icons Onu's icon sets (Lucide, FontAwesome Free solid) don't include brand logos, so networks use generic icons with their names as text. Pass `icons` (e.g. from Simple Icons via the Iconify adapter) for logos. ::: diff --git a/docs/guides/dark-mode.md b/docs/guides/dark-mode.md index 783e476b8..40aa662ce 100644 --- a/docs/guides/dark-mode.md +++ b/docs/guides/dark-mode.md @@ -26,7 +26,9 @@ function MyToggle() { | `forcedTheme` | | Fix the theme, e.g. `"light"` for print pages | | `storageKey` | `"onu-theme"` | `localStorage` key | -The provider sets `class="dark"`, `data-theme` and `color-scheme` on ``, so dialogs and menus in portals follow it. +The provider sets `class="dark"`, `data-theme` and `color-scheme` on ``, so dialogs and menus in portals follow it. A choice made in another tab applies here too. + +When server-rendered, the provider hydrates with `defaultTheme` (the server can't read `localStorage`) and switches to the stored theme straight after hydration, so the markup matches and controls such as `ThemeToggle` show the stored choice. In server-rendered apps, add `themeScript()` to `` to apply the stored theme before the page paints: @@ -34,4 +36,10 @@ In server-rendered apps, add `themeScript()` to `` to apply the stored the