compostrap 0.0.0-stage → 1.0.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.
- package/dist/css/auth.css +166 -0
- package/dist/css/blog.css +512 -0
- package/dist/css/chart.css +99 -0
- package/dist/css/compostrap.css +5047 -0
- package/dist/css/dashboard.css +360 -0
- package/dist/css/datagrid.css +64 -0
- package/dist/css/datepicker.css +514 -0
- package/dist/css/dialogs.css +185 -0
- package/dist/css/dropzone.css +86 -0
- package/dist/css/elements.css +181 -0
- package/dist/css/empty.css +94 -0
- package/dist/css/gallery.css +122 -0
- package/dist/css/lightbox.css +140 -0
- package/dist/css/number-input.css +100 -0
- package/dist/css/otp-input.css +177 -0
- package/dist/css/password-toggle.css +52 -0
- package/dist/css/rating.css +95 -0
- package/dist/css/selection.css +59 -0
- package/dist/css/settings.css +85 -0
- package/dist/css/shop.css +1026 -0
- package/dist/css/sidebar-menu.css +438 -0
- package/dist/css/sidebar.css +95 -0
- package/dist/css/spinner.css +102 -0
- package/dist/css/strength.css +118 -0
- package/dist/css/theme-switcher.css +5 -0
- package/dist/css/theme.css +13006 -0
- package/dist/css/tooltip.css +158 -0
- package/dist/js/chart.js +257 -0
- package/dist/js/datepicker.js +82 -0
- package/dist/js/dialogs.js +7 -0
- package/dist/js/dropzone.js +15 -0
- package/dist/js/index.js +24 -0
- package/dist/js/lightbox.js +77 -0
- package/dist/js/number-input.js +44 -0
- package/dist/js/otp-input.js +182 -0
- package/dist/js/password-toggle.js +16 -0
- package/dist/js/selection.js +32 -0
- package/dist/js/sidebar-menu.js +76 -0
- package/dist/js/sidebar.js +120 -0
- package/dist/js/spinner.js +27 -0
- package/dist/js/strength.js +87 -0
- package/dist/js/theme-switcher.js +98 -0
- package/dist/js/tooltip.js +17 -0
- package/docs/auth.md +25 -0
- package/docs/blog.md +85 -0
- package/docs/chart.md +39 -0
- package/docs/datagrid.md +64 -0
- package/docs/datepicker.md +35 -0
- package/docs/dialogs.md +81 -0
- package/docs/dropzone.md +23 -0
- package/docs/elements.md +38 -0
- package/docs/empty.md +25 -0
- package/docs/gallery.md +23 -0
- package/docs/layout.md +143 -0
- package/docs/lightbox.md +18 -0
- package/docs/number-input.md +19 -0
- package/docs/otp-input.md +52 -0
- package/docs/password-toggle.md +21 -0
- package/docs/rating.md +15 -0
- package/docs/selection.md +52 -0
- package/docs/settings.md +25 -0
- package/docs/shop.md +140 -0
- package/docs/spinner.md +51 -0
- package/docs/strength.md +26 -0
- package/docs/theme-switcher.md +60 -0
- package/docs/theme.md +100 -0
- package/docs/tooltip.md +30 -0
- package/license +21 -0
- package/package.json +106 -6
- package/readme.md +198 -0
- package/src/illustrations/empty.svg +15 -0
- package/src/illustrations/forbidden.svg +16 -0
- package/src/illustrations/maintenance.svg +14 -0
- package/src/illustrations/not-found.svg +22 -0
- package/src/illustrations/server-error.svg +21 -0
- package/src/js/chart.js +359 -0
- package/src/js/datepicker.js +154 -0
- package/src/js/dialogs.js +25 -0
- package/src/js/dropzone.js +35 -0
- package/src/js/index.js +29 -0
- package/src/js/lightbox.js +165 -0
- package/src/js/number-input.js +87 -0
- package/src/js/otp-input.js +401 -0
- package/src/js/password-toggle.js +45 -0
- package/src/js/selection.js +114 -0
- package/src/js/sidebar-menu.js +178 -0
- package/src/js/sidebar.js +326 -0
- package/src/js/spinner.js +76 -0
- package/src/js/strength.js +115 -0
- package/src/js/theme-switcher.js +197 -0
- package/src/js/tooltip.js +46 -0
- package/src/scss/_bootstrap.scss +9 -0
- package/src/scss/_variables.scss +58 -0
- package/src/scss/auth/_index.scss +210 -0
- package/src/scss/auth.scss +5 -0
- package/src/scss/blog/_article.scss +181 -0
- package/src/scss/blog/_comments.scss +108 -0
- package/src/scss/blog/_index.scss +18 -0
- package/src/scss/blog/_list.scss +246 -0
- package/src/scss/blog/_page.scss +138 -0
- package/src/scss/blog.scss +5 -0
- package/src/scss/chart/_index.scss +114 -0
- package/src/scss/chart.scss +5 -0
- package/src/scss/compostrap.scss +29 -0
- package/src/scss/dashboard/_content.scss +25 -0
- package/src/scss/dashboard/_dropdown.scss +71 -0
- package/src/scss/dashboard/_index.scss +9 -0
- package/src/scss/dashboard/_nanobar.scss +34 -0
- package/src/scss/dashboard/_navbar.scss +314 -0
- package/src/scss/dashboard/_theme.scss +27 -0
- package/src/scss/dashboard.scss +5 -0
- package/src/scss/datagrid/_index.scss +111 -0
- package/src/scss/datagrid.scss +5 -0
- package/src/scss/datepicker/_index.scss +557 -0
- package/src/scss/datepicker.scss +5 -0
- package/src/scss/dialogs/_index.scss +8 -0
- package/src/scss/dialogs/_modal.scss +82 -0
- package/src/scss/dialogs/_offcanvas.scss +13 -0
- package/src/scss/dialogs/_search.scss +79 -0
- package/src/scss/dialogs/_toast.scss +61 -0
- package/src/scss/dialogs.scss +5 -0
- package/src/scss/dropzone/_index.scss +111 -0
- package/src/scss/dropzone.scss +5 -0
- package/src/scss/elements/_datagrid-filter.scss +21 -0
- package/src/scss/elements/_index.scss +9 -0
- package/src/scss/elements/_list-row.scss +40 -0
- package/src/scss/elements/_loading.scss +47 -0
- package/src/scss/elements/_stat.scss +73 -0
- package/src/scss/elements/_status-dot.scss +38 -0
- package/src/scss/elements.scss +5 -0
- package/src/scss/empty/_index.scss +117 -0
- package/src/scss/empty.scss +5 -0
- package/src/scss/gallery/_index.scss +162 -0
- package/src/scss/gallery.scss +5 -0
- package/src/scss/lightbox/_index.scss +164 -0
- package/src/scss/lightbox.scss +5 -0
- package/src/scss/number-input/_index.scss +143 -0
- package/src/scss/number-input.scss +5 -0
- package/src/scss/otp-input/_index.scss +214 -0
- package/src/scss/otp-input.scss +5 -0
- package/src/scss/password-toggle/_index.scss +82 -0
- package/src/scss/password-toggle.scss +5 -0
- package/src/scss/rating/_index.scss +121 -0
- package/src/scss/rating.scss +5 -0
- package/src/scss/selection/_index.scss +84 -0
- package/src/scss/selection.scss +5 -0
- package/src/scss/settings/_index.scss +6 -0
- package/src/scss/settings/_nav-list.scss +52 -0
- package/src/scss/settings/_setting-row.scss +50 -0
- package/src/scss/settings.scss +5 -0
- package/src/scss/shop/_bar.scss +64 -0
- package/src/scss/shop/_catalog.scss +308 -0
- package/src/scss/shop/_checkout.scss +204 -0
- package/src/scss/shop/_filters.scss +116 -0
- package/src/scss/shop/_hero.scss +130 -0
- package/src/scss/shop/_index.scss +22 -0
- package/src/scss/shop/_page.scss +154 -0
- package/src/scss/shop/_reviews.scss +165 -0
- package/src/scss/shop/_stepper.scss +159 -0
- package/src/scss/shop.scss +5 -0
- package/src/scss/sidebar/_body.scss +8 -0
- package/src/scss/sidebar/_index.scss +8 -0
- package/src/scss/sidebar/_sidebar.scss +89 -0
- package/src/scss/sidebar/_theme.scss +7 -0
- package/src/scss/sidebar/_wrapper.scss +17 -0
- package/src/scss/sidebar-menu/_compact.scss +173 -0
- package/src/scss/sidebar-menu/_index.scss +9 -0
- package/src/scss/sidebar-menu/_list.scss +131 -0
- package/src/scss/sidebar-menu/_pills.scss +82 -0
- package/src/scss/sidebar-menu/_scrollbar.scss +53 -0
- package/src/scss/sidebar-menu/_theme.scss +109 -0
- package/src/scss/sidebar-menu.scss +5 -0
- package/src/scss/sidebar.scss +5 -0
- package/src/scss/spinner/_index.scss +130 -0
- package/src/scss/spinner.scss +5 -0
- package/src/scss/strength/_index.scss +118 -0
- package/src/scss/strength.scss +5 -0
- package/src/scss/theme/_accordion.scss +20 -0
- package/src/scss/theme/_alerts.scss +24 -0
- package/src/scss/theme/_avatar.scss +37 -0
- package/src/scss/theme/_badges.scss +53 -0
- package/src/scss/theme/_base.scss +9 -0
- package/src/scss/theme/_breadcrumb.scss +64 -0
- package/src/scss/theme/_buttons.scss +200 -0
- package/src/scss/theme/_cards.scss +17 -0
- package/src/scss/theme/_colors.scss +139 -0
- package/src/scss/theme/_forms.scss +175 -0
- package/src/scss/theme/_index.scss +18 -0
- package/src/scss/theme/_navs.scss +15 -0
- package/src/scss/theme/_overlays.scss +114 -0
- package/src/scss/theme/_tables.scss +59 -0
- package/src/scss/theme/_variables.scss +189 -0
- package/src/scss/theme-switcher/_index.scss +9 -0
- package/src/scss/theme-switcher.scss +5 -0
- package/src/scss/theme.scss +9 -0
- package/src/scss/tooltip/_index.scss +177 -0
- package/src/scss/tooltip.scss +5 -0
- package/README.md +0 -3
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Number input
|
|
2
|
+
|
|
3
|
+
[← Compostrap](../readme.md#documentation)
|
|
4
|
+
|
|
5
|
+
A number between a minus and a plus button, without a border: two quiet gray buttons with the number between them on the surface of the page (the variables `--number-input-btn-size`, `--number-input-btn-bg`, `--number-input-btn-hover-bg` and `--number-input-focus-bg` tune it). A fractional `step` sets the decimals the value keeps (`step="0.25"` → 1.50), `min` and `max` disable the buttons at the ends. A step fires `input` and `change` on the input, so a form can react (e.g. recount a cart by AJAX); the keys ↑ ↓ step a text input too. The buttons draw their minus and plus themselves. `number-input-sm` and `number-input-lg` follow the heights of the form controls.
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<div class="number-input">
|
|
9
|
+
<button type="button" class="number-input-btn" data-number-input="down" aria-label="Decrease"></button>
|
|
10
|
+
<input type="number" class="form-control" name="quantity" value="1" min="1" max="99" aria-label="Quantity">
|
|
11
|
+
<button type="button" class="number-input-btn" data-number-input="up" aria-label="Increase"></button>
|
|
12
|
+
</div>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { NumberInput } from 'compostrap/number-input';
|
|
17
|
+
|
|
18
|
+
NumberInput.init(); // once; inputs loaded later by AJAX work without a new init
|
|
19
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# OTP input
|
|
2
|
+
|
|
3
|
+
[← Compostrap](../readme.md#documentation)
|
|
4
|
+
|
|
5
|
+
A one-time code (a verification code from an e-mail or an SMS, a PIN) typed into separate slots, with the markup, options, methods and events of the OTP input of Bootstrap 6, so the markup stays when a project moves to it. One real input holds the value: a form sends it as any other field, a screen reader reads one field, a password manager and the autofill of a code from an SMS (`autocomplete="one-time-code"`) fill it. The script draws a slot for each character and lays the transparent input over them. The number of slots is the `maxlength` of the input (6 without it).
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<label class="form-label" for="code">Verification code</label>
|
|
9
|
+
<div class="otp" data-bs-otp>
|
|
10
|
+
<input type="text" class="otp-input" id="code" name="code" maxlength="6" aria-describedby="code-help">
|
|
11
|
+
</div>
|
|
12
|
+
<div class="form-text" id="code-help">Enter the 6-digit code sent to your phone.</div>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
An input without a label needs `aria-label`.
|
|
16
|
+
|
|
17
|
+
| Class | What it does |
|
|
18
|
+
|-------|--------------|
|
|
19
|
+
| `otp-connected` | the slots share their borders, one field |
|
|
20
|
+
| `otp-sm`, `otp-lg` | 36px and 52px slots (44px by default) |
|
|
21
|
+
| `otp-fill` | the slots share the whole width of the wrapper, e.g. in a narrow sign-in form (not in Bootstrap 6) |
|
|
22
|
+
| `is-valid`, `is-invalid` | the state of the validation, on the wrapper; on the input (as a form renderer writes it) it works too, a `valid-feedback`/`invalid-feedback` after the wrapper shows |
|
|
23
|
+
|
|
24
|
+
| Attribute of the wrapper | Default | What it does |
|
|
25
|
+
|--------------------------|---------|--------------|
|
|
26
|
+
| `data-bs-length` | `maxlength` of the input, or 6 | the number of slots |
|
|
27
|
+
| `data-bs-type` | `numeric` | `numeric`, `alphanumeric` or `alpha`: the characters that are let in (and the keyboard of a phone) |
|
|
28
|
+
| `data-bs-mask` | `false` | `true` shows `•` in the slots; the value stays |
|
|
29
|
+
| `data-bs-groups` | – | the sizes of the groups, e.g. `[3,3]`; a separator stands between them, the last size repeats |
|
|
30
|
+
| `data-bs-separator` | `·` | the text of the separator |
|
|
31
|
+
|
|
32
|
+
A typed character replaces the one of its slot and the caret goes to the next slot; Backspace and Delete remove a character, the arrows move, a click chooses a slot (never past the first empty one). A pasted code is cleaned first (`123 456` fills six slots), a whole code replaces what was there.
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
import { OtpInput } from 'compostrap/otp-input';
|
|
36
|
+
|
|
37
|
+
OtpInput.init(); // once; a code loaded later by AJAX works from its first focus
|
|
38
|
+
OtpInput.update(snippet); // draws the slots of a redrawn part at once
|
|
39
|
+
|
|
40
|
+
const otp = OtpInput.getOrCreateInstance(document.querySelector('.otp'));
|
|
41
|
+
otp.getValue();
|
|
42
|
+
otp.setValue('123456');
|
|
43
|
+
otp.clear();
|
|
44
|
+
otp.focus();
|
|
45
|
+
otp.dispose();
|
|
46
|
+
|
|
47
|
+
element.addEventListener('complete.bs.otpInput', (event) => form.requestSubmit()); // event.value is the code
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The wrapper fires `input.bs.otpInput` after every change and `complete.bs.otpInput` when all slots are filled, both with the code in `event.value` (and `event.detail.value`). The options can be passed as the second argument of `new OtpInput(element, { length, type, mask, groups, separator })` too.
|
|
51
|
+
|
|
52
|
+
The variables of the wrapper tune the look: `--otp-size`, `--otp-font-size`, `--otp-gap`, `--otp-slot-fg`, `--otp-slot-bg`, `--otp-slot-border-width`, `--otp-slot-border-color` and `--otp-slot-border-radius`. A slot has the look of a form control; the slot at the caret takes the focus of a text field and blinks a caret while it is empty.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Password toggle
|
|
2
|
+
|
|
3
|
+
[← Compostrap](../readme.md#documentation)
|
|
4
|
+
|
|
5
|
+
A button with an eye inside a password input shows the typed password and hides it again. The input and the button stand in a `.password-toggle`; the button carries `data-password-toggle`, its text for readers is the `aria-label` and `aria-pressed` says whether the password is shown. The icon follows the type of the input: an eye for a hidden password, a crossed eye for a shown one.
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<label class="form-label" for="password">Password</label>
|
|
9
|
+
<div class="password-toggle">
|
|
10
|
+
<input type="password" class="form-control" id="password" autocomplete="current-password">
|
|
11
|
+
<button type="button" class="password-toggle-btn" data-password-toggle aria-label="Show password" aria-pressed="false"></button>
|
|
12
|
+
</div>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { PasswordToggle } from 'compostrap/password-toggle';
|
|
17
|
+
|
|
18
|
+
PasswordToggle.init(); // once; forms loaded later by AJAX work without a new init
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The button is shown only once the script runs, so a page without JavaScript has a plain password input. A shown password is switched back to a password input when its form is sent. A meter of the strength (`.strength`) goes under the wrapper, not inside it, and rates a shown password too. The icons are glyphs of the icon font (Bootstrap Icons, the Sass variables `$icon-eye` and `$icon-eye-slash`), so the font has to be loaded. `--password-toggle-width` and `--password-toggle-icon` set the size of the button and of the icon.
|
package/docs/rating.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Rating
|
|
2
|
+
|
|
3
|
+
[← Compostrap](../readme.md#documentation)
|
|
4
|
+
|
|
5
|
+
Stars to choose a rating are radio inputs, so a form sends the value without JavaScript; the stars up to the checked one are filled, on hover they show the rating a click gives. A shown rating fills five stars to `--rating-value` (halves and tenths too). `rating-sm` and `rating-lg` change the size, `--rating-color` the color.
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<div class="rating" role="radiogroup" aria-label="Rating">
|
|
9
|
+
<input type="radio" class="rating-input" name="rating" id="rating-1" value="1">
|
|
10
|
+
<label class="rating-star" for="rating-1"><span class="visually-hidden">1 star</span></label>
|
|
11
|
+
<!-- … up to 5 -->
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<span class="rating-static" style="--rating-value: 4.5" role="img" aria-label="4.5 of 5"></span>
|
|
15
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Selection
|
|
2
|
+
|
|
3
|
+
[← Compostrap](../readme.md#documentation)
|
|
4
|
+
|
|
5
|
+
Rows of a table chosen by checkboxes and a bar with the actions for them (the bulk actions of a datagrid).
|
|
6
|
+
|
|
7
|
+
- `data-selection` is the wrapper of the table and the bar.
|
|
8
|
+
- `data-selection-all` is the checkbox that checks all `data-selection-item` checkboxes and shows a dash when only some are checked.
|
|
9
|
+
- `table-active` is the class a chosen row gets.
|
|
10
|
+
- `selection-bar` (`data-selection-bar`) is the bar, hidden until a row is chosen. It floats over the bottom edge of the window while its table is on the screen and stays inside its box.
|
|
11
|
+
- `data-selection-count` holds the number of the chosen rows.
|
|
12
|
+
- `data-selection-clear` unchecks them.
|
|
13
|
+
- `selection-cell` is the narrow column of the checkboxes.
|
|
14
|
+
- `data-selection-single` on a button of the bar makes it an action for one row: it is disabled while more rows are chosen.
|
|
15
|
+
- `data-selection-rows` on the wrapper lets a click anywhere on a row choose it like its checkbox. A click on a link, a button, a field or a label keeps its own meaning, a click in a cell that holds a button (the menu of the row) does nothing, and selecting a text of the row by the mouse does not choose it.
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<form class="content-box" data-selection data-selection-rows>
|
|
19
|
+
<table class="table">
|
|
20
|
+
<thead>
|
|
21
|
+
<tr>
|
|
22
|
+
<th class="selection-cell"><input type="checkbox" class="form-check-input" data-selection-all aria-label="Select all"></th>
|
|
23
|
+
<th>Title</th>
|
|
24
|
+
</tr>
|
|
25
|
+
</thead>
|
|
26
|
+
<tbody>
|
|
27
|
+
<tr>
|
|
28
|
+
<td class="selection-cell"><input type="checkbox" class="form-check-input" data-selection-item name="ids[]" value="1" aria-label="Select the row"></td>
|
|
29
|
+
<td>First steps</td>
|
|
30
|
+
</tr>
|
|
31
|
+
</tbody>
|
|
32
|
+
</table>
|
|
33
|
+
|
|
34
|
+
<div class="selection-bar" data-selection-bar hidden>
|
|
35
|
+
<span class="selection-count"><strong data-selection-count>0</strong> selected</span>
|
|
36
|
+
<div class="selection-actions">
|
|
37
|
+
<button type="submit" name="edit" class="btn btn-sm btn-secondary" data-selection-single>Edit</button>
|
|
38
|
+
<button type="submit" name="publish" class="btn btn-sm btn-secondary">Publish</button>
|
|
39
|
+
<button type="submit" name="delete" class="btn btn-sm btn-subtle theme-danger">Delete</button>
|
|
40
|
+
</div>
|
|
41
|
+
<button type="button" class="btn-close" data-selection-clear aria-label="Clear the selection"></button>
|
|
42
|
+
</div>
|
|
43
|
+
</form>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
import { RowSelection } from 'compostrap/selection';
|
|
48
|
+
|
|
49
|
+
RowSelection.init();
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The checkboxes are found on every change, so a table drawn again by AJAX needs no new `init()`; `RowSelection.update(wrapper)` brings the bar in line with the new rows and `RowSelection.clear(wrapper)` unchecks them. The bar can be changed by `--selection-bar-bg`, `--selection-bar-box-shadow`, `--selection-bar-border-radius` and `--selection-bar-offset` (its distance from the bottom edge).
|
package/docs/settings.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Settings
|
|
2
|
+
|
|
3
|
+
[← Compostrap](../readme.md#documentation)
|
|
4
|
+
|
|
5
|
+
The module `settings` holds a list of the sections of a page and rows of settings:
|
|
6
|
+
|
|
7
|
+
- `nav-list` is a vertical list of links with a count on the right, the current one in a pill of the page background.
|
|
8
|
+
- `nav-list-box` puts it in a box of the section color with the current link in the plain surface color.
|
|
9
|
+
- `setting-row` is a row of settings with the text on the left and a control on the right. The control keeps the least width `--setting-row-control-width` (7rem), so the texts of all rows line up.
|
|
10
|
+
- `setting-list` keeps a list of rows readable on wide screens (`--setting-list-max-width`, 60rem).
|
|
11
|
+
- `setting-row-locked` (a lock and a short text, its reason in a tooltip) stands for a control that cannot be changed here.
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<nav class="nav-list" aria-label="Presenters">
|
|
15
|
+
<a class="nav-list-link active" aria-current="true" href="...">Blog<span class="nav-list-count">4/5</span></a>
|
|
16
|
+
</nav>
|
|
17
|
+
|
|
18
|
+
<div class="setting-row">
|
|
19
|
+
<div class="setting-row-text">Approving comments</div>
|
|
20
|
+
<div class="setting-row-control form-check form-switch">
|
|
21
|
+
<input class="form-check-input" type="checkbox" role="switch" id="approve" checked>
|
|
22
|
+
<label class="form-check-label" for="approve">Allowed</label>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
```
|
package/docs/shop.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# Shop
|
|
2
|
+
|
|
3
|
+
[← Compostrap](../readme.md#documentation)
|
|
4
|
+
|
|
5
|
+
The module `shop` styles the storefront of an e-shop, outside the administration: a header with a mini cart, a product list and detail, the cart, the steps of the order and the summary of prices. The page is a column with a header, a `main` and a footer, so a short page keeps the footer at the bottom. The surfaces are white boxes (`.card`) on the page color, darker in the dark theme; there are no borders. The amount of an item is the `number-input` module.
|
|
6
|
+
|
|
7
|
+
The mini cart of the header (`a.shop-minicart`) shows the count of pieces in a badge over the icon and the price next to it: the shop prints the number, `99+` over 99 pieces and nothing for an empty cart (the empty badge is not shown, it stays in the page as the `aria-live` region); a wider count moves the price, it does not cover it.
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<body class="shop-page">
|
|
11
|
+
<header class="shop-header">
|
|
12
|
+
<div class="container">
|
|
13
|
+
<a class="shop-brand" href="/">Logo Name</a>
|
|
14
|
+
<ul class="shop-nav"><li><a href="/products" class="active">Products</a></li></ul>
|
|
15
|
+
<a class="shop-minicart" href="/cart" aria-label="Go to shopping cart">
|
|
16
|
+
<span class="shop-minicart-icon"><i class="bi bi-cart3"></i><span class="badge badge-sm theme-danger rounded-pill">2</span></span>
|
|
17
|
+
<span>$1,399</span>
|
|
18
|
+
</a>
|
|
19
|
+
</div>
|
|
20
|
+
</header>
|
|
21
|
+
<main class="container">…</main>
|
|
22
|
+
<footer class="shop-footer"><div class="container">© 2026 Name</div></footer>
|
|
23
|
+
</body>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Welcome band.** A low band right under the header, in the whole width of the window and tinted with the primary color (the header drops its gap, the band has it under itself): a title in two tones (`.shop-hero-title`, its `<em>` is the second one), a short text and a row of white icons of products on round chips that grow stronger towards the edge; a label over the title (`.shop-hero-eyebrow`) is optional. The icons are left out below 768px. The size of a chip is `--shop-hero-icon-size`.
|
|
27
|
+
|
|
28
|
+
```html
|
|
29
|
+
<header class="shop-header">…</header>
|
|
30
|
+
<section class="shop-hero">
|
|
31
|
+
<div class="container">
|
|
32
|
+
<div class="shop-hero-copy">
|
|
33
|
+
<p class="shop-hero-title">Your shopping, <em>simply.</em></p>
|
|
34
|
+
<p class="shop-hero-text">Browse the offer, put products into the cart and finish the order in a few easy steps.</p>
|
|
35
|
+
</div>
|
|
36
|
+
<div class="shop-hero-art" aria-hidden="true">
|
|
37
|
+
<span class="shop-hero-icon"><i class="bi bi-headphones"></i></span>
|
|
38
|
+
<span class="shop-hero-icon"><i class="bi bi-laptop"></i></span>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</section>
|
|
42
|
+
<main class="container">…</main>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Product list.** Over the list, a box `.shop-toolbar` holds the chosen filters and the order:
|
|
46
|
+
|
|
47
|
+
- `.shop-filter-chips` are the chosen filters.
|
|
48
|
+
- `nav.shop-sort` under them holds the links of the order (recommended, bestsellers, cheapest…) as `nav nav-tabs` in one row that scrolls on a phone. In the box the tabs have no frames and the current one has a line under it, on the bottom edge of the box.
|
|
49
|
+
- The page needs no visible heading then, its `h1` can be `visually-hidden`.
|
|
50
|
+
|
|
51
|
+
A tile is an `article.shop-product` with an image and a body:
|
|
52
|
+
|
|
53
|
+
- `.shop-product-image` is the image, with a `badge` of the discount in `.shop-product-badge`.
|
|
54
|
+
- `.shop-product-rating` is a `rating-static rating-sm`, the value and a link with the count of reviews. Without a rating the row gets `.shop-product-rating-empty`: empty stars with `--rating-value: 0` and a quiet text; two tiles in a row on a phone show only the text.
|
|
55
|
+
- `.shop-product-title` is the title.
|
|
56
|
+
- `.shop-product-text` is the text, cut after four lines below 768px (`--shop-product-text-lines`).
|
|
57
|
+
- `.shop-product-footer` holds the row `.shop-product-buy` and the availability under it.
|
|
58
|
+
- `.shop-product-buy` is a tinted strip with the prices in `.shop-product-prices` and a small button on the right. The price is `.shop-price`, with the original one in `.shop-price-old` under it or a word such as "from" over it.
|
|
59
|
+
- `.shop-stock` is the availability in the middle under the strip, a text with a color class: `text-success` in stock, `text-danger` out of stock.
|
|
60
|
+
|
|
61
|
+
Tiles go into a Bootstrap grid (`col-6 col-md-4 col-lg-6 col-xl-4 col-xxl-3` next to the filters, `col-xl-3` without them).
|
|
62
|
+
|
|
63
|
+
**Filters.**
|
|
64
|
+
|
|
65
|
+
- `.shop-catalog` puts the filters into a column next to the list (`--shop-filters-width`, from lg up).
|
|
66
|
+
- Below lg they are a panel: the wrapper is the responsive offcanvas of Bootstrap (`offcanvas-lg offcanvas-start`), opened by a button with `data-bs-toggle="offcanvas"`.
|
|
67
|
+
- `form.shop-filters` inside holds groups `fieldset.shop-filter` with a `legend.shop-filter-title` and plain `form-check` choices (the count of products in `.shop-filter-count`).
|
|
68
|
+
- `.shop-filter-range` is a row of two fields (price from – to).
|
|
69
|
+
- `.shop-filter-chips` shows the chosen filters over the list as links `.shop-filter-chip`; a click removes one.
|
|
70
|
+
|
|
71
|
+
**Product detail.** The photos and the text with the choice of a variant stand side by side in one box (a `card` with a `row` inside).
|
|
72
|
+
|
|
73
|
+
- `.shop-detail-gallery` holds the photos (no surface of its own): a big `img.shop-detail-main` and `.shop-detail-thumbs` of `.shop-detail-thumb` buttons or links (the shown one has `active`).
|
|
74
|
+
- The big photo opens in the [lightbox](lightbox.md) when it stands in a link `a.shop-detail-zoom` with `data-lightbox`. With the thumbnails as links of the same group (`<a href="photo.jpg" class="shop-detail-thumb" data-lightbox="product">`) the lightbox browses all the photos and opens at the shown one; the script of the project that shows a thumbnail in the big photo prevents the click, so a thumbnail does not open the lightbox itself.
|
|
75
|
+
- `.shop-variant-group` is a choice of a variant, with a `.shop-variant-title` and `.shop-variant-options` of `button.shop-variant-pill`: the chosen one has `active`, an unavailable combination is `disabled`.
|
|
76
|
+
- Switching the variants and the photos is up to the project.
|
|
77
|
+
|
|
78
|
+
**Reviews.** On the detail, `.shop-reviews-summary` shows the average next to the shares of the grades:
|
|
79
|
+
|
|
80
|
+
- `.shop-reviews-score` is the average: `.shop-reviews-value`, a `rating-static` and the count.
|
|
81
|
+
- `ul.shop-reviews-bars` are the shares of the grades, a row per grade with a `.shop-reviews-bar` filled by `--shop-reviews-share`.
|
|
82
|
+
|
|
83
|
+
A review is an `article.shop-review`:
|
|
84
|
+
|
|
85
|
+
- `.shop-review-header`: an `avatar`, `.shop-review-author` with the name and the date, a `rating-static rating-sm`,
|
|
86
|
+
- the text,
|
|
87
|
+
- `.shop-review-points` with the lists `.shop-review-pros` and `.shop-review-cons` (a green plus and a red minus before each item),
|
|
88
|
+
- `.shop-review-footer` with the buttons of a helpful review.
|
|
89
|
+
|
|
90
|
+
The rating row of a tile (`.shop-product-rating`) is used under the name of the product too, its link leads to the reviews.
|
|
91
|
+
|
|
92
|
+
**Steps of the order.** A step of the order starts with `header.shop-checkout-head`, one bar from lg up:
|
|
93
|
+
|
|
94
|
+
- The title of the page (`h1`) stands in its left third, the steps in the other two thirds (5 : 7 between lg and xl), so they stay in place whatever the length of the title.
|
|
95
|
+
- Below lg the steps go under the title.
|
|
96
|
+
- Where the steps have little room, only the current one keeps its name; on phones too.
|
|
97
|
+
|
|
98
|
+
The steps are an `ol.shop-stepper` of `li.shop-stepper-item`:
|
|
99
|
+
|
|
100
|
+
- `.shop-stepper-badge` is the number, or a check icon in a done step.
|
|
101
|
+
- `.shop-stepper-label` is the name of the step.
|
|
102
|
+
- `.shop-stepper-line` joins it with the next one.
|
|
103
|
+
- `is-done` marks a step already passed (its badge is a link back), `is-current` the present one.
|
|
104
|
+
|
|
105
|
+
```html
|
|
106
|
+
<nav aria-label="Checkout steps">
|
|
107
|
+
<ol class="shop-stepper">
|
|
108
|
+
<li class="shop-stepper-item is-done"><a href="/cart"><span class="shop-stepper-badge"><i class="bi bi-check-lg"></i></span><span class="shop-stepper-label">Cart</span></a><span class="shop-stepper-line"></span></li>
|
|
109
|
+
<li class="shop-stepper-item is-current" aria-current="step"><span><span class="shop-stepper-badge">2</span><span class="shop-stepper-label">Delivery and payment</span></span><span class="shop-stepper-line"></span></li>
|
|
110
|
+
<li class="shop-stepper-item"><span><span class="shop-stepper-badge">3</span><span class="shop-stepper-label">Summary</span></span></li>
|
|
111
|
+
</ol>
|
|
112
|
+
</nav>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Cart.** A row of an item is `.shop-cart-item` with `.shop-cart-photo`, `.shop-cart-info`, `.shop-cart-qty` (a number input), `.shop-cart-price` and a button to remove it.
|
|
116
|
+
|
|
117
|
+
**Delivery and payment.** A choice is a hidden radio `.btn-check` followed by a `label.shop-option` with the name (`.shop-option-main` with a `.shop-option-icon`) and the price (`.shop-option-price`); the chosen option is tinted.
|
|
118
|
+
|
|
119
|
+
```html
|
|
120
|
+
<input type="radio" class="btn-check" name="carrier" id="carrier-1" checked>
|
|
121
|
+
<label class="shop-option" for="carrier-1">
|
|
122
|
+
<span class="shop-option-main"><i class="shop-option-icon bi bi-truck"></i><span>Courier</span></span>
|
|
123
|
+
<span class="shop-option-price">$5</span>
|
|
124
|
+
</label>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Summary of prices.** `.shop-summary` holds a card that stays in view while the page scrolls (from large screens); its rows are `.shop-summary-row` and the line of the total `.shop-summary-total` with the sum in `.shop-summary-sum`.
|
|
128
|
+
|
|
129
|
+
**Bar on a phone.** `.shop-bar` is fixed at the bottom of the screen below the large breakpoint: the total (`.shop-bar-total` with `.shop-bar-label` and `.shop-bar-sum`) and the button to go on, so the button is not far below the content. The button of the summary card then gets `d-none d-lg-block` (one button at a time); from large screens the bar is hidden and the sticky `.shop-summary` is used. A page with the bar gets room under its footer.
|
|
130
|
+
|
|
131
|
+
```html
|
|
132
|
+
<div class="shop-bar">
|
|
133
|
+
<div class="shop-bar-total"><span class="shop-bar-label">Total to pay</span><span class="shop-bar-sum">$1,404</span></div>
|
|
134
|
+
<a class="btn btn-primary" href="/customer">Continue <i class="bi bi-arrow-right"></i></a>
|
|
135
|
+
</div>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Facts of an order.** `dl.shop-info` shows the facts to read (the customer, the address, the carrier and the payment in the summary and the confirmation): each pair is a `div` with a `dt` (a quiet label) over a `dd` (the value), side by side as many as fit. An address inside is an `address.shop-address`, written as on a parcel: the name in a `strong` on its own line, then the street, the town and the country.
|
|
139
|
+
|
|
140
|
+
**Confirmation of an order.** `.shop-confirm` (with `theme-success`) is the banner after the order is placed, in the tint of a subtle success badge: `.shop-confirm-icon` (a check in a green circle) on the left, next to it `.shop-confirm-title` in the green of the text and a text with the number of the order. Under it go the ordered items (`.shop-cart-item` rows without the amount control), the delivery and the `.shop-summary`; all steps of the stepper are `is-done`.
|
package/docs/spinner.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Spinner
|
|
2
|
+
|
|
3
|
+
[← Compostrap](../readme.md#documentation)
|
|
4
|
+
|
|
5
|
+
A spinner shows that a request runs, for example an AJAX request of the page. It has two forms:
|
|
6
|
+
|
|
7
|
+
- `.spinner`: a thin line at the top of the window with a piece that runs from left to right. The page stays in use.
|
|
8
|
+
- `.spinner-overlay`: the whole window darkens and a ring turns in its middle. It lies over everything, so nothing can be clicked until the request ends.
|
|
9
|
+
|
|
10
|
+
```html
|
|
11
|
+
<div class="spinner" role="status"><span class="spinner-label">Loading</span></div>
|
|
12
|
+
|
|
13
|
+
<div class="spinner-overlay" role="status"><span class="spinner-label">Loading</span></div>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The element stands at the end of `<body>` only while the request runs. The script adds and removes it:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
import { Spinner } from 'compostrap/spinner';
|
|
20
|
+
|
|
21
|
+
const spinner = new Spinner(); // the line at the top
|
|
22
|
+
const spinner = new Spinner({ overlay: true }); // the dark overlay
|
|
23
|
+
|
|
24
|
+
spinner.show();
|
|
25
|
+
fetch(url).finally(() => spinner.hide());
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`show()` and `hide()` are counted: with more requests at once the spinner stays until the last one ends. `spinner.active` says whether a request runs. The overlay also stops the keys Tab, Enter and Space, so a focused button cannot send a form once more, and gives the focus back when it ends. The options are `overlay` (false), `label` (the text for a screen reader in `.spinner-label`, "Loading"; the script writes it a moment after the spinner is shown, so a screen reader announces it) and `parent` (`document.body`).
|
|
29
|
+
|
|
30
|
+
With Naja, show the spinner on its `start` event and hide it on `complete`:
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
naja.addEventListener('start', () => spinner.show());
|
|
34
|
+
naja.addEventListener('complete', () => spinner.hide());
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
A single box that loads does not need a spinner of the window: see the loading state `aria-busy` of [elements](elements.md).
|
|
38
|
+
|
|
39
|
+
## Variables
|
|
40
|
+
|
|
41
|
+
| Variable | Form | Default | Meaning |
|
|
42
|
+
|----------|------|---------|---------|
|
|
43
|
+
| `--spinner-zindex` | both | `9999` | the layer, over modals and offcanvases |
|
|
44
|
+
| `--spinner-color` | both | `var(--bs-primary)`, overlay `#fff` | the color of the running piece or of the ring |
|
|
45
|
+
| `--spinner-duration` | both | `1.5s`, overlay `.7s` | the time of one run or turn |
|
|
46
|
+
| `--spinner-height` | line | `.2rem` | the height of the line |
|
|
47
|
+
| `--spinner-width` | line | `15rem` | the width of the running piece |
|
|
48
|
+
| `--spinner-overlay-bg` | overlay | `rgba(0, 0, 0, .5)` | the color over the page |
|
|
49
|
+
| `--spinner-size` | overlay | `3rem` | the size of the ring |
|
|
50
|
+
| `--spinner-border-width` | overlay | `3px` | the width of the ring |
|
|
51
|
+
| `--spinner-track-color` | overlay | `rgba(255, 255, 255, .25)` | the color of the rest of the ring |
|
package/docs/strength.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Password strength
|
|
2
|
+
|
|
3
|
+
[← Compostrap](../readme.md#documentation)
|
|
4
|
+
|
|
5
|
+
A meter under a password input rates the password while it is typed, with the markup of the strength component of Bootstrap 6, so the markup stays when a project moves to it. Four segments (`strength`) or one growing bar (`strength-bar`) take the colors of the levels weak, fair, good and strong; `strength-text` next to the meter shows the name of the level. The meter belongs to the password input in the same parent (or a parent up to three levels above, e.g. around a show-password wrapper).
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<label class="form-label" for="password">Password</label>
|
|
9
|
+
<input type="password" class="form-control" id="password" aria-describedby="password-strength">
|
|
10
|
+
<div class="strength" data-bs-strength>
|
|
11
|
+
<div class="strength-segment"></div>
|
|
12
|
+
<div class="strength-segment"></div>
|
|
13
|
+
<div class="strength-segment"></div>
|
|
14
|
+
<div class="strength-segment"></div>
|
|
15
|
+
</div>
|
|
16
|
+
<span class="strength-text" id="password-strength" aria-live="polite"></span>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import { Strength } from 'compostrap/strength';
|
|
21
|
+
|
|
22
|
+
Strength.init(); // once; forms loaded later by AJAX work without a new init
|
|
23
|
+
Strength.init({ messages: { weak: 'Slabé', fair: 'Ucházející', good: 'Dobré', strong: 'Silné' } }); // translated levels
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
A point is given for 8 characters, for 12, for lower case, upper case, a digit, a special character, two special characters and for 16 characters; up to 2 points is weak, 4 fair, 6 good, more strong. `minLength`, `thresholds` and an own `scorer(password)` change it. The meter fires `strengthChange` with `detail.strength` and `detail.score`. It only helps the user: the rules of a password belong to the validation of the form.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Theme switcher
|
|
2
|
+
|
|
3
|
+
[← Compostrap](../readme.md#documentation)
|
|
4
|
+
|
|
5
|
+
The theme is light, dark or `auto`: the setting of the system, followed when the system switches. The choice is remembered in `localStorage`; until a user chooses, the page follows the system (`defaultTheme: 'auto'`; a project that wants one theme for new visitors sets `'light'` or `'dark'`, also in the script of the head). A choice made in another tab of the browser is taken over. The administration puts it in the user menu as a segmented control: choice buttons with `data-theme-value`, the chosen one gets `active` and `aria-pressed`. `data-bs-auto-close="outside"` on the toggle of the menu keeps it open after a click on a choice; `dropdown-theme` (module `dashboard`) lays the row out.
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<li class="dropdown-theme">
|
|
9
|
+
<span class="dropdown-theme-label">Theme</span>
|
|
10
|
+
<div class="btn-group btn-group-segmented" role="group" aria-label="Theme">
|
|
11
|
+
<button type="button" class="btn btn-sm" data-theme-value="light"><i class="bi bi-sun"></i>Light</button>
|
|
12
|
+
<button type="button" class="btn btn-sm" data-theme-value="dark"><i class="bi bi-moon"></i>Dark</button>
|
|
13
|
+
<button type="button" class="btn btn-sm" data-theme-value="auto"><i class="bi bi-display"></i>Auto</button>
|
|
14
|
+
</div>
|
|
15
|
+
</li>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The auto choice says which theme the system has now: the script sets its `title` (`autoLightTitle`, `autoDarkTitle`, or `data-theme-auto-light-title` and `data-theme-auto-dark-title` on the button) and `data-theme-system="light|dark"`, a hook for an own mark.
|
|
19
|
+
|
|
20
|
+
A single toggle button (e.g. on a sign-in page) switches light ↔ dark. It shows the opposite of the theme on the screen; when that is the theme of the system, the page goes back to following the system (`auto` is stored) instead of being pinned to it. A label and an icon from any icon library are optional:
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<button
|
|
24
|
+
type="button"
|
|
25
|
+
class="btn btn-link nav-link theme-switcher"
|
|
26
|
+
aria-label="Toggle theme"
|
|
27
|
+
data-theme-switcher
|
|
28
|
+
data-theme-light-icon="bi bi-sun"
|
|
29
|
+
data-theme-dark-icon="bi bi-moon"
|
|
30
|
+
data-theme-light-label="Light mode"
|
|
31
|
+
data-theme-dark-label="Dark mode"
|
|
32
|
+
>
|
|
33
|
+
<i data-theme-switcher-icon class="bi bi-moon"></i>
|
|
34
|
+
<span data-theme-switcher-label>Dark mode</span>
|
|
35
|
+
</button>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`data-theme-light-label` is shown when the page is dark and the button switches to light, `data-theme-dark-label` the other way round; the shorter `data-light-label`, `data-dark-label`, `data-light-icon` and `data-dark-icon` work too. Labels are English by default. The same values can be passed to JavaScript:
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
new ThemeSwitcher({
|
|
42
|
+
selector: '[data-theme-switcher]',
|
|
43
|
+
storageKey: 'bootstrap-theme',
|
|
44
|
+
defaultTheme: 'auto',
|
|
45
|
+
lightIcon: '',
|
|
46
|
+
darkIcon: '',
|
|
47
|
+
lightLabel: 'Light mode',
|
|
48
|
+
darkLabel: 'Dark mode',
|
|
49
|
+
autoLightTitle: 'System theme: light',
|
|
50
|
+
autoDarkTitle: 'System theme: dark',
|
|
51
|
+
}).initialize();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
After each change the switcher dispatches `theme-switcher:change` on `window`:
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
window.addEventListener('theme-switcher:change', (event) => {
|
|
58
|
+
console.log(event.detail.theme, event.detail.mode); // "dark", "auto"
|
|
59
|
+
});
|
|
60
|
+
```
|
package/docs/theme.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Theme
|
|
2
|
+
|
|
3
|
+
[← Compostrap](../readme.md#documentation)
|
|
4
|
+
|
|
5
|
+
The theme changes the components of Bootstrap and adds the classes of Bootstrap 6; there are no classes of its own besides the size modifiers `badge-sm` and `form-check-sm` and `btn-group-segmented`.
|
|
6
|
+
|
|
7
|
+
## Colors, buttons, alerts and badges
|
|
8
|
+
|
|
9
|
+
The theme uses the colors of Bootstrap 6 (a lighter blue, livelier green, red and cyan). Badges look like in Bootstrap 6 and take its classes, so the markup stays valid after the upgrade: a `theme-*` class gives the color (`theme-primary`, `theme-success`, `theme-danger`, `theme-warning`, `theme-info`, `theme-secondary`…), `badge-subtle` and `badge-outline` the variant.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<span class="badge theme-primary">New</span>
|
|
13
|
+
<span class="badge badge-subtle theme-primary">New</span>
|
|
14
|
+
<span class="badge badge-outline theme-primary">New</span>
|
|
15
|
+
<span class="badge badge-subtle">Draft</span> <!-- gray without a color -->
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Buttons and alerts take the colors of Bootstrap 6 too. Buttons darken a little on hover; outline buttons have a light border in the color, `btn-secondary` is a light gray button. The new variants of Bootstrap 6 work with a `theme-*` class:
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<button class="btn btn-primary">Save</button> <!-- the same as btn-solid theme-primary -->
|
|
22
|
+
<button class="btn btn-outline-primary">Preview</button>
|
|
23
|
+
<button class="btn btn-subtle theme-primary">Duplicate</button>
|
|
24
|
+
<button class="btn btn-text theme-danger">Delete</button>
|
|
25
|
+
<a class="btn btn-xs btn-icon btn-outline-secondary" aria-label="Edit" data-tooltip><i class="bi bi-pencil"></i></a> <!-- 24px square icon button -->
|
|
26
|
+
<div class="alert alert-success">The order was paid.</div> <!-- or alert theme-success -->
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Alerts are the text of the color on its light tint, without a border. A `theme-*` class (and `btn-primary`, `btn-outline-primary`, `alert-primary`…) sets the CSS variables `--theme-bg`, `--theme-contrast`, `--theme-fg`, `--theme-fg-emphasis`, `--theme-bg-subtle`, `--theme-bg-muted` and `--theme-border` of its color, also for the dark theme.
|
|
30
|
+
|
|
31
|
+
## Breadcrumb
|
|
32
|
+
|
|
33
|
+
The theme has the breadcrumb of Bootstrap 6 with its markup: links with a quiet pill on hover, a thin chevron as a separate divider, the current page in the body color.
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<ol class="breadcrumb">
|
|
37
|
+
<li class="breadcrumb-item"><a class="breadcrumb-link" href="...">Dashboard</a></li>
|
|
38
|
+
<li class="breadcrumb-divider" aria-hidden="true"></li>
|
|
39
|
+
<li class="breadcrumb-item"><a class="breadcrumb-link active" aria-current="page">Blog articles</a></li>
|
|
40
|
+
</ol>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Tabs as a segmented control
|
|
44
|
+
|
|
45
|
+
With the theme a button group with `role="tablist"` (or the class `btn-group-segmented`) looks like a segmented control: a quiet track with the active tab raised on it.
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<div class="btn-group" role="tablist">
|
|
49
|
+
<button class="btn btn-secondary btn-sm active" type="button" role="tab" data-bs-toggle="pill" data-bs-target="#tab-1">Product</button>
|
|
50
|
+
<button class="btn btn-secondary btn-sm" type="button" role="tab" data-bs-toggle="pill" data-bs-target="#tab-2">Variants</button>
|
|
51
|
+
</div>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Forms
|
|
55
|
+
|
|
56
|
+
An icon or a unit stands inside its field: the form adorn of Bootstrap 6. The wrapper is a `<label>` with `form-control form-adorn` (a click anywhere in it focuses the field), the field inside is a `form-ghost`; `form-adorn-end` moves the adornment to the end, `form-control-sm` and `form-control-lg` size it. Adornments are decorative (`aria-hidden`), and a button does not belong inside a label: a button or a select next to a field stays an `input-group`.
|
|
57
|
+
|
|
58
|
+
```html
|
|
59
|
+
<label class="form-control form-adorn">
|
|
60
|
+
<span class="form-adorn-icon" aria-hidden="true"><i class="bi bi-search"></i></span>
|
|
61
|
+
<input type="search" class="form-ghost" placeholder="Search" aria-label="Search">
|
|
62
|
+
</label>
|
|
63
|
+
|
|
64
|
+
<label for="price" class="form-label">Price</label>
|
|
65
|
+
<label class="form-control form-adorn">
|
|
66
|
+
<span class="form-adorn-text" aria-hidden="true">$</span>
|
|
67
|
+
<input type="number" class="form-ghost" id="price">
|
|
68
|
+
</label>
|
|
69
|
+
|
|
70
|
+
<label class="form-control form-adorn form-adorn-end">
|
|
71
|
+
<span class="form-adorn-text" aria-hidden="true">%</span>
|
|
72
|
+
<input type="number" class="form-ghost" aria-label="Discount">
|
|
73
|
+
</label>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The variables `--form-adorn-gap`, `--form-adorn-icon-size` and `--form-adorn-icon-color` tune it.
|
|
77
|
+
|
|
78
|
+
Checks, radios and switches are 20px; `form-check-sm` makes them 16px (a 28 × 16px switch), on the wrapper or on a check without one:
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<div class="form-check form-check-sm">
|
|
82
|
+
<input class="form-check-input" type="checkbox" id="terms">
|
|
83
|
+
<label class="form-check-label" for="terms">I agree</label>
|
|
84
|
+
</div>
|
|
85
|
+
<div class="form-check form-check-sm form-switch">…</div>
|
|
86
|
+
<input class="form-check-input form-check-sm" type="checkbox" aria-label="Select the row">
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
On an iPhone or an iPad the text of a field is 16px instead of 14px (12px in the small size): Safari of iOS zooms the page in when a field with a smaller text gets the focus. The rule is inside `@supports (-webkit-touch-callout: none)`, which only iOS matches; the line keeps its height, so the fields are as high as elsewhere. The number of `number-input` does the same.
|
|
90
|
+
|
|
91
|
+
A field with an error of the server (`is-invalid`) also says it to a screen reader: `aria-invalid="true"` and `aria-describedby` with the `id` of its `invalid-feedback`.
|
|
92
|
+
|
|
93
|
+
```html
|
|
94
|
+
<input type="email" class="form-control is-invalid" id="email" aria-invalid="true" aria-describedby="email-error">
|
|
95
|
+
<div class="invalid-feedback" id="email-error">Please enter a valid e-mail.</div>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Offcanvas and modals
|
|
99
|
+
|
|
100
|
+
An offcanvas floats: it keeps a gap of 8px from the edges of the window, has rounded corners and a shadow instead of a border. `offcanvas-flush` keeps a panel stuck to the edge. A modal has no border, a shadow and a light line above the footer. Dropdowns have no border and a soft shadow, the chosen item is tinted instead of filled with the primary color. A toast follows the modals: no border, an opaque surface (a lighter one in the dark theme), larger corners and a shadow.
|
package/docs/tooltip.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Tooltip
|
|
2
|
+
|
|
3
|
+
[← Compostrap](../readme.md#documentation)
|
|
4
|
+
|
|
5
|
+
A tooltip of pure CSS for buttons and links with an icon only: the text of `aria-label` is shown on hover and keyboard focus, dark on a light page and light on a dark one, and screen readers read it as the name. It needs no JavaScript, so it works in content loaded by AJAX too. An optional script adds one key: Esc hides the tooltip that is shown, without moving the mouse or the focus away (WCAG 1.4.13); the first Esc goes no further, so a modal under the tooltip stays open, and the tooltip comes back when the mouse or the focus returns to the element.
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { CssTooltip } from 'compostrap/tooltip';
|
|
9
|
+
|
|
10
|
+
CssTooltip.init(); // once; content loaded later works without a new init
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<a href="..." class="btn btn-sm btn-danger" aria-label="Delete" data-tooltip>
|
|
15
|
+
<i class="bi bi-trash" aria-hidden="true"></i>
|
|
16
|
+
</a>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`data-tooltip="left"` shows it on the left, e.g. at the right edge of a table, `data-tooltip="end"` above but aligned to its right edge (a button at the right edge of a card or an offcanvas), `data-tooltip="start"` above but aligned to its left edge (a wide tooltip near the left edge), `data-tooltip="bottom"` under the element, e.g. in a navbar. `data-tooltip-color` colors it by a theme color of Bootstrap (`primary`, `secondary`, `success`, `danger`, `warning`, `info`, `light`, `dark`), with dark text on the light ones (on `warning` the brown of the solid warning button):
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<button class="btn btn-sm btn-icon btn-secondary" aria-label="Delete" data-tooltip data-tooltip-color="danger"><i class="bi bi-trash"></i></button>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
A tooltip is one line. A long text, such as a list, takes `data-tooltip-wrap`: it wraps within 22rem (never wider than the window), keeps the line breaks of the `aria-label` (` `, one item per line) and is aligned to the left:
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<span class="badge badge-subtle theme-warning" tabindex="0" data-tooltip="start" data-tooltip-wrap
|
|
29
|
+
aria-label="Action: ArticleControl::handleEdit CategoryControl::handleEdit">Action</span>
|
|
30
|
+
```
|
package/license
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Zdeněk Papučík
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|