@jcsoftdev/ui 0.3.0 → 0.5.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 +200 -1
- package/README.md +56 -3
- package/bin/ui-theme.mjs +13 -2
- package/dist/atoms/button/button.d.ts +8 -1
- package/dist/atoms/button/button.js +10 -3
- package/dist/atoms/checkbox/checkbox.js +3 -1
- package/dist/atoms/chip/chip.d.ts +11 -3
- package/dist/atoms/chip/chip.js +8 -1
- package/dist/atoms/chip/index.d.ts +1 -1
- package/dist/atoms/chip/index.js +2 -0
- package/dist/atoms/divider/divider.d.ts +15 -0
- package/dist/atoms/divider/divider.js +27 -0
- package/dist/atoms/divider/index.d.ts +1 -0
- package/dist/atoms/divider/index.js +1 -0
- package/dist/atoms/due-chip/due-chip.d.ts +31 -0
- package/dist/atoms/due-chip/due-chip.js +41 -0
- package/dist/atoms/due-chip/index.d.ts +2 -0
- package/dist/atoms/due-chip/index.js +6 -0
- package/dist/atoms/due-chip/model.d.ts +25 -0
- package/dist/atoms/due-chip/model.js +44 -0
- package/dist/atoms/icon-button/icon-button.d.ts +22 -0
- package/dist/atoms/icon-button/icon-button.js +38 -0
- package/dist/atoms/icon-button/index.d.ts +1 -0
- package/dist/atoms/icon-button/index.js +8 -0
- package/dist/atoms/index.d.ts +6 -0
- package/dist/atoms/index.js +6 -0
- package/dist/atoms/internal/hit-area.d.ts +6 -0
- package/dist/atoms/internal/hit-area.js +4 -0
- package/dist/atoms/kbd/index.d.ts +1 -0
- package/dist/atoms/kbd/index.js +4 -0
- package/dist/atoms/kbd/kbd.d.ts +7 -0
- package/dist/atoms/kbd/kbd.js +17 -0
- package/dist/atoms/radio-group/radio-group.js +6 -2
- package/dist/atoms/seal/index.d.ts +1 -0
- package/dist/atoms/seal/index.js +4 -0
- package/dist/atoms/seal/seal.d.ts +30 -0
- package/dist/atoms/seal/seal.js +71 -0
- package/dist/atoms/spinner/index.d.ts +1 -0
- package/dist/atoms/spinner/index.js +5 -0
- package/dist/atoms/spinner/spinner.d.ts +19 -0
- package/dist/atoms/spinner/spinner.js +31 -0
- package/dist/atoms/switch/switch.js +3 -1
- package/dist/auth/auth-illustration/auth-illustration.d.ts +35 -0
- package/dist/auth/auth-illustration/auth-illustration.js +72 -0
- package/dist/auth/auth-illustration/index.d.ts +3 -0
- package/dist/auth/auth-illustration/index.js +11 -0
- package/dist/auth/auth-illustration/look.d.ts +30 -0
- package/dist/auth/auth-illustration/look.js +0 -0
- package/dist/auth/auth-illustration/model.d.ts +133 -0
- package/dist/auth/auth-illustration/model.js +202 -0
- package/dist/auth/auth-illustration/use-art-pointer.d.ts +9 -0
- package/dist/auth/auth-illustration/use-art-pointer.js +69 -0
- package/dist/auth/auth-layout/auth-layout.d.ts +80 -0
- package/dist/auth/auth-layout/auth-layout.js +190 -0
- package/dist/auth/auth-layout/index.d.ts +1 -0
- package/dist/auth/auth-layout/index.js +1 -0
- package/dist/auth/character/character.d.ts +12 -0
- package/dist/auth/character/character.js +333 -0
- package/dist/auth/character/index.d.ts +1 -0
- package/dist/auth/character/index.js +1 -0
- package/dist/auth/index.d.ts +4 -0
- package/dist/auth/index.js +4 -0
- package/dist/auth/internal/auth-context.d.ts +17 -0
- package/dist/auth/internal/auth-context.js +10 -0
- package/dist/auth/internal/auth-styles.d.ts +1 -0
- package/dist/auth/internal/auth-styles.js +29 -0
- package/dist/auth/internal/portal-glyphs.d.ts +6 -0
- package/dist/auth/internal/portal-glyphs.js +39 -0
- package/dist/auth/login-form/context.d.ts +51 -0
- package/dist/auth/login-form/context.js +12 -0
- package/dist/auth/login-form/index.d.ts +2 -0
- package/dist/auth/login-form/index.js +23 -0
- package/dist/auth/login-form/login-form.d.ts +66 -0
- package/dist/auth/login-form/login-form.js +233 -0
- package/dist/auth/login-form/parts.d.ts +71 -0
- package/dist/auth/login-form/parts.js +371 -0
- package/dist/auth/looks/auth-illustration-any.d.ts +16 -0
- package/dist/auth/looks/auth-illustration-any.js +24 -0
- package/dist/auth/looks/index.d.ts +1 -0
- package/dist/auth/looks/index.js +1 -0
- package/dist/auth/mosaic/index.d.ts +1 -0
- package/dist/auth/mosaic/index.js +1 -0
- package/dist/auth/mosaic/mosaic.d.ts +11 -0
- package/dist/auth/mosaic/mosaic.js +195 -0
- package/dist/auth/slabs/index.d.ts +1 -0
- package/dist/auth/slabs/index.js +1 -0
- package/dist/auth/slabs/slabs.d.ts +13 -0
- package/dist/auth/slabs/slabs.js +136 -0
- package/dist/auth/stack/index.d.ts +1 -0
- package/dist/auth/stack/index.js +1 -0
- package/dist/auth/stack/stack.d.ts +6 -0
- package/dist/auth/stack/stack.js +222 -0
- package/dist/auth/statement/index.d.ts +1 -0
- package/dist/auth/statement/index.js +1 -0
- package/dist/auth/statement/statement.d.ts +13 -0
- package/dist/auth/statement/statement.js +99 -0
- package/dist/calendar/date-calendar/date-calendar.d.ts +32 -0
- package/dist/calendar/date-calendar/date-calendar.js +189 -0
- package/dist/calendar/date-calendar/index.d.ts +1 -0
- package/dist/calendar/date-calendar/index.js +6 -0
- package/dist/calendar/index.d.ts +1 -0
- package/dist/calendar/index.js +1 -0
- package/dist/calendar/internal/date-utils.d.ts +26 -0
- package/dist/calendar/internal/date-utils.js +95 -1
- package/dist/containers/aside/aside.d.ts +14 -0
- package/dist/containers/aside/aside.js +25 -0
- package/dist/containers/aside/index.d.ts +1 -0
- package/dist/containers/aside/index.js +5 -0
- package/dist/containers/banner/banner.d.ts +4 -1
- package/dist/containers/banner/banner.js +9 -1
- package/dist/containers/description-list/description-list.d.ts +29 -6
- package/dist/containers/description-list/description-list.js +47 -6
- package/dist/containers/feed/feed.d.ts +23 -0
- package/dist/containers/feed/feed.js +77 -0
- package/dist/containers/feed/index.d.ts +2 -0
- package/dist/containers/feed/index.js +10 -0
- package/dist/containers/feed/model.d.ts +19 -0
- package/dist/containers/feed/model.js +38 -0
- package/dist/containers/index.d.ts +6 -0
- package/dist/containers/index.js +6 -0
- package/dist/containers/kpi/kpi.d.ts +50 -8
- package/dist/containers/kpi/kpi.js +91 -39
- package/dist/containers/list-detail/index.d.ts +1 -0
- package/dist/containers/list-detail/index.js +20 -0
- package/dist/containers/list-detail/list-detail.d.ts +55 -0
- package/dist/containers/list-detail/list-detail.js +221 -0
- package/dist/containers/note/index.d.ts +1 -0
- package/dist/containers/note/index.js +4 -0
- package/dist/containers/note/note.d.ts +13 -0
- package/dist/containers/note/note.js +27 -0
- package/dist/containers/section/index.d.ts +1 -0
- package/dist/containers/section/index.js +6 -0
- package/dist/containers/section/section.d.ts +68 -0
- package/dist/containers/section/section.js +198 -0
- package/dist/containers/shortcuts/index.d.ts +1 -0
- package/dist/containers/shortcuts/index.js +8 -0
- package/dist/containers/shortcuts/shortcuts.d.ts +18 -0
- package/dist/containers/shortcuts/shortcuts.js +50 -0
- package/dist/containers/table/selection.d.ts +9 -0
- package/dist/containers/table/selection.js +20 -0
- package/dist/containers/table/table.d.ts +66 -4
- package/dist/containers/table/table.js +128 -7
- package/dist/containers/timeline/index.d.ts +1 -1
- package/dist/containers/timeline/index.js +4 -2
- package/dist/containers/timeline/timeline.d.ts +32 -5
- package/dist/containers/timeline/timeline.js +154 -90
- package/dist/forms/chip-group/chip-group.d.ts +54 -0
- package/dist/forms/chip-group/chip-group.js +114 -0
- package/dist/forms/chip-group/index.d.ts +1 -0
- package/dist/forms/chip-group/index.js +6 -0
- package/dist/forms/combobox/combobox.d.ts +60 -0
- package/dist/forms/combobox/combobox.js +281 -0
- package/dist/forms/combobox/index.d.ts +1 -0
- package/dist/forms/combobox/index.js +6 -0
- package/dist/forms/date-picker/date-picker.d.ts +40 -0
- package/dist/forms/date-picker/date-picker.js +183 -0
- package/dist/forms/date-picker/date-time-picker.d.ts +43 -0
- package/dist/forms/date-picker/date-time-picker.js +121 -0
- package/dist/forms/date-picker/index.d.ts +2 -0
- package/dist/forms/date-picker/index.js +10 -0
- package/dist/forms/date-picker/model.d.ts +35 -0
- package/dist/forms/date-picker/model.js +83 -0
- package/dist/forms/dropzone/dropzone.d.ts +30 -2
- package/dist/forms/dropzone/dropzone.js +153 -23
- package/dist/forms/field/field.d.ts +16 -10
- package/dist/forms/field/field.js +41 -5
- package/dist/forms/index.d.ts +5 -0
- package/dist/forms/index.js +5 -0
- package/dist/forms/input/index.d.ts +1 -1
- package/dist/forms/input/index.js +4 -1
- package/dist/forms/input/input.d.ts +21 -5
- package/dist/forms/input/input.js +75 -9
- package/dist/forms/input-icon/input-icon.d.ts +1 -1
- package/dist/forms/internal/listbox-items.d.ts +18 -0
- package/dist/forms/internal/listbox-items.js +88 -0
- package/dist/forms/internal/listbox.d.ts +44 -0
- package/dist/forms/internal/listbox.js +74 -0
- package/dist/forms/number-stepper/model.d.ts +16 -0
- package/dist/forms/number-stepper/model.js +23 -0
- package/dist/forms/number-stepper/number-stepper.d.ts +36 -6
- package/dist/forms/number-stepper/number-stepper.js +86 -37
- package/dist/forms/password-input/index.d.ts +1 -0
- package/dist/forms/password-input/index.js +1 -0
- package/dist/forms/password-input/password-input.d.ts +16 -0
- package/dist/forms/password-input/password-input.js +45 -0
- package/dist/forms/select-menu/index.d.ts +1 -0
- package/dist/forms/select-menu/index.js +6 -0
- package/dist/forms/select-menu/select-menu.d.ts +35 -0
- package/dist/forms/select-menu/select-menu.js +230 -0
- package/dist/i18n/strings.d.ts +153 -0
- package/dist/i18n/strings.js +86 -2
- package/dist/i18n/ui-strings-provider.d.ts +1 -1
- package/dist/i18n/ui-strings-provider.js +6 -2
- package/dist/icons/eye.d.ts +2 -0
- package/dist/icons/eye.js +11 -0
- package/dist/icons/graduation-cap.d.ts +2 -0
- package/dist/icons/graduation-cap.js +12 -0
- package/dist/icons/house.d.ts +2 -0
- package/dist/icons/house.js +11 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +8 -0
- package/dist/icons/mail.d.ts +2 -0
- package/dist/icons/mail.js +11 -0
- package/dist/navigation/index.d.ts +1 -0
- package/dist/navigation/index.js +1 -0
- package/dist/navigation/stepper/index.d.ts +1 -1
- package/dist/navigation/stepper/index.js +3 -1
- package/dist/navigation/stepper/stepper.d.ts +8 -0
- package/dist/navigation/stepper/stepper.js +68 -45
- package/dist/navigation/tabs/index.d.ts +1 -0
- package/dist/navigation/tabs/index.js +6 -0
- package/dist/navigation/tabs/tabs-nav.d.ts +37 -0
- package/dist/navigation/tabs/tabs-nav.js +57 -0
- package/dist/navigation/wizard/index.d.ts +1 -0
- package/dist/navigation/wizard/index.js +6 -0
- package/dist/navigation/wizard/model.d.ts +33 -0
- package/dist/navigation/wizard/model.js +34 -0
- package/dist/navigation/wizard/wizard.d.ts +45 -0
- package/dist/navigation/wizard/wizard.js +169 -0
- package/dist/overlays/alert-dialog/alert-dialog.d.ts +103 -0
- package/dist/overlays/alert-dialog/alert-dialog.js +342 -0
- package/dist/overlays/alert-dialog/index.d.ts +1 -0
- package/dist/overlays/alert-dialog/index.js +26 -0
- package/dist/overlays/dropdown-menu/dropdown-menu.d.ts +17 -1
- package/dist/overlays/dropdown-menu/dropdown-menu.js +12 -4
- package/dist/overlays/dropdown-menu/index.d.ts +1 -1
- package/dist/overlays/dropdown-menu/index.js +8 -2
- package/dist/overlays/index.d.ts +2 -0
- package/dist/overlays/index.js +2 -0
- package/dist/overlays/testing/index.d.ts +5 -0
- package/dist/overlays/testing/index.js +4 -0
- package/dist/overlays/toaster/index.d.ts +2 -1
- package/dist/overlays/toaster/index.js +4 -2
- package/dist/overlays/toaster/toast-store.d.ts +6 -2
- package/dist/overlays/toaster/toast.d.ts +3 -0
- package/dist/overlays/toaster/toast.js +3 -0
- package/dist/overlays/toaster/toaster.d.ts +3 -0
- package/dist/overlays/toaster/toaster.js +36 -3
- package/dist/overlays/tooltip/index.d.ts +1 -0
- package/dist/overlays/tooltip/index.js +4 -0
- package/dist/overlays/tooltip/model.d.ts +10 -0
- package/dist/overlays/tooltip/model.js +13 -0
- package/dist/overlays/tooltip/tooltip.d.ts +41 -0
- package/dist/overlays/tooltip/tooltip.js +116 -0
- package/dist/primitives/use-dismissable-layer.js +1 -1
- package/dist/states/error-state/error-state.d.ts +6 -1
- package/dist/states/error-state/error-state.js +13 -9
- package/dist/states/skeleton/skeleton.d.ts +8 -2
- package/dist/states/skeleton/skeleton.js +44 -2
- package/icons/svg/eye.svg +4 -0
- package/icons/svg/graduation-cap.svg +5 -0
- package/icons/svg/house.svg +4 -0
- package/icons/svg/mail.svg +4 -0
- package/package.json +2 -2
- package/scripts/build-theme.mjs +12 -1
- package/src/atoms/button/button.tsx +25 -3
- package/src/atoms/checkbox/checkbox.tsx +3 -1
- package/src/atoms/chip/chip.tsx +18 -3
- package/src/atoms/chip/index.ts +2 -0
- package/src/atoms/divider/divider.tsx +40 -0
- package/src/atoms/divider/index.ts +1 -0
- package/src/atoms/due-chip/due-chip.tsx +75 -0
- package/src/atoms/due-chip/index.ts +2 -0
- package/src/atoms/due-chip/model.ts +67 -0
- package/src/atoms/icon-button/icon-button.tsx +58 -0
- package/src/atoms/icon-button/index.ts +6 -0
- package/src/atoms/index.ts +6 -0
- package/src/atoms/internal/hit-area.ts +7 -0
- package/src/atoms/kbd/index.ts +1 -0
- package/src/atoms/kbd/kbd.tsx +20 -0
- package/src/atoms/radio-group/radio-group.tsx +8 -2
- package/src/atoms/seal/index.ts +1 -0
- package/src/atoms/seal/seal.tsx +107 -0
- package/src/atoms/spinner/index.ts +1 -0
- package/src/atoms/spinner/spinner.tsx +49 -0
- package/src/atoms/switch/switch.tsx +3 -1
- package/src/auth/auth-illustration/auth-illustration.tsx +100 -0
- package/src/auth/auth-illustration/index.ts +8 -0
- package/src/auth/auth-illustration/look.ts +32 -0
- package/src/auth/auth-illustration/model.ts +330 -0
- package/src/auth/auth-illustration/use-art-pointer.ts +78 -0
- package/src/auth/auth-layout/auth-layout.tsx +282 -0
- package/src/auth/auth-layout/index.ts +1 -0
- package/src/auth/character/character.tsx +346 -0
- package/src/auth/character/index.ts +1 -0
- package/src/auth/index.ts +4 -0
- package/src/auth/internal/auth-context.ts +26 -0
- package/src/auth/internal/auth-styles.tsx +39 -0
- package/src/auth/internal/portal-glyphs.tsx +32 -0
- package/src/auth/login-form/context.ts +78 -0
- package/src/auth/login-form/index.ts +21 -0
- package/src/auth/login-form/login-form.tsx +330 -0
- package/src/auth/login-form/parts.tsx +457 -0
- package/src/auth/looks/auth-illustration-any.tsx +38 -0
- package/src/auth/looks/index.ts +1 -0
- package/src/auth/mosaic/index.ts +1 -0
- package/src/auth/mosaic/mosaic.tsx +255 -0
- package/src/auth/slabs/index.ts +1 -0
- package/src/auth/slabs/slabs.tsx +181 -0
- package/src/auth/stack/index.ts +1 -0
- package/src/auth/stack/stack.tsx +267 -0
- package/src/auth/statement/index.ts +1 -0
- package/src/auth/statement/statement.tsx +122 -0
- package/src/calendar/date-calendar/date-calendar.tsx +230 -0
- package/src/calendar/date-calendar/index.ts +5 -0
- package/src/calendar/index.ts +1 -0
- package/src/calendar/internal/date-utils.ts +115 -0
- package/src/containers/aside/aside.tsx +40 -0
- package/src/containers/aside/index.ts +1 -0
- package/src/containers/banner/banner.tsx +18 -1
- package/src/containers/description-list/description-list.tsx +85 -9
- package/src/containers/feed/feed.tsx +99 -0
- package/src/containers/feed/index.ts +8 -0
- package/src/containers/feed/model.ts +54 -0
- package/src/containers/index.ts +6 -0
- package/src/containers/kpi/kpi.tsx +161 -62
- package/src/containers/list-detail/index.ts +15 -0
- package/src/containers/list-detail/list-detail.tsx +293 -0
- package/src/containers/note/index.ts +1 -0
- package/src/containers/note/note.tsx +38 -0
- package/src/containers/section/index.ts +11 -0
- package/src/containers/section/section.tsx +281 -0
- package/src/containers/shortcuts/index.ts +6 -0
- package/src/containers/shortcuts/shortcuts.tsx +92 -0
- package/src/containers/table/selection.ts +26 -0
- package/src/containers/table/table.tsx +215 -13
- package/src/containers/timeline/index.ts +3 -0
- package/src/containers/timeline/timeline.tsx +204 -93
- package/src/forms/chip-group/chip-group.tsx +184 -0
- package/src/forms/chip-group/index.ts +8 -0
- package/src/forms/combobox/combobox.tsx +359 -0
- package/src/forms/combobox/index.ts +7 -0
- package/src/forms/date-picker/date-picker.tsx +239 -0
- package/src/forms/date-picker/date-time-picker.tsx +178 -0
- package/src/forms/date-picker/index.ts +10 -0
- package/src/forms/date-picker/model.ts +108 -0
- package/src/forms/dropzone/dropzone.tsx +217 -35
- package/src/forms/field/field.tsx +72 -7
- package/src/forms/index.ts +5 -0
- package/src/forms/input/index.ts +8 -1
- package/src/forms/input/input.tsx +99 -12
- package/src/forms/input-icon/input-icon.tsx +1 -1
- package/src/forms/internal/listbox-items.tsx +103 -0
- package/src/forms/internal/listbox.ts +124 -0
- package/src/forms/number-stepper/model.ts +35 -0
- package/src/forms/number-stepper/number-stepper.tsx +132 -42
- package/src/forms/password-input/index.ts +1 -0
- package/src/forms/password-input/password-input.tsx +57 -0
- package/src/forms/select-menu/index.ts +7 -0
- package/src/forms/select-menu/select-menu.tsx +280 -0
- package/src/i18n/strings.ts +153 -0
- package/src/i18n/ui-strings-provider.tsx +15 -4
- package/src/icons/eye.tsx +12 -0
- package/src/icons/graduation-cap.tsx +13 -0
- package/src/icons/house.tsx +12 -0
- package/src/icons/index.ts +4 -0
- package/src/icons/mail.tsx +12 -0
- package/src/navigation/index.ts +1 -0
- package/src/navigation/stepper/index.ts +7 -1
- package/src/navigation/stepper/stepper.tsx +41 -5
- package/src/navigation/tabs/index.ts +7 -0
- package/src/navigation/tabs/tabs-nav.tsx +131 -0
- package/src/navigation/wizard/index.ts +7 -0
- package/src/navigation/wizard/model.ts +61 -0
- package/src/navigation/wizard/wizard.tsx +222 -0
- package/src/overlays/alert-dialog/alert-dialog.tsx +486 -0
- package/src/overlays/alert-dialog/index.ts +19 -0
- package/src/overlays/dropdown-menu/dropdown-menu.tsx +29 -4
- package/src/overlays/dropdown-menu/index.ts +3 -0
- package/src/overlays/index.ts +2 -0
- package/src/overlays/testing/index.ts +5 -0
- package/src/overlays/toaster/index.ts +2 -0
- package/src/overlays/toaster/toast-store.ts +6 -2
- package/src/overlays/toaster/toast.ts +6 -0
- package/src/overlays/toaster/toaster.tsx +44 -2
- package/src/overlays/tooltip/index.ts +1 -0
- package/src/overlays/tooltip/model.ts +18 -0
- package/src/overlays/tooltip/tooltip.tsx +166 -0
- package/src/primitives/use-dismissable-layer.ts +7 -2
- package/src/states/error-state/error-state.tsx +19 -8
- package/src/states/skeleton/skeleton.tsx +68 -2
- package/styles/tailwind.css +33 -30
- package/styles/theme.css +33 -30
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type ComponentPropsWithoutRef,
|
|
5
|
+
type CSSProperties,
|
|
6
|
+
createContext,
|
|
7
|
+
useContext,
|
|
8
|
+
useMemo,
|
|
9
|
+
} from "react";
|
|
10
|
+
import type { ClassNames } from "../../utils/class-names.js";
|
|
11
|
+
import { cn } from "../../utils/cn.js";
|
|
12
|
+
import { useControllableState } from "../../utils/use-controllable-state.js";
|
|
13
|
+
import {
|
|
14
|
+
AuthIllustration,
|
|
15
|
+
type AuthIllustrationProps,
|
|
16
|
+
} from "../auth-illustration/auth-illustration.js";
|
|
17
|
+
import type { AuthLook } from "../auth-illustration/look.js";
|
|
18
|
+
import type { AuthState } from "../auth-illustration/model.js";
|
|
19
|
+
import { AuthContext, type AuthContextValue, type AuthPanel } from "../internal/auth-context.js";
|
|
20
|
+
import { AuthStyles } from "../internal/auth-styles.js";
|
|
21
|
+
|
|
22
|
+
export type AuthLayoutKind = "split" | "split-reverse" | "centered";
|
|
23
|
+
|
|
24
|
+
export type AuthLayoutPart = "root" | "content" | "brand" | "art" | "panel" | "footer";
|
|
25
|
+
|
|
26
|
+
interface AuthLayoutParts {
|
|
27
|
+
layout: AuthLayoutKind;
|
|
28
|
+
panel: AuthPanel;
|
|
29
|
+
classNames: ClassNames<AuthLayoutPart> | undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const AuthLayoutPartsContext = createContext<AuthLayoutParts | null>(null);
|
|
33
|
+
|
|
34
|
+
function useAuthLayoutParts(part: string): AuthLayoutParts {
|
|
35
|
+
const parts = useContext(AuthLayoutPartsContext);
|
|
36
|
+
if (!parts) throw new Error(`AuthLayout.${part} must be rendered inside an AuthLayout`);
|
|
37
|
+
return parts;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** State shared by the illustration and the form of an `AuthLayout`. Throws outside one. */
|
|
41
|
+
export function useAuthLayout(): AuthContextValue {
|
|
42
|
+
const auth = useContext(AuthContext);
|
|
43
|
+
if (!auth) throw new Error("useAuthLayout must be called inside an AuthLayout");
|
|
44
|
+
return auth;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface AuthLayoutProps extends ComponentPropsWithoutRef<"div"> {
|
|
48
|
+
/**
|
|
49
|
+
* `split` puts the art beside the panel once the layout is 768px wide, `split-reverse` swaps the
|
|
50
|
+
* sides, `centered` centers the panel over a faded illustration. Narrower than that the art
|
|
51
|
+
* stacks above the panel, and under 448px it is dropped. All of it follows the layout's own
|
|
52
|
+
* width, not the viewport's.
|
|
53
|
+
*/
|
|
54
|
+
layout?: AuthLayoutKind;
|
|
55
|
+
/**
|
|
56
|
+
* `paper` is the card over a tinted page. `solid` fills one side with a solid color for the art
|
|
57
|
+
* and leaves the form open on the other (no card). It applies to `split` and `split-reverse`;
|
|
58
|
+
* `centered` ignores it. A solid root sets `--auth-art-bg` and `--auth-art-ink` for the art, the
|
|
59
|
+
* brand and the illustration, which carries `data-panel="solid"`.
|
|
60
|
+
*/
|
|
61
|
+
panel?: AuthPanel;
|
|
62
|
+
/** What the screen is doing, for the illustration. Controlled; `LoginForm` keeps it current when left alone. */
|
|
63
|
+
state?: AuthState;
|
|
64
|
+
defaultState?: AuthState;
|
|
65
|
+
onStateChange?: (state: AuthState) => void;
|
|
66
|
+
/** Fill of the whole form, 0 to 1. */
|
|
67
|
+
progress?: number;
|
|
68
|
+
defaultProgress?: number;
|
|
69
|
+
onProgressChange?: (progress: number) => void;
|
|
70
|
+
/** Index of the portal in use (0 to 2). */
|
|
71
|
+
activeIndex?: number;
|
|
72
|
+
defaultActiveIndex?: number;
|
|
73
|
+
onActiveIndexChange?: (index: number) => void;
|
|
74
|
+
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root and is merged last. */
|
|
75
|
+
classNames?: ClassNames<AuthLayoutPart>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Screen for signing in: a brand, an illustration that reacts to the form and the form itself,
|
|
80
|
+
* laid out by the width of the layout. It owns the sign-in state (controlled or not) and shares it
|
|
81
|
+
* with `AuthIllustration` and `LoginForm`, so wiring them is just placing them inside.
|
|
82
|
+
*
|
|
83
|
+
* Parts: `AuthLayout.Brand`, `AuthLayout.Art`, `AuthLayout.Panel` and `AuthLayout.Footer`.
|
|
84
|
+
*/
|
|
85
|
+
export function AuthLayout({
|
|
86
|
+
layout = "split",
|
|
87
|
+
panel: panelProp = "paper",
|
|
88
|
+
state: stateProp,
|
|
89
|
+
defaultState = "idle",
|
|
90
|
+
onStateChange,
|
|
91
|
+
progress: progressProp,
|
|
92
|
+
defaultProgress = 0,
|
|
93
|
+
onProgressChange,
|
|
94
|
+
activeIndex: activeIndexProp,
|
|
95
|
+
defaultActiveIndex = 0,
|
|
96
|
+
onActiveIndexChange,
|
|
97
|
+
className,
|
|
98
|
+
classNames,
|
|
99
|
+
children,
|
|
100
|
+
...props
|
|
101
|
+
}: AuthLayoutProps) {
|
|
102
|
+
const [state, setState] = useControllableState<AuthState>({
|
|
103
|
+
prop: stateProp,
|
|
104
|
+
defaultProp: defaultState,
|
|
105
|
+
onChange: onStateChange,
|
|
106
|
+
});
|
|
107
|
+
const [progress, setProgress] = useControllableState<number>({
|
|
108
|
+
prop: progressProp,
|
|
109
|
+
defaultProp: defaultProgress,
|
|
110
|
+
onChange: onProgressChange,
|
|
111
|
+
});
|
|
112
|
+
const [activeIndex, setActiveIndex] = useControllableState<number>({
|
|
113
|
+
prop: activeIndexProp,
|
|
114
|
+
defaultProp: defaultActiveIndex,
|
|
115
|
+
onChange: onActiveIndexChange,
|
|
116
|
+
});
|
|
117
|
+
const panel: AuthPanel = layout === "centered" ? "paper" : panelProp;
|
|
118
|
+
const auth = useMemo<AuthContextValue>(
|
|
119
|
+
() => ({ panel, state, setState, progress, setProgress, activeIndex, setActiveIndex }),
|
|
120
|
+
[panel, state, setState, progress, setProgress, activeIndex, setActiveIndex],
|
|
121
|
+
);
|
|
122
|
+
const parts = useMemo(() => ({ layout, panel, classNames }), [layout, panel, classNames]);
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<AuthContext value={auth}>
|
|
126
|
+
<AuthLayoutPartsContext value={parts}>
|
|
127
|
+
<AuthStyles />
|
|
128
|
+
<div
|
|
129
|
+
{...props}
|
|
130
|
+
style={panel === "solid" ? { ...SOLID_ART_VARS, ...props.style } : props.style}
|
|
131
|
+
data-layout={layout}
|
|
132
|
+
data-panel={panel}
|
|
133
|
+
data-state={state}
|
|
134
|
+
className={cn(
|
|
135
|
+
"@container/auth relative isolate min-h-164 min-w-0 overflow-hidden",
|
|
136
|
+
panel === "solid"
|
|
137
|
+
? "bg-surface"
|
|
138
|
+
: "rounded-card border-divider bg-[color-mix(in_srgb,var(--accent)_14%,var(--bg))]",
|
|
139
|
+
classNames?.root,
|
|
140
|
+
className,
|
|
141
|
+
)}
|
|
142
|
+
>
|
|
143
|
+
<div
|
|
144
|
+
className={cn(
|
|
145
|
+
"grid min-h-[inherit] grid-cols-1",
|
|
146
|
+
panel === "solid"
|
|
147
|
+
? "content-start items-stretch @3xl/auth:grid-cols-2 @3xl/auth:content-stretch"
|
|
148
|
+
: [
|
|
149
|
+
"content-center items-center gap-2 px-4 pt-14 pb-6 @max-md/auth:content-start @max-md/auth:bg-surface @lg/auth:px-8 @3xl/auth:px-14 @3xl/auth:pt-7 @3xl/auth:pb-8",
|
|
150
|
+
layout !== "centered" &&
|
|
151
|
+
"@3xl/auth:grid-cols-[minmax(0,1.1fr)_minmax(0,.9fr)] @3xl/auth:gap-12",
|
|
152
|
+
],
|
|
153
|
+
classNames?.content,
|
|
154
|
+
)}
|
|
155
|
+
>
|
|
156
|
+
{children}
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
</AuthLayoutPartsContext>
|
|
160
|
+
</AuthContext>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface AuthLayoutBrandProps extends ComponentPropsWithoutRef<"div"> {}
|
|
165
|
+
|
|
166
|
+
/** Colors of the solid art panel, derived from the theme so every accent and dark mode apply. */
|
|
167
|
+
const SOLID_ART_VARS = {
|
|
168
|
+
"--auth-art-bg": "var(--accent)",
|
|
169
|
+
"--auth-art-ink": "var(--on-accent)",
|
|
170
|
+
} as CSSProperties;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Logo or wordmark pinned to the top corner on the art's side: left in `split` and `centered`,
|
|
174
|
+
* right in `split-reverse` once the art sits beside the panel, so it never lands on the card.
|
|
175
|
+
*/
|
|
176
|
+
export function AuthLayoutBrand({ className, ...props }: AuthLayoutBrandProps) {
|
|
177
|
+
const { layout, panel, classNames } = useAuthLayoutParts("Brand");
|
|
178
|
+
const onSolid = panel === "solid";
|
|
179
|
+
return (
|
|
180
|
+
<div
|
|
181
|
+
{...props}
|
|
182
|
+
className={cn(
|
|
183
|
+
"absolute top-5.5 left-4 z-[3] font-bold text-lg tracking-tight @lg/auth:left-8 @3xl/auth:left-14",
|
|
184
|
+
layout === "split-reverse" && "@3xl/auth:right-14 @3xl/auth:left-auto",
|
|
185
|
+
!onSolid && "text-ink",
|
|
186
|
+
onSolid && "text-[var(--auth-art-ink)] @max-md/auth:text-ink",
|
|
187
|
+
classNames?.brand,
|
|
188
|
+
className,
|
|
189
|
+
)}
|
|
190
|
+
/>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface AuthLayoutArtProps
|
|
195
|
+
extends ComponentPropsWithoutRef<"div">,
|
|
196
|
+
Pick<AuthIllustrationProps, "headline" | "caption" | "action"> {
|
|
197
|
+
/** Look of the default illustration, used when there are no children (default `Slabs`). */
|
|
198
|
+
look?: AuthLook;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Holds the illustration (a default `AuthIllustration` when empty). It hides under 448px of layout
|
|
203
|
+
* width and, in `centered`, sits faded behind the panel. A drawn look is at most 12rem tall while
|
|
204
|
+
* it is stacked above the panel, so the form stays in reach, and 34rem beside it; set
|
|
205
|
+
* `--auth-art-max-h` on this part to change that.
|
|
206
|
+
*/
|
|
207
|
+
export function AuthLayoutArt({
|
|
208
|
+
look,
|
|
209
|
+
headline,
|
|
210
|
+
caption,
|
|
211
|
+
action,
|
|
212
|
+
className,
|
|
213
|
+
children,
|
|
214
|
+
...props
|
|
215
|
+
}: AuthLayoutArtProps) {
|
|
216
|
+
const { layout, panel, classNames } = useAuthLayoutParts("Art");
|
|
217
|
+
const solid = panel === "solid";
|
|
218
|
+
const art = children ?? (
|
|
219
|
+
<AuthIllustration look={look} headline={headline} caption={caption} action={action} />
|
|
220
|
+
);
|
|
221
|
+
return (
|
|
222
|
+
<div
|
|
223
|
+
{...props}
|
|
224
|
+
className={cn(
|
|
225
|
+
"grid min-w-0 place-items-center [--auth-art-max-h:12rem] @max-md/auth:hidden @3xl/auth:[--auth-art-max-h:34rem]",
|
|
226
|
+
layout === "centered" && "pointer-events-none absolute inset-0 -z-10 px-8 opacity-35",
|
|
227
|
+
layout !== "centered" && !solid && "relative mx-auto w-full max-w-90 @3xl/auth:max-w-160",
|
|
228
|
+
layout !== "centered" &&
|
|
229
|
+
solid &&
|
|
230
|
+
"bg-[var(--auth-art-bg)] px-4 pt-16 pb-6 text-[var(--auth-art-ink)] @lg/auth:px-8 @3xl/auth:px-14 @3xl/auth:py-14",
|
|
231
|
+
layout === "split-reverse" && "@3xl/auth:order-2",
|
|
232
|
+
classNames?.art,
|
|
233
|
+
className,
|
|
234
|
+
)}
|
|
235
|
+
>
|
|
236
|
+
{solid ? <div className="w-full max-w-90 @3xl/auth:max-w-160">{art}</div> : art}
|
|
237
|
+
</div>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export interface AuthLayoutPanelProps extends ComponentPropsWithoutRef<"div"> {}
|
|
242
|
+
|
|
243
|
+
/** The card that holds the form. */
|
|
244
|
+
export function AuthLayoutPanel({ className, ...props }: AuthLayoutPanelProps) {
|
|
245
|
+
const { layout, panel, classNames } = useAuthLayoutParts("Panel");
|
|
246
|
+
return (
|
|
247
|
+
<div
|
|
248
|
+
{...props}
|
|
249
|
+
className={cn(
|
|
250
|
+
panel === "solid"
|
|
251
|
+
? "relative z-[2] grid min-w-0 content-center px-4 py-10 text-ink @max-md/auth:pt-20 @lg/auth:px-8 @3xl/auth:px-14 @3xl/auth:py-14"
|
|
252
|
+
: "ui-auth-rise relative z-[2] w-full max-w-110 min-w-0 justify-self-center overflow-hidden rounded-card border-[1.5px] border-ink bg-surface text-ink shadow-[0_3px_0_var(--ink),0_24px_50px_-12px_color-mix(in_srgb,black_20%,transparent)] @max-md/auth:overflow-visible @max-md/auth:rounded-none @max-md/auth:border-0 @max-md/auth:shadow-none",
|
|
253
|
+
layout === "split-reverse" && "@3xl/auth:order-1",
|
|
254
|
+
classNames?.panel,
|
|
255
|
+
className,
|
|
256
|
+
)}
|
|
257
|
+
/>
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export interface AuthLayoutFooterProps extends ComponentPropsWithoutRef<"div"> {}
|
|
262
|
+
|
|
263
|
+
/** Line under the panel, across the full width (terms, support, a language switch). */
|
|
264
|
+
export function AuthLayoutFooter({ className, ...props }: AuthLayoutFooterProps) {
|
|
265
|
+
const { panel, classNames } = useAuthLayoutParts("Footer");
|
|
266
|
+
return (
|
|
267
|
+
<div
|
|
268
|
+
{...props}
|
|
269
|
+
className={cn(
|
|
270
|
+
"relative z-[2] col-span-full text-center text-ink-3 text-meta",
|
|
271
|
+
panel === "solid" && "px-4 pb-6",
|
|
272
|
+
classNames?.footer,
|
|
273
|
+
className,
|
|
274
|
+
)}
|
|
275
|
+
/>
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
AuthLayout.Brand = AuthLayoutBrand;
|
|
280
|
+
AuthLayout.Art = AuthLayoutArt;
|
|
281
|
+
AuthLayout.Panel = AuthLayoutPanel;
|
|
282
|
+
AuthLayout.Footer = AuthLayoutFooter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./auth-layout.js";
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { CSSProperties } from "react";
|
|
4
|
+
import type { AuthVariantProps } from "../auth-illustration/look.js";
|
|
5
|
+
import { BOARD_LIGHTS, boardLit, keystroke } from "../auth-illustration/model.js";
|
|
6
|
+
import { PORTAL_GLYPHS } from "../internal/portal-glyphs.js";
|
|
7
|
+
|
|
8
|
+
const CSS = `
|
|
9
|
+
@keyframes ui-chr-bob{50%{transform:translateY(-12px)}}
|
|
10
|
+
@keyframes ui-chr-pulse{50%{transform:scale(.8);opacity:.6}}
|
|
11
|
+
@keyframes ui-chr-blink{0%,93%,100%{transform:scaleY(0)}96%{transform:scaleY(1)}}
|
|
12
|
+
@keyframes ui-chr-nod-0{40%{transform:rotate(-5deg) translateY(2px)}}
|
|
13
|
+
@keyframes ui-chr-nod-1{40%{transform:rotate(5deg) translateY(2px)}}
|
|
14
|
+
@keyframes ui-chr-shake{15%,55%{transform:translateX(-7px) rotate(-4deg)}35%,75%{transform:translateX(7px) rotate(4deg)}}
|
|
15
|
+
@keyframes ui-chr-hop{0%{transform:translateY(0)}18%{transform:translateY(8px) scaleY(.94)}48%{transform:translateY(-58px)}74%{transform:translateY(4px)}100%{transform:translateY(0)}}
|
|
16
|
+
@keyframes ui-chr-hop-shadow{48%{transform:scale(.55);opacity:.35}}
|
|
17
|
+
@keyframes ui-chr-boost{0%,12%{opacity:0;transform:scaleY(.2)}30%{opacity:1;transform:scaleY(1.25)}62%{opacity:1;transform:scaleY(.9)}100%{opacity:0;transform:scaleY(.3)}}
|
|
18
|
+
@keyframes ui-chr-flicker{50%{transform:scaleY(.7)}}
|
|
19
|
+
@keyframes ui-chr-drift{50%{transform:translate(10px,-8px)}}
|
|
20
|
+
@keyframes ui-chr-in{from{opacity:0;transform:translateY(36px) scale(.92)}}
|
|
21
|
+
.ui-chr{--side:1;--line:color-mix(in srgb,black 80%,var(--accent));--skin:color-mix(in srgb,white 90%,var(--accent));--hoodie:var(--accent);--pack:color-mix(in srgb,var(--ink) 22%,color-mix(in srgb,black 62%,var(--accent)));--hair:color-mix(in srgb,var(--ink) 22%,color-mix(in srgb,black 72%,var(--accent)));--pants:color-mix(in srgb,black 45%,var(--accent));--deck:color-mix(in srgb,var(--ink) 22%,color-mix(in srgb,black 70%,var(--accent)));--lamp:color-mix(in srgb,white 30%,var(--accent-2));--lamp-off:color-mix(in srgb,white 18%,var(--deck));--blush:color-mix(in srgb,var(--danger) 30%,white);--flame:var(--accent-2);--decor:color-mix(in srgb,var(--accent) 45%,transparent);overflow:visible}
|
|
22
|
+
.ui-auth-art[data-panel=solid] .ui-chr{--hoodie:color-mix(in srgb,var(--auth-art-ink) 34%,var(--auth-art-bg));--decor:color-mix(in srgb,var(--auth-art-ink) 18%,transparent);--flame:var(--ua-tint)}
|
|
23
|
+
:where([data-layout=split-reverse]) .ui-chr{--side:-1}
|
|
24
|
+
.ui-chr-line{stroke:var(--line);stroke-width:3;stroke-linejoin:round;stroke-linecap:round}
|
|
25
|
+
.ui-chr-fill-skin{fill:var(--skin)}.ui-chr-fill-hoodie{fill:var(--hoodie)}.ui-chr-fill-pack{fill:var(--pack)}.ui-chr-fill-hair{fill:var(--hair)}.ui-chr-fill-pants{fill:var(--pants)}.ui-chr-fill-deck{fill:var(--deck)}.ui-chr-fill-line{fill:var(--line)}
|
|
26
|
+
.ui-chr-dots{fill:color-mix(in srgb,black 30%,transparent)}
|
|
27
|
+
.ui-chr-shine{fill:white;opacity:.7}
|
|
28
|
+
.ui-chr-blush{fill:var(--blush);opacity:.75}
|
|
29
|
+
.ui-chr-in{animation:ui-chr-in .9s var(--ua-land) backwards .1s}
|
|
30
|
+
.ui-chr-shadow{fill:var(--ua-shadow);transform-box:fill-box;transform-origin:center;animation:ui-chr-pulse 3.2s ease-in-out infinite}
|
|
31
|
+
.ui-chr-bob{animation:ui-chr-bob 3.2s ease-in-out infinite}
|
|
32
|
+
.ui-chr-par{transform:translate(calc(var(--px,0) * 6px),calc(var(--py,0) * 3px));transition:transform .6s var(--ua-glide)}
|
|
33
|
+
.ui-chr-hop,.ui-chr-head,.ui-chr-nod,.ui-chr-turn,.ui-chr-arm,.ui-chr-brow,.ui-chr-flame,.ui-chr-lid{transform-box:view-box}
|
|
34
|
+
.ui-chr-head,.ui-chr-nod{transform-origin:200px 200px}
|
|
35
|
+
.ui-chr-turn{transition:transform .45s var(--ua-bounce)}
|
|
36
|
+
.ui-chr-nod-0{animation:ui-chr-nod-0 .34s var(--ua-glide)}
|
|
37
|
+
.ui-chr-nod-1{animation:ui-chr-nod-1 .34s var(--ua-glide)}
|
|
38
|
+
.ui-chr-eyes{transform:translate(calc(var(--ex,var(--px,0)) * 6px),calc(var(--ey,var(--py,0)) * 4px));transition:transform .3s var(--ua-glide)}
|
|
39
|
+
.ui-auth-art[data-state=typing] .ui-chr-eyes{--ex:calc(var(--side) * 1.1);--ey:.9}
|
|
40
|
+
.ui-auth-art[data-state=password] .ui-chr-turn{transform:translateX(calc(var(--side) * -6px)) rotate(calc(var(--side) * -6deg))}
|
|
41
|
+
.ui-chr-lid{transform-box:fill-box;transform-origin:50% 0;transform:scaleY(0);animation:ui-chr-blink 4.6s infinite}
|
|
42
|
+
.ui-chr-lid rect{fill:var(--skin)}
|
|
43
|
+
.ui-auth-art[data-state=password] .ui-chr-lid{animation:none;transform:scaleY(1);transition:transform .18s ease-out}
|
|
44
|
+
.ui-chr-brow{transition:transform .35s var(--ua-bounce)}
|
|
45
|
+
.ui-auth-art[data-state=error] .ui-chr-brow-l{transform:translateY(3px) rotate(16deg);transform-box:fill-box;transform-origin:center}
|
|
46
|
+
.ui-auth-art[data-state=error] .ui-chr-brow-r{transform:translateY(3px) rotate(-16deg);transform-box:fill-box;transform-origin:center}
|
|
47
|
+
.ui-auth-art[data-state=success] .ui-chr-brow{transform:translateY(-4px)}
|
|
48
|
+
.ui-chr-mouth{opacity:0;transition:opacity .2s linear}
|
|
49
|
+
.ui-auth-art:is([data-state=idle],[data-state=typing]) .ui-chr-mouth-smile,.ui-auth-art[data-state=password] .ui-chr-mouth-hush,.ui-auth-art[data-state=error] .ui-chr-mouth-wobble,.ui-auth-art[data-state=success] .ui-chr-mouth-grin{opacity:1}
|
|
50
|
+
.ui-chr-sweat{fill:color-mix(in srgb,white 55%,var(--accent-2));opacity:0;transform:translateY(-6px);transition:opacity .2s linear,transform .5s var(--ua-glide)}
|
|
51
|
+
.ui-auth-art[data-state=error] .ui-chr-sweat{opacity:1;transform:none}
|
|
52
|
+
.ui-chr-arm{transition:transform .5s var(--ua-bounce)}
|
|
53
|
+
.ui-chr-arm-l{transform-origin:158px 214px}.ui-chr-arm-r{transform-origin:242px 214px}
|
|
54
|
+
.ui-auth-art[data-state=password] .ui-chr-arm-l{transform:rotate(-170deg)}
|
|
55
|
+
.ui-auth-art[data-state=password] .ui-chr-arm-r{transform:rotate(170deg)}
|
|
56
|
+
.ui-auth-art[data-state=success] .ui-chr-arm-l{transform:rotate(138deg)}
|
|
57
|
+
.ui-auth-art[data-state=success] .ui-chr-arm-r{transform:rotate(-138deg)}
|
|
58
|
+
.ui-auth-art[data-state=error] .ui-chr-arm-l{transform:rotate(-18deg)}
|
|
59
|
+
.ui-auth-art[data-state=error] .ui-chr-arm-r{transform:rotate(18deg)}
|
|
60
|
+
.ui-auth-art[data-state=error] .ui-chr-head{animation:ui-chr-shake .6s var(--ua-glide)}
|
|
61
|
+
.ui-auth-art[data-state=success] .ui-chr-hop{animation:ui-chr-hop 1s var(--ua-glide) .1s}
|
|
62
|
+
.ui-auth-art[data-state=success] .ui-chr-shadow-hop{animation:ui-chr-hop-shadow 1s var(--ua-glide) .1s;transform-box:fill-box;transform-origin:center}
|
|
63
|
+
.ui-chr-lamp{fill:var(--lamp-off);transition:opacity .3s linear}
|
|
64
|
+
.ui-chr-lamp-on{fill:var(--lamp);opacity:var(--on);transition:opacity .3s linear;transition-delay:calc(var(--i) * 60ms)}
|
|
65
|
+
.ui-auth-art[data-state=error] .ui-chr-lamp-on{fill:var(--danger)}
|
|
66
|
+
.ui-chr-flame{fill:var(--flame);transform-box:fill-box;transform-origin:50% 0;opacity:0}
|
|
67
|
+
.ui-chr-flame-idle{opacity:.55;animation:ui-chr-flicker .5s ease-in-out infinite;transform:scaleY(.55)}
|
|
68
|
+
.ui-auth-art[data-state=success] .ui-chr-flame-boost{animation:ui-chr-boost 1.1s var(--ua-glide) .1s}
|
|
69
|
+
.ui-chr-decor{display:none;fill:var(--decor)}
|
|
70
|
+
.ui-chr-drift{transform-box:fill-box;animation:ui-chr-drift 7s ease-in-out infinite;animation-delay:calc(var(--i) * -2.3s)}
|
|
71
|
+
@container art (min-width:24rem){.ui-chr-decor{display:inline}}
|
|
72
|
+
.ui-auth-art[data-state=success] .ui-auth-spark{animation-delay:.45s}
|
|
73
|
+
@media (prefers-reduced-motion:reduce){
|
|
74
|
+
.ui-chr *,.ui-auth-art[data-state] .ui-chr *{animation:none!important;transition:none!important}
|
|
75
|
+
.ui-chr-par,.ui-chr-eyes{transform:none}
|
|
76
|
+
.ui-chr-flame-idle{transform:scaleY(.55)}
|
|
77
|
+
}
|
|
78
|
+
`;
|
|
79
|
+
|
|
80
|
+
/** Lamps along the deck, left to right. */
|
|
81
|
+
const LAMPS = Array.from({ length: BOARD_LIGHTS }, (_, i) => 132 + i * 30);
|
|
82
|
+
|
|
83
|
+
const SPARKS = [
|
|
84
|
+
{ dx: "-70px", dy: "-60px", star: true },
|
|
85
|
+
{ dx: "60px", dy: "-80px", star: false },
|
|
86
|
+
{ dx: "86px", dy: "-20px", star: true },
|
|
87
|
+
{ dx: "-90px", dy: "-10px", star: false },
|
|
88
|
+
{ dx: "10px", dy: "-104px", star: true },
|
|
89
|
+
] as const;
|
|
90
|
+
|
|
91
|
+
function Arm({ side }: { side: "l" | "r" }) {
|
|
92
|
+
const d = side === "l" ? "M158 216 Q142 244 148 268" : "M242 216 Q258 244 252 268";
|
|
93
|
+
const hand = side === "l" ? { cx: 148, cy: 272 } : { cx: 252, cy: 272 };
|
|
94
|
+
return (
|
|
95
|
+
<g className={`ui-chr-arm ui-chr-arm-${side}`}>
|
|
96
|
+
<path d={d} fill="none" stroke="var(--line)" strokeWidth="25" strokeLinecap="round" />
|
|
97
|
+
<path d={d} fill="none" stroke="var(--hoodie)" strokeWidth="19" strokeLinecap="round" />
|
|
98
|
+
<circle className="ui-chr-fill-skin ui-chr-line" cx={hand.cx} cy={hand.cy} r="10.5" />
|
|
99
|
+
</g>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* A student with a backpack riding a hover board over a pulsing shadow, for the art panel. They bob,
|
|
105
|
+
* blink and follow the pointer; while the form is typed into they look toward it and nod per
|
|
106
|
+
* keystroke, for the password they cover their eyes, on an error they shake their head and on
|
|
107
|
+
* success they hop with a boost. The deck lamps fill with progress and the chest badge carries the
|
|
108
|
+
* active portal's glyph.
|
|
109
|
+
*/
|
|
110
|
+
export function Character({ state, progress, activeIndex, uid }: AuthVariantProps) {
|
|
111
|
+
const dots = `url(#${uid}-chr-dots)`;
|
|
112
|
+
// The nod sits on its own element, apart from the error head shake, and its class stays on
|
|
113
|
+
// through every state: a CSS animation restarts only when its class changes, so leaving an
|
|
114
|
+
// error does not replay the last nod.
|
|
115
|
+
const tick = keystroke(progress);
|
|
116
|
+
const nod = tick.count > 0 ? `ui-chr-nod ui-chr-nod-${tick.phase}` : "ui-chr-nod";
|
|
117
|
+
const lit = boardLit(state, progress);
|
|
118
|
+
return (
|
|
119
|
+
<>
|
|
120
|
+
<style href="jcsoftdev-ui-auth-character" precedence="default">
|
|
121
|
+
{CSS}
|
|
122
|
+
</style>
|
|
123
|
+
{/* The view box leaves room above the head for the success hop, so it never leaves the frame. */}
|
|
124
|
+
{/* biome-ignore lint/a11y/noSvgWithoutTitle: the wrapper names the illustration or hides it */}
|
|
125
|
+
<svg viewBox="40 8 320 432" focusable="false" className="ui-chr">
|
|
126
|
+
<defs>
|
|
127
|
+
<pattern id={`${uid}-chr-dots`} width="5" height="5" patternUnits="userSpaceOnUse">
|
|
128
|
+
<circle className="ui-chr-dots" cx="2.5" cy="2.5" r="1" />
|
|
129
|
+
</pattern>
|
|
130
|
+
</defs>
|
|
131
|
+
<g className="ui-chr-decor">
|
|
132
|
+
{[
|
|
133
|
+
{ x: 84, y: 130, s: 1.2 },
|
|
134
|
+
{ x: 312, y: 104, s: 0.8 },
|
|
135
|
+
{ x: 318, y: 290, s: 1 },
|
|
136
|
+
{ x: 76, y: 300, s: 0.7 },
|
|
137
|
+
].map((star, i) => (
|
|
138
|
+
<g key={star.x} transform={`translate(${star.x} ${star.y}) scale(${star.s})`}>
|
|
139
|
+
<path
|
|
140
|
+
className="ui-chr-drift"
|
|
141
|
+
style={{ "--i": i } as CSSProperties}
|
|
142
|
+
d="M0 -14 Q2 -2 14 0 Q2 2 0 14 Q-2 2 -14 0 Q-2 -2 0 -14 Z"
|
|
143
|
+
/>
|
|
144
|
+
</g>
|
|
145
|
+
))}
|
|
146
|
+
</g>
|
|
147
|
+
<g className="ui-chr-in">
|
|
148
|
+
<g className="ui-chr-shadow-hop">
|
|
149
|
+
<ellipse className="ui-chr-shadow" cx="200" cy="414" rx="92" ry="11" />
|
|
150
|
+
</g>
|
|
151
|
+
<g className="ui-chr-par">
|
|
152
|
+
<g className="ui-chr-hop">
|
|
153
|
+
<g className="ui-chr-bob">
|
|
154
|
+
{/* board */}
|
|
155
|
+
{[150, 250].map((x) => (
|
|
156
|
+
<g key={x}>
|
|
157
|
+
<path
|
|
158
|
+
className="ui-chr-flame ui-chr-flame-idle"
|
|
159
|
+
d={`M${x - 8} 360 Q${x} 392 ${x + 8} 360 Z`}
|
|
160
|
+
/>
|
|
161
|
+
<path
|
|
162
|
+
className="ui-chr-flame ui-chr-flame-boost"
|
|
163
|
+
d={`M${x - 11} 360 Q${x - 4} 420 ${x} 432 Q${x + 4} 420 ${x + 11} 360 Z`}
|
|
164
|
+
/>
|
|
165
|
+
<rect
|
|
166
|
+
className="ui-chr-fill-deck ui-chr-line"
|
|
167
|
+
x={x - 14}
|
|
168
|
+
y="344"
|
|
169
|
+
width="28"
|
|
170
|
+
height="18"
|
|
171
|
+
rx="6"
|
|
172
|
+
/>
|
|
173
|
+
</g>
|
|
174
|
+
))}
|
|
175
|
+
<rect
|
|
176
|
+
className="ui-chr-fill-deck ui-chr-line"
|
|
177
|
+
x="104"
|
|
178
|
+
y="326"
|
|
179
|
+
width="192"
|
|
180
|
+
height="22"
|
|
181
|
+
rx="11"
|
|
182
|
+
/>
|
|
183
|
+
<rect x="104" y="326" width="192" height="22" rx="11" fill={dots} />
|
|
184
|
+
{LAMPS.map((x, i) => (
|
|
185
|
+
<g key={x}>
|
|
186
|
+
<rect className="ui-chr-lamp" x={x} y="334" width="16" height="6" rx="3" />
|
|
187
|
+
<rect
|
|
188
|
+
className="ui-chr-lamp-on"
|
|
189
|
+
style={{ "--i": i, "--on": i < lit ? 1 : 0 } as CSSProperties}
|
|
190
|
+
x={x}
|
|
191
|
+
y="334"
|
|
192
|
+
width="16"
|
|
193
|
+
height="6"
|
|
194
|
+
rx="3"
|
|
195
|
+
/>
|
|
196
|
+
</g>
|
|
197
|
+
))}
|
|
198
|
+
{/* legs and shoes */}
|
|
199
|
+
<rect
|
|
200
|
+
className="ui-chr-fill-pants ui-chr-line"
|
|
201
|
+
x="174"
|
|
202
|
+
y="276"
|
|
203
|
+
width="22"
|
|
204
|
+
height="44"
|
|
205
|
+
rx="8"
|
|
206
|
+
/>
|
|
207
|
+
<rect
|
|
208
|
+
className="ui-chr-fill-pants ui-chr-line"
|
|
209
|
+
x="204"
|
|
210
|
+
y="276"
|
|
211
|
+
width="22"
|
|
212
|
+
height="44"
|
|
213
|
+
rx="8"
|
|
214
|
+
/>
|
|
215
|
+
<path
|
|
216
|
+
className="ui-chr-fill-skin ui-chr-line"
|
|
217
|
+
d="M170 314 h28 v9 q0 5 -5 5 h-28 q-6 0 -6 -6 q0 -8 11 -8 Z"
|
|
218
|
+
/>
|
|
219
|
+
<path
|
|
220
|
+
className="ui-chr-fill-skin ui-chr-line"
|
|
221
|
+
d="M230 314 h-28 v9 q0 5 5 5 h28 q6 0 6 -6 q0 -8 -11 -8 Z"
|
|
222
|
+
/>
|
|
223
|
+
{/* backpack, body, straps and badge */}
|
|
224
|
+
<rect
|
|
225
|
+
className="ui-chr-fill-pack ui-chr-line"
|
|
226
|
+
x="134"
|
|
227
|
+
y="204"
|
|
228
|
+
width="132"
|
|
229
|
+
height="76"
|
|
230
|
+
rx="24"
|
|
231
|
+
/>
|
|
232
|
+
<rect x="134" y="204" width="132" height="76" rx="24" fill={dots} />
|
|
233
|
+
<path
|
|
234
|
+
className="ui-chr-fill-hoodie ui-chr-line"
|
|
235
|
+
d="M160 208 Q200 190 240 208 L252 278 Q200 296 148 278 Z"
|
|
236
|
+
/>
|
|
237
|
+
<path d="M226 202 Q244 210 252 278 Q240 284 228 286 Z" fill={dots} />
|
|
238
|
+
<path className="ui-chr-line" fill="none" d="M170 206 Q166 236 172 270" />
|
|
239
|
+
<path className="ui-chr-line" fill="none" d="M230 206 Q234 236 228 270" />
|
|
240
|
+
<circle className="ui-chr-fill-skin ui-chr-line" cx="200" cy="246" r="17" />
|
|
241
|
+
<g
|
|
242
|
+
transform="translate(188 234) scale(.24)"
|
|
243
|
+
style={
|
|
244
|
+
{
|
|
245
|
+
"--glyph-a": "var(--hoodie)",
|
|
246
|
+
"--glyph-b": "var(--line)",
|
|
247
|
+
"--glyph-c": "var(--skin)",
|
|
248
|
+
"--glyph-line": "var(--line)",
|
|
249
|
+
} as CSSProperties
|
|
250
|
+
}
|
|
251
|
+
>
|
|
252
|
+
{PORTAL_GLYPHS[activeIndex] ?? PORTAL_GLYPHS[0]}
|
|
253
|
+
</g>
|
|
254
|
+
{/* head */}
|
|
255
|
+
<g className="ui-chr-head">
|
|
256
|
+
<g className={nod}>
|
|
257
|
+
<g className="ui-chr-turn">
|
|
258
|
+
<circle className="ui-chr-fill-skin ui-chr-line" cx="200" cy="148" r="54" />
|
|
259
|
+
<path
|
|
260
|
+
className="ui-chr-fill-hair ui-chr-line"
|
|
261
|
+
d="M146 146 Q144 92 200 92 Q258 92 254 148 Q240 122 214 120 Q206 132 186 126 Q164 124 146 146 Z"
|
|
262
|
+
/>
|
|
263
|
+
<path d="M216 96 Q250 104 254 146 Q242 124 220 120 Z" fill={dots} />
|
|
264
|
+
<circle className="ui-chr-blush" cx="168" cy="172" r="9" />
|
|
265
|
+
<circle className="ui-chr-blush" cx="232" cy="172" r="9" />
|
|
266
|
+
<g className="ui-chr-brow ui-chr-brow-l">
|
|
267
|
+
<path className="ui-chr-line" fill="none" d="M172 136 q10 -6 20 -2" />
|
|
268
|
+
</g>
|
|
269
|
+
<g className="ui-chr-brow ui-chr-brow-r">
|
|
270
|
+
<path className="ui-chr-line" fill="none" d="M208 134 q10 -4 20 2" />
|
|
271
|
+
</g>
|
|
272
|
+
<g className="ui-chr-eyes">
|
|
273
|
+
{[182, 218].map((x) => (
|
|
274
|
+
<g key={x}>
|
|
275
|
+
<ellipse className="ui-chr-fill-line" cx={x} cy="156" rx="6" ry="8" />
|
|
276
|
+
<circle className="ui-chr-shine" cx={x + 2} cy="152" r="2.2" />
|
|
277
|
+
</g>
|
|
278
|
+
))}
|
|
279
|
+
</g>
|
|
280
|
+
{[182, 218].map((x) => (
|
|
281
|
+
<g key={x} className="ui-chr-lid">
|
|
282
|
+
<rect x={x - 9} y="146" width="18" height="18" />
|
|
283
|
+
<path className="ui-chr-line" fill="none" d={`M${x - 8} 164 q8 5 16 0`} />
|
|
284
|
+
</g>
|
|
285
|
+
))}
|
|
286
|
+
<path
|
|
287
|
+
className="ui-chr-mouth ui-chr-mouth-smile ui-chr-line"
|
|
288
|
+
fill="none"
|
|
289
|
+
d="M190 178 q10 8 20 0"
|
|
290
|
+
/>
|
|
291
|
+
<path
|
|
292
|
+
className="ui-chr-mouth ui-chr-mouth-hush ui-chr-line"
|
|
293
|
+
fill="none"
|
|
294
|
+
d="M194 180 h12"
|
|
295
|
+
/>
|
|
296
|
+
<path
|
|
297
|
+
className="ui-chr-mouth ui-chr-mouth-wobble ui-chr-line"
|
|
298
|
+
fill="none"
|
|
299
|
+
d="M188 182 q4 -5 8 0 t8 0 t8 0"
|
|
300
|
+
/>
|
|
301
|
+
<path
|
|
302
|
+
className="ui-chr-mouth ui-chr-mouth-grin ui-chr-fill-line ui-chr-line"
|
|
303
|
+
d="M186 174 h28 q0 18 -14 18 q-14 0 -14 -18 Z"
|
|
304
|
+
/>
|
|
305
|
+
<path
|
|
306
|
+
className="ui-chr-sweat ui-chr-line"
|
|
307
|
+
strokeWidth="2"
|
|
308
|
+
d="M246 118 q8 12 0 16 q-8 -4 0 -16 Z"
|
|
309
|
+
/>
|
|
310
|
+
</g>
|
|
311
|
+
</g>
|
|
312
|
+
</g>
|
|
313
|
+
<Arm side="l" />
|
|
314
|
+
<Arm side="r" />
|
|
315
|
+
</g>
|
|
316
|
+
</g>
|
|
317
|
+
</g>
|
|
318
|
+
{state === "success" ? (
|
|
319
|
+
<g transform="translate(200 210)">
|
|
320
|
+
{SPARKS.map((spark) => (
|
|
321
|
+
<g
|
|
322
|
+
key={`${spark.dx}${spark.dy}`}
|
|
323
|
+
className="ui-auth-spark"
|
|
324
|
+
style={{ "--dx": spark.dx, "--dy": spark.dy } as CSSProperties}
|
|
325
|
+
>
|
|
326
|
+
{spark.star ? (
|
|
327
|
+
<path
|
|
328
|
+
d="M0 -9 L2.5 -2.5 L9 0 L2.5 2.5 L0 9 L-2.5 2.5 L-9 0 L-2.5 -2.5 Z"
|
|
329
|
+
fill="var(--ua-spark-0)"
|
|
330
|
+
stroke="var(--line)"
|
|
331
|
+
strokeWidth="1.6"
|
|
332
|
+
/>
|
|
333
|
+
) : (
|
|
334
|
+
<circle r="5" fill="var(--ua-spark-1)" stroke="var(--line)" strokeWidth="1.6" />
|
|
335
|
+
)}
|
|
336
|
+
</g>
|
|
337
|
+
))}
|
|
338
|
+
</g>
|
|
339
|
+
) : null}
|
|
340
|
+
</g>
|
|
341
|
+
</svg>
|
|
342
|
+
</>
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
Character.variant = "character";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./character.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
import type { AuthState } from "../auth-illustration/model.js";
|
|
5
|
+
|
|
6
|
+
export type AuthPanel = "paper" | "solid";
|
|
7
|
+
|
|
8
|
+
export interface AuthContextValue {
|
|
9
|
+
/** Composition of the screen: the card over paper, or a solid side panel with an open form. */
|
|
10
|
+
panel: AuthPanel;
|
|
11
|
+
state: AuthState;
|
|
12
|
+
setState: (state: AuthState) => void;
|
|
13
|
+
/** Fill of the whole form, 0 to 1. */
|
|
14
|
+
progress: number;
|
|
15
|
+
setProgress: (progress: number) => void;
|
|
16
|
+
/** Index of the portal the user is signing in through; the illustration lifts it. */
|
|
17
|
+
activeIndex: number;
|
|
18
|
+
setActiveIndex: (index: number) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const AuthContext = createContext<AuthContextValue | null>(null);
|
|
22
|
+
|
|
23
|
+
/** The state an `AuthLayout` shares with its illustration and form, or `null` outside one. */
|
|
24
|
+
export function useOptionalAuth(): AuthContextValue | null {
|
|
25
|
+
return useContext(AuthContext);
|
|
26
|
+
}
|