You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: rfcs/2024-05-21-ui-component-model.md
+15-12Lines changed: 15 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@ Context: converge on a default UI component model for LLM-generated UI.
11
11
Product goals:
12
12
13
13
- Easy for LLMs to generate
14
+
- Leverages patterns and/or frameworks that are widely present in the training data, or can be learned within a small context window.
14
15
- Easy for humans to edit
15
16
- Leverages familiar or established patterns for UI development
16
17
- Conformable with existing web FE toolchains.
@@ -22,14 +23,17 @@ Technical goals:
22
23
- Components are black boxes, with inputs and outputs
23
24
- Components have inputs, and output UI and events
24
25
- Are pure-ish functions of state (we may allow cheats for local component state ala hooks)
25
-
- Components have statically-typed inputs and outputs
26
-
- E.g. via TypeScript
27
-
- Allows the runtime to enforce data policies on component
26
+
- Component inputs and outputs are statically-typed
27
+
- E.g. via TypeScript
28
+
- Allows the runtime to enforce data policies on component
28
29
- Components have local state
29
30
- State is encapsulated within component
30
31
- Components may pass state down to child components as input
31
32
- E.g. the React “[lifting state up](https://legacy.reactjs.org/docs/lifting-state-up.html)” pattern.
32
33
- Local state may be persisted. If it isn’t, it is ephemeral, and lasts for the lifetime of the component.
34
+
- Components are islands
35
+
- Components can be used free-standing, or within a larger component tree.
36
+
- 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.
33
37
- Components are composable
34
38
- Components can be combined together like lego to create larger components
35
39
- Composition should involve plugging together component inputs, outputs, and events, and arranging UI tree. It shouldn’t be more complicated than that.
@@ -38,24 +42,23 @@ Technical goals:
38
42
- The shape of the hole is determined by the data input and output types
39
43
- Example mechanisms: [slots](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_templates_and_slots), [passing down closures that evaluate to components](https://swiftwithmajid.com/2019/11/06/the-power-of-closures-in-swiftui/), [overridable blocks](https://mustache.github.io/mustache.5.html#Blocks), etc.
40
44
- Components have [high locality of behavior](https://github.com/gordonbrander/generative-ui-playbook?tab=readme-ov-file#llms-work-best-with-high-locality)
41
-
- Components are islands
42
-
- Components can be used free-standing, or within a larger component tree.
43
-
- 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.
44
-
- UI templates are pure
45
-
- They take inputs, and output a UI tree and events
46
-
- They produce a UI tree that is easy for the runtime to analyze and sanitize (probably a VDOM, probably not raw DOM).
45
+
- UI templates are pure functions of state
46
+
- Templates take inputs, and output a UI tree and events
47
+
- Templates produce a UI tree that is easy for the runtime to analyze and sanitize (probably a VDOM, probably not raw DOM).
47
48
- Components can be rendered on the web platform
48
49
49
50
Soft goals:
50
-
- Static templates
51
+
- UI templates are static
52
+
- They are compiled once at program start, and produce a static tree with specific “binding points” in the tree, where dynamic values and dynamic lists are rendered.
53
+
- This may have a performance advantage over a totally dynamic VDOM tree, since it would allow us to analyze and enforce policies on the tree once, rather than after every render
51
54
52
55
Non-goals:
53
56
54
57
- Separation of concerns. At odds with high locality of behavior.
0 commit comments