create-foldkit-app 0.31.1 → 0.32.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/dist/templates/base/FOLDKIT.md +1 -1
- package/dist/templates/examples/api-cache/package.json +7 -7
- package/dist/templates/examples/auth/package.json +7 -7
- package/dist/templates/examples/auth/src/page/loggedOut/page/login.ts +28 -35
- package/dist/templates/examples/auth/src/update.ts +10 -13
- package/dist/templates/examples/canvas-art/package.json +7 -7
- package/dist/templates/examples/charting/package.json +7 -7
- package/dist/templates/examples/charting/src/view/chart.ts +43 -45
- package/dist/templates/examples/counter/package.json +7 -7
- package/dist/templates/examples/counters/package.json +7 -7
- package/dist/templates/examples/crash-view/package.json +7 -7
- package/dist/templates/examples/embedding/package.json +7 -7
- package/dist/templates/examples/form/package.json +7 -7
- package/dist/templates/examples/form/src/main.ts +59 -74
- package/dist/templates/examples/generative-art/package.json +7 -7
- package/dist/templates/examples/interrupting-commands/package.json +7 -7
- package/dist/templates/examples/interrupting-commands/src/main.ts +6 -9
- package/dist/templates/examples/job-application/package.json +7 -7
- package/dist/templates/examples/job-application/src/view/education.ts +31 -32
- package/dist/templates/examples/job-application/src/view/field.ts +7 -8
- package/dist/templates/examples/job-application/src/view/workHistory.ts +40 -41
- package/dist/templates/examples/kanban/package.json +8 -8
- package/dist/templates/examples/managed-resource-layer/package.json +7 -7
- package/dist/templates/examples/managed-resource-layer/src/main.ts +10 -11
- package/dist/templates/examples/map/package.json +8 -8
- package/dist/templates/examples/map/src/main.ts +59 -63
- package/dist/templates/examples/map/src/vite-env.d.ts +1 -0
- package/dist/templates/examples/pixel-art/package.json +7 -7
- package/dist/templates/examples/pixel-art/src/scene.test.ts +3 -3
- package/dist/templates/examples/pixel-art/src/story.test.ts +3 -3
- package/dist/templates/examples/query-sync/package.json +7 -7
- package/dist/templates/examples/query-sync/src/main.ts +25 -37
- package/dist/templates/examples/route-transitions/package.json +7 -7
- package/dist/templates/examples/route-transitions/src/main.ts +24 -32
- package/dist/templates/examples/routing/package.json +7 -7
- package/dist/templates/examples/routing/src/main.ts +24 -30
- package/dist/templates/examples/routing/src/page/people.ts +80 -86
- package/dist/templates/examples/shopping-cart/package.json +7 -7
- package/dist/templates/examples/shopping-cart/src/main.ts +16 -22
- package/dist/templates/examples/slow-warnings/package.json +7 -7
- package/dist/templates/examples/snake/package.json +7 -7
- package/dist/templates/examples/ssg/package.json +6 -8
- package/dist/templates/examples/ssg/src/main.ts +65 -75
- package/dist/templates/examples/ssr/package.json +8 -9
- package/dist/templates/examples/state-machine/package.json +7 -7
- package/dist/templates/examples/state-machine/src/view.ts +50 -59
- package/dist/templates/examples/stopwatch/package.json +7 -7
- package/dist/templates/examples/todo/package.json +7 -7
- package/dist/templates/examples/todo/src/main.ts +29 -37
- package/dist/templates/examples/ui-showcase/package.json +7 -7
- package/dist/templates/examples/ui-showcase/src/main.ts +49 -42
- package/dist/templates/examples/ui-showcase/src/scene.test.ts +11 -0
- package/dist/templates/examples/ui-showcase/src/ui/init.ts +2 -0
- package/dist/templates/examples/ui-showcase/src/ui/message.ts +2 -0
- package/dist/templates/examples/ui-showcase/src/ui/model.ts +2 -0
- package/dist/templates/examples/ui-showcase/src/ui/update.ts +21 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/hoverIntent.ts +89 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/index.ts +1 -0
- package/dist/templates/examples/view-transitions/package.json +7 -7
- package/dist/templates/examples/view-transitions/src/main.ts +29 -40
- package/dist/templates/examples/weather/package.json +7 -7
- package/dist/templates/examples/web-components/package.json +7 -7
- package/dist/templates/examples/websocket-chat/package.json +7 -7
- package/dist/templates/examples/websocket-chat/src/main.ts +22 -32
- package/dist/templates/release.json +18 -18
- package/dist/templates/rendering/ssg/README.md +8 -7
- package/dist/templates/rendering/ssg/package.json +2 -2
- package/dist/templates/rendering/ssg/src/main.ts +61 -70
- package/dist/templates/rendering/ssg/tsconfig.json +1 -1
- package/dist/templates/rendering/ssg/vite.config.ts +22 -1
- package/dist/templates/rendering/ssr/README.md +10 -7
- package/dist/templates/rendering/ssr/package.json +2 -2
- package/dist/templates/rendering/ssr/vite.config.ts +22 -1
- package/package.json +5 -5
- package/dist/templates/rendering/ssg/scripts/build.mjs +0 -27
- package/dist/templates/rendering/ssg/scripts/prerender.ts +0 -120
- package/dist/templates/rendering/ssr/scripts/build.mjs +0 -23
|
@@ -40,6 +40,7 @@ export const AppRoute = defineRouteUnion({
|
|
|
40
40
|
DragAndDrop: {},
|
|
41
41
|
Fieldset: {},
|
|
42
42
|
FileDrop: {},
|
|
43
|
+
HoverIntent: {},
|
|
43
44
|
Input: {},
|
|
44
45
|
Listbox: {},
|
|
45
46
|
Menu: {},
|
|
@@ -82,6 +83,10 @@ const fileDropRouter = pipe(
|
|
|
82
83
|
literal('file-drop'),
|
|
83
84
|
Route.mapTo(AppRoute.FileDrop),
|
|
84
85
|
)
|
|
86
|
+
const hoverIntentRouter = pipe(
|
|
87
|
+
literal('hover-intent'),
|
|
88
|
+
Route.mapTo(AppRoute.HoverIntent),
|
|
89
|
+
)
|
|
85
90
|
const inputRouter = pipe(literal('input'), Route.mapTo(AppRoute.Input))
|
|
86
91
|
const listboxRouter = pipe(literal('listbox'), Route.mapTo(AppRoute.Listbox))
|
|
87
92
|
const menuRouter = pipe(literal('menu'), Route.mapTo(AppRoute.Menu))
|
|
@@ -117,6 +122,7 @@ const routeParser = Route.oneOf(
|
|
|
117
122
|
dragAndDropRouter,
|
|
118
123
|
fieldsetRouter,
|
|
119
124
|
fileDropRouter,
|
|
125
|
+
hoverIntentRouter,
|
|
120
126
|
inputRouter,
|
|
121
127
|
listboxRouter,
|
|
122
128
|
menuRouter,
|
|
@@ -247,19 +253,16 @@ export const update = (model: Model, message: Message) =>
|
|
|
247
253
|
CompletedLoadExternal: () => ({ model }),
|
|
248
254
|
|
|
249
255
|
ClickedLink: ({ request }) =>
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
model,
|
|
255
|
-
commands: [NavigateInternal({ url: urlToString(url) })],
|
|
256
|
-
}),
|
|
257
|
-
External: ({ href }) => ({
|
|
258
|
-
model,
|
|
259
|
-
commands: [LoadExternal({ href })],
|
|
260
|
-
}),
|
|
256
|
+
UrlRequest.match<UpdateReturn>(request, {
|
|
257
|
+
Internal: ({ url }) => ({
|
|
258
|
+
model,
|
|
259
|
+
commands: [NavigateInternal({ url: urlToString(url) })],
|
|
261
260
|
}),
|
|
262
|
-
|
|
261
|
+
External: ({ href }) => ({
|
|
262
|
+
model,
|
|
263
|
+
commands: [LoadExternal({ href })],
|
|
264
|
+
}),
|
|
265
|
+
}),
|
|
263
266
|
|
|
264
267
|
ChangedUrl: ({ url }) =>
|
|
265
268
|
Update.combine(model, [
|
|
@@ -296,6 +299,11 @@ const NAV_ITEMS: ReadonlyArray<NavItem> = [
|
|
|
296
299
|
},
|
|
297
300
|
{ label: 'Fieldset', routeTag: 'Fieldset', href: fieldsetRouter() },
|
|
298
301
|
{ label: 'File Drop', routeTag: 'FileDrop', href: fileDropRouter() },
|
|
302
|
+
{
|
|
303
|
+
label: 'Hover Intent',
|
|
304
|
+
routeTag: 'HoverIntent',
|
|
305
|
+
href: hoverIntentRouter(),
|
|
306
|
+
},
|
|
299
307
|
{ label: 'Input', routeTag: 'Input', href: inputRouter() },
|
|
300
308
|
{ label: 'Listbox', routeTag: 'Listbox', href: listboxRouter() },
|
|
301
309
|
{ label: 'Menu', routeTag: 'Menu', href: menuRouter() },
|
|
@@ -586,36 +594,35 @@ const contentView = (model: Model, h: HtmlBuilder<Message>): Html => {
|
|
|
586
594
|
toParentMessage: toUiMessage,
|
|
587
595
|
})
|
|
588
596
|
|
|
589
|
-
return
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
)
|
|
597
|
+
return AppRoute.match(model.route, {
|
|
598
|
+
Home: () => homeView(h),
|
|
599
|
+
Button: () => embedUi('ui-button', View.button),
|
|
600
|
+
Calendar: () => embedUi('ui-calendar', View.calendar),
|
|
601
|
+
Checkbox: () => embedUi('ui-checkbox', View.checkbox),
|
|
602
|
+
Combobox: () => embedUi('ui-combobox', View.combobox),
|
|
603
|
+
DatePicker: () => embedUi('ui-date-picker', View.datePicker),
|
|
604
|
+
Dialog: () => embedUi('ui-dialog', View.dialog),
|
|
605
|
+
Disclosure: () => embedUi('ui-disclosure', View.disclosure),
|
|
606
|
+
DragAndDrop: () => embedUi('ui-drag-and-drop', View.dragAndDrop),
|
|
607
|
+
Fieldset: () => embedUi('ui-fieldset', View.fieldset),
|
|
608
|
+
FileDrop: () => embedUi('ui-file-drop', View.fileDrop),
|
|
609
|
+
HoverIntent: () => embedUi('ui-hover-intent', View.hoverIntent),
|
|
610
|
+
Input: () => embedUi('ui-input', View.input),
|
|
611
|
+
Listbox: () => embedUi('ui-listbox', View.listbox),
|
|
612
|
+
Menu: () => embedUi('ui-menu', View.menu),
|
|
613
|
+
Popover: () => embedUi('ui-popover', View.popover),
|
|
614
|
+
RadioGroup: () => embedUi('ui-radio-group', View.radioGroup),
|
|
615
|
+
Select: () => embedUi('ui-select', View.select),
|
|
616
|
+
Slider: () => embedUi('ui-slider', View.slider),
|
|
617
|
+
Switch: () => embedUi('ui-switch', View.switch_),
|
|
618
|
+
Tabs: () => embedUi('ui-tabs', View.tabs),
|
|
619
|
+
Textarea: () => embedUi('ui-textarea', View.textarea),
|
|
620
|
+
Toast: () => embedUi('ui-toast', View.toast),
|
|
621
|
+
Tooltip: () => embedUi('ui-tooltip', View.tooltip),
|
|
622
|
+
Animation: () => embedUi('ui-animation', View.animation),
|
|
623
|
+
VirtualList: () => embedUi('ui-virtual-list', View.virtualList),
|
|
624
|
+
NotFound: ({ path }) => notFoundView(path, h),
|
|
625
|
+
})
|
|
619
626
|
}
|
|
620
627
|
|
|
621
628
|
const routeTitle = (route: Model['route']): string =>
|
|
@@ -23,6 +23,7 @@ describe('view', () => {
|
|
|
23
23
|
expect(role('link', { name: 'Button' })).toExist(),
|
|
24
24
|
expect(role('link', { name: 'Calendar' })).toExist(),
|
|
25
25
|
expect(role('link', { name: 'Dialog' })).toExist(),
|
|
26
|
+
expect(role('link', { name: 'Hover Intent' })).toExist(),
|
|
26
27
|
expect(role('link', { name: 'Toast' })).toExist(),
|
|
27
28
|
expect(role('link', { name: 'Virtual List' })).toExist(),
|
|
28
29
|
)
|
|
@@ -47,6 +48,7 @@ describe('view', () => {
|
|
|
47
48
|
AppRoute.Checkbox(),
|
|
48
49
|
AppRoute.Disclosure(),
|
|
49
50
|
AppRoute.Fieldset(),
|
|
51
|
+
AppRoute.HoverIntent(),
|
|
50
52
|
AppRoute.Input(),
|
|
51
53
|
AppRoute.RadioGroup(),
|
|
52
54
|
AppRoute.Select(),
|
|
@@ -64,6 +66,15 @@ describe('view', () => {
|
|
|
64
66
|
})
|
|
65
67
|
})
|
|
66
68
|
|
|
69
|
+
test('the Hover Intent route renders its interactive trigger', () => {
|
|
70
|
+
scene(
|
|
71
|
+
{ update, view },
|
|
72
|
+
given(modelForRoute(AppRoute.HoverIntent())),
|
|
73
|
+
expect(role('heading', { name: 'Hover Intent' })).toExist(),
|
|
74
|
+
expect(role('button', { name: 'Preview account' })).toExist(),
|
|
75
|
+
)
|
|
76
|
+
})
|
|
77
|
+
|
|
67
78
|
test('the Disclosure panel stays mounted while collapsed so it can animate', () => {
|
|
68
79
|
scene(
|
|
69
80
|
{ update, view },
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
Dialog,
|
|
9
9
|
DragAndDrop,
|
|
10
10
|
FileDrop,
|
|
11
|
+
HoverIntent,
|
|
11
12
|
Listbox,
|
|
12
13
|
Menu,
|
|
13
14
|
Popover,
|
|
@@ -107,6 +108,7 @@ export const uiInit = (today: Calendar.CalendarDate): InitReturn => ({
|
|
|
107
108
|
],
|
|
108
109
|
fileDropBasicDemo: FileDrop.init({ id: 'file-drop-basic-demo' }),
|
|
109
110
|
fileDropBasicDemoFiles: [],
|
|
111
|
+
hoverIntentDemo: HoverIntent.init(),
|
|
110
112
|
listboxDemo: Listbox.init({ id: 'listbox-demo' }),
|
|
111
113
|
maybeListboxDemoSelectedItem: Option.none(),
|
|
112
114
|
listboxMultiDemo: Listbox.Multi.init({
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Dialog,
|
|
10
10
|
DragAndDrop,
|
|
11
11
|
FileDrop,
|
|
12
|
+
HoverIntent,
|
|
12
13
|
Listbox,
|
|
13
14
|
Menu,
|
|
14
15
|
Popover,
|
|
@@ -59,6 +60,7 @@ export const UiMessage = defineMessageUnion({
|
|
|
59
60
|
GotDragAndDropDemoMessage: { message: DragAndDrop.Message },
|
|
60
61
|
GotFileDropBasicDemoMessage: { message: FileDrop.Message },
|
|
61
62
|
ClickedRemoveFileDropDemoFile: { fileIndex: S.Number },
|
|
63
|
+
GotHoverIntentDemoMessage: { message: HoverIntent.Message },
|
|
62
64
|
GotListboxDemoMessage: { message: Listbox.Message },
|
|
63
65
|
GotListboxMultiDemoMessage: { message: Listbox.Message },
|
|
64
66
|
GotListboxGroupedDemoMessage: { message: Listbox.Message },
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Dialog,
|
|
10
10
|
DragAndDrop,
|
|
11
11
|
FileDrop,
|
|
12
|
+
HoverIntent,
|
|
12
13
|
Listbox,
|
|
13
14
|
Menu,
|
|
14
15
|
Popover,
|
|
@@ -101,6 +102,7 @@ export const UiModel = S.Struct({
|
|
|
101
102
|
dragAndDropDemoColumns: S.Array(DemoColumn),
|
|
102
103
|
fileDropBasicDemo: FileDrop.Model,
|
|
103
104
|
fileDropBasicDemoFiles: S.Array(File.File),
|
|
105
|
+
hoverIntentDemo: HoverIntent.Model,
|
|
104
106
|
listboxDemo: Listbox.Model,
|
|
105
107
|
maybeListboxDemoSelectedItem: S.Option(ListboxItem),
|
|
106
108
|
listboxMultiDemo: Listbox.Multi.Model,
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
Dialog,
|
|
11
11
|
DragAndDrop,
|
|
12
12
|
FileDrop,
|
|
13
|
+
HoverIntent,
|
|
13
14
|
Listbox,
|
|
14
15
|
Menu,
|
|
15
16
|
Popover,
|
|
@@ -120,6 +121,14 @@ const foldTooltipOutMessage = M.type<Tooltip.OutMessage>().pipe(
|
|
|
120
121
|
}),
|
|
121
122
|
)
|
|
122
123
|
|
|
124
|
+
const foldHoverIntentOutMessage = M.type<HoverIntent.OutMessage>().pipe(
|
|
125
|
+
M.withReturnType<Update.Step<UiModel, UiMessage>>(),
|
|
126
|
+
M.tagsExhaustive({
|
|
127
|
+
Opened: () => model => ({ model }),
|
|
128
|
+
Closed: () => model => ({ model }),
|
|
129
|
+
}),
|
|
130
|
+
)
|
|
131
|
+
|
|
123
132
|
const foldMobileMenuDialog = Update.foldChild({
|
|
124
133
|
update: Dialog.update,
|
|
125
134
|
read: (model: UiModel) => Option.some(model.mobileMenuDialog),
|
|
@@ -825,6 +834,15 @@ const foldTooltipNoDelayDemo = Update.foldChild({
|
|
|
825
834
|
foldOutMessage: foldTooltipOutMessage,
|
|
826
835
|
})
|
|
827
836
|
|
|
837
|
+
const foldHoverIntentDemo = Update.foldChild({
|
|
838
|
+
update: HoverIntent.update,
|
|
839
|
+
read: (model: UiModel) => Option.some(model.hoverIntentDemo),
|
|
840
|
+
write: (model, nextHoverIntentDemo) =>
|
|
841
|
+
evo(model, { hoverIntentDemo: () => nextHoverIntentDemo }),
|
|
842
|
+
toParentMessage: message => UiMessage.GotHoverIntentDemoMessage({ message }),
|
|
843
|
+
foldOutMessage: foldHoverIntentOutMessage,
|
|
844
|
+
})
|
|
845
|
+
|
|
828
846
|
const foldAnimationDemoOutMessage: (
|
|
829
847
|
outMessage: Animation.OutMessage,
|
|
830
848
|
context: Update.FoldContext<Animation.Message, UiMessage>,
|
|
@@ -1133,6 +1151,9 @@ export const uiUpdate = (model: UiModel, message: UiMessage) =>
|
|
|
1133
1151
|
GotTooltipNoDelayDemoMessage: ({ message }) =>
|
|
1134
1152
|
foldTooltipNoDelayDemo(model, message),
|
|
1135
1153
|
|
|
1154
|
+
GotHoverIntentDemoMessage: ({ message }) =>
|
|
1155
|
+
foldHoverIntentDemo(model, message),
|
|
1156
|
+
|
|
1136
1157
|
GotAnimationDemoMessage: ({ message }) => foldAnimationDemo(model, message),
|
|
1137
1158
|
|
|
1138
1159
|
ToggledAnimationDemo: () => {
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Submodel } from 'foldkit'
|
|
2
|
+
import type { Html } from 'foldkit/html'
|
|
3
|
+
|
|
4
|
+
import { HoverIntent } from '@foldkit/ui'
|
|
5
|
+
|
|
6
|
+
import { UiMessage } from '../message'
|
|
7
|
+
import type { UiModel } from '../model'
|
|
8
|
+
|
|
9
|
+
const triggerClassName =
|
|
10
|
+
'rounded-lg border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-900 transition hover:border-accent-500 hover:text-accent-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent-600'
|
|
11
|
+
|
|
12
|
+
const panelClassName =
|
|
13
|
+
'absolute left-0 top-full z-10 mt-2 w-72 rounded-lg border border-gray-200 bg-white p-4 shadow-lg'
|
|
14
|
+
|
|
15
|
+
const TRIGGER_ID = 'hover-intent-showcase-trigger'
|
|
16
|
+
const PANEL_ID = 'hover-intent-showcase-panel'
|
|
17
|
+
|
|
18
|
+
export const view = Submodel.defineView<UiModel, UiMessage>((model, h): Html =>
|
|
19
|
+
h.div(
|
|
20
|
+
[],
|
|
21
|
+
[
|
|
22
|
+
h.h2(
|
|
23
|
+
[h.Class('text-2xl font-bold text-gray-900 mb-6')],
|
|
24
|
+
['Hover Intent'],
|
|
25
|
+
),
|
|
26
|
+
h.p(
|
|
27
|
+
[h.Class('mb-4 max-w-xl text-sm text-gray-600')],
|
|
28
|
+
[
|
|
29
|
+
'Hover or focus the trigger, then move into the interactive panel. Press Escape to return focus to the trigger.',
|
|
30
|
+
],
|
|
31
|
+
),
|
|
32
|
+
h.submodel({
|
|
33
|
+
slotId: 'hover-intent-showcase',
|
|
34
|
+
model: model.hoverIntentDemo,
|
|
35
|
+
view: HoverIntent.view,
|
|
36
|
+
viewInputs: {
|
|
37
|
+
focusTriggerSelector: `#${TRIGGER_ID}`,
|
|
38
|
+
toView: ({ trigger, panel, isVisible }) =>
|
|
39
|
+
h.div(
|
|
40
|
+
[h.Class('relative inline-block')],
|
|
41
|
+
[
|
|
42
|
+
h.button(
|
|
43
|
+
[
|
|
44
|
+
...trigger,
|
|
45
|
+
h.Id(TRIGGER_ID),
|
|
46
|
+
h.AriaControls(PANEL_ID),
|
|
47
|
+
h.AriaExpanded(isVisible),
|
|
48
|
+
h.Class(triggerClassName),
|
|
49
|
+
],
|
|
50
|
+
['Preview account'],
|
|
51
|
+
),
|
|
52
|
+
...(isVisible
|
|
53
|
+
? [
|
|
54
|
+
h.div(
|
|
55
|
+
[...panel, h.Id(PANEL_ID), h.Class(panelClassName)],
|
|
56
|
+
[
|
|
57
|
+
h.h3(
|
|
58
|
+
[
|
|
59
|
+
h.Id('hover-intent-showcase-details'),
|
|
60
|
+
h.Class('font-semibold text-gray-900'),
|
|
61
|
+
],
|
|
62
|
+
['Account summary'],
|
|
63
|
+
),
|
|
64
|
+
h.p(
|
|
65
|
+
[h.Class('mt-2 text-sm text-gray-600')],
|
|
66
|
+
['Review your profile and recent activity.'],
|
|
67
|
+
),
|
|
68
|
+
h.a(
|
|
69
|
+
[
|
|
70
|
+
h.Href('#hover-intent-showcase-details'),
|
|
71
|
+
h.Class(
|
|
72
|
+
'mt-3 inline-block text-sm font-medium text-accent-700 underline underline-offset-4',
|
|
73
|
+
),
|
|
74
|
+
],
|
|
75
|
+
['View account details'],
|
|
76
|
+
),
|
|
77
|
+
],
|
|
78
|
+
),
|
|
79
|
+
]
|
|
80
|
+
: []),
|
|
81
|
+
],
|
|
82
|
+
),
|
|
83
|
+
},
|
|
84
|
+
toParentMessage: message =>
|
|
85
|
+
UiMessage.GotHoverIntentDemoMessage({ message }),
|
|
86
|
+
}),
|
|
87
|
+
],
|
|
88
|
+
),
|
|
89
|
+
)
|
|
@@ -8,6 +8,7 @@ export { view as disclosure } from './disclosure'
|
|
|
8
8
|
export { view as dragAndDrop } from './dragAndDrop'
|
|
9
9
|
export { view as fieldset } from './fieldset'
|
|
10
10
|
export { view as fileDrop } from './fileDrop'
|
|
11
|
+
export { view as hoverIntent } from './hoverIntent'
|
|
11
12
|
export { view as input } from './input'
|
|
12
13
|
export { view as listbox } from './listbox'
|
|
13
14
|
export { view as menu } from './menu'
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@foldkit/devtools": "workspace:*",
|
|
18
18
|
"@foldkit/vite-plugin": "workspace:*",
|
|
19
|
-
"@tailwindcss/vite": "^4.3.
|
|
19
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
20
20
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
21
|
-
"happy-dom": "^20.
|
|
22
|
-
"prettier": "^3.
|
|
23
|
-
"tailwindcss": "^4.3.
|
|
24
|
-
"typescript": "^
|
|
25
|
-
"vite": "^8.
|
|
26
|
-
"vitest": "^4.1.
|
|
21
|
+
"happy-dom": "^20.11.13",
|
|
22
|
+
"prettier": "^3.9.6",
|
|
23
|
+
"tailwindcss": "^4.3.3",
|
|
24
|
+
"typescript": "^7.0.2",
|
|
25
|
+
"vite": "^8.2.2",
|
|
26
|
+
"vitest": "^4.1.11"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Array, Effect,
|
|
1
|
+
import { Array, Effect, Option, Schema as S, String } from 'effect'
|
|
2
2
|
import { Command, Runtime, type Update } from 'foldkit'
|
|
3
3
|
import { Document, Html, HtmlBuilder } from 'foldkit/html'
|
|
4
4
|
import { defineMessageUnion } from 'foldkit/message'
|
|
@@ -57,7 +57,6 @@ const LoadExternal = Command.define('LoadExternal', {
|
|
|
57
57
|
// UPDATE
|
|
58
58
|
|
|
59
59
|
type UpdateReturn = Update.Return<Model, Message>
|
|
60
|
-
const withUpdateReturn = M.withReturnType<UpdateReturn>()
|
|
61
60
|
|
|
62
61
|
export const update = (model: Model, message: Message) =>
|
|
63
62
|
Message.match<UpdateReturn>(message, {
|
|
@@ -65,19 +64,16 @@ export const update = (model: Model, message: Message) =>
|
|
|
65
64
|
CompletedLoadExternal: () => ({ model }),
|
|
66
65
|
|
|
67
66
|
ClickedLink: ({ request }) =>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
model,
|
|
73
|
-
commands: [NavigateInternal({ url: urlToString(url) })],
|
|
74
|
-
}),
|
|
75
|
-
External: ({ href }) => ({
|
|
76
|
-
model,
|
|
77
|
-
commands: [LoadExternal({ href })],
|
|
78
|
-
}),
|
|
67
|
+
UrlRequest.match<UpdateReturn>(request, {
|
|
68
|
+
Internal: ({ url }) => ({
|
|
69
|
+
model,
|
|
70
|
+
commands: [NavigateInternal({ url: urlToString(url) })],
|
|
79
71
|
}),
|
|
80
|
-
|
|
72
|
+
External: ({ href }) => ({
|
|
73
|
+
model,
|
|
74
|
+
commands: [LoadExternal({ href })],
|
|
75
|
+
}),
|
|
76
|
+
}),
|
|
81
77
|
|
|
82
78
|
ChangedUrl: ({ url }) => ({
|
|
83
79
|
model: evo(model, { route: () => urlToAppRoute(url) }),
|
|
@@ -105,14 +101,11 @@ export const viewTransition: Runtime.ViewTransitionConfig<Model, Message> = ({
|
|
|
105
101
|
|
|
106
102
|
return Option.match(Transition.enteredAny(transition), {
|
|
107
103
|
onNone: () => true,
|
|
108
|
-
onSome:
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
NotFound: () => true,
|
|
114
|
-
}),
|
|
115
|
-
),
|
|
104
|
+
onSome: AppRoute.match<Runtime.ViewTransitionDecision>({
|
|
105
|
+
Artwork: () => ({ types: ['to-artwork-detail'] }),
|
|
106
|
+
Gallery: () => ({ types: ['to-gallery'] }),
|
|
107
|
+
NotFound: () => true,
|
|
108
|
+
}),
|
|
116
109
|
})
|
|
117
110
|
}
|
|
118
111
|
|
|
@@ -291,26 +284,22 @@ const notFoundView = (path: string, h: HtmlBuilder<Message>): Html =>
|
|
|
291
284
|
)
|
|
292
285
|
|
|
293
286
|
const routeTitle = (route: AppRoute): string =>
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}),
|
|
304
|
-
)
|
|
287
|
+
AppRoute.match(route, {
|
|
288
|
+
Gallery: () => 'View Transitions',
|
|
289
|
+
Artwork: ({ artworkId }) =>
|
|
290
|
+
Option.match(findArtwork(artworkId), {
|
|
291
|
+
onNone: () => 'Artwork Not Found | View Transitions',
|
|
292
|
+
onSome: artwork => `${artwork.title} | View Transitions`,
|
|
293
|
+
}),
|
|
294
|
+
NotFound: () => 'Page Not Found | View Transitions',
|
|
295
|
+
})
|
|
305
296
|
|
|
306
297
|
export const view = (model: Model, h: HtmlBuilder<Message>): Document => {
|
|
307
|
-
const routeContent =
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}),
|
|
313
|
-
)
|
|
298
|
+
const routeContent = AppRoute.match(model.route, {
|
|
299
|
+
Gallery: () => galleryView(model.filterText, h),
|
|
300
|
+
Artwork: ({ artworkId }) => artworkDetailView(artworkId, h),
|
|
301
|
+
NotFound: ({ path }) => notFoundView(path, h),
|
|
302
|
+
})
|
|
314
303
|
|
|
315
304
|
return {
|
|
316
305
|
title: routeTitle(model.route),
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@foldkit/devtools": "workspace:*",
|
|
19
19
|
"@foldkit/vite-plugin": "workspace:*",
|
|
20
|
-
"@tailwindcss/vite": "^4.3.
|
|
20
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
21
21
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
22
|
-
"happy-dom": "^20.
|
|
23
|
-
"prettier": "^3.
|
|
24
|
-
"tailwindcss": "^4.3.
|
|
25
|
-
"typescript": "^
|
|
26
|
-
"vite": "^8.
|
|
27
|
-
"vitest": "^4.1.
|
|
22
|
+
"happy-dom": "^20.11.13",
|
|
23
|
+
"prettier": "^3.9.6",
|
|
24
|
+
"tailwindcss": "^4.3.3",
|
|
25
|
+
"typescript": "^7.0.2",
|
|
26
|
+
"vite": "^8.2.2",
|
|
27
|
+
"vitest": "^4.1.11"
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@foldkit/devtools": "workspace:*",
|
|
22
22
|
"@foldkit/vite-plugin": "workspace:*",
|
|
23
|
-
"@tailwindcss/vite": "^4.3.
|
|
23
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
24
24
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
25
|
-
"happy-dom": "^20.
|
|
26
|
-
"prettier": "^3.
|
|
27
|
-
"tailwindcss": "^4.3.
|
|
28
|
-
"typescript": "^
|
|
29
|
-
"vite": "^8.
|
|
30
|
-
"vitest": "^4.1.
|
|
25
|
+
"happy-dom": "^20.11.13",
|
|
26
|
+
"prettier": "^3.9.6",
|
|
27
|
+
"tailwindcss": "^4.3.3",
|
|
28
|
+
"typescript": "^7.0.2",
|
|
29
|
+
"vite": "^8.2.2",
|
|
30
|
+
"vitest": "^4.1.11"
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@foldkit/devtools": "workspace:*",
|
|
19
19
|
"@foldkit/vite-plugin": "workspace:*",
|
|
20
|
-
"@tailwindcss/vite": "^4.3.
|
|
20
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
21
21
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
22
|
-
"happy-dom": "^20.
|
|
23
|
-
"prettier": "^3.
|
|
24
|
-
"tailwindcss": "^4.3.
|
|
25
|
-
"typescript": "^
|
|
26
|
-
"vite": "^8.
|
|
27
|
-
"vitest": "^4.1.
|
|
22
|
+
"happy-dom": "^20.11.13",
|
|
23
|
+
"prettier": "^3.9.6",
|
|
24
|
+
"tailwindcss": "^4.3.3",
|
|
25
|
+
"typescript": "^7.0.2",
|
|
26
|
+
"vite": "^8.2.2",
|
|
27
|
+
"vitest": "^4.1.11"
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -378,14 +378,12 @@ export const view = (model: Model, h: HtmlBuilder<Message>): Document => ({
|
|
|
378
378
|
|
|
379
379
|
messagesView(model.messages, h),
|
|
380
380
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
}),
|
|
388
|
-
),
|
|
381
|
+
ConnectionState.match(model.connection, {
|
|
382
|
+
Disconnected: () => connectButtonView(h),
|
|
383
|
+
Connecting: () => connectingView(h),
|
|
384
|
+
Connected: () => messageInputView(model.messageInput, h),
|
|
385
|
+
Error: ({ error }) => errorView(error, h),
|
|
386
|
+
}),
|
|
389
387
|
],
|
|
390
388
|
),
|
|
391
389
|
],
|
|
@@ -399,30 +397,22 @@ const connectionStatusView = (
|
|
|
399
397
|
h.div(
|
|
400
398
|
[h.Class('flex items-center gap-2')],
|
|
401
399
|
[
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
h.span([h.Class('text-sm text-gray-600')], ['Disconnected']),
|
|
419
|
-
Connecting: () =>
|
|
420
|
-
h.span([h.Class('text-sm text-gray-600')], ['Connecting...']),
|
|
421
|
-
Connected: () =>
|
|
422
|
-
h.span([h.Class('text-sm text-gray-600')], ['Connected']),
|
|
423
|
-
Error: () => h.span([h.Class('text-sm text-red-600')], ['Error']),
|
|
424
|
-
}),
|
|
425
|
-
),
|
|
400
|
+
ConnectionState.match(connection, {
|
|
401
|
+
Disconnected: () => h.div([h.Class('w-3 h-3 rounded-full bg-red-500')]),
|
|
402
|
+
Connecting: () =>
|
|
403
|
+
h.div([h.Class('w-3 h-3 rounded-full bg-yellow-500 animate-pulse')]),
|
|
404
|
+
Connected: () => h.div([h.Class('w-3 h-3 rounded-full bg-green-500')]),
|
|
405
|
+
Error: () => h.div([h.Class('w-3 h-3 rounded-full bg-red-500')]),
|
|
406
|
+
}),
|
|
407
|
+
ConnectionState.match(connection, {
|
|
408
|
+
Disconnected: () =>
|
|
409
|
+
h.span([h.Class('text-sm text-gray-600')], ['Disconnected']),
|
|
410
|
+
Connecting: () =>
|
|
411
|
+
h.span([h.Class('text-sm text-gray-600')], ['Connecting...']),
|
|
412
|
+
Connected: () =>
|
|
413
|
+
h.span([h.Class('text-sm text-gray-600')], ['Connected']),
|
|
414
|
+
Error: () => h.span([h.Class('text-sm text-red-600')], ['Error']),
|
|
415
|
+
}),
|
|
426
416
|
],
|
|
427
417
|
)
|
|
428
418
|
|