fjkit 0.1.0.dev0__py3-none-any.whl
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.
- fjkit/__init__.py +49 -0
- fjkit/auth/__init__.py +54 -0
- fjkit/auth/csrf.py +88 -0
- fjkit/auth/errors.py +31 -0
- fjkit/auth/plugin.py +496 -0
- fjkit/auth/sources.py +24 -0
- fjkit/auth/stores.py +141 -0
- fjkit/auth/types.py +141 -0
- fjkit/cli/__init__.py +67 -0
- fjkit/cli/build_css.py +135 -0
- fjkit/cli/check.py +193 -0
- fjkit/cli/eject.py +562 -0
- fjkit/cli/ejected.py +202 -0
- fjkit/cli/vocabulary.py +85 -0
- fjkit/config.py +130 -0
- fjkit/errors.py +156 -0
- fjkit/flash.py +189 -0
- fjkit/forms.py +145 -0
- fjkit/htmx.py +76 -0
- fjkit/icons.py +60 -0
- fjkit/messages.py +227 -0
- fjkit/mounting.py +72 -0
- fjkit/plugins.py +223 -0
- fjkit/py.typed +0 -0
- fjkit/rendering.py +554 -0
- fjkit/signing.py +63 -0
- fjkit/static/brand/torii-bolt.png +0 -0
- fjkit/static/dist/fjkit-luma.css +2 -0
- fjkit/static/dist/fjkit-lyra.css +2 -0
- fjkit/static/dist/fjkit-maia.css +2 -0
- fjkit/static/dist/fjkit-mira.css +2 -0
- fjkit/static/dist/fjkit-nova.css +2 -0
- fjkit/static/dist/fjkit-rhea.css +2 -0
- fjkit/static/dist/fjkit-sera.css +2 -0
- fjkit/static/dist/fjkit-vega.css +2 -0
- fjkit/static/icons/lucide.json +1 -0
- fjkit/static/js/errors.js +117 -0
- fjkit/static/js/multiselect.js +126 -0
- fjkit/static/js/reveal.js +51 -0
- fjkit/static/js/select.js +113 -0
- fjkit/static/src/fjkit.css +385 -0
- fjkit/static/vendor/basecoat/base/base.css +136 -0
- fjkit/static/vendor/basecoat/basecoat-base.css +2 -0
- fjkit/static/vendor/basecoat/basecoat-components.css +39 -0
- fjkit/static/vendor/basecoat/basecoat-luma.css +2 -0
- fjkit/static/vendor/basecoat/basecoat-lyra.css +2 -0
- fjkit/static/vendor/basecoat/basecoat-maia.css +2 -0
- fjkit/static/vendor/basecoat/basecoat-mira.css +2 -0
- fjkit/static/vendor/basecoat/basecoat-nova.css +2 -0
- fjkit/static/vendor/basecoat/basecoat-rhea.css +2 -0
- fjkit/static/vendor/basecoat/basecoat-sera.css +2 -0
- fjkit/static/vendor/basecoat/basecoat-vega.css +2 -0
- fjkit/static/vendor/basecoat/basecoat.all.css +1 -0
- fjkit/static/vendor/basecoat/basecoat.css +1 -0
- fjkit/static/vendor/basecoat/components/accordion.css +27 -0
- fjkit/static/vendor/basecoat/components/alert.css +38 -0
- fjkit/static/vendor/basecoat/components/avatar.css +47 -0
- fjkit/static/vendor/basecoat/components/badge.css +6 -0
- fjkit/static/vendor/basecoat/components/breadcrumb.css +30 -0
- fjkit/static/vendor/basecoat/components/button-group.css +54 -0
- fjkit/static/vendor/basecoat/components/button.css +6 -0
- fjkit/static/vendor/basecoat/components/card.css +26 -0
- fjkit/static/vendor/basecoat/components/chart.css +56 -0
- fjkit/static/vendor/basecoat/components/checkbox.css +12 -0
- fjkit/static/vendor/basecoat/components/collapsible.css +21 -0
- fjkit/static/vendor/basecoat/components/combobox.css +99 -0
- fjkit/static/vendor/basecoat/components/command.css +140 -0
- fjkit/static/vendor/basecoat/components/dialog.css +101 -0
- fjkit/static/vendor/basecoat/components/drawer.css +89 -0
- fjkit/static/vendor/basecoat/components/dropdown-menu.css +56 -0
- fjkit/static/vendor/basecoat/components/empty.css +26 -0
- fjkit/static/vendor/basecoat/components/field.css +82 -0
- fjkit/static/vendor/basecoat/components/form.css +9 -0
- fjkit/static/vendor/basecoat/components/input-group.css +74 -0
- fjkit/static/vendor/basecoat/components/input.css +32 -0
- fjkit/static/vendor/basecoat/components/item.css +50 -0
- fjkit/static/vendor/basecoat/components/kbd.css +6 -0
- fjkit/static/vendor/basecoat/components/label.css +13 -0
- fjkit/static/vendor/basecoat/components/native-select.css +12 -0
- fjkit/static/vendor/basecoat/components/popover.css +107 -0
- fjkit/static/vendor/basecoat/components/progress.css +14 -0
- fjkit/static/vendor/basecoat/components/radio.css +11 -0
- fjkit/static/vendor/basecoat/components/range.css +50 -0
- fjkit/static/vendor/basecoat/components/scrollbar.css +46 -0
- fjkit/static/vendor/basecoat/components/select.css +64 -0
- fjkit/static/vendor/basecoat/components/sidebar.css +101 -0
- fjkit/static/vendor/basecoat/components/skeleton.css +6 -0
- fjkit/static/vendor/basecoat/components/switch.css +8 -0
- fjkit/static/vendor/basecoat/components/table.css +34 -0
- fjkit/static/vendor/basecoat/components/tabs.css +31 -0
- fjkit/static/vendor/basecoat/components/textarea.css +7 -0
- fjkit/static/vendor/basecoat/components/toast.css +57 -0
- fjkit/static/vendor/basecoat/components/tooltip.css +82 -0
- fjkit/static/vendor/basecoat/js/all.min.js +1 -0
- fjkit/static/vendor/basecoat/styles/luma.css +1376 -0
- fjkit/static/vendor/basecoat/styles/lyra.css +1379 -0
- fjkit/static/vendor/basecoat/styles/maia.css +1364 -0
- fjkit/static/vendor/basecoat/styles/mira.css +1373 -0
- fjkit/static/vendor/basecoat/styles/nova.css +1387 -0
- fjkit/static/vendor/basecoat/styles/rhea.css +1381 -0
- fjkit/static/vendor/basecoat/styles/sera.css +1397 -0
- fjkit/static/vendor/basecoat/styles/vega.css +1386 -0
- fjkit/static/vendor/htmx/htmx.min.js +1 -0
- fjkit/static/vendor/htmx/json-enc.js +38 -0
- fjkit/styles.py +30 -0
- fjkit/templates/errors/page.html +92 -0
- fjkit/templates/ui/attrs.html +18 -0
- fjkit/templates/ui/button.html +64 -0
- fjkit/templates/ui/data.html +362 -0
- fjkit/templates/ui/disclosure.html +89 -0
- fjkit/templates/ui/feedback.html +313 -0
- fjkit/templates/ui/form.html +595 -0
- fjkit/templates/ui/icon.html +13 -0
- fjkit/templates/ui/layout.html +189 -0
- fjkit/templates/ui/nav.html +110 -0
- fjkit/templates/ui/overlay.html +624 -0
- fjkit/templates/ui/shell.html +170 -0
- fjkit/templates/ui/sidebar.html +170 -0
- fjkit/templates/ui/table.html +427 -0
- fjkit/templates/ui/tabs.html +133 -0
- fjkit/templating.py +365 -0
- fjkit/vendored.py +46 -0
- fjkit-0.1.0.dev0.dist-info/METADATA +119 -0
- fjkit-0.1.0.dev0.dist-info/RECORD +127 -0
- fjkit-0.1.0.dev0.dist-info/WHEEL +4 -0
- fjkit-0.1.0.dev0.dist-info/entry_points.txt +2 -0
- fjkit-0.1.0.dev0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
{#
|
|
2
|
+
Layout primitives.
|
|
3
|
+
|
|
4
|
+
These exist to keep one promise: an app using fjkit never writes a raw
|
|
5
|
+
utility class. Components alone do not reach it — two cards side by side
|
|
6
|
+
means `grid gap-4`, and the closed vocabulary is broken on page one. So
|
|
7
|
+
arrangement is a component too.
|
|
8
|
+
|
|
9
|
+
Every spacing and column value is a closed lookup whose entries appear
|
|
10
|
+
verbatim below. Never build a class by interpolation (`gap-{{ n }}`):
|
|
11
|
+
Tailwind finds classes by scanning source text, so an interpolated one is
|
|
12
|
+
absent from the stylesheet. An unknown key falls back to the default rather
|
|
13
|
+
than emitting a class that does not exist.
|
|
14
|
+
#}
|
|
15
|
+
{% from "ui/attrs.html" import attrs %}
|
|
16
|
+
|
|
17
|
+
{% set _GAP = {
|
|
18
|
+
0: "gap-0", 1: "gap-1", 2: "gap-2", 3: "gap-3",
|
|
19
|
+
4: "gap-4", 5: "gap-5", 6: "gap-6", 8: "gap-8",
|
|
20
|
+
} %}
|
|
21
|
+
|
|
22
|
+
{% set _ALIGN = {
|
|
23
|
+
"start": "items-start", "center": "items-center", "end": "items-end",
|
|
24
|
+
"stretch": "items-stretch", "baseline": "items-baseline",
|
|
25
|
+
} %}
|
|
26
|
+
|
|
27
|
+
{% set _JUSTIFY = {
|
|
28
|
+
"start": "justify-start", "center": "justify-center", "end": "justify-end",
|
|
29
|
+
"between": "justify-between", "around": "justify-around",
|
|
30
|
+
} %}
|
|
31
|
+
|
|
32
|
+
{#
|
|
33
|
+
stack(gap, align) — vertical flow.
|
|
34
|
+
|
|
35
|
+
{% call stack(4) %}
|
|
36
|
+
{{ card_a }}
|
|
37
|
+
{{ card_b }}
|
|
38
|
+
{% endcall %}
|
|
39
|
+
|
|
40
|
+
flex + gap rather than `space-y-*`: gap cannot collapse, cannot double up
|
|
41
|
+
when a child is conditionally absent, and reads the same as row().
|
|
42
|
+
#}
|
|
43
|
+
{% macro stack(gap=4, align=none) -%}
|
|
44
|
+
<div class="flex flex-col {{ _GAP.get(gap, "gap-4") }}{% if align %} {{ _ALIGN.get(align, "") }}{% endif %}"{% if kwargs %}{{ attrs(kwargs) }}{% endif %}>
|
|
45
|
+
{{- caller() -}}
|
|
46
|
+
</div>
|
|
47
|
+
{%- endmacro %}
|
|
48
|
+
|
|
49
|
+
{#
|
|
50
|
+
row(gap, align, justify, wrap) — horizontal flow.
|
|
51
|
+
|
|
52
|
+
`wrap` defaults to true because a row of buttons or badges that cannot wrap
|
|
53
|
+
is a horizontal-scrollbar bug waiting for a narrow screen.
|
|
54
|
+
#}
|
|
55
|
+
{% macro row(gap=3, align="center", justify=none, wrap=true) -%}
|
|
56
|
+
<div class="flex{% if wrap %} flex-wrap{% endif %} {{ _GAP.get(gap, "gap-3") }}
|
|
57
|
+
{{- " " ~ _ALIGN.get(align, "") if align }}{{ " " ~ _JUSTIFY.get(justify, "") if justify }}"{% if kwargs %}{{ attrs(kwargs) }}{% endif %}>
|
|
58
|
+
{{- caller() -}}
|
|
59
|
+
</div>
|
|
60
|
+
{%- endmacro %}
|
|
61
|
+
|
|
62
|
+
{#
|
|
63
|
+
grid(cols, gap) — an even grid that collapses on small screens.
|
|
64
|
+
|
|
65
|
+
`cols` is the wide-screen count; the breakpoints below are fixed. Letting
|
|
66
|
+
callers choose breakpoints turns a layout vocabulary back into Tailwind with
|
|
67
|
+
extra steps.
|
|
68
|
+
#}
|
|
69
|
+
{% set _COLS = {
|
|
70
|
+
2: "sm:grid-cols-2",
|
|
71
|
+
3: "sm:grid-cols-2 lg:grid-cols-3",
|
|
72
|
+
4: "sm:grid-cols-2 lg:grid-cols-4",
|
|
73
|
+
} %}
|
|
74
|
+
|
|
75
|
+
{% macro grid(cols=3, gap=4) -%}
|
|
76
|
+
<div class="grid {{ _GAP.get(gap, "gap-4") }} {{ _COLS.get(cols, "sm:grid-cols-2 lg:grid-cols-3") }}"{% if kwargs %}{{ attrs(kwargs) }}{% endif %}>
|
|
77
|
+
{{- caller() -}}
|
|
78
|
+
</div>
|
|
79
|
+
{%- endmacro %}
|
|
80
|
+
|
|
81
|
+
{#
|
|
82
|
+
split(aside, gap) — main column plus a fixed-width sidebar, stacking on
|
|
83
|
+
narrow screens. Two slots, so it is called with a slot argument:
|
|
84
|
+
|
|
85
|
+
{% call(slot) split() %}
|
|
86
|
+
{% if slot == "main" %}
|
|
87
|
+
…the board…
|
|
88
|
+
{% else %}
|
|
89
|
+
…the stats panel…
|
|
90
|
+
{% endif %}
|
|
91
|
+
{% endcall %}
|
|
92
|
+
|
|
93
|
+
The body runs once per slot, and each branch renders in exactly one of them.
|
|
94
|
+
#}
|
|
95
|
+
{% set _ASIDE = {
|
|
96
|
+
"sm": "lg:grid-cols-[1fr_16rem]",
|
|
97
|
+
"md": "lg:grid-cols-[1fr_19rem]",
|
|
98
|
+
"lg": "lg:grid-cols-[1fr_22rem]",
|
|
99
|
+
} %}
|
|
100
|
+
|
|
101
|
+
{% macro split(aside="md", gap=6) -%}
|
|
102
|
+
<div class="grid {{ _GAP.get(gap, "gap-6") }} {{ _ASIDE.get(aside, "lg:grid-cols-[1fr_19rem]") }}"{% if kwargs %}{{ attrs(kwargs) }}{% endif %}>
|
|
103
|
+
<div>{{ caller("main") }}</div>
|
|
104
|
+
<aside>{{ caller("aside") }}</aside>
|
|
105
|
+
</div>
|
|
106
|
+
{%- endmacro %}
|
|
107
|
+
|
|
108
|
+
{#
|
|
109
|
+
centered(width, gap) — one column, capped and centred.
|
|
110
|
+
|
|
111
|
+
{% call centered("sm") %}
|
|
112
|
+
{{ brand(…) }}
|
|
113
|
+
{{ page_header("Sign in", "…") }}
|
|
114
|
+
{% call card() %}…{% endcall %}
|
|
115
|
+
{% endcall %}
|
|
116
|
+
|
|
117
|
+
Until this macro there was no way to cap a width. `stack(align="center")`
|
|
118
|
+
centres a column without capping it, `grid` divides a width it is given, and
|
|
119
|
+
`split`'s two numbers are grid tracks belonging to the aside. So a sign-in
|
|
120
|
+
card, a settings form or a page of prose — anything that should not run to
|
|
121
|
+
the 1152px the shell's wrapper does — left an app two moves: `max-w-sm`,
|
|
122
|
+
which `fjkit check` rejects as a utility, or an inline `style="width: …"`,
|
|
123
|
+
which it does not reject and should. Reported by an app that wrote the second
|
|
124
|
+
one and said so in a comment.
|
|
125
|
+
|
|
126
|
+
A flex column rather than a bare `<div>`, because every caller wanted a
|
|
127
|
+
`stack` inside it. `gap` is the closed lookup `stack` uses.
|
|
128
|
+
|
|
129
|
+
`width` is a closed enumeration, for the reason every lookup in this file is:
|
|
130
|
+
Tailwind finds classes by scanning source text, so `max-w-{{ width }}` names
|
|
131
|
+
a class absent from the stylesheet, and the column renders at full width with
|
|
132
|
+
nothing to say it went wrong. The six below cover the cases; a seventh is a
|
|
133
|
+
one-line change here, not a caller's business.
|
|
134
|
+
|
|
135
|
+
It centres nothing vertically. A sign-in page that wants its card in the
|
|
136
|
+
middle of the viewport asks the shell for that: leave `header` and
|
|
137
|
+
`footer_wrapper` empty and the main element is the page. Merging the two jobs
|
|
138
|
+
would give this macro a parameter that does nothing in the common case.
|
|
139
|
+
#}
|
|
140
|
+
{% set _WIDTH = {
|
|
141
|
+
"xs": "max-w-xs", "sm": "max-w-sm", "md": "max-w-md",
|
|
142
|
+
"lg": "max-w-lg", "xl": "max-w-xl", "prose": "max-w-prose",
|
|
143
|
+
} %}
|
|
144
|
+
|
|
145
|
+
{% macro centered(width="sm", gap=6) -%}
|
|
146
|
+
<div class="mx-auto flex w-full flex-col {{ _GAP.get(gap, "gap-6") }} {{ _WIDTH.get(width, "max-w-sm") }}"{% if kwargs %}{{ attrs(kwargs) }}{% endif %}>
|
|
147
|
+
{{- caller() -}}
|
|
148
|
+
</div>
|
|
149
|
+
{%- endmacro %}
|
|
150
|
+
|
|
151
|
+
{#
|
|
152
|
+
page_header(title, description) — the title block every page opens with.
|
|
153
|
+
|
|
154
|
+
Works plain, or as a call block whose body becomes the right-hand actions:
|
|
155
|
+
|
|
156
|
+
{% call page_header("Tasks", "One board, no page reloads") %}
|
|
157
|
+
{{ button("New", variant="primary") }}
|
|
158
|
+
{% endcall %}
|
|
159
|
+
#}
|
|
160
|
+
{% macro page_header(title, description=none) -%}
|
|
161
|
+
<div class="mb-6 flex flex-wrap items-end justify-between gap-4">
|
|
162
|
+
<div>
|
|
163
|
+
<h1 class="text-2xl font-semibold tracking-tight">{{ title }}</h1>
|
|
164
|
+
{% if description %}<p class="text-muted-foreground text-sm">{{ description }}</p>{% endif %}
|
|
165
|
+
</div>
|
|
166
|
+
{% if caller is defined %}{{ caller() }}{% endif %}
|
|
167
|
+
</div>
|
|
168
|
+
{%- endmacro %}
|
|
169
|
+
|
|
170
|
+
{#
|
|
171
|
+
section(title, description) — a labelled band within a page. Use when a page
|
|
172
|
+
has more than one topic; a page with one topic just needs page_header.
|
|
173
|
+
#}
|
|
174
|
+
{% macro section(title=none, description=none, gap=4) -%}
|
|
175
|
+
<section class="flex flex-col {{ _GAP.get(gap, "gap-4") }}"{% if kwargs %}{{ attrs(kwargs) }}{% endif %}>
|
|
176
|
+
{% if title or description %}
|
|
177
|
+
<div>
|
|
178
|
+
{% if title %}<h2 class="text-lg font-semibold tracking-tight">{{ title }}</h2>{% endif %}
|
|
179
|
+
{% if description %}<p class="text-muted-foreground text-sm">{{ description }}</p>{% endif %}
|
|
180
|
+
</div>
|
|
181
|
+
{% endif %}
|
|
182
|
+
{{- caller() -}}
|
|
183
|
+
</section>
|
|
184
|
+
{%- endmacro %}
|
|
185
|
+
|
|
186
|
+
{# divider() — a horizontal rule that uses the border token, not a hue. #}
|
|
187
|
+
{% macro divider() -%}
|
|
188
|
+
<hr class="border-border">
|
|
189
|
+
{%- endmacro %}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
{#
|
|
2
|
+
The pieces of the shell's header. Separate from shell.html so an app can
|
|
3
|
+
import them without importing the template it extends.
|
|
4
|
+
#}
|
|
5
|
+
{% from "ui/attrs.html" import attrs %}
|
|
6
|
+
{% from "ui/icon.html" import icon %}
|
|
7
|
+
|
|
8
|
+
{#
|
|
9
|
+
brand(label, href, icon_name | icon_src) — the wordmark and home link.
|
|
10
|
+
|
|
11
|
+
Two ways to give it a mark, and they are mutually exclusive.
|
|
12
|
+
|
|
13
|
+
`icon_name` draws a Lucide glyph on a token-coloured tile. The tile uses
|
|
14
|
+
`bg-primary text-primary-foreground`, never `text-white`: the contrast token
|
|
15
|
+
keeps the mark legible after a rebrand to a light primary.
|
|
16
|
+
|
|
17
|
+
`icon_src` places artwork — a real logo, served from wherever the app keeps
|
|
18
|
+
it. No tile, because a logo brings its own ground and `bg-primary` behind it
|
|
19
|
+
would box it in. The mark then stops following `--primary`, which is the
|
|
20
|
+
trade a brand asset always makes.
|
|
21
|
+
|
|
22
|
+
`alt=""` is deliberate: the label sits beside the image inside the same
|
|
23
|
+
anchor, so a screen reader announcing both would say the name twice. `width`
|
|
24
|
+
and `height` are set so the row does not reflow when the image arrives.
|
|
25
|
+
#}
|
|
26
|
+
{% macro brand(label, href="/", icon_name=none, icon_src=none) -%}
|
|
27
|
+
<a href="{{ href }}" class="flex items-center gap-2 font-semibold tracking-tight"{% if kwargs %}{{ attrs(kwargs) }}{% endif %}>
|
|
28
|
+
{%- if icon_src %}
|
|
29
|
+
<img class="size-7" src="{{ icon_src }}" width="28" height="28" alt="">
|
|
30
|
+
{% elif icon_name %}
|
|
31
|
+
<span class="bg-primary text-primary-foreground grid size-7 place-items-center rounded-lg">
|
|
32
|
+
{{- icon(icon_name, 16) -}}
|
|
33
|
+
</span>
|
|
34
|
+
{% endif -%}
|
|
35
|
+
{{ label }}
|
|
36
|
+
</a>
|
|
37
|
+
{%- endmacro %}
|
|
38
|
+
|
|
39
|
+
{#
|
|
40
|
+
nav_links(request, links) — top-level navigation.
|
|
41
|
+
|
|
42
|
+
`links` is a list of (route_name, label) pairs. Route names rather than URLs,
|
|
43
|
+
so the active state compares routes instead of string-matching paths, and
|
|
44
|
+
stays correct when a URL gains a query string.
|
|
45
|
+
#}
|
|
46
|
+
{% macro nav_links(request, links) -%}
|
|
47
|
+
<nav class="text-muted-foreground flex items-center gap-1 text-sm">
|
|
48
|
+
{% for route, label in links %}
|
|
49
|
+
<a class="hover:text-foreground rounded-md px-2.5 py-1.5 transition-colors
|
|
50
|
+
{% if is_active(request, route) %}text-foreground bg-muted{% endif %}"
|
|
51
|
+
href="{{ url_for(request, route) }}"
|
|
52
|
+
{%- if is_active(request, route) %} aria-current="page"{% endif %}>{{ label }}</a>
|
|
53
|
+
{% endfor %}
|
|
54
|
+
</nav>
|
|
55
|
+
{%- endmacro %}
|
|
56
|
+
|
|
57
|
+
{#
|
|
58
|
+
theme_toggle() — light/dark switch.
|
|
59
|
+
|
|
60
|
+
The only inline script fjkit ships besides the shell's flash-guard. Two
|
|
61
|
+
lines, and it has to run before any bundle would have loaded, so it is not in
|
|
62
|
+
a .js file.
|
|
63
|
+
#}
|
|
64
|
+
{% macro theme_toggle() -%}
|
|
65
|
+
<button class="btn" data-variant="ghost" data-size="icon-sm" type="button"
|
|
66
|
+
aria-label="Toggle theme"
|
|
67
|
+
onclick="document.documentElement.classList.toggle('dark');
|
|
68
|
+
localStorage.setItem('theme', document.documentElement.classList.contains('dark') ? 'dark' : 'light')">
|
|
69
|
+
{{- icon("sun", 16, "hidden dark:block") }}{{ icon("moon", 16, "dark:hidden") -}}
|
|
70
|
+
</button>
|
|
71
|
+
{%- endmacro %}
|
|
72
|
+
|
|
73
|
+
{#
|
|
74
|
+
breadcrumb(trail, separator)
|
|
75
|
+
|
|
76
|
+
`trail` is a list of `(label, href)` pairs. A pair whose href is none is the
|
|
77
|
+
current page: it renders as `<span aria-current="page">` rather than a link,
|
|
78
|
+
so the trail holds exactly one non-navigable entry and assistive tech is told
|
|
79
|
+
which. Passing the current page as a link is the usual way this component
|
|
80
|
+
goes wrong, and the parameter's shape prevents it.
|
|
81
|
+
|
|
82
|
+
Separators are their own `<li aria-hidden="true">` rather than CSS `::after`
|
|
83
|
+
content: some screen readers read generated content aloud, and a trail
|
|
84
|
+
punctuated by "greater than" five times is worse than silence. This follows
|
|
85
|
+
Basecoat's structure.
|
|
86
|
+
|
|
87
|
+
The separator mirrors under `dir="rtl"`; a dot has nothing to mirror, so the
|
|
88
|
+
flip skips it.
|
|
89
|
+
#}
|
|
90
|
+
{% set _CRUMB_SEPARATORS = {"chevron": "chevron-right", "slash": "slash", "dot": "dot"} %}
|
|
91
|
+
|
|
92
|
+
{% macro breadcrumb(trail, separator="chevron", label="Breadcrumb") -%}
|
|
93
|
+
{%- set glyph = _CRUMB_SEPARATORS.get(separator, "chevron-right") -%}
|
|
94
|
+
<nav class="breadcrumb" aria-label="{{ label }}"{% if kwargs %}{{ attrs(kwargs) }}{% endif %}>
|
|
95
|
+
<ol>
|
|
96
|
+
{%- for crumb_label, href in trail %}
|
|
97
|
+
{%- if not loop.first %}
|
|
98
|
+
<li aria-hidden="true">{{ icon(glyph, 16, "" if separator == "dot" else "rtl:rotate-180") }}</li>
|
|
99
|
+
{%- endif %}
|
|
100
|
+
<li>
|
|
101
|
+
{%- if href %}
|
|
102
|
+
<a href="{{ href }}">{{ crumb_label }}</a>
|
|
103
|
+
{%- else %}
|
|
104
|
+
<span aria-current="page">{{ crumb_label }}</span>
|
|
105
|
+
{%- endif %}
|
|
106
|
+
</li>
|
|
107
|
+
{%- endfor %}
|
|
108
|
+
</ol>
|
|
109
|
+
</nav>
|
|
110
|
+
{%- endmacro %}
|