From 0060bb792adc5c62f99bccf6e0511baaa14eac59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Sun, 6 Jul 2025 03:21:05 +0200 Subject: [PATCH] Example work --- bun.lock | 3 + packages/example/package.json | 3 +- packages/example/src/todo/Todo.tsx | 133 +++++++++++++++++----------- packages/example/src/todo/Todos.tsx | 22 +---- 4 files changed, 88 insertions(+), 73 deletions(-) diff --git a/bun.lock b/bun.lock index ec0cbc9..25eebc8 100644 --- a/bun.lock +++ b/bun.lock @@ -36,6 +36,7 @@ "effect-fc": "workspace:*", "lucide-react": "^0.510.0", "mobx": "^6.13.7", + "react-icons": "^5.5.0", }, "devDependencies": { "@effect/language-service": "^0.23.4", @@ -725,6 +726,8 @@ "react-dom": ["react-dom@19.1.0", "", { "dependencies": { "scheduler": "^0.26.0" }, "peerDependencies": { "react": "^19.1.0" } }, "sha512-Xs1hdnE+DyKgeHJeJznQmYMIBG3TKIHJJT95Q58nHLSrElKlGQqDTR2HQ9fx5CN/Gk6Vh/kupBTDLU11/nDk/g=="], + "react-icons": ["react-icons@5.5.0", "", { "peerDependencies": { "react": "*" } }, "sha512-MEFcXdkP3dLo8uumGI5xN3lDFNsRtrjbOEKDLD7yv76v4wpnEq2Lt2qeHaQOr34I/wPN3s3+N08WkQ+CW37Xiw=="], + "react-refresh": ["react-refresh@0.17.0", "", {}, "sha512-z6F7K9bV85EfseRCp2bzrpyQ0Gkw1uLoCel9XBVWPg/TjRj94SkJzUTGfOa4bs7iJvBWtQG0Wq7wnI0syw3EBQ=="], "react-remove-scroll": ["react-remove-scroll@2.7.1", "", { "dependencies": { "react-remove-scroll-bar": "^2.3.7", "react-style-singleton": "^2.2.3", "tslib": "^2.1.0", "use-callback-ref": "^1.3.3", "use-sidecar": "^1.1.3" }, "peerDependencies": { "@types/react": "*", "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-HpMh8+oahmIdOuS5aFKKY6Pyog+FNaZV/XyJOq7b4YFwsFHe5yYfdbIalI4k3vU2nSDql7YskmUseHsRrJqIPA=="], diff --git a/packages/example/package.json b/packages/example/package.json index 2d2e941..44515c9 100644 --- a/packages/example/package.json +++ b/packages/example/package.json @@ -37,9 +37,10 @@ "@typed/id": "^0.17.2", "@typed/lazy-ref": "^0.3.3", "effect": "^3.15.1", + "effect-fc": "workspace:*", "lucide-react": "^0.510.0", "mobx": "^6.13.7", - "effect-fc": "workspace:*" + "react-icons": "^5.5.0" }, "overrides": { "effect": "^3.15.1", diff --git a/packages/example/src/todo/Todo.tsx b/packages/example/src/todo/Todo.tsx index 314b08a..13a6872 100644 --- a/packages/example/src/todo/Todo.tsx +++ b/packages/example/src/todo/Todo.tsx @@ -1,63 +1,15 @@ import * as Domain from "@/domain" -import { Button, Flex, TextArea } from "@radix-ui/themes" +import { Box, Button, Flex, IconButton, TextArea } from "@radix-ui/themes" import { GetRandomValues, makeUuid4 } from "@typed/id" import { Chunk, Effect, Match, Option, Ref, Runtime, SubscriptionRef } from "effect" import { Component, Hook } from "effect-fc" import { SubscriptionSubRef } from "effect-fc/types" import * as React from "react" +import { FaArrowDown, FaArrowUp } from "react-icons/fa" +import { FaDeleteLeft } from "react-icons/fa6" import { TodosState } from "./TodosState.service" -export type TodoProps = ( - | { - readonly _tag: "new" - readonly ref?: never - } - | { - readonly _tag: "edit" - readonly ref: SubscriptionRef.SubscriptionRef - } -) - -export const Todo = Component.make(function* Todo(props: TodoProps) { - const runtime = yield* Effect.runtime() - const state = yield* TodosState - - const ref = yield* Hook.useMemo(() => Match.value(props).pipe( - Match.tag("new", () => Effect.andThen(makeTodo, SubscriptionRef.make)), - Match.tag("edit", ({ ref }) => Effect.succeed(ref)), - Match.exhaustive, - ), [props._tag, props.ref]) - - const contentRef = React.useMemo(() => SubscriptionSubRef.makeFromPath(ref, ["content"]), [ref]) - const [todo] = yield* Hook.useSubscribeRefs(ref) - - return ( - -