Skip to content

Commit ded0b6d

Browse files
committed
More details
1 parent ccb9f3b commit ded0b6d

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

rfcs/2024-05-21-ui-component-model.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,43 @@ Context: converge on a default UI component model for LLM-generated UI.
1919

2020
### Technical goals
2121

22-
- Components are **encapsulated**
22+
- Components are **encapsulated** (P1)
2323
- A component may control its child tree, but not its siblings or parent
24-
- Components have **inputs**, and **output UI** and **events**
25-
- Components are pure-ish functions of state (we may allow cheats for local component state ala hooks)
24+
- Components have **inputs**, and **output UI** and **events** (P1)
25+
- Components can be understood as pure-ish functions that receive props and return a view description (we may allow cheats for local component state ala hooks)
2626
- Components are **black boxes**
2727
- Components are decoupled and only communicate via input and output channels.
28-
- Component **inputs** and **outputs** are **statically-typed**
28+
- Component **inputs** and **outputs** are **statically-typed** (P1)
2929
- E.g. via TypeScript
3030
- Allows the runtime to enforce data policies on component
31-
- Components have **local state**
31+
- Components have **local state** (P1)
3232
- State is encapsulated within component
3333
- Components may pass state down to child components as input
3434
- E.g. the React **[“lifting state up” pattern](https://legacy.reactjs.org/docs/lifting-state-up.html)**.
3535
- Local state may be **persisted**.
3636
- If it isn’t, it is **ephemeral**, and lasts for the lifetime of the component.
37-
- Components are **islands**
37+
- Components are **islands** (P1)
3838
- Components can be used free-standing, or within a larger component tree.
39-
- Note: in something like the Elm App Architecture Pattern, Models, Views, and Update functions are “zippered” together, meaning components are “some assembly required”. This would fall short of this goal without some additional means of making an individual component free-standing.
40-
- Components are **composable**
39+
- Note: this is in contrast to something like the Elm App Architecture Pattern, where models, views, and update functions are “zippered” together, meaning components are “some assembly required”. This would fall short of this goal without some additional means of making an individual component a free-standing island.
40+
- Components are **composable** (P1)
4141
- Components can be combined together like lego to create larger components
4242
- Composing plugins should be as easy as plugging together component inputs, outputs, and events, and arranging a UI tree. It shouldn’t be more complicated than that.
43-
- Components can have **holes**, allowing you to slot in an arbitrary component of the right shape.
43+
- Components can have **holes**, allowing you to slot in an arbitrary component of the right shape. (P1)
4444
- Inversion of control for templates.
4545
- The shape of the hole is determined by the data’s input and output types
4646
- Example mechanisms
4747
- [slots](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_templates_and_slots)
4848
- [passing down closures that evaluate to components](https://swiftwithmajid.com/2019/11/06/the-power-of-closures-in-swiftui/)
4949
- [overridable blocks](https://mustache.github.io/mustache.5.html#Blocks)
50-
- Components have **[high locality of behavior](https://github.com/gordonbrander/generative-ui-playbook?tab=readme-ov-file#llms-work-best-with-high-locality)**
50+
- Components have **[high locality of behavior](https://github.com/gordonbrander/generative-ui-playbook?tab=readme-ov-file#llms-work-best-with-high-locality)** (P1)
51+
- All component behavior is colocated, including structure, style, and behavior
5152
- Components are relatively **small**
5253
- LLMs will have higher accuracy generating small islands of interactivity vs whole apps
5354
- Small composable components are easier to understand and debug
54-
- UI **templates** are **pure functions of state**
55+
- UI **templates** are **pure functions** (P1)
5556
- Templates take inputs, and output a UI tree and events
5657
- Templates produce a UI tree that is easy for the runtime to analyze and sanitize (probably a VDOM, probably not raw DOM).
57-
- Components are renderable to web
58+
- Components are renderable to web (P1)
5859
- Other platforms may be supported in future, but web platform is primary
5960

6061
Soft goals:

0 commit comments

Comments
 (0)