A layer's specs and its code as CSS or a component, with copy, for handoff.
Habit card
- Position
- 24px, 136px
- Size
- 342px × 88px
- Radius
- 16px
- Fill
- #FFFFFF
- Shadow
- 0px 2px 8px 0px · #000000 10%
.habitCard {
width: 342px;
height: 88px;
border-radius: 16px;
background: #FFFFFF;
box-shadow: 0px 2px 8px 0px rgb(0 0 0 / 0.102);
}import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { type CodeFormat, InspectPanel } from "./ui/uicontext/components/canvas/InspectPanel.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { habitScreens } from "./canvas.ts"const styles = stylex.create({ panel: { inlineSize: "min(100%, 300px)", borderWidth: 1, borderStyle: "solid", borderColor: "light-dark(#ececef, #232327)", borderRadius: 12 } })const Message = UiSchema.TaggedEnum({ PickedFormat: { format: Schema.Literals(["css", "jsx"]) } })const card = habitScreens.find((s) => s.id === "home-card-1")!const home = habitScreens.find((s) => s.id === "home")!// A habit card's specs, its position in its frame, and its CSS with a copy button.export const CardSpecs = Html.component({ name: "CardSpecs", model: Schema.Struct({ format: Schema.Literals(["css", "jsx"]) }), message: Message,}).make({ init: () => ({ format: "css" as CodeFormat }), update: { PickedFormat: ($, { format }) => $.evolve({ format }) }, view: (h, { format }) => h.div.attrs(sx(styles.panel)).children(InspectPanel(h, { shape: card, parent: home, format, onFormat: (f) => Message.PickedFormat({ format: f }) })),})Installation
pnpm dlx shadcn@latest add checkfu/uicontext/inspect-panelUsage
import { InspectPanel } from "./ui/uicontext/components/canvas/InspectPanel.ts"import type { Shape } from "./ui/uicontext/components/canvas/Scene.ts"const Message = UiSchema.TaggedEnum({ PickedFormat: { format: Schema.Literals(["css", "jsx"]) } })export const Specs = (h: Html.H<typeof Message.Type>, shape: Shape | null, format: "css" | "jsx") => InspectPanel(h, { shape, format, onFormat: (f) => Message.PickedFormat({ format: f }) })API reference
Options
| Name | Type | Description |
|---|---|---|
shaperequired | Shape | null | — |
parent | Shape | null | The frame the shape sits in, for its position |
main | Shape | An instance's main component, for its code |
formatrequired | "css" | "jsx" | — |
onFormatrequired | (format: CodeFormat) => Message | — |