@markout-lang/bootstrap-kit 0.2.2 → 0.4.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.
@@ -9,14 +9,13 @@
9
9
  <:define tag="bs-placeholder:span"
10
10
 
11
11
  // parameters
12
- :extra=${null} // extra classes for this instance
13
- :cols=${6}
14
- :size=${null} // 'xs' | 'sm' | 'lg'
15
- :variant=${null}
16
- :animation=${'glow'} // 'glow' | 'wave' | null
12
+ ::cols=${6}
13
+ ::size=${null} // 'xs' | 'sm' | 'lg'
14
+ ::variant=${null}
15
+ ::animation=${'glow'} // 'glow' | 'wave' | null
17
16
 
18
17
  // private
19
- :_class=${[animation ? `placeholder-${animation}` : '', extra]
18
+ :_class=${[animation ? `placeholder-${animation}` : '']
20
19
  .filter(s => s).join(' ') || null}
21
20
  :_barClass=${[
22
21
  'placeholder',
package/parts/popover.htm CHANGED
@@ -10,15 +10,14 @@
10
10
  part that usually changes; both are read when it runs.
11
11
  -->
12
12
  <:define tag="bs-popover:span"
13
- class="d-inline-block ${extra ?? ''}"
13
+ class="d-inline-block"
14
14
 
15
15
  // parameters
16
- :extra=${null} // extra classes for this instance
17
- :title=${''}
18
- :content=${''}
19
- :placement=${'right'}
20
- :trigger=${'click'}
21
- :html=${false}
16
+ ::title=${''}
17
+ ::content=${''}
18
+ ::placement=${'right'}
19
+ ::trigger=${'click'}
20
+ ::html=${false}
22
21
 
23
22
  // private
24
23
  :_build=${() => {
@@ -9,19 +9,18 @@
9
9
  `:label` is the text drawn inside the bar; leave it off for a bare bar.
10
10
  -->
11
11
  <:define tag="bs-progress:div"
12
- class="progress ${extra ?? ''}"
12
+ class="progress"
13
13
 
14
14
  // parameters
15
- :extra=${null} // extra classes for this instance
16
- :value=${0}
17
- :min=${0}
18
- :max=${100}
19
- :label=${null}
20
- :variant=${null}
21
- :striped=${false}
22
- :animated=${false}
23
- :height=${null}
24
- :name=${'Progress'}
15
+ ::value=${0}
16
+ ::min=${0}
17
+ ::max=${100}
18
+ ::label=${null}
19
+ ::variant=${null}
20
+ ::striped=${false}
21
+ ::animated=${false}
22
+ ::height=${null}
23
+ ::name=${'Progress'}
25
24
 
26
25
  // private
27
26
  :_percent=${Math.max(0, Math.min(100, ((value - min) / (max - min || 1)) * 100))}
@@ -6,19 +6,17 @@
6
6
  nav that matches what is currently on screen. `:target` is the selector
7
7
  of that nav, and the element this sits on is the thing being scrolled.
8
8
 
9
- <bs-nav :vertical id="toc" :items=${sections} />
10
- <bs-scrollspy :target="#toc" :height="300">…</bs-scrollspy>
9
+ <bs-nav ::vertical id="toc" ::items=${sections} />
10
+ <bs-scrollspy ::target="#toc" ::height="300">…</bs-scrollspy>
11
11
  -->
12
12
  <:define tag="bs-scrollspy:div"
13
13
 
14
14
  // parameters
15
- :extra=${null} // extra classes for this instance
16
- :target=${null}
17
- :offset=${0}
18
- :smooth=${false}
19
- :height=${null}
15
+ ::target=${null}
16
+ ::offset=${0}
17
+ ::smooth=${false}
18
+ ::height=${null}
20
19
 
21
- class=${extra}
22
20
  data-bs-spy="scroll"
23
21
  data-bs-target=${target}
24
22
  data-bs-root-margin="${offset}px 0px -40%"
package/parts/select.htm CHANGED
@@ -5,24 +5,23 @@
5
5
  A select whose options come from an array. An entry is either a string or
6
6
  `{ name, value, disabled }`, so the quick case stays quick:
7
7
 
8
- <bs-select :label="Size" :options=${['S', 'M', 'L']} />
8
+ <bs-select ::label="Size" ::options=${['S', 'M', 'L']} />
9
9
  -->
10
10
  <:define tag="bs-select:div"
11
- class="mb-3 ${extra ?? ''}"
11
+ class="mb-3"
12
12
 
13
13
  // parameters
14
- :extra=${null} // extra classes for this instance
15
- :label=${null}
16
- :name=${null}
17
- :options=${[]}
18
- :value=${null}
19
- :placeholder=${null}
20
- :help=${null}
21
- :size=${null} // 'sm' | 'lg'
22
- :multiple=${false}
23
- :disabled=${false}
24
- :required=${false}
25
- :floating=${false}
14
+ ::label=${null}
15
+ ::name=${null}
16
+ ::options=${[]}
17
+ ::value=${null}
18
+ ::placeholder=${null}
19
+ ::help=${null}
20
+ ::size=${null} // 'sm' | 'lg'
21
+ ::multiple=${false}
22
+ ::disabled=${false}
23
+ ::required=${false}
24
+ ::floating=${false}
26
25
 
27
26
  // private
28
27
  :_id=${`bs-select-${$id}`}
@@ -51,13 +50,15 @@
51
50
 
52
51
  <option value=""
53
52
  :if=${placeholder}
54
- :attr-selected=${value == null}>${placeholder}</option>
53
+ :attr-selected=${value == null}
54
+ :prop-selected=${value == null}>${placeholder}</option>
55
55
 
56
56
  <option :for-each=${_options}
57
57
  :for-as="option"
58
58
  value=${option.value}
59
59
  :attr-disabled=${option.disabled}
60
- :attr-selected=${option.value === value}>${option.name}</option>
60
+ :attr-selected=${option.value === value}
61
+ :prop-selected=${option.value === value}>${option.name}</option>
61
62
  </select>
62
63
 
63
64
  <label for=${_id}
package/parts/spinner.htm CHANGED
@@ -10,18 +10,16 @@
10
10
  role="status"
11
11
 
12
12
  // parameters
13
- :extra=${null} // extra classes for this instance
14
- :variant=${null}
15
- :type=${'border'} // 'border' | 'grow'
16
- :small=${false}
17
- :label=${'Loading…'}
13
+ ::variant=${null}
14
+ ::type=${'border'} // 'border' | 'grow'
15
+ ::small=${false}
16
+ ::label=${'Loading…'}
18
17
 
19
18
  // private
20
19
  :_class=${[
21
20
  `spinner-${type}`,
22
21
  small ? `spinner-${type}-sm` : '',
23
22
  variant ? `text-${variant}` : '',
24
- extra,
25
23
  ].filter(s => s).join(' ')}
26
24
 
27
25
  class=${_class}
package/parts/table.htm CHANGED
@@ -16,19 +16,18 @@
16
16
  <:define tag="bs-table:div"
17
17
 
18
18
  // parameters
19
- :extra=${null} // extra classes for this instance
20
- :columns=${[]}
21
- :rows=${[]}
22
- :caption=${null}
23
- :striped=${false}
24
- :hover=${false}
25
- :bordered=${false}
26
- :borderless=${false}
27
- :small=${false}
28
- :variant=${null}
29
- :headVariant=${null}
30
- :align=${null} // 'middle' | 'bottom'
31
- :responsive=${false}
19
+ ::columns=${[]}
20
+ ::rows=${[]}
21
+ ::caption=${null}
22
+ ::striped=${false}
23
+ ::hover=${false}
24
+ ::bordered=${false}
25
+ ::borderless=${false}
26
+ ::small=${false}
27
+ ::variant=${null}
28
+ ::headVariant=${null}
29
+ ::align=${null} // 'middle' | 'bottom'
30
+ ::responsive=${false}
32
31
 
33
32
  // private
34
33
  :_class=${[
@@ -42,7 +41,6 @@
42
41
  align ? `align-${align}` : '',
43
42
  ].filter(s => s).join(' ')}
44
43
 
45
- class=${extra}
46
44
  :class-table-responsive=${responsive}
47
45
  >
48
46
  <table class=${_class}>
package/parts/theme.htm CHANGED
@@ -10,6 +10,16 @@
10
10
  piece of this kit that cannot be reactive, because it has to happen
11
11
  before Markout exists.
12
12
 
13
+ It is also the one piece that would otherwise DO something merely because
14
+ a file was imported. `all.htm` pulls this file in, so every page taking
15
+ the whole kit used to get colour modes whether it asked for them or not —
16
+ which is the kind of action at a distance the rest of the kit has none
17
+ of. So the script waits on a tag: write `<bs-theme-auto />` for the
18
+ behaviour on its own, or a `<bs-theme-toggle />` for the behaviour and a
19
+ button to drive it, and a page that writes neither ships neither. Naming
20
+ a tag no `<:define>` declares is a compile error, which is what stops a
21
+ rename from leaving this waiting on a name nothing will ever use.
22
+
13
23
  From there `_theme` is an ordinary value, and it starts as whatever that
14
24
  script decided rather than as a literal: a served page knows nothing
15
25
  about this visitor, so a default written here would be a guess that the
@@ -28,7 +38,7 @@
28
38
  kit would rather say so at the point of use than pretend a server has
29
39
  them.
30
40
  -->
31
- <script>
41
+ <script :when-used="bs-theme-auto bs-theme-toggle">
32
42
  (() => {
33
43
  const stored = localStorage.getItem('bs-theme');
34
44
  const theme = stored
@@ -37,14 +47,28 @@
37
47
  })();
38
48
  </script>
39
49
 
50
+ <!---
51
+ "This page uses colour modes", and nothing else. The script above does
52
+ the work; this is how a page asks for it without also asking for a
53
+ button, and it has no element, so what it costs the page is one empty
54
+ scope — 58 bytes on the counter example.
55
+
56
+ Deliberately holding no value. It could expose the current mode for a
57
+ page that needs it in an expression rather than in CSS, and that is 109
58
+ bytes of props on every page that opts in and doesn't read it, which is
59
+ all of them so far. A component whose job is to say one thing should
60
+ cost what saying it costs; the value can be added the day something
61
+ wants it, and adding it then breaks nothing.
62
+ -->
63
+ <:define tag="bs-theme-auto:logic" />
64
+
40
65
  <:define tag="bs-theme-toggle:button"
41
66
  type="button"
42
67
 
43
68
  // parameters
44
- :extra=${null} // extra classes for this instance
45
- :variant=${'secondary'}
46
- :outline=${true}
47
- :size=${null}
69
+ ::variant=${'secondary'}
70
+ ::outline=${true}
71
+ ::size=${null}
48
72
 
49
73
  // private
50
74
  :_theme=${globalThis.document?.documentElement.getAttribute('data-bs-theme') ?? 'light'}
@@ -52,7 +76,6 @@
52
76
  'btn',
53
77
  `btn-${outline ? 'outline-' : ''}${variant}`,
54
78
  size ? `btn-${size}` : '',
55
- extra,
56
79
  ].filter(s => s).join(' ')}
57
80
 
58
81
  class=${_class}
package/parts/toast.htm CHANGED
@@ -5,7 +5,7 @@
5
5
  <!---
6
6
  A toast, shown by setting a value rather than by calling anything:
7
7
 
8
- <bs-toast :aka="saved" :title="Saved">Your changes are safe.</bs-toast>
8
+ <bs-toast :aka="saved" ::title="Saved">Your changes are safe.</bs-toast>
9
9
  <bs-button :on-click=${() => saved.open = true}>Save</bs-button>
10
10
 
11
11
  `:handle-open` turns that value into the `show()` / `hide()` the plugin
@@ -20,16 +20,15 @@
20
20
  aria-atomic="true"
21
21
 
22
22
  // parameters
23
- :extra=${null} // extra classes for this instance
24
- :title=${null}
25
- :time=${null}
26
- :variant=${null}
27
- :open=${false}
28
- :autohide=${true}
29
- :delay=${5000}
23
+ ::title=${null}
24
+ ::time=${null}
25
+ ::variant=${null}
26
+ ::open=${false}
27
+ ::autohide=${true}
28
+ ::delay=${5000}
30
29
 
31
30
  // private
32
- :_class=${['toast', variant ? `text-bg-${variant} border-0` : '', extra]
31
+ :_class=${['toast', variant ? `text-bg-${variant} border-0` : '']
33
32
  .filter(s => s).join(' ')}
34
33
 
35
34
  class=${_class}
@@ -60,7 +59,7 @@
60
59
  <strong class="me-auto">${title}</strong>
61
60
  <small class="text-body-secondary"
62
61
  :if=${time}>${time}</small>
63
- <bs-close :dismiss="toast" :label="Close notification" />
62
+ <bs-close ::dismiss="toast" ::label="Close notification" />
64
63
  </div>
65
64
 
66
65
  <!---
@@ -79,9 +78,9 @@
79
78
  <:slot />
80
79
  </div>
81
80
 
82
- <bs-close :dismiss="toast"
83
- :label="Close notification"
84
- :extra="me-2 m-auto"
81
+ <bs-close ::dismiss="toast"
82
+ ::label="Close notification"
83
+ class+="me-2 m-auto"
85
84
  :if=${!title} />
86
85
  </div>
87
86
  </:define>
@@ -93,8 +92,7 @@
93
92
  <:define tag="bs-toast-container:div"
94
93
 
95
94
  // parameters
96
- :extra=${null} // extra classes for this instance
97
- :placement=${'bottom-end'} // 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'top-center'
95
+ ::placement=${'bottom-end'} // 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'top-center'
98
96
 
99
97
  // private
100
98
  :_class=${[
@@ -103,7 +101,6 @@
103
101
  placement.endsWith('start') ? 'start-0' : '',
104
102
  placement.endsWith('end') ? 'end-0' : '',
105
103
  placement.endsWith('center') ? 'start-50 translate-middle-x' : '',
106
- extra,
107
104
  ].filter(s => s).join(' ')}
108
105
 
109
106
  class=${_class}
package/parts/tooltip.htm CHANGED
@@ -26,14 +26,13 @@
26
26
  of its own to hang off; wrap the trigger, not the page around it.
27
27
  -->
28
28
  <:define tag="bs-tooltip:span"
29
- class="d-inline-block ${extra ?? ''}"
29
+ class="d-inline-block"
30
30
 
31
31
  // parameters
32
- :extra=${null} // extra classes for this instance
33
- :title=${''}
34
- :placement=${'top'}
35
- :html=${false}
36
- :trigger=${'hover focus'}
32
+ ::title=${''}
33
+ ::placement=${'top'}
34
+ ::html=${false}
35
+ ::trigger=${'hover focus'}
37
36
 
38
37
  // private
39
38
  :_build=${() => {