@gramlot/gramlot-examples 0.2.11 → 0.2.14
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/README.md +10 -3
- package/package.json +3 -3
- package/src/gramlot_examples/catalog.json +36 -6
- package/src/gramlot_examples/gallery/dist/frame.js +1742 -5
- package/src/gramlot_examples/gallery/dist/gallery.js +4073 -17144
- package/src/gramlot_examples/gallery/dist/inspector.js +1801 -0
- package/src/gramlot_examples/gallery/dist/notices.json +2 -22
- package/src/gramlot_examples/gallery/dist/theme-styles.js +2 -0
- package/src/gramlot_examples/gallery/gallery-page.js +35 -67
- package/src/gramlot_examples/gallery/gallery.css +23 -94
- package/src/gramlot_examples/index.js +2 -1
- package/src/gramlot_examples/pages/README.md +84 -1
- package/src/gramlot_examples/pages/binding/01_pointers.js +9 -0
- package/src/gramlot_examples/pages/binding/01_pointers.md +56 -9
- package/src/gramlot_examples/pages/binding/02_variable_datapath.md +50 -4
- package/src/gramlot_examples/pages/binding/03_setters_and_defaults.md +45 -6
- package/src/gramlot_examples/pages/binding/04_native_editing.md +48 -6
- package/src/gramlot_examples/pages/binding/05_checkbox_radio.md +44 -4
- package/src/gramlot_examples/pages/binding/06_style_and_visibility.md +40 -6
- package/src/gramlot_examples/pages/binding/07_bound_svg.md +48 -3
- package/src/gramlot_examples/pages/binding/08_freeze.js +1 -1
- package/src/gramlot_examples/pages/binding/08_freeze.md +44 -6
- package/src/gramlot_examples/pages/binding/09_forms.js +2 -1
- package/src/gramlot_examples/pages/binding/09_forms.md +53 -7
- package/src/gramlot_examples/pages/binding/10_svg_shapes.md +50 -5
- package/src/gramlot_examples/pages/binding/11_complete_page.md +53 -7
- package/src/gramlot_examples/pages/binding/README.md +34 -0
- package/src/gramlot_examples/pages/controllers/01_formula.md +48 -7
- package/src/gramlot_examples/pages/controllers/02_controller.js +24 -2
- package/src/gramlot_examples/pages/controllers/02_controller.md +61 -6
- package/src/gramlot_examples/pages/controllers/03_named_logic.md +63 -7
- package/src/gramlot_examples/pages/controllers/04_inline_expressions.md +50 -7
- package/src/gramlot_examples/pages/controllers/05_node_methods.md +41 -7
- package/src/gramlot_examples/pages/controllers/06_button_controller.md +49 -6
- package/src/gramlot_examples/pages/controllers/07_events.md +45 -6
- package/src/gramlot_examples/pages/controllers/08_end_to_end.js +26 -1
- package/src/gramlot_examples/pages/controllers/08_end_to_end.md +138 -9
- package/src/gramlot_examples/pages/controllers/09_endpoint.md +47 -7
- package/src/gramlot_examples/pages/controllers/10_call_on_change.md +48 -8
- package/src/gramlot_examples/pages/controllers/11_call_on_click.js +6 -0
- package/src/gramlot_examples/pages/controllers/11_call_on_click.md +58 -6
- package/src/gramlot_examples/pages/controllers/12_remote.md +55 -8
- package/src/gramlot_examples/pages/controllers/13_cached_remote.js +2 -2
- package/src/gramlot_examples/pages/controllers/13_cached_remote.md +62 -7
- package/src/gramlot_examples/pages/controllers/14_data_remote.js +10 -2
- package/src/gramlot_examples/pages/controllers/14_data_remote.md +65 -6
- package/src/gramlot_examples/pages/controllers/15_lifecycle.js +51 -0
- package/src/gramlot_examples/pages/controllers/15_lifecycle.md +59 -0
- package/src/gramlot_examples/pages/controllers/16_attribute_projection.js +25 -0
- package/src/gramlot_examples/pages/controllers/16_attribute_projection.md +58 -0
- package/src/gramlot_examples/pages/controllers/17_data_exchange.js +51 -0
- package/src/gramlot_examples/pages/controllers/17_data_exchange.md +61 -0
- package/src/gramlot_examples/pages/controllers/18_publish_subscribe.js +36 -0
- package/src/gramlot_examples/pages/controllers/18_publish_subscribe.md +20 -0
- package/src/gramlot_examples/pages/controllers/19_frame_messages.js +39 -0
- package/src/gramlot_examples/pages/controllers/19_frame_messages.md +20 -0
- package/src/gramlot_examples/pages/controllers/README.md +57 -1
- package/src/gramlot_examples/pages/html_svg/01_hello_world.md +48 -4
- package/src/gramlot_examples/pages/html_svg/02_text_and_links.md +42 -4
- package/src/gramlot_examples/pages/html_svg/03_lists.md +45 -4
- package/src/gramlot_examples/pages/html_svg/04_semantic_page.md +44 -4
- package/src/gramlot_examples/pages/html_svg/05_tables.md +46 -4
- package/src/gramlot_examples/pages/html_svg/06_forms.md +48 -4
- package/src/gramlot_examples/pages/html_svg/07_native_disclosure.md +41 -4
- package/src/gramlot_examples/pages/html_svg/08_svg_shapes.md +45 -4
- package/src/gramlot_examples/pages/html_svg/09_svg_composition.md +44 -4
- package/src/gramlot_examples/pages/html_svg/10_cards_with_icons.md +42 -15
- package/src/gramlot_examples/pages/html_svg/11_static_report.md +37 -4
- package/src/gramlot_examples/pages/html_svg/12_complete_page.md +41 -4
- package/src/gramlot_examples/pages/html_svg/13_live_source.md +47 -16
- package/src/gramlot_examples/pages/html_svg/README.md +36 -0
|
@@ -1,9 +1,46 @@
|
|
|
1
1
|
# 12 · A complete page
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A complete event page that combines the HTML and SVG pieces from this section. You learn how to organize a larger page into small building methods. Later, **Complete page with binding** makes the same page follow shared Data.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Uses:** Source and native HTML/SVG — core 0.1.x. No Data binding.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
<details>
|
|
8
|
+
<summary>More detail</summary>
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
**Release stage:** Source foundation (core 0.1.x); maintained syntax is used here.
|
|
12
|
+
|
|
13
|
+
**Goal:** Assemble a complete static page from already understood Source sections.
|
|
14
|
+
|
|
15
|
+
**Before this lesson:** [e04 · Semantic page](https://github.com/gramlot-org/gramlot-examples/blob/main/src/gramlot_examples/pages/html_svg/04_semantic_page.md), [e07 · Native disclosure](https://github.com/gramlot-org/gramlot-examples/blob/main/src/gramlot_examples/pages/html_svg/07_native_disclosure.md), [e09 · SVG composition](https://github.com/gramlot-org/gramlot-examples/blob/main/src/gramlot_examples/pages/html_svg/09_svg_composition.md), [e11 · Static report](https://github.com/gramlot-org/gramlot-examples/blob/main/src/gramlot_examples/pages/html_svg/11_static_report.md). These prerequisites support the release sequence; later comparisons are explicitly labelled below.
|
|
16
|
+
|
|
17
|
+
**Open and edit:** select **e12 · Complete page** in your environment’s gallery. For source changes, copy/edit the matching page in your own project using the [setup guide](https://github.com/gramlot-org/gramlot/blob/main/docs/public/025-try.md); the gallery is a source viewer. Save, then reload/reopen as that guide explains. The snippets below are excerpts/edits within that Page, not standalone launch commands.
|
|
18
|
+
|
|
19
|
+
## Read the page
|
|
20
|
+
|
|
21
|
+
`main` calls helpers for header, hero, highlights, schedule, speakers, map and FAQ. The schedule and speaker cards read local tuples. Native anchor links connect the navigation to section IDs; the map is an SVG illustration.
|
|
22
|
+
|
|
23
|
+
Python builds Source on the server; its JavaScript counterpart builds it on Node/Bun or in a standalone Worker. Bindings, actions and any Logic execute in the browser; Python strings containing JavaScript are not executed by Python.
|
|
24
|
+
|
|
25
|
+
## Try it and predict the result
|
|
26
|
+
|
|
27
|
+
1. Follow Schedule and count three sessions; Speakers shows Mira and Theo.
|
|
28
|
+
2. Open the FAQ about the map: it says the map is not interactive. There is no booking action.
|
|
29
|
+
|
|
30
|
+
## Change it and check yourself
|
|
31
|
+
|
|
32
|
+
Add a fourth session tuple, then change the table caption from “Three short sessions” to “Four short sessions”.
|
|
33
|
+
|
|
34
|
+
**Answer:** four rows appear after reload; the caption requires its own edit because it is literal. Adding a speaker to a session does not automatically add a speaker card: `SPEAKERS` is a separate dataset.
|
|
35
|
+
|
|
36
|
+
## The same example across stages
|
|
37
|
+
|
|
38
|
+
Keep this page as the earlier stage. In **0.2.0**, [b11 · Complete page with binding](https://github.com/gramlot-org/gramlot-examples/blob/main/src/gramlot_examples/pages/binding/11_complete_page.md) revisits the event page: one Data title drives multiple texts, one speaker flag controls both row and card, and one FAQ flag controls every answer. These shared pointers eliminate separate update code for each destination; the new controls make the later page richer rather than universally shorter.
|
|
39
|
+
|
|
40
|
+
## Limits and next step
|
|
41
|
+
|
|
42
|
+
“Complete” means a composed example of the features at this stage, not a booking application or coverage of all Gramlot APIs.
|
|
43
|
+
|
|
44
|
+
Continue with [e13 · Live Source playground](https://github.com/gramlot-org/gramlot-examples/blob/main/src/gramlot_examples/pages/html_svg/13_live_source.md). The [authoring reference](https://github.com/gramlot-org/gramlot/blob/main/docs/public/095-writing-pages.md) explains the full contract.
|
|
45
|
+
|
|
46
|
+
</details>
|
|
@@ -1,18 +1,49 @@
|
|
|
1
1
|
# 13 · Live Source playground
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
A playground for adding, removing and changing parts of a running page, including a small SVG animation. You learn how Source changes affect the screen and why a timer must stop when its page is removed. Try this after **Events** and **Lifecycle**.
|
|
4
|
+
|
|
5
|
+
**Uses:** Live Source and browser actions (0.2.0), with the `src` name from 0.2.10. No Data binding.
|
|
6
|
+
|
|
7
|
+
<details>
|
|
8
|
+
<summary>More detail</summary>
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
**Release stage:** Source foundation (core 0.1.x); maintained syntax is used here. The interactive controls are a later 0.2.0 layer; return to them after c07. The src proxy spelling is from 0.2.10.
|
|
12
|
+
|
|
13
|
+
**Goal:** Separate live Source changes from Data reactivity and release an owned timer.
|
|
14
|
+
|
|
15
|
+
**Before this lesson:** [e10 · Cards with icons](https://github.com/gramlot-org/gramlot-examples/blob/main/src/gramlot_examples/pages/html_svg/10_cards_with_icons.md), [c07 · Events](https://github.com/gramlot-org/gramlot-examples/blob/main/src/gramlot_examples/pages/controllers/07_events.md). These prerequisites support the release sequence; later comparisons are explicitly labelled below.
|
|
16
|
+
|
|
17
|
+
**Open and edit:** select **e13 · Live Source playground** in your environment’s gallery. For source changes, copy/edit the matching page in your own project using the [setup guide](https://github.com/gramlot-org/gramlot/blob/main/docs/public/025-try.md); the gallery is a source viewer. Save, then reload/reopen as that guide explains. The snippets below are excerpts/edits within that Page, not standalone launch commands. This lesson executes authored inline JavaScript and needs the gallery’s permissive CSP profile; a strict named-Logic starter needs the corresponding named form.
|
|
18
|
+
|
|
19
|
+
## Read the page
|
|
20
|
+
|
|
21
|
+
Buttons declare browser actions on Source: `wrapSource(...).li(...)` adds an item; `popNode`/`clear` remove children; `setValue` changes text; `setAttr` changes the circle. They never build application DOM directly.
|
|
22
|
+
|
|
23
|
+
The authored script schedules a 50 ms interval updating the Source `cx`. `renderer.onDispose(motion, ...)` clears it when its section is removed. The script is browser JavaScript, including when declared by Python; the Logic class in the module is empty.
|
|
24
|
+
|
|
25
|
+
Python builds Source on the server; its JavaScript counterpart builds it on Node/Bun or in a standalone Worker. Bindings, actions and any Logic execute in the browser; Python strings containing JavaScript are not executed by Python.
|
|
26
|
+
|
|
27
|
+
## Try it and predict the result
|
|
28
|
+
|
|
29
|
+
1. Begin with two list items. Add one: expect three. Remove last: expect two. Clear list: expect none.
|
|
30
|
+
2. Change heading: it becomes “Source is alive!”. Change ball color while it moves.
|
|
31
|
+
3. Remove animation: the entire motion section disappears and its disposal callback clears the interval. Reload restores the original list and animation.
|
|
32
|
+
|
|
33
|
+
## Change it and check yourself
|
|
34
|
+
|
|
35
|
+
Change the interval delay from 50 to 100 ms in the authored script. Keep the same `onDispose` cleanup.
|
|
36
|
+
|
|
37
|
+
**Answer:** updates occur about half as often; the position still depends on elapsed time, so the motion becomes less smooth, not half-speed. Removing the section must still release the interval.
|
|
38
|
+
|
|
39
|
+
## The same example across stages
|
|
40
|
+
|
|
41
|
+
In **0.2.0**, [b07 · Bound SVG](https://github.com/gramlot-org/gramlot-examples/blob/main/src/gramlot_examples/pages/binding/07_bound_svg.md) makes geometry follow Data (`r="^.radius"`), while c02 supplies declarative timing for a controller. A repeated task can then use `_timing` with lifecycle managed by its provider. That reduces timer/setup/cleanup code for that task; it does not mean the existing Source animation has secretly become a binding.
|
|
42
|
+
|
|
43
|
+
## Limits and next step
|
|
44
|
+
|
|
45
|
+
This advanced bridge uses a Source script and inline actions, so it is not a pure 0.1.x executable snapshot. No Data persistence or server synchronization is present. Do not copy the timer without its cleanup.
|
|
46
|
+
|
|
47
|
+
Continue with [b01 · Pointers](https://github.com/gramlot-org/gramlot-examples/blob/main/src/gramlot_examples/pages/binding/01_pointers.md). The [authoring reference](https://github.com/gramlot-org/gramlot/blob/main/docs/public/095-writing-pages.md) explains the full contract.
|
|
48
|
+
|
|
49
|
+
</details>
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# HTML / SVG
|
|
2
2
|
|
|
3
|
+
Build pages from text, lists, tables, forms and drawings, then combine those pieces into a complete page.
|
|
4
|
+
|
|
5
|
+
**This section uses only Source to declare native HTML and SVG: the core 0.1.x foundation, before Data binding and controllers.** Forms already allow typing and Reset because those are browser features.
|
|
6
|
+
|
|
7
|
+
Start with **Hello World**. The Binding section later revisits the same forms, drawings and complete page to show what binding adds.
|
|
8
|
+
|
|
9
|
+
**Later follow-ups:** the × buttons in **Cards with icons** and the **Live Source playground** use browser actions from 0.2.0 and the `src` name from 0.2.10. Return to these parts after **Events** and **Lifecycle**.
|
|
10
|
+
|
|
11
|
+
<details>
|
|
12
|
+
<summary>More detail</summary>
|
|
13
|
+
|
|
14
|
+
|
|
3
15
|
Learn to build a page with Gramlot: each instruction adds an element, and nested instructions describe its structure.
|
|
4
16
|
|
|
5
17
|
Start with **Hello World**, then explore text, lists, tables and form controls. Continue with SVG shapes and combine them with HTML. The final examples use methods and loops to compose larger pages from simple parts.
|
|
@@ -8,3 +20,27 @@ Compare each preview with its code, then try the small change suggested in the e
|
|
|
8
20
|
|
|
9
21
|
Finish with **Live Source playground**: change the page while it is running and
|
|
10
22
|
watch a small SVG animation driven by Source attributes. The live examples also run in the static gallery of `gramlot-serverless gallery <folder>`, opened from disk, offline.
|
|
23
|
+
|
|
24
|
+
## Prerequisites within the release sequence
|
|
25
|
+
|
|
26
|
+
Start with e01/e03 for structure. HTML details (e02/e04/e05/e06/e07) and
|
|
27
|
+
SVG (e08/e09/e11) are optional branches. e10/e13 are advanced live Source lessons:
|
|
28
|
+
read c07's event explanation first and learn removal/cleanup before adapting the
|
|
29
|
+
animation. A loop in main builds Source once; it is not reactive Data. See the
|
|
30
|
+
[release-by-release route](https://github.com/gramlot-org/gramlot/blob/main/docs/public/025-try.md#gc-025-015). Prerequisites support the
|
|
31
|
+
chronological sequence; they do not replace it. The maintained files may use
|
|
32
|
+
later APIs, so they are not snapshots of the earliest release.
|
|
33
|
+
|
|
34
|
+
## How to work through a lesson
|
|
35
|
+
|
|
36
|
+
Read its core release stage first, then its goal and prerequisites. Open the
|
|
37
|
+
existing preview, predict the guided result, and only then try the source-change
|
|
38
|
+
exercise in your own editable page. Each exercise includes an answer. Follow
|
|
39
|
+
"The same example across stages" links to compare earlier/later declarations;
|
|
40
|
+
keep both stages visible. A newer interactive page can contain more total code
|
|
41
|
+
while requiring less explicit state synchronization or request coordination.
|
|
42
|
+
|
|
43
|
+
e10/e13 contain inline actions/scripts; their empty Logic class is not the source
|
|
44
|
+
of those actions. They are advanced bridges to the 0.2.0 behavior lessons.
|
|
45
|
+
|
|
46
|
+
</details>
|