compostrap 1.0.2 → 1.0.3
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/compostrap.css +4 -4
- package/dist/css/sidebar-menu.css +4 -4
- package/dist/css/theme.css +5 -22
- package/docs/blog.md +85 -85
- package/docs/layout.md +143 -143
- package/package.json +1 -1
- package/readme.md +198 -198
- package/src/js/datepicker.js +154 -154
- package/src/scss/datagrid.scss +5 -5
- package/src/scss/datepicker/_index.scss +557 -557
- package/src/scss/sidebar/_index.scss +8 -8
- package/src/scss/sidebar-menu/_pills.scss +10 -8
package/readme.md
CHANGED
|
@@ -1,198 +1,198 @@
|
|
|
1
|
-
## Compostrap
|
|
2
|
-
|
|
3
|
-
Bootstrap 5 for administrations and websites in one package: a theme with the look, colors and classes of Bootstrap 6, a layout with a sidebar, a multi-level menu and a navbar, and components that Bootstrap does not have (gallery, dropzone, lightbox, password strength, empty states, sign-in pages…). Every part is a module that can be used alone, or all of them together.
|
|
4
|
-
|
|
5
|
-
[](https://github.com/compostrap/compostrap/blob/main/license)
|
|
6
|
-
[](https://badge.fury.io/js/compostrap)
|
|
7
|
-
[](https://github.com/compostrap/compostrap/actions/workflows/build.yml)
|
|
8
|
-
|
|
9
|
-
## Contents
|
|
10
|
-
|
|
11
|
-
- [Requirements](#requirements)
|
|
12
|
-
- [Installation](#installation)
|
|
13
|
-
- [Architecture](#architecture): the three layers and the table of the modules
|
|
14
|
-
- [Usage](#usage)
|
|
15
|
-
- [Light and dark theme](#light-and-dark-theme)
|
|
16
|
-
- [Documentation](#documentation): the theme, the layout and every component
|
|
17
|
-
- [Demo](#demo)
|
|
18
|
-
- [Tests](#tests)
|
|
19
|
-
|
|
20
|
-
## Requirements
|
|
21
|
-
|
|
22
|
-
- [Bootstrap](https://getbootstrap.com) 5.3
|
|
23
|
-
- [Bootstrap Icons](https://icons.getbootstrap.com) 1.11 for the arrows of the menu and the breadcrumb separators (`sidebar-menu`, `dashboard`); another icon font can be set by the Sass variables `$icon-font`, `$icon-font-weight`, `$icon-chevron-right` and `$icon-chevron-down`
|
|
24
|
-
- [Perfect scrollbar](https://github.com/mdbootstrap/perfect-scrollbar) when the menu scrolls with it (`sidebar-menu` styles its rail)
|
|
25
|
-
- [Nanobar](https://github.com/jacoborus/nanobar) when the page shows a nanobar (`dashboard` styles it)
|
|
26
|
-
- [Vanilla Calendar Pro](https://vanilla-calendar.pro) 3.4 for the module `datepicker` (as in Bootstrap 6)
|
|
27
|
-
- [Chart.js](https://www.chartjs.org) 4.6 for the module `chart`
|
|
28
|
-
|
|
29
|
-
## Installation
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
npm install compostrap bootstrap
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Architecture
|
|
36
|
-
|
|
37
|
-
The package has three layers:
|
|
38
|
-
|
|
39
|
-
| Layer | What it is | Classes |
|
|
40
|
-
|-------|------------|---------|
|
|
41
|
-
| **Theme** | Bootstrap itself, built with the variables of compostrap and finished by its CSS: the colors, buttons, badges, forms, tables, navs, overlays… in a calm, dense look | only the classes of Bootstrap 5 and of Bootstrap 6 (`btn-subtle`, `badge-subtle`, `theme-*`, `breadcrumb-link`, `avatar`…), so the markup stays valid after the upgrade to Bootstrap 6 |
|
|
42
|
-
| **Layout** | the frame of an administration: the sidebar, its menu, the navbar over the content and the boxes of the page | `sidebar-*`, `list-*` (menu), `navbar-*`, `content-box` |
|
|
43
|
-
| **Components** | what compostrap adds, each a module of its own | the name of the module as the prefix (`gallery-*`, `empty-*`, `auth-*`…) |
|
|
44
|
-
|
|
45
|
-
| Module | Layer | What it does | JavaScript |
|
|
46
|
-
|--------|-------|--------------|------------|
|
|
47
|
-
| [`theme`](docs/theme.md) | theme | Bootstrap in the look of compostrap: neutral grays, 14px text, quiet shadows, one size scale of buttons and form controls, the colors and variants of Bootstrap 6 | – |
|
|
48
|
-
| [`sidebar`](docs/layout.md#sidebar) | layout | the sidebar: fixed on large screens, an overlay with a backdrop on small | `Sidebar` |
|
|
49
|
-
| [`sidebar-menu`](docs/layout.md#sidebar-menu) | layout | a multi-level menu in the sidebar, links as pills, the current page on any level in a pill; a compact sidebar with the icons only | `SidebarMenu`, `Sidebar` (compact) |
|
|
50
|
-
| [`dashboard`](docs/layout.md) | layout | the page background, the navbar over the content with a breadcrumb, icons and the user, the content boxes, the nanobar | – |
|
|
51
|
-
| [`theme-switcher`](docs/theme-switcher.md) | component | switches the light and dark theme of Bootstrap and remembers the choice | `ThemeSwitcher` |
|
|
52
|
-
| [`tooltip`](docs/tooltip.md) | component | a tooltip of pure CSS for buttons and links with an icon only | `CssTooltip` (optional: Esc hides it) |
|
|
53
|
-
| [`elements`](docs/elements.md) | component | small pieces of a page: state dots, stat tiles, list rows, the loading state of a box | – |
|
|
54
|
-
| [`dialogs`](docs/dialogs.md) | component | a colored line and a confirmation of a modal, a bar of buttons at the bottom of an offcanvas, a toast with the message of a state, a search dialog; dialogs that stay open on a click outside | `Dialogs` |
|
|
55
|
-
| [`settings`](docs/settings.md) | component | a list of the sections of a page and rows of settings with their controls | – |
|
|
56
|
-
| [`datagrid`](docs/datagrid.md) | component | the table of a list: the row of filters, clickable rows and the column of row actions | – |
|
|
57
|
-
| [`selection`](docs/selection.md) | component | rows of a table chosen by checkboxes and a bar with the actions for them | `RowSelection` |
|
|
58
|
-
| [`number-input`](docs/number-input.md) | component | a number with minus and plus buttons, e.g. the quantity in a cart | `NumberInput` |
|
|
59
|
-
| [`otp-input`](docs/otp-input.md) | component | a one-time code typed into separate slots over one real input (the OTP input of Bootstrap 6) | `OtpInput` |
|
|
60
|
-
| [`datepicker`](docs/datepicker.md) | component | the calendar of Bootstrap 6 (Vanilla Calendar Pro) under a date input | `Datepicker` |
|
|
61
|
-
| [`chart`](docs/chart.md) | component | charts of Chart.js written as markup, in the colors and fonts of the theme | `Charts` |
|
|
62
|
-
| [`rating`](docs/rating.md) | component | stars to choose a rating in a form or to show one, halves too | – |
|
|
63
|
-
| [`gallery`](docs/gallery.md) | component | square tiles of images with buttons over the image on hover | – |
|
|
64
|
-
| [`dropzone`](docs/dropzone.md) | component | a large area to drop files on or to click, made of a plain file input | `DropzoneInput` |
|
|
65
|
-
| [`lightbox`](docs/lightbox.md) | component | a full-screen preview of images, browsed by arrows, keys and swipe | `Lightbox` |
|
|
66
|
-
| [`strength`](docs/strength.md) | component | a meter of the password strength under a password input (markup of Bootstrap 6) | `Strength` |
|
|
67
|
-
| [`password-toggle`](docs/password-toggle.md) | component | a button with an eye in a password input that shows and hides the password | `PasswordToggle` |
|
|
68
|
-
| [`empty`](docs/empty.md) | component | empty states in boxes and error pages (404, 403, 500, maintenance) with illustrations | – |
|
|
69
|
-
| [`spinner`](docs/spinner.md) | component | shows that a request runs: a line at the top of the window, or a dark overlay that stops clicks | `Spinner` |
|
|
70
|
-
| [`auth`](docs/auth.md) | component | pages outside the administration (sign in, sign up, recovery): a box in the middle of the page | – |
|
|
71
|
-
| [`shop`](docs/shop.md) | component | the storefront of an e-shop: header with the mini cart, product tiles and detail, cart, steps of the order, choice of the delivery, price summary | `number-input` (amount) |
|
|
72
|
-
| [`blog`](docs/blog.md) | component | a website with a blog: header with the links, list of articles with categories, an article with its text, comments | `avatar` of the theme |
|
|
73
|
-
|
|
74
|
-
The components and the layout work with plain Bootstrap too; the ones with colors (`theme-*` classes) take them from the theme.
|
|
75
|
-
|
|
76
|
-
## Usage
|
|
77
|
-
|
|
78
|
-
The theme is Bootstrap built with the variables of compostrap, so it takes the place of Bootstrap's own styles:
|
|
79
|
-
|
|
80
|
-
```javascript
|
|
81
|
-
import 'compostrap/css/theme.css'; // instead of 'bootstrap/dist/css/bootstrap.css'
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
```scss
|
|
85
|
-
// own Bootstrap variables before it, e.g. $primary: #066fd1;
|
|
86
|
-
@import 'compostrap/src/scss/theme'; // instead of @import 'bootstrap/scss/bootstrap';
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
The other modules work with plain Bootstrap too. All of them at once:
|
|
90
|
-
|
|
91
|
-
```javascript
|
|
92
|
-
import 'compostrap/css/compostrap.css';
|
|
93
|
-
import { Sidebar, SidebarMenuApp, ThemeSwitcher, DropzoneInput, Lightbox, Strength, NumberInput } from 'compostrap';
|
|
94
|
-
import { Datepicker } from 'compostrap/datepicker'; // only with vanilla-calendar-pro installed
|
|
95
|
-
import { Charts } from 'compostrap/chart'; // only with chart.js installed
|
|
96
|
-
|
|
97
|
-
document.addEventListener('DOMContentLoaded', () => {
|
|
98
|
-
Sidebar.init();
|
|
99
|
-
SidebarMenuApp.init();
|
|
100
|
-
new ThemeSwitcher().initialize();
|
|
101
|
-
});
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Or only the modules you need, each has its own CSS and JavaScript:
|
|
105
|
-
|
|
106
|
-
```javascript
|
|
107
|
-
import 'compostrap/css/theme-switcher.css';
|
|
108
|
-
import { ThemeSwitcher } from 'compostrap/theme-switcher';
|
|
109
|
-
|
|
110
|
-
new ThemeSwitcher().initialize();
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
The styles can also be imported as SCSS:
|
|
114
|
-
|
|
115
|
-
```scss
|
|
116
|
-
@import 'compostrap/src/scss/compostrap';
|
|
117
|
-
// or a single module
|
|
118
|
-
@import 'compostrap/src/scss/sidebar-menu';
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
When modules are loaded one by one, load them after the theme (or Bootstrap) in the order `theme-switcher`, `tooltip`, `elements`, `dialogs`, `settings`, `datagrid`, `selection`, `number-input`, `otp-input`, `datepicker`, `rating`, `chart`, `gallery`, `dropzone`, `lightbox`, `strength`, `password-toggle`, `empty`, `spinner`, `auth`, `shop`, `blog`, `sidebar`, `sidebar-menu`, `dashboard`: each later one finishes the layout of the earlier ones.
|
|
122
|
-
|
|
123
|
-
## Light and dark theme
|
|
124
|
-
|
|
125
|
-
All modules follow the global theme of Bootstrap in `data-bs-theme`:
|
|
126
|
-
|
|
127
|
-
```html
|
|
128
|
-
<html lang="en" data-bs-theme="light">
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
The switcher stores the choice in `localStorage` under `bootstrap-theme`; without a stored choice the page follows the system. To avoid a light flash of a dark page, set the theme before the page is drawn:
|
|
132
|
-
|
|
133
|
-
```html
|
|
134
|
-
<script>
|
|
135
|
-
try {
|
|
136
|
-
let theme = localStorage.getItem('bootstrap-theme') || 'auto';
|
|
137
|
-
if (theme === 'auto') {
|
|
138
|
-
theme = matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
139
|
-
}
|
|
140
|
-
if (theme === 'light' || theme === 'dark') {
|
|
141
|
-
document.documentElement.setAttribute('data-bs-theme', theme);
|
|
142
|
-
}
|
|
143
|
-
} catch (e) { }
|
|
144
|
-
</script>
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
The dashboard keeps the surface colors of Bootstrap:
|
|
148
|
-
|
|
149
|
-
| Theme | Page background | Sidebar and content |
|
|
150
|
-
|-------|----------------------------|---------------------|
|
|
151
|
-
| Light | `--bs-tertiary-bg` darkened by 1.6 % (`#f6f6f6` in the theme) | `var(--bs-body-bg)` |
|
|
152
|
-
| Dark | `--bs-body-bg` mixed 55 % with black | `var(--bs-body-bg)` |
|
|
153
|
-
|
|
154
|
-
## Documentation
|
|
155
|
-
|
|
156
|
-
Every module is described in `docs/`, with its markup, classes, variables and JavaScript:
|
|
157
|
-
|
|
158
|
-
- **Theme**: [theme](docs/theme.md) (colors, buttons, alerts and badges, breadcrumb, tabs as a segmented control, forms, offcanvas and modals)
|
|
159
|
-
- **Layout**: [layout](docs/layout.md) ([page](docs/layout.md#page), [sidebar](docs/layout.md#sidebar), [sidebar menu](docs/layout.md#sidebar-menu) and its [compact form](docs/layout.md#compact-sidebar), [navbar](docs/layout.md#navbar), [content boxes](docs/layout.md#content-boxes-and-the-older-navbar))
|
|
160
|
-
- **Components**: [theme switcher](docs/theme-switcher.md), [tooltip](docs/tooltip.md), [elements](docs/elements.md), [dialogs](docs/dialogs.md), [settings](docs/settings.md), [datagrid](docs/datagrid.md), [selection](docs/selection.md), [number input](docs/number-input.md), [OTP input](docs/otp-input.md), [datepicker](docs/datepicker.md), [rating](docs/rating.md), [charts](docs/chart.md), [gallery](docs/gallery.md), [dropzone](docs/dropzone.md), [lightbox](docs/lightbox.md), [password strength](docs/strength.md), [password toggle](docs/password-toggle.md), [empty states and error pages](docs/empty.md), [spinner](docs/spinner.md), [sign-in pages](docs/auth.md), [shop](docs/shop.md), [blog](docs/blog.md)
|
|
161
|
-
|
|
162
|
-
## Demo
|
|
163
|
-
|
|
164
|
-
The demo runs at [compostrap.github.io/demo](https://compostrap.github.io/demo/). To run it from the package:
|
|
165
|
-
|
|
166
|
-
```bash
|
|
167
|
-
npm install
|
|
168
|
-
npm run dev
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
The demo is an overview of the components, one page each, with a menu by kind:
|
|
172
|
-
|
|
173
|
-
- **Overview**: `index.html`, a dashboard (stat tiles, numbers with a trend, revenue, sales by category, orders per day, this year against the last, what waits, the latest articles).
|
|
174
|
-
- **Bootstrap**: typography, buttons, badges and alerts, forms, tables and cards, navigation, overlays (modals, offcanvas, toasts, accordion, progress), in the look of the theme.
|
|
175
|
-
- **Compostrap**: `elements.html`, what the package adds to Bootstrap (tooltips, avatars, state dots, stat tiles, list rows, theme switcher).
|
|
176
|
-
- **Modules**: `datagrid.html`, `gallery.html` and `commerce.html` (an e-shop administration with products, variants and photos).
|
|
177
|
-
- **Compostrap** also has `states.html` (empty states with an illustration and with an icon, a box that loads, both spinners) and `inputs.html` (number inputs and a cart that recounts, one-time codes, datepickers, ratings).
|
|
178
|
-
- **Pages**: `sign-in.html`, `sign-up.html` and `recovery.html` (module `auth`, the password strength of module `strength`, the eye in the password inputs of module `password-toggle`; recovery goes through its three steps, its code is typed into the slots of module `otp-input`), `account.html` (the account of the signed-in user: profile information and the change of the password next to each other) and `permissions.html` (role permissions: a section list and setting rows), and the error pages `error-404.html`, `error-403.html`, `error-500.html` and `maintenance.html` (module `empty`).
|
|
179
|
-
- **Blog** (module `blog`, a website without the sidebar): `blog-articles.html` (categories, the newest article, cards) and `blog-article.html` (an article with its text, comments and the comment form).
|
|
180
|
-
- **Shop** (module `shop`, a storefront without the sidebar): `shop-products.html`, `shop-product.html`, `shop-cart.html`, `shop-delivery.html`, `shop-customer.html`, `shop-summary.html`, `shop-confirmation.html` and `shop-states.html` (an empty cart, a product out of stock, a valid and an invalid discount code, a form with errors, a cart that recounts), the whole way from the list of products to the confirmation of an order.
|
|
181
|
-
|
|
182
|
-
## Tests
|
|
183
|
-
|
|
184
|
-
```bash
|
|
185
|
-
npx playwright install chromium # once
|
|
186
|
-
npm test
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
Smoke tests in Playwright over the demo pages: every page loads without an error, and the JavaScript modules (sidebar and its compact form, menu, theme switcher, number input, OTP input, password toggle, strength, row selection, lightbox, dropzone, datepicker, charts, spinner) behave as described here.
|
|
190
|
-
|
|
191
|
-
## Built on
|
|
192
|
-
|
|
193
|
-
- [Bootstrap 5](https://getbootstrap.com)
|
|
194
|
-
- [Bootstrap Icons](https://icons.getbootstrap.com)
|
|
195
|
-
- [Perfect scrollbar](https://github.com/mdbootstrap/perfect-scrollbar)
|
|
196
|
-
- [Nanobar](https://github.com/jacoborus/nanobar)
|
|
197
|
-
- [Vanilla Calendar Pro](https://vanilla-calendar.pro)
|
|
198
|
-
- [Chart.js](https://www.chartjs.org)
|
|
1
|
+
## Compostrap
|
|
2
|
+
|
|
3
|
+
Bootstrap 5 for administrations and websites in one package: a theme with the look, colors and classes of Bootstrap 6, a layout with a sidebar, a multi-level menu and a navbar, and components that Bootstrap does not have (gallery, dropzone, lightbox, password strength, empty states, sign-in pages…). Every part is a module that can be used alone, or all of them together.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/compostrap/compostrap/blob/main/license)
|
|
6
|
+
[](https://badge.fury.io/js/compostrap)
|
|
7
|
+
[](https://github.com/compostrap/compostrap/actions/workflows/build.yml)
|
|
8
|
+
|
|
9
|
+
## Contents
|
|
10
|
+
|
|
11
|
+
- [Requirements](#requirements)
|
|
12
|
+
- [Installation](#installation)
|
|
13
|
+
- [Architecture](#architecture): the three layers and the table of the modules
|
|
14
|
+
- [Usage](#usage)
|
|
15
|
+
- [Light and dark theme](#light-and-dark-theme)
|
|
16
|
+
- [Documentation](#documentation): the theme, the layout and every component
|
|
17
|
+
- [Demo](#demo)
|
|
18
|
+
- [Tests](#tests)
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
- [Bootstrap](https://getbootstrap.com) 5.3
|
|
23
|
+
- [Bootstrap Icons](https://icons.getbootstrap.com) 1.11 for the arrows of the menu and the breadcrumb separators (`sidebar-menu`, `dashboard`); another icon font can be set by the Sass variables `$icon-font`, `$icon-font-weight`, `$icon-chevron-right` and `$icon-chevron-down`
|
|
24
|
+
- [Perfect scrollbar](https://github.com/mdbootstrap/perfect-scrollbar) when the menu scrolls with it (`sidebar-menu` styles its rail)
|
|
25
|
+
- [Nanobar](https://github.com/jacoborus/nanobar) when the page shows a nanobar (`dashboard` styles it)
|
|
26
|
+
- [Vanilla Calendar Pro](https://vanilla-calendar.pro) 3.4 for the module `datepicker` (as in Bootstrap 6)
|
|
27
|
+
- [Chart.js](https://www.chartjs.org) 4.6 for the module `chart`
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install compostrap bootstrap
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Architecture
|
|
36
|
+
|
|
37
|
+
The package has three layers:
|
|
38
|
+
|
|
39
|
+
| Layer | What it is | Classes |
|
|
40
|
+
|-------|------------|---------|
|
|
41
|
+
| **Theme** | Bootstrap itself, built with the variables of compostrap and finished by its CSS: the colors, buttons, badges, forms, tables, navs, overlays… in a calm, dense look | only the classes of Bootstrap 5 and of Bootstrap 6 (`btn-subtle`, `badge-subtle`, `theme-*`, `breadcrumb-link`, `avatar`…), so the markup stays valid after the upgrade to Bootstrap 6 |
|
|
42
|
+
| **Layout** | the frame of an administration: the sidebar, its menu, the navbar over the content and the boxes of the page | `sidebar-*`, `list-*` (menu), `navbar-*`, `content-box` |
|
|
43
|
+
| **Components** | what compostrap adds, each a module of its own | the name of the module as the prefix (`gallery-*`, `empty-*`, `auth-*`…) |
|
|
44
|
+
|
|
45
|
+
| Module | Layer | What it does | JavaScript |
|
|
46
|
+
|--------|-------|--------------|------------|
|
|
47
|
+
| [`theme`](docs/theme.md) | theme | Bootstrap in the look of compostrap: neutral grays, 14px text, quiet shadows, one size scale of buttons and form controls, the colors and variants of Bootstrap 6 | – |
|
|
48
|
+
| [`sidebar`](docs/layout.md#sidebar) | layout | the sidebar: fixed on large screens, an overlay with a backdrop on small | `Sidebar` |
|
|
49
|
+
| [`sidebar-menu`](docs/layout.md#sidebar-menu) | layout | a multi-level menu in the sidebar, links as pills, the current page on any level in a pill; a compact sidebar with the icons only | `SidebarMenu`, `Sidebar` (compact) |
|
|
50
|
+
| [`dashboard`](docs/layout.md) | layout | the page background, the navbar over the content with a breadcrumb, icons and the user, the content boxes, the nanobar | – |
|
|
51
|
+
| [`theme-switcher`](docs/theme-switcher.md) | component | switches the light and dark theme of Bootstrap and remembers the choice | `ThemeSwitcher` |
|
|
52
|
+
| [`tooltip`](docs/tooltip.md) | component | a tooltip of pure CSS for buttons and links with an icon only | `CssTooltip` (optional: Esc hides it) |
|
|
53
|
+
| [`elements`](docs/elements.md) | component | small pieces of a page: state dots, stat tiles, list rows, the loading state of a box | – |
|
|
54
|
+
| [`dialogs`](docs/dialogs.md) | component | a colored line and a confirmation of a modal, a bar of buttons at the bottom of an offcanvas, a toast with the message of a state, a search dialog; dialogs that stay open on a click outside | `Dialogs` |
|
|
55
|
+
| [`settings`](docs/settings.md) | component | a list of the sections of a page and rows of settings with their controls | – |
|
|
56
|
+
| [`datagrid`](docs/datagrid.md) | component | the table of a list: the row of filters, clickable rows and the column of row actions | – |
|
|
57
|
+
| [`selection`](docs/selection.md) | component | rows of a table chosen by checkboxes and a bar with the actions for them | `RowSelection` |
|
|
58
|
+
| [`number-input`](docs/number-input.md) | component | a number with minus and plus buttons, e.g. the quantity in a cart | `NumberInput` |
|
|
59
|
+
| [`otp-input`](docs/otp-input.md) | component | a one-time code typed into separate slots over one real input (the OTP input of Bootstrap 6) | `OtpInput` |
|
|
60
|
+
| [`datepicker`](docs/datepicker.md) | component | the calendar of Bootstrap 6 (Vanilla Calendar Pro) under a date input | `Datepicker` |
|
|
61
|
+
| [`chart`](docs/chart.md) | component | charts of Chart.js written as markup, in the colors and fonts of the theme | `Charts` |
|
|
62
|
+
| [`rating`](docs/rating.md) | component | stars to choose a rating in a form or to show one, halves too | – |
|
|
63
|
+
| [`gallery`](docs/gallery.md) | component | square tiles of images with buttons over the image on hover | – |
|
|
64
|
+
| [`dropzone`](docs/dropzone.md) | component | a large area to drop files on or to click, made of a plain file input | `DropzoneInput` |
|
|
65
|
+
| [`lightbox`](docs/lightbox.md) | component | a full-screen preview of images, browsed by arrows, keys and swipe | `Lightbox` |
|
|
66
|
+
| [`strength`](docs/strength.md) | component | a meter of the password strength under a password input (markup of Bootstrap 6) | `Strength` |
|
|
67
|
+
| [`password-toggle`](docs/password-toggle.md) | component | a button with an eye in a password input that shows and hides the password | `PasswordToggle` |
|
|
68
|
+
| [`empty`](docs/empty.md) | component | empty states in boxes and error pages (404, 403, 500, maintenance) with illustrations | – |
|
|
69
|
+
| [`spinner`](docs/spinner.md) | component | shows that a request runs: a line at the top of the window, or a dark overlay that stops clicks | `Spinner` |
|
|
70
|
+
| [`auth`](docs/auth.md) | component | pages outside the administration (sign in, sign up, recovery): a box in the middle of the page | – |
|
|
71
|
+
| [`shop`](docs/shop.md) | component | the storefront of an e-shop: header with the mini cart, product tiles and detail, cart, steps of the order, choice of the delivery, price summary | `number-input` (amount) |
|
|
72
|
+
| [`blog`](docs/blog.md) | component | a website with a blog: header with the links, list of articles with categories, an article with its text, comments | `avatar` of the theme |
|
|
73
|
+
|
|
74
|
+
The components and the layout work with plain Bootstrap too; the ones with colors (`theme-*` classes) take them from the theme.
|
|
75
|
+
|
|
76
|
+
## Usage
|
|
77
|
+
|
|
78
|
+
The theme is Bootstrap built with the variables of compostrap, so it takes the place of Bootstrap's own styles:
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
import 'compostrap/css/theme.css'; // instead of 'bootstrap/dist/css/bootstrap.css'
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```scss
|
|
85
|
+
// own Bootstrap variables before it, e.g. $primary: #066fd1;
|
|
86
|
+
@import 'compostrap/src/scss/theme'; // instead of @import 'bootstrap/scss/bootstrap';
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The other modules work with plain Bootstrap too. All of them at once:
|
|
90
|
+
|
|
91
|
+
```javascript
|
|
92
|
+
import 'compostrap/css/compostrap.css';
|
|
93
|
+
import { Sidebar, SidebarMenuApp, ThemeSwitcher, DropzoneInput, Lightbox, Strength, NumberInput } from 'compostrap';
|
|
94
|
+
import { Datepicker } from 'compostrap/datepicker'; // only with vanilla-calendar-pro installed
|
|
95
|
+
import { Charts } from 'compostrap/chart'; // only with chart.js installed
|
|
96
|
+
|
|
97
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
98
|
+
Sidebar.init();
|
|
99
|
+
SidebarMenuApp.init();
|
|
100
|
+
new ThemeSwitcher().initialize();
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Or only the modules you need, each has its own CSS and JavaScript:
|
|
105
|
+
|
|
106
|
+
```javascript
|
|
107
|
+
import 'compostrap/css/theme-switcher.css';
|
|
108
|
+
import { ThemeSwitcher } from 'compostrap/theme-switcher';
|
|
109
|
+
|
|
110
|
+
new ThemeSwitcher().initialize();
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The styles can also be imported as SCSS:
|
|
114
|
+
|
|
115
|
+
```scss
|
|
116
|
+
@import 'compostrap/src/scss/compostrap';
|
|
117
|
+
// or a single module
|
|
118
|
+
@import 'compostrap/src/scss/sidebar-menu';
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
When modules are loaded one by one, load them after the theme (or Bootstrap) in the order `theme-switcher`, `tooltip`, `elements`, `dialogs`, `settings`, `datagrid`, `selection`, `number-input`, `otp-input`, `datepicker`, `rating`, `chart`, `gallery`, `dropzone`, `lightbox`, `strength`, `password-toggle`, `empty`, `spinner`, `auth`, `shop`, `blog`, `sidebar`, `sidebar-menu`, `dashboard`: each later one finishes the layout of the earlier ones.
|
|
122
|
+
|
|
123
|
+
## Light and dark theme
|
|
124
|
+
|
|
125
|
+
All modules follow the global theme of Bootstrap in `data-bs-theme`:
|
|
126
|
+
|
|
127
|
+
```html
|
|
128
|
+
<html lang="en" data-bs-theme="light">
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The switcher stores the choice in `localStorage` under `bootstrap-theme`; without a stored choice the page follows the system. To avoid a light flash of a dark page, set the theme before the page is drawn:
|
|
132
|
+
|
|
133
|
+
```html
|
|
134
|
+
<script>
|
|
135
|
+
try {
|
|
136
|
+
let theme = localStorage.getItem('bootstrap-theme') || 'auto';
|
|
137
|
+
if (theme === 'auto') {
|
|
138
|
+
theme = matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
139
|
+
}
|
|
140
|
+
if (theme === 'light' || theme === 'dark') {
|
|
141
|
+
document.documentElement.setAttribute('data-bs-theme', theme);
|
|
142
|
+
}
|
|
143
|
+
} catch (e) { }
|
|
144
|
+
</script>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
The dashboard keeps the surface colors of Bootstrap:
|
|
148
|
+
|
|
149
|
+
| Theme | Page background | Sidebar and content |
|
|
150
|
+
|-------|----------------------------|---------------------|
|
|
151
|
+
| Light | `--bs-tertiary-bg` darkened by 1.6 % (`#f6f6f6` in the theme) | `var(--bs-body-bg)` |
|
|
152
|
+
| Dark | `--bs-body-bg` mixed 55 % with black | `var(--bs-body-bg)` |
|
|
153
|
+
|
|
154
|
+
## Documentation
|
|
155
|
+
|
|
156
|
+
Every module is described in `docs/`, with its markup, classes, variables and JavaScript:
|
|
157
|
+
|
|
158
|
+
- **Theme**: [theme](docs/theme.md) (colors, buttons, alerts and badges, breadcrumb, tabs as a segmented control, forms, offcanvas and modals)
|
|
159
|
+
- **Layout**: [layout](docs/layout.md) ([page](docs/layout.md#page), [sidebar](docs/layout.md#sidebar), [sidebar menu](docs/layout.md#sidebar-menu) and its [compact form](docs/layout.md#compact-sidebar), [navbar](docs/layout.md#navbar), [content boxes](docs/layout.md#content-boxes-and-the-older-navbar))
|
|
160
|
+
- **Components**: [theme switcher](docs/theme-switcher.md), [tooltip](docs/tooltip.md), [elements](docs/elements.md), [dialogs](docs/dialogs.md), [settings](docs/settings.md), [datagrid](docs/datagrid.md), [selection](docs/selection.md), [number input](docs/number-input.md), [OTP input](docs/otp-input.md), [datepicker](docs/datepicker.md), [rating](docs/rating.md), [charts](docs/chart.md), [gallery](docs/gallery.md), [dropzone](docs/dropzone.md), [lightbox](docs/lightbox.md), [password strength](docs/strength.md), [password toggle](docs/password-toggle.md), [empty states and error pages](docs/empty.md), [spinner](docs/spinner.md), [sign-in pages](docs/auth.md), [shop](docs/shop.md), [blog](docs/blog.md)
|
|
161
|
+
|
|
162
|
+
## Demo
|
|
163
|
+
|
|
164
|
+
The demo runs at [compostrap.github.io/demo](https://compostrap.github.io/demo/). To run it from the package:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
npm install
|
|
168
|
+
npm run dev
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
The demo is an overview of the components, one page each, with a menu by kind:
|
|
172
|
+
|
|
173
|
+
- **Overview**: `index.html`, a dashboard (stat tiles, numbers with a trend, revenue, sales by category, orders per day, this year against the last, what waits, the latest articles).
|
|
174
|
+
- **Bootstrap**: typography, buttons, badges and alerts, forms, tables and cards, navigation, overlays (modals, offcanvas, toasts, accordion, progress), in the look of the theme.
|
|
175
|
+
- **Compostrap**: `elements.html`, what the package adds to Bootstrap (tooltips, avatars, state dots, stat tiles, list rows, theme switcher).
|
|
176
|
+
- **Modules**: `datagrid.html`, `gallery.html` and `commerce.html` (an e-shop administration with products, variants and photos).
|
|
177
|
+
- **Compostrap** also has `states.html` (empty states with an illustration and with an icon, a box that loads, both spinners) and `inputs.html` (number inputs and a cart that recounts, one-time codes, datepickers, ratings).
|
|
178
|
+
- **Pages**: `sign-in.html`, `sign-up.html` and `recovery.html` (module `auth`, the password strength of module `strength`, the eye in the password inputs of module `password-toggle`; recovery goes through its three steps, its code is typed into the slots of module `otp-input`), `account.html` (the account of the signed-in user: profile information and the change of the password next to each other) and `permissions.html` (role permissions: a section list and setting rows), and the error pages `error-404.html`, `error-403.html`, `error-500.html` and `maintenance.html` (module `empty`).
|
|
179
|
+
- **Blog** (module `blog`, a website without the sidebar): `blog-articles.html` (categories, the newest article, cards) and `blog-article.html` (an article with its text, comments and the comment form).
|
|
180
|
+
- **Shop** (module `shop`, a storefront without the sidebar): `shop-products.html`, `shop-product.html`, `shop-cart.html`, `shop-delivery.html`, `shop-customer.html`, `shop-summary.html`, `shop-confirmation.html` and `shop-states.html` (an empty cart, a product out of stock, a valid and an invalid discount code, a form with errors, a cart that recounts), the whole way from the list of products to the confirmation of an order.
|
|
181
|
+
|
|
182
|
+
## Tests
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
npx playwright install chromium # once
|
|
186
|
+
npm test
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Smoke tests in Playwright over the demo pages: every page loads without an error, and the JavaScript modules (sidebar and its compact form, menu, theme switcher, number input, OTP input, password toggle, strength, row selection, lightbox, dropzone, datepicker, charts, spinner) behave as described here.
|
|
190
|
+
|
|
191
|
+
## Built on
|
|
192
|
+
|
|
193
|
+
- [Bootstrap 5](https://getbootstrap.com)
|
|
194
|
+
- [Bootstrap Icons](https://icons.getbootstrap.com)
|
|
195
|
+
- [Perfect scrollbar](https://github.com/mdbootstrap/perfect-scrollbar)
|
|
196
|
+
- [Nanobar](https://github.com/jacoborus/nanobar)
|
|
197
|
+
- [Vanilla Calendar Pro](https://vanilla-calendar.pro)
|
|
198
|
+
- [Chart.js](https://www.chartjs.org)
|