janela 0.7.0 → 0.9.0

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -0
  3. data/README.md +36 -5
  4. data/UPGRADING.md +111 -0
  5. data/app/assets/javascripts/janela/frame_controller.js +15 -0
  6. data/app/assets/stylesheets/janela.css +29 -0
  7. data/app/controllers/janela/application_controller.rb +7 -0
  8. data/app/controllers/janela/panes_controller.rb +22 -7
  9. data/app/controllers/janela/queries_controller.rb +2 -1
  10. data/app/helpers/janela/frames_helper.rb +26 -7
  11. data/app/models/janela/frame.rb +20 -0
  12. data/app/models/janela/pane.rb +67 -4
  13. data/app/models/janela/query.rb +7 -2
  14. data/app/views/janela/frames/_content.html.erb +26 -0
  15. data/app/views/janela/frames/_frame.html.erb +9 -1
  16. data/app/views/janela/frames/_pane.html.erb +2 -2
  17. data/app/views/janela/panes/_content_form.html.erb +33 -0
  18. data/app/views/janela/panes/_row.html.erb +1 -1
  19. data/app/views/janela/panes/edit.html.erb +5 -1
  20. data/app/views/janela/panes/new.html.erb +6 -1
  21. data/app/views/janela/queries/_query.html.erb +15 -11
  22. data/config/locales/en.yml +5 -0
  23. data/db/migrate/20260924000001_add_content_to_janela_panes.rb +16 -0
  24. data/db/migrate/20260924000002_add_key_to_janela_frames.rb +10 -0
  25. data/docs/composing.md +269 -0
  26. data/docs/decisions/032-janela-will-not-read-a-model-it-cannot-scope.md +1 -0
  27. data/docs/decisions/035-a-check-does-what-janela-does-or-says-what-it-saw.md +262 -0
  28. data/docs/decisions/036-janela-publishes-what-a-theme-may-target.md +171 -0
  29. data/docs/decisions/037-what-1-0-means.md +172 -0
  30. data/docs/decisions/038-a-ratio-is-a-measure-of-its-own.md +194 -0
  31. data/docs/decisions/039-a-pane-can-hold-words-and-only-code-writes-markup.md +168 -0
  32. data/docs/decisions/040-a-host-can-fix-a-frames-filter.md +145 -0
  33. data/docs/decisions/041-a-host-finds-its-frame-by-owner-and-key.md +112 -0
  34. data/docs/decisions/042-a-charts-title-is-a-figcaption.md +174 -0
  35. data/docs/decisions/INDEX.md +26 -15
  36. data/docs/multi-tenancy.md +22 -0
  37. data/docs/naming.md +7 -0
  38. data/docs/roadmap.md +218 -0
  39. data/docs/theming.md +179 -0
  40. data/lib/janela/definition.rb +16 -1
  41. data/lib/janela/doctor.rb +121 -32
  42. data/lib/janela/model.rb +6 -1
  43. data/lib/janela/version.rb +1 -1
  44. data/lib/janela.rb +47 -3
  45. metadata +30 -15
@@ -7,7 +7,7 @@ module Janela
7
7
  class Query
8
8
  RENDERERS = %w[table bar line].freeze
9
9
 
10
- attr_reader :definition, :measure, :dimension, :renderer, :limit, :filters, :snapshot
10
+ attr_reader :definition, :measure, :dimension, :renderer, :limit, :filters, :fixed, :snapshot
11
11
 
12
12
  # The helper renders the turbo frame and the controller renders its
13
13
  # replacement, so both derive the id the same way from the same parameters.
@@ -17,13 +17,14 @@ module Janela
17
17
  parts.compact.join("_")
18
18
  end
19
19
 
20
- def initialize(definition:, measure:, dimension: nil, renderer: "table", granularity: nil, limit: nil, filters: {}, snapshot: nil, title: nil)
20
+ def initialize(definition:, measure:, dimension: nil, renderer: "table", granularity: nil, limit: nil, filters: {}, fixed: {}, snapshot: nil, title: nil)
21
21
  @definition = definition
22
22
  @title = title
23
23
  @measure = measure
24
24
  @dimension = dimension
25
25
  @renderer = renderer.to_s
26
26
  @filters = filters
27
+ @fixed = fixed
27
28
  @snapshot = snapshot
28
29
 
29
30
  raise BadRequest, "unknown pane renderer #{renderer.inspect}" unless RENDERERS.include?(@renderer)
@@ -97,6 +98,10 @@ module Janela
97
98
  def result(on: nil)
98
99
  return snapshot.stored_result(self) if frozen?
99
100
 
101
+ # The fixed filter applies even on this pane's own dimension, unlike the
102
+ # reader's: it is the host saying which rows the frame is about, not a
103
+ # selection this pane should show the alternatives to (ADR 040).
104
+ on = definition.narrow(on || model.all, fixed) if fixed.present?
100
105
  definition.query(measure, by: dimension, where: applicable_filters, on: on, granularity: granularity, limit: limit)
101
106
  end
102
107
 
@@ -0,0 +1,26 @@
1
+ <%# Words an analyst wrote, escaped like any other string, or a partial the
2
+ host wrote that is handed the same words (ADR 039). Nothing a row holds
3
+ reaches the page as markup. The same shape as a query pane, a grid cell
4
+ holding the pane, so a theme that draws the cell as glass draws this too. %>
5
+ <%= tag.div class: "janela-span-#{pane.span}", id: "janela_pane_#{pane.id}" do %>
6
+ <%= tag.div class: [ "janela-pane", "janela-content" ] do %>
7
+ <% if pane.partial? %>
8
+ <%# The analyst's words, and what the partial is about: its row, its frame,
9
+ so the frame's owner and key, and the filter the host fixed for this
10
+ render (#60). Not the reader's q[...]: this pane is not refreshed when
11
+ they click, so a figure scoped by it would be stale after the first. %>
12
+ <%= render pane.partial_path, heading: pane.heading, body: pane.body, link: pane.link,
13
+ pane: pane, frame: frame, where: fixed %>
14
+ <% else %>
15
+ <% if pane.heading.present? %>
16
+ <h2 class="janela-content-heading"><%= pane.link.present? ? link_to(pane.heading, pane.link) : pane.heading %></h2>
17
+ <% end %>
18
+ <% pane.body.to_s.split(/\n\s*\n/).map(&:strip).reject(&:empty?).each do |paragraph| %>
19
+ <p><%= paragraph %></p>
20
+ <% end %>
21
+ <% if pane.link.present? && pane.heading.blank? %>
22
+ <p><%= link_to pane.link, pane.link %></p>
23
+ <% end %>
24
+ <% end %>
25
+ <% end %>
26
+ <% end %>
@@ -1,5 +1,13 @@
1
1
  <%= tag.div class: janela_frame_classes(frame),
2
2
  data: { controller: "janela--frame", action: janela_frame_actions,
3
3
  janela__frame_filters_value: filters.to_json } do %>
4
- <%= render partial: "janela/frames/pane", collection: frame.panes, as: :pane, locals: { filters: filters, charts: charts } %>
4
+ <% frame.panes.each do |pane| %>
5
+ <%# A content pane has no query, so it is not a turbo frame and the frame
6
+ controller has nothing of it to refresh (ADR 039). %>
7
+ <% if pane.query? %>
8
+ <%= render "janela/frames/pane", pane: pane, filters: filters, fixed: fixed, charts: charts %>
9
+ <% else %>
10
+ <%= render "janela/frames/content", pane: pane, frame: frame, fixed: fixed %>
11
+ <% end %>
12
+ <% end %>
5
13
  <% end %>
@@ -5,8 +5,8 @@
5
5
  change, which is what makes cross-filtering work from here. %>
6
6
  <%# A table needs no JavaScript, so it is what a surface with no chart runtime
7
7
  shows in place of an empty canvas (ADR 018). %>
8
- <% query = pane.query(filters: filters, renderer: pane.chart? && !charts ? "table" : pane.renderer) %>
8
+ <% query = pane.query(filters: filters, fixed: fixed, renderer: pane.chart? && !charts ? "table" : pane.renderer) %>
9
9
  <%= turbo_frame_tag pane.turbo_frame_id, class: "janela-span-#{pane.span}",
10
- data: { janela__frame_target: "pane", janela_src: janela_routes.frame_pane_path(pane.frame_id, pane) } do %>
10
+ data: { janela__frame_target: "pane", janela_src: janela_routes.frame_pane_path(pane.frame_id, pane, where: fixed.presence) } do %>
11
11
  <%= render "janela/queries/query", query: query, result: query.result(on: janela_scope(query.model)) %>
12
12
  <% end %>
@@ -0,0 +1,33 @@
1
+ <%# Words for a content pane (ADR 039). Plain fields, because what is typed
2
+ here is shown as text: there is no markup to write. %>
3
+ <%= form_with model: pane, url: pane.persisted? ? frame_pane_path(frame, pane) : frame_panes_path(frame), class: "janela-form" do |form| %>
4
+ <%= render "janela/shared/errors", record: pane %>
5
+ <%= form.hidden_field :kind %>
6
+ <%= form.hidden_field :partial if pane.partial? %>
7
+
8
+ <div class="janela-field">
9
+ <%= form.label :heading %>
10
+ <%= form.text_field :heading %>
11
+ </div>
12
+
13
+ <div class="janela-field">
14
+ <%= form.label :body %>
15
+ <%= form.text_area :body, rows: 5 %>
16
+ </div>
17
+
18
+ <div class="janela-field">
19
+ <%= form.label :link %>
20
+ <%= form.text_field :link %>
21
+ <span class="janela-hint"><%= t("janela.panes.link_hint") %></span>
22
+ </div>
23
+
24
+ <div class="janela-field">
25
+ <%= form.label :span %>
26
+ <%= form.select :span, Janela::Pane::SPANS.to_a %>
27
+ </div>
28
+
29
+ <div class="janela-actions">
30
+ <%= form.submit t("janela.actions.save"), class: "janela-button" %>
31
+ <%= link_to t("janela.actions.cancel"), edit_frame_path(frame) %>
32
+ </div>
33
+ <% end %>
@@ -1,6 +1,6 @@
1
1
  <li class="janela-list-row">
2
2
  <span class="janela-list-name"><%= pane.label %></span>
3
- <span class="janela-card-meta"><%= t("janela.panes.summary", renderer: pane.renderer, span: pane.span) %></span>
3
+ <span class="janela-card-meta"><%= pane.query? ? t("janela.panes.summary", renderer: pane.renderer, span: pane.span) : t("janela.panes.content_summary", kind: pane.partial? ? pane.partial.humanize : t("janela.panes.text"), span: pane.span) %></span>
4
4
  <span class="janela-actions">
5
5
  <%= button_to t("janela.actions.move_up"), move_up_frame_pane_path(frame, pane), method: :patch,
6
6
  class: "janela-button", disabled: pane == frame.panes.first %>
@@ -2,4 +2,8 @@
2
2
  <h1 class="janela-heading"><%= @pane.label %></h1>
3
3
  <p class="janela-crumb"><%= link_to @frame.name, edit_frame_path(@frame) %></p>
4
4
 
5
- <%= render "form", frame: @frame, pane: @pane, definition: @definition %>
5
+ <% if @pane.query? %>
6
+ <%= render "form", frame: @frame, pane: @pane, definition: @definition %>
7
+ <% else %>
8
+ <%= render "content_form", frame: @frame, pane: @pane %>
9
+ <% end %>
@@ -4,6 +4,8 @@
4
4
 
5
5
  <% if @definition %>
6
6
  <%= render "form", frame: @frame, pane: @pane, definition: @definition %>
7
+ <% elsif !@pane.query? %>
8
+ <%= render "content_form", frame: @frame, pane: @pane %>
7
9
  <% else %>
8
10
  <%# Step one of two. The engine's pages run no JavaScript, so one select
9
11
  cannot refill another: picking the model first is what lets step two
@@ -11,7 +13,10 @@
11
13
  <%= form_with url: new_frame_pane_path(@frame), method: :get, class: "janela-form" do |form| %>
12
14
  <div class="janela-field">
13
15
  <%= form.label :model, Janela::Pane.human_attribute_name(:model) %>
14
- <%= form.select :model, Janela.definitions.map { |definition| [ definition.model.model_name.human, definition.model.model_name.route_key ] } %>
16
+ <%= form.select :model, grouped_options_for_select(
17
+ t("janela.panes.numbers") => Janela.definitions.map { |definition| [ definition.model.model_name.human, definition.model.model_name.route_key ] },
18
+ t("janela.panes.words") => [ [ t("janela.panes.text"), "text" ] ] +
19
+ Janela::Pane.content_partials.map { |name| [ name.humanize, "partial:#{name}" ] }) %>
15
20
  </div>
16
21
 
17
22
  <div class="janela-actions">
@@ -8,17 +8,21 @@
8
8
  <% elsif result.empty? %>
9
9
  <p class="janela-pane janela-empty"><%= query.title %>: no data</p>
10
10
  <% elsif query.chart? %>
11
- <canvas class="janela-pane janela-chart"
12
- data-controller="janela--chart"
13
- data-action="janela--chart:toggle->janela--frame#toggle"
14
- data-janela--chart-type-value="<%= query.renderer %>"
15
- data-janela--chart-title-value="<%= query.title %>"
16
- data-janela--chart-selected-value="<%= query.selected_values.to_json %>"
17
- data-janela--chart-labels-value="<%= result.keys.to_json %>"
18
- data-janela--chart-values-value="<%= result.values.map(&:to_f).to_json %>"
19
- data-janela--chart-formatted-value="<%= result.values.map { |measured| query.format(measured) }.to_json %>"
20
- data-janela--chart-filters-value="<%= query.filters_for(result.keys).to_json %>"
21
- role="img" aria-label="<%= query.title %>"></canvas>
11
+ <% title_id = "#{query.turbo_frame_id}-title" %>
12
+ <figure class="janela-pane">
13
+ <figcaption class="janela-chart-title" id="<%= title_id %>"><%= query.title %></figcaption>
14
+ <canvas class="janela-chart"
15
+ data-controller="janela--chart"
16
+ data-action="janela--chart:toggle->janela--frame#toggle"
17
+ data-janela--chart-type-value="<%= query.renderer %>"
18
+ data-janela--chart-title-value="<%= query.title %>"
19
+ data-janela--chart-selected-value="<%= query.selected_values.to_json %>"
20
+ data-janela--chart-labels-value="<%= result.keys.to_json %>"
21
+ data-janela--chart-values-value="<%= result.values.map(&:to_f).to_json %>"
22
+ data-janela--chart-formatted-value="<%= result.values.map { |measured| query.format(measured) }.to_json %>"
23
+ data-janela--chart-filters-value="<%= query.filters_for(result.keys).to_json %>"
24
+ role="img" aria-labelledby="<%= title_id %>"></canvas>
25
+ </figure>
22
26
  <% else %>
23
27
  <table class="janela-pane">
24
28
  <caption><%= query.title %></caption>
@@ -58,6 +58,11 @@ en:
58
58
  no_dimension: "No breakdown, one number"
59
59
  no_limit: Every row
60
60
  summary: "%{renderer}, %{span} wide"
61
+ content_summary: "%{kind}, %{span} wide"
62
+ numbers: Numbers
63
+ words: Words
64
+ text: Text
65
+ link_hint: "A path on this site, such as /orders. Makes the heading a link."
61
66
  title_placeholder: Janela writes one if you leave this blank
62
67
  renderers:
63
68
  bar: Bar chart
@@ -0,0 +1,16 @@
1
+ class AddContentToJanelaPanes < ActiveRecord::Migration[8.0]
2
+ def change
3
+ # A pane can hold words instead of a query (ADR 039). Every existing row
4
+ # is a query, which is the default.
5
+ add_column :janela_panes, :kind, :string, null: false, default: "query"
6
+ add_column :janela_panes, :heading, :string
7
+ add_column :janela_panes, :body, :text
8
+ add_column :janela_panes, :link, :string
9
+ add_column :janela_panes, :partial, :string
10
+
11
+ # A content pane has no query, so these are required by kind in the
12
+ # model rather than by the column.
13
+ change_column_null :janela_panes, :model, true
14
+ change_column_null :janela_panes, :measure, true
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ class AddKeyToJanelaFrames < ActiveRecord::Migration[8.0]
2
+ def change
3
+ # The host's own name for a frame, so it finds one of an owner's several
4
+ # from code (ADR 041). Janela reads it only in Frame.for.
5
+ add_column :janela_frames, :key, :string
6
+ # One frame per owner and key. Frames without a key, every one an analyst
7
+ # makes, are not constrained: a null is never equal to another.
8
+ add_index :janela_frames, [ :owner_type, :owner_id, :key ], unique: true
9
+ end
10
+ end
data/docs/composing.md ADDED
@@ -0,0 +1,269 @@
1
+ ---
2
+ Topics: composing, html, layout, host-integration, styling
3
+ ---
4
+
5
+ # Composing a Page Around Panes
6
+
7
+ A pane is a number, a table or a chart. Everything a dashboard has that
8
+ is not a query result, the heading, the icon beside it, a sentence of
9
+ explanation, a link to the full list, a progress bar, is ordinary HTML
10
+ that your application writes. This page is the reference for writing it
11
+ so that it sits properly beside Janela's own markup.
12
+
13
+ The short version: compose with the block form of `janela_frame`, put
14
+ your markup and the panes inside a `janela-frame` grid, and style both
15
+ with your own classes plus the hooks in [Theming Janela](theming).
16
+
17
+ ## Where your markup can go
18
+
19
+ `janela_frame` has two forms, and only one of them takes your HTML.
20
+
21
+ | Form | Your own HTML | Use it when |
22
+ | --- | --- | --- |
23
+ | `janela_frame do ... end` | anywhere inside the block | the page needs a heading, text, links or a layout of its own |
24
+ | `janela_frame @frame` | none | the dashboard is data an analyst edits without a deploy |
25
+
26
+ A stored frame renders panes and nothing else. That is deliberate (ADR
27
+ 012): a row names a measure the model declared, so an analyst arranges
28
+ what is shown and cannot put arbitrary content on the page. If a
29
+ dashboard needs a heading and an explanation, write them in the page
30
+ around the frame, or use the block form. Whether a stored frame should
31
+ hold content of its own, such as text or an image, has not been decided.
32
+
33
+ ```erb
34
+ <h2>Orders</h2>
35
+ <p>Everything placed this financial year.</p>
36
+ <%= janela_frame @frame %>
37
+ ```
38
+
39
+ Inside the block form, anything goes. The block's own `<div>` carries
40
+ the cross-filtering controller, so a button or a link inside it can
41
+ clear or re-point the panes, and markup that has nothing to do with
42
+ filtering is simply ignored by it.
43
+
44
+ ## The grid
45
+
46
+ The block form's wrapper is not a grid. Write the grid yourself with the
47
+ same classes a stored frame gets from its integers:
48
+
49
+ ```erb
50
+ <%= janela_frame do %>
51
+ <div class="janela-frame janela-cols-3 janela-gap-4">
52
+ <%= janela_pane Order, :revenue %>
53
+ <%= janela_pane Order, :orders %>
54
+ <%= janela_pane Order, :average_order %>
55
+ </div>
56
+ <% end %>
57
+ ```
58
+
59
+ Every direct child is a grid item, your own elements included, so a
60
+ heading can take a whole row and a text box can sit between two panes.
61
+ `janela_pane` takes no class of its own yet
62
+ ([#29](https://github.com/retail-tasker/janela/issues/29)), so wrap a
63
+ pane to span it:
64
+
65
+ ```erb
66
+ <div class="janela-span-2"><%= janela_pane Order, :revenue, by: :status, as: :bar %></div>
67
+ ```
68
+
69
+ Below `40rem` the grid is one column whatever you asked for.
70
+
71
+ Under the vitral theme every direct child of `janela-frame` is drawn as a
72
+ pane of glass, your heading and your notes included. That is usually
73
+ what you want, since the page reads as one window. When it is not, put
74
+ the element above the grid rather than in it.
75
+
76
+ ## A frame for one record
77
+
78
+ One frame is often wanted on every record's page, each copy narrowed to
79
+ its own record. Pass the condition as `where:` and every pane is
80
+ filtered by it before anything the reader selects:
81
+
82
+ ```erb
83
+ <%= janela_frame @frame, where: { queue_id_eq: @queue.id } %>
84
+ ```
85
+
86
+ The block form takes the same argument. Do not carry the record in the
87
+ page URL's `q[...]` instead: that is the reader's selection, and Clear
88
+ filters or Escape takes it off. `where:` is a view filter, not a
89
+ permission, so a record a reader must not see is kept out of reach by
90
+ your `policy_scope` (ADR 040). Do not also offer the fixed dimension as a
91
+ pane the reader can click: any value but the fixed one returns nothing.
92
+
93
+ A figure you compute yourself for the same page, such as the progress
94
+ bar below, takes the same condition in its own `where:`.
95
+
96
+ ## Components
97
+
98
+ Each of these is plain HTML. The class names that start `janela-` are
99
+ the contract and will not change without an entry in `UPGRADING.md`.
100
+ The ones that do not are yours to name; the examples use a `card-`
101
+ prefix only so they read clearly.
102
+
103
+ ### A heading with an icon
104
+
105
+ A heading belongs to your page, not to a pane. Make it a full-width grid
106
+ item so it sits above the panes it introduces.
107
+
108
+ ```erb
109
+ <%= janela_frame do %>
110
+ <div class="janela-frame janela-cols-3 janela-gap-4">
111
+ <header class="janela-span-3 card-heading">
112
+ <svg aria-hidden="true" class="card-icon">...</svg>
113
+ <h2>Orders overview</h2>
114
+ </header>
115
+ <%= janela_pane Order, :revenue %>
116
+ ...
117
+ </div>
118
+ <% end %>
119
+ ```
120
+
121
+ Mark the icon `aria-hidden="true"`. The heading's text is its name, and
122
+ an icon read aloud as "image" adds nothing.
123
+
124
+ ### A text box
125
+
126
+ Explanation, a caveat, what the numbers exclude. A grid item like any
127
+ other, so it can span the row or sit beside a pane.
128
+
129
+ ```erb
130
+ <p class="janela-span-3 card-note">
131
+ Refunds are excluded. Figures are in the store's own currency.
132
+ </p>
133
+ ```
134
+
135
+ Write it in the page rather than in a pane's title. A title is the
136
+ pane's accessible name and should say what it measures, not carry a
137
+ paragraph.
138
+
139
+ ### A labelled number
140
+
141
+ A single value pane already renders its own label and number
142
+ (`janela-value-label`, `janela-value-number`). When your card already
143
+ says what the number is, hide the pane's label with
144
+ `janela-own-headings` so it is not on screen twice. It stays in the
145
+ accessibility tree.
146
+
147
+ ```erb
148
+ <div class="card janela-own-headings">
149
+ <p class="card-label">Revenue</p>
150
+ <%= janela_pane Order, :revenue %>
151
+ </div>
152
+ ```
153
+
154
+ ### Several numbers in one card
155
+
156
+ Two single value panes side by side read as one figure. Each is its own
157
+ query, so each cross-filters on its own.
158
+
159
+ ```erb
160
+ <div class="card janela-own-headings">
161
+ <p class="card-label">Revenue, from orders</p>
162
+ <div class="card-figure">
163
+ <%= janela_pane Order, :revenue %>
164
+ <span>from</span>
165
+ <%= janela_pane Order, :orders %>
166
+ </div>
167
+ </div>
168
+ ```
169
+
170
+ ```css
171
+ .card-figure { display: flex; align-items: baseline; gap: .5rem; }
172
+ ```
173
+
174
+ A single value pane is a block of its own, a `<p>` holding its label
175
+ and number, so the figure needs a `<div>` rather than a `<p>` around it,
176
+ and a line of CSS to put the numbers side by side. Without it they
177
+ stack.
178
+
179
+ A done out of total figure cannot be two panes yet. A measure has no
180
+ condition of its own, so there is no pane for the done half. Compute it
181
+ as the progress bar below does. A measure that is itself the ratio is
182
+ proposed in ADR 038
183
+ ([#27](https://github.com/retail-tasker/janela/issues/27)).
184
+
185
+ ### A progress bar
186
+
187
+ There is no progress renderer. A bar is your own markup, from a value
188
+ your controller computes through the same scope Janela uses.
189
+ `where:` takes the same Ransack conditions a pane's filters do, on the
190
+ dimensions the model declared:
191
+
192
+ ```ruby
193
+ scope = policy_scope(Order)
194
+ done = Order.janela.query(:orders, where: { status_eq: "paid" }, on: scope)
195
+ total = Order.janela.query(:orders, on: scope)
196
+ @percent = total.zero? ? 0 : (100.0 * done / total).round
197
+ ```
198
+
199
+ ```erb
200
+ <div class="janela-span-3 card-progress">
201
+ <p><span>Paid</span> <span><%= @percent %>%</span></p>
202
+ <progress max="100" value="<%= @percent %>"><%= @percent %>%</progress>
203
+ </div>
204
+ ```
205
+
206
+ Use `<progress>` rather than two nested `<div>`s: it has a role and a
207
+ value a screen reader can announce without any ARIA of your own. It is
208
+ computed once, when the page renders, so it does not move when a click
209
+ cross-filters the panes around it. Put it outside the frame, or say
210
+ that it is the unfiltered figure, so nobody reads it as filtered.
211
+
212
+ ### A link or an action
213
+
214
+ A link to the full list, or a button that clears the filters.
215
+
216
+ ```erb
217
+ <%= link_to "View all", orders_path, class: "card-link" %>
218
+ <button type="button" data-action="janela--frame#clear">Clear filters</button>
219
+ ```
220
+
221
+ A button only reaches `janela--frame` from inside the block. Outside
222
+ it, it has no frame to clear.
223
+
224
+ ## Putting it together
225
+
226
+ An overview card: a heading with an icon and a link, two numbers and a
227
+ note, then a progress bar under it.
228
+
229
+ ```erb
230
+ <%= janela_frame do %>
231
+ <div class="janela-frame janela-cols-3 janela-gap-4">
232
+ <header class="janela-span-3 card-heading">
233
+ <svg aria-hidden="true" class="card-icon">...</svg>
234
+ <h2>Orders overview</h2>
235
+ <%= link_to "View all", orders_path, class: "card-link" %>
236
+ </header>
237
+
238
+ <div class="janela-span-2 card janela-own-headings">
239
+ <p class="card-label">Revenue, from orders</p>
240
+ <div class="card-figure">
241
+ <%= janela_pane Order, :revenue %>
242
+ <span>from</span>
243
+ <%= janela_pane Order, :orders %>
244
+ </div>
245
+ </div>
246
+
247
+ <p class="card-note">Refunds are excluded.</p>
248
+ </div>
249
+ <% end %>
250
+
251
+ <div class="card-progress">
252
+ <p><span>Paid, across every order</span> <span><%= @percent %>%</span></p>
253
+ <progress max="100" value="<%= @percent %>"><%= @percent %>%</progress>
254
+ </div>
255
+ ```
256
+
257
+ The progress bar sits below the frame, and its label says it covers
258
+ every order, because it does not move when a click filters the panes
259
+ above it.
260
+
261
+ ## What this page is not
262
+
263
+ It is not a component library. Janela ships no `card` class and will
264
+ not: a heading, a paragraph and a link already exist, and your
265
+ application already has a way of drawing them. What Janela promises is
266
+ the grid and the pane hooks, so that your markup and its markup can sit
267
+ in one layout. If a component keeps needing something from a pane that
268
+ the hooks cannot give it, that is worth an issue rather than a
269
+ workaround.
@@ -2,6 +2,7 @@
2
2
  Date: 2026-09-20
3
3
  Status: Accepted
4
4
  Related: ADR 002, ADR 004, ADR 015, ADR 019, ADR 021, ADR 025
5
+ Superseded in part by: ADR 035
5
6
  Triggers:
6
7
  - deciding what Janela should do when a host has configured nothing
7
8
  - adding a hook a host answers by defining a method