compostrap 1.0.3 → 1.1.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/docs/blog.md CHANGED
@@ -1,85 +1,85 @@
1
- # Blog
2
-
3
- [← Compostrap](../readme.md#documentation)
4
-
5
- The module `blog` styles a website with a blog, outside the administration: a header with the links of the website, the list of articles with its categories, an article with its text and the comments under it. The page is white, the header and the footer are tinted bars and the boxes (cards of articles, comments, the comment form) are tinted instead of framed (`--blog-page-bg`, `--blog-tint-bg`, `--blog-tint-hover-bg`). The header holds a navbar of Bootstrap, so the links fold into a menu on a phone.
6
-
7
- ```html
8
- <body class="blog-page">
9
- <header class="blog-header">
10
- <nav class="navbar navbar-expand-lg">
11
- <div class="container">
12
- <a class="blog-brand" href="/">Logo <span>Name</span></a>
13
- <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#blog-menu" aria-controls="blog-menu" aria-expanded="false" aria-label="Menu"><span class="navbar-toggler-icon"></span></button>
14
- <div class="collapse navbar-collapse" id="blog-menu">
15
- <ul class="navbar-nav ms-auto"><li class="nav-item"><a class="nav-link active" href="/blog">Blog</a></li></ul>
16
- <div class="blog-header-actions"><a class="btn btn-primary btn-sm" href="/sign-in">Sign in</a></div>
17
- </div>
18
- </div>
19
- </nav>
20
- </header>
21
- <main class="container">…</main>
22
- <footer class="blog-footer">
23
- <div class="container">
24
- <div class="row g-4">
25
- <div class="col-lg-4">…</div>
26
- <div class="col-6 col-md-4 col-lg-2"><h2 class="blog-footer-title">Links</h2><ul class="blog-footer-links"><li><a href="/blog">Blog</a></li></ul></div>
27
- </div>
28
- </div>
29
- </footer>
30
- </body>
31
- ```
32
-
33
- **List of articles.**
34
-
35
- - `.blog-title` is the heading of a page; `.blog-heading` puts a link on its right.
36
- - `nav.blog-pills` holds the categories as links `.blog-pill`, the chosen one with `active`.
37
- - `article.blog-featured` is the newest article over the whole row: a picture in `.blog-featured-image` next to `.blog-featured-body`.
38
- - `article.blog-card` are the other articles, in a Bootstrap grid (`row row-cols-1 row-cols-md-2 row-cols-xl-3 g-4`).
39
- - `.blog-card-title` holds the link of the whole block (`stretched-link`); other links in the block get `.blog-over`.
40
- - `.blog-meta` is a line of date, category and comments parted by dots.
41
- - `.blog-author` is an `avatar` of the theme with the name (`.blog-author-name`).
42
-
43
- ```html
44
- <article class="blog-card">
45
- <div class="blog-card-image"><img src="…" alt="" loading="lazy"></div>
46
- <div class="blog-meta"><time datetime="2026-11-05">5 days ago</time><a class="blog-over" href="/blog/latte">Latte</a></div>
47
- <h2 class="blog-card-title"><a class="stretched-link" href="/blog/article">Title</a></h2>
48
- <p class="blog-card-text">Perex, cut after three lines.</p>
49
- <div class="blog-card-footer">
50
- <div class="blog-author"><span class="avatar avatar-sm theme-success">PK</span><span>Petra Králová</span></div>
51
- <a class="blog-over" href="/blog/article#comments">Comments: 5</a>
52
- </div>
53
- </article>
54
- ```
55
-
56
- **Article.** `article.blog-article` is a narrow column (`--blog-article-width`, 48rem) with:
57
-
58
- - `.blog-back`, a link back,
59
- - `.blog-article-title` and the perex `.blog-article-lead`,
60
- - `.blog-meta.blog-article-meta` with the author, the date and the category,
61
- - `.blog-article-image`, the cover (a 21 : 9 cut),
62
- - `.blog-content`, the text: 16px text with more room between lines, headings, lists, pictures as wide cuts, a quote with a line of the primary color and code blocks on the tint. Links in the text are underlined (the theme draws links without a line, and a color alone does not tell a link from the text); so are the links in `.blog-comment-content`.
63
-
64
- A highlighted code is written with the text classes of Bootstrap; in a code block they take the colors of the code on nette.org, which can be changed by a variable (each as `r, g, b`):
65
-
66
- | Class | Part of the code | Variable |
67
- |-------|------------------|----------|
68
- | `text-primary` | keyword and tag | `--blog-code-keyword` |
69
- | `text-primary-emphasis` | name of a function or method | `--blog-code-function` |
70
- | `text-success` | string | `--blog-code-string` |
71
- | `text-danger` | number | `--blog-code-number` |
72
- | `text-warning-emphasis` | variable | `--blog-code-variable` |
73
- | `text-info-emphasis` | attribute | `--blog-code-attribute` |
74
- | `text-danger-emphasis` | Latte tag | `--blog-code-macro` |
75
- | `text-body-secondary` | comment | `--blog-code-comment` |
76
-
77
- The box of a code is `--blog-code-bg`.
78
-
79
- **Comments.** `section.blog-comments` with `.blog-comments-title`; a comment is `article.blog-comment` with:
80
-
81
- - `.blog-comment-head`: the avatar, `.blog-comment-author`, the link of its number and the time,
82
- - `.blog-comment-content`: the text of a comment, which holds only the message;
83
- - `.blog-meta.blog-comment-foot`: Reply and, in a comment that answers another one, the link to it as "In reply to".
84
-
85
- A comment opened by its link (`#comment-2`) is stronger and stays under the sticky header. The form of a new comment stands in `.blog-comment-form` with its title `.blog-comment-form-title` over the box.
1
+ # Blog
2
+
3
+ [← Compostrap](../readme.md#documentation)
4
+
5
+ The module `blog` styles a website with a blog, outside the administration: a header with the links of the website, the list of articles with its categories, an article with its text and the comments under it. The page is white, the header and the footer are tinted bars and the boxes (cards of articles, comments, the comment form) are tinted instead of framed (`--blog-page-bg`, `--blog-tint-bg`, `--blog-tint-hover-bg`). The header holds a navbar of Bootstrap, so the links fold into a menu on a phone.
6
+
7
+ ```html
8
+ <body class="blog-page">
9
+ <header class="blog-header">
10
+ <nav class="navbar navbar-expand-lg">
11
+ <div class="container">
12
+ <a class="blog-brand" href="/">Logo <span>Name</span></a>
13
+ <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#blog-menu" aria-controls="blog-menu" aria-expanded="false" aria-label="Menu"><span class="navbar-toggler-icon"></span></button>
14
+ <div class="collapse navbar-collapse" id="blog-menu">
15
+ <ul class="navbar-nav ms-auto"><li class="nav-item"><a class="nav-link active" href="/blog">Blog</a></li></ul>
16
+ <div class="blog-header-actions"><a class="btn btn-primary btn-sm" href="/sign-in">Sign in</a></div>
17
+ </div>
18
+ </div>
19
+ </nav>
20
+ </header>
21
+ <main class="container">…</main>
22
+ <footer class="blog-footer">
23
+ <div class="container">
24
+ <div class="row g-4">
25
+ <div class="col-lg-4">…</div>
26
+ <div class="col-6 col-md-4 col-lg-2"><h2 class="blog-footer-title">Links</h2><ul class="blog-footer-links"><li><a href="/blog">Blog</a></li></ul></div>
27
+ </div>
28
+ </div>
29
+ </footer>
30
+ </body>
31
+ ```
32
+
33
+ **List of articles.**
34
+
35
+ - `.blog-title` is the heading of a page; `.blog-heading` puts a link on its right.
36
+ - `nav.blog-pills` holds the categories as links `.blog-pill`, the chosen one with `active`.
37
+ - `article.blog-featured` is the newest article over the whole row: a picture in `.blog-featured-image` next to `.blog-featured-body`.
38
+ - `article.blog-card` are the other articles, in a Bootstrap grid (`row row-cols-1 row-cols-md-2 row-cols-xl-3 g-4`).
39
+ - `.blog-card-title` holds the link of the whole block (`stretched-link`); other links in the block get `.blog-over`.
40
+ - `.blog-meta` is a line of date, category and comments parted by dots.
41
+ - `.blog-author` is an `avatar` of the theme with the name (`.blog-author-name`).
42
+
43
+ ```html
44
+ <article class="blog-card">
45
+ <div class="blog-card-image"><img src="…" alt="" loading="lazy"></div>
46
+ <div class="blog-meta"><time datetime="2026-11-05">5 days ago</time><a class="blog-over" href="/blog/latte">Latte</a></div>
47
+ <h2 class="blog-card-title"><a class="stretched-link" href="/blog/article">Title</a></h2>
48
+ <p class="blog-card-text">Perex, cut after three lines.</p>
49
+ <div class="blog-card-footer">
50
+ <div class="blog-author"><span class="avatar avatar-sm theme-success">PK</span><span>Petra Králová</span></div>
51
+ <a class="blog-over" href="/blog/article#comments">Comments: 5</a>
52
+ </div>
53
+ </article>
54
+ ```
55
+
56
+ **Article.** `article.blog-article` is a narrow column (`--blog-article-width`, 48rem) with:
57
+
58
+ - `.blog-back`, a link back,
59
+ - `.blog-article-title` and the perex `.blog-article-lead`,
60
+ - `.blog-meta.blog-article-meta` with the author, the date and the category,
61
+ - `.blog-article-image`, the cover (a 21 : 9 cut),
62
+ - `.blog-content`, the text: 16px text with more room between lines, headings, lists, pictures as wide cuts, a quote with a line of the primary color and code blocks on the tint. Links in the text are underlined (the theme draws links without a line, and a color alone does not tell a link from the text); so are the links in `.blog-comment-content`.
63
+
64
+ A highlighted code is written with the text classes of Bootstrap; in a code block they take the colors of the code on nette.org, which can be changed by a variable (each as `r, g, b`):
65
+
66
+ | Class | Part of the code | Variable |
67
+ |-------|------------------|----------|
68
+ | `text-primary` | keyword and tag | `--blog-code-keyword` |
69
+ | `text-primary-emphasis` | name of a function or method | `--blog-code-function` |
70
+ | `text-success` | string | `--blog-code-string` |
71
+ | `text-danger` | number | `--blog-code-number` |
72
+ | `text-warning-emphasis` | variable | `--blog-code-variable` |
73
+ | `text-info-emphasis` | attribute | `--blog-code-attribute` |
74
+ | `text-danger-emphasis` | Latte tag | `--blog-code-macro` |
75
+ | `text-body-secondary` | comment | `--blog-code-comment` |
76
+
77
+ The box of a code is `--blog-code-bg`.
78
+
79
+ **Comments.** `section.blog-comments` with `.blog-comments-title`; a comment is `article.blog-comment` with:
80
+
81
+ - `.blog-comment-head`: the avatar, `.blog-comment-author`, the link of its number and the time,
82
+ - `.blog-comment-content`: the text of a comment, which holds only the message;
83
+ - `.blog-meta.blog-comment-foot`: Reply and, in a comment that answers another one, the link to it as "In reply to".
84
+
85
+ A comment opened by its link (`#comment-2`) is stronger and stays under the sticky header. The form of a new comment stands in `.blog-comment-form` with its title `.blog-comment-form-title` over the box.
package/docs/layout.md CHANGED
@@ -1,143 +1,143 @@
1
- # Layout
2
-
3
- [← Compostrap](../readme.md#documentation)
4
-
5
- ## Page
6
-
7
- The sidebar runs over the whole height with the brand on top, the navbar sits over the content only, in the color of the page and stuck to the top:
8
-
9
- ```html
10
- <div class="d-flex wrapper">
11
- <nav class="sidebar" id="navigation">
12
- <div class="sidebar-menu"><div class="sidebar-menu-fixed">
13
- <a class="sidebar-brand" href="/"><svg>…</svg><span>Compostrap</span></a>
14
- <div class="scrollbar scrollbar-use-navbar">…menu…</div>
15
- </div></div>
16
- </nav>
17
- <div class="layout-content">
18
- <header class="navbar navbar-expand-md navbar-content navbar-bar sticky-top">…breadcrumb, icons, user…</header>
19
- <div class="container-fluid"><main>…</main></div>
20
- </div>
21
- </div>
22
- ```
23
-
24
-
25
- The layout comes in three combinations of the navbar and the brand of the sidebar, each with the navbar stuck to the top (`sticky-top`) or scrolling away with the page:
26
-
27
- | Combination | Navbar | Brand |
28
- |-------------|--------|-------|
29
- | On the page: the navbar and the brand on the background of the page, the white menu below the brand as a panel with a rounded corner, in line with the first box | `navbar-content` | `sidebar-brand sidebar-brand-page` |
30
- | The navbar on the page, a white sidebar | `navbar-content` | `sidebar-brand` |
31
- | A white navbar and a white sidebar; a soft shadow under the navbar when the content scrolls under it | `navbar-content navbar-bar` | `sidebar-brand` |
32
-
33
- The white navbar can take a color, together with the brand of the sidebar, so one colored strip runs over the top: `navbar-colored` and `sidebar-brand-colored` with a `theme-*` class (`theme-primary`, `theme-success`, `theme-danger`, `theme-info`, or `theme-gray`, a gray between the light secondary and dark). Its text and icons turn light, a status dot gets a light ring, and the nanobar takes the color of the navbar, lightened; the dropdowns in it keep the colors of the page.
34
-
35
- ```html
36
- <a class="sidebar-brand sidebar-brand-colored theme-primary" href="/">…</a>
37
- <header class="navbar navbar-expand-md navbar-content navbar-bar navbar-colored theme-primary sticky-top">…</header>
38
- ```
39
-
40
- The demo has a *Customize* panel to try them.
41
-
42
- Below `md`, where the sidebar is hidden, `navbar-brand-mobile` shows the brand in the navbar (as its first item; only the logo on phones under 360px); the open sidebar covers it with its own brand at the same place.
43
-
44
- The layout with a navbar over the whole width (`wrapper-navbar-used wrapper-navbar-fixed`, `navbar fixed-top`) works too.
45
-
46
- ## Sidebar
47
-
48
- The sidebar is the element `#navigation`, its toggle button is `#sidebar`. On small screens it opens as an overlay over the page and takes the focus; closed, it stands outside the window and is `inert`, so the keyboard and a screen reader skip its links. The backdrop, a click on it, Escape and the focus that leaves it (Tab after its last link) close it, and the toggle reports its state in `aria-expanded`. From the `md` breakpoint up it stays in the layout.
49
-
50
- | Description | Class |
51
- |----------------------------------------------------|-----------------------------|
52
- | Layout without a navbar | `wrapper` |
53
- | Layout with a navbar | `wrapper-navbar-used` |
54
- | Layout with a fixed navbar | `wrapper-navbar-fixed` |
55
- | Rounded top right corner of the sidebar | `sidebar-rounded-top-right` |
56
- | Fixed menu in the sidebar | `sidebar-menu-fixed` |
57
- | Toggle visible on small screens (used by `Sidebar`) | `sidebar-toggle` |
58
- | Toggle visible on all screens | `sidebar-toggle-visible` |
59
-
60
- ## Sidebar menu
61
-
62
- `SidebarMenuApp.init()` can be called again after menu items are added. It sets `aria-expanded` and `aria-controls` on submenu links, `aria-current="page"` on the current link, and opens a submenu at once; only its arrow rotates. Set `SidebarMenu.slideDuration = 200` (ms) before `init()` to slide submenus open instead; the slide is skipped when reduced motion is requested.
63
-
64
- | Description | Class |
65
- |-------------------------|----------------|
66
- | Current item | `link-current` |
67
- | Link with a submenu (without `href`, it becomes a button) | `link-arrow` |
68
- | Hidden submenu | `list-hidden` |
69
- | Shaking icon on hover | `bell` |
70
-
71
- The colors of the menu come from the body color of Bootstrap (titles at 60 %, icons at 60 %, arrows at 85 %), so both themes work without settings; they can be changed by the `--sm-*` CSS variables, the sizes by the Sass variables in `src/scss/_variables.scss`. The pills of the links have `--sm-pill-border-radius`, `--sm-pill-icon-color`, `--sm-pill-link-bg` (the current page) and `--sm-pill-hover-bg` (a hovered link, a bit weaker).
72
-
73
- ### Compact sidebar
74
-
75
- From the `md` breakpoint up the sidebar can be narrowed to the icons of the first level (`$sm-compact-width`, 72px); a phone keeps its sliding menu. A button with `data-sidebar-compact` switches the class `sidebar-compact` of `<html>`, keeps its `aria-pressed` in line and remembers the choice in `localStorage` (`sidebar-compact`); it is handled by `Sidebar.init()`. In the compact sidebar:
76
-
77
- - the brand shows only its logo, a section title becomes a short line, badges and submenus are hidden (a group holding the current page gets its pill);
78
- - the name of a hovered or focused link is shown next to it in the colors of the tooltip;
79
- - a link with a submenu opens its links in a menu of the theme next to the icon (the group name over them, the current page marked); it is closed by another click on the icon, a click outside, Esc or a scroll, and works by the keyboard like a dropdown (Enter or Space moves the focus into it, the arrows between the links, Tab leaves it to the next icon).
80
-
81
- ```html
82
- <html class="…">
83
- <head>
84
- <!-- the remembered compact sidebar before the page is drawn, so the menu does not jump -->
85
- <script>try { if (localStorage.getItem('sidebar-compact') === '1') document.documentElement.classList.add('sidebar-compact'); } catch (e) { }</script>
86
- </head>
87
- …
88
- <button type="button" class="navbar-icon" data-sidebar-compact aria-pressed="false" aria-label="Compact menu" data-tooltip="bottom">
89
- <i class="bi bi-layout-sidebar" aria-hidden="true"></i>
90
- </button>
91
- ```
92
-
93
- `Sidebar.setCompact(true|false)` sets it from a script, `Sidebar.isCompact()` tells whether the compact sidebar is shown.
94
-
95
- ## Navbar
96
-
97
- Icon buttons on the right of the navbar (module `dashboard`): `navbar-icon` is a quiet square for an icon, an icon with a short text (`navbar-icon-text`, e.g. the code of the language) widens it; tinted on hover and while its dropdown is open. A `status-dot` (module `elements`) marks that something waits; `status-dot-pulse` makes it pulse.
98
-
99
- ```html
100
- <button type="button" class="navbar-icon" aria-label="Toggle theme" data-tooltip="bottom" data-theme-switcher
101
- data-theme-light-icon="bi bi-sun" data-theme-dark-icon="bi bi-moon"><i data-theme-switcher-icon class="bi bi-moon"></i></button>
102
-
103
- <div class="dropdown">
104
- <button type="button" class="navbar-icon" data-bs-toggle="dropdown" aria-label="Notifications">
105
- <i class="bi bi-bell"></i><span class="status-dot status-dot-pulse theme-danger"></span>
106
- <span class="navbar-icon-text d-none d-lg-inline">Notifications</span>
107
- </button>
108
- <ul class="dropdown-menu dropdown-menu-end">…</ul>
109
- </div>
110
-
111
- <div class="dropdown">
112
- <button type="button" class="navbar-icon" data-bs-toggle="dropdown"><i class="bi bi-translate" aria-hidden="true"></i><span class="visually-hidden">Language: </span><span class="navbar-icon-text">EN</span></button>
113
- <ul class="dropdown-menu dropdown-menu-end">
114
- <li><a class="dropdown-item" href="...">Čeština</a></li>
115
- <li><a class="dropdown-item active" href="..." aria-current="true">English</a></li>
116
- </ul>
117
- </div>
118
- ```
119
-
120
- The user sits in the navbar as `navbar-user`: an `avatar` (initials or a photo in a circle, in a `theme-*` color; `avatar-sm`, `avatar-lg`) with the name and the role, the account in its dropdown.
121
-
122
- ## Content boxes and the older navbar
123
-
124
- The navbar `navbar fixed-top` gets the page background, `navbar-nav-breadcrumb` separates its items by an arrow, and `content-box` is a box of the page content on the surface color.
125
-
126
- ## Datagrid tables
127
-
128
- A table of a datagrid stands in a `table-responsive`, so it scrolls inside its box on a narrow screen. The wrapper is `<div class="table-responsive" tabindex="0" role="region" aria-label="Articles">` (the name of the table): with `tabindex` the keyboard can scroll it in every browser, the role and the name tell a screen reader what the focused box is. The actions of a row are a menu: three vertical dots open a dropdown with the items, delete last after a divider. The button needs `data-bs-popper-config='{"strategy":"fixed"}'`, or the scrolling wrapper cuts the menu off.
129
-
130
- ```html
131
- <td class="text-end">
132
- <div class="dropdown">
133
- <button type="button" class="btn btn-xs btn-icon btn-text" data-bs-toggle="dropdown" data-bs-popper-config='{"strategy":"fixed"}' aria-expanded="false" aria-label="Actions"><i class="bi bi-three-dots-vertical" aria-hidden="true"></i></button>
134
- <ul class="dropdown-menu dropdown-menu-end">
135
- <li><a class="dropdown-item" href="..."><i class="bi bi-pencil me-2" aria-hidden="true"></i>Edit</a></li>
136
- <li><hr class="dropdown-divider"></li>
137
- <li><a class="dropdown-item text-danger" href="..."><i class="bi bi-trash me-2" aria-hidden="true"></i>Delete</a></li>
138
- </ul>
139
- </div>
140
- </td>
141
- ```
142
-
143
- A datagrid can also open an item by a click on its row (`datagrid-row-clickable` on the `tr` and `row-click.js` of drago-ex/datagrid; compostrap has no script for it). Use it only with icon buttons as the row actions (`btn btn-xs btn-icon` with a `data-tooltip`), never with the menu of three dots: a click that misses the small button of the menu lands on the row and opens the item instead of the menu.
1
+ # Layout
2
+
3
+ [← Compostrap](../readme.md#documentation)
4
+
5
+ ## Page
6
+
7
+ The sidebar runs over the whole height with the brand on top, the navbar sits over the content only, in the color of the page and stuck to the top:
8
+
9
+ ```html
10
+ <div class="d-flex wrapper">
11
+ <nav class="sidebar" id="navigation">
12
+ <div class="sidebar-menu"><div class="sidebar-menu-fixed">
13
+ <a class="sidebar-brand" href="/"><svg>…</svg><span>Compostrap</span></a>
14
+ <div class="scrollbar scrollbar-use-navbar">…menu…</div>
15
+ </div></div>
16
+ </nav>
17
+ <div class="layout-content">
18
+ <header class="navbar navbar-expand-md navbar-content navbar-bar sticky-top">…breadcrumb, icons, user…</header>
19
+ <div class="container-fluid"><main>…</main></div>
20
+ </div>
21
+ </div>
22
+ ```
23
+
24
+
25
+ The layout comes in three combinations of the navbar and the brand of the sidebar, each with the navbar stuck to the top (`sticky-top`) or scrolling away with the page:
26
+
27
+ | Combination | Navbar | Brand |
28
+ |-------------|--------|-------|
29
+ | On the page: the navbar and the brand on the background of the page, the white menu below the brand as a panel with a rounded corner, in line with the first box | `navbar-content` | `sidebar-brand sidebar-brand-page` |
30
+ | The navbar on the page, a white sidebar | `navbar-content` | `sidebar-brand` |
31
+ | A white navbar and a white sidebar; a soft shadow under the navbar when the content scrolls under it | `navbar-content navbar-bar` | `sidebar-brand` |
32
+
33
+ The white navbar can take a color, together with the brand of the sidebar, so one colored strip runs over the top: `navbar-colored` and `sidebar-brand-colored` with a `theme-*` class (`theme-primary`, `theme-success`, `theme-danger`, `theme-info`, or `theme-gray`, a gray between the light secondary and dark). Its text and icons turn light, a status dot gets a light ring, and the nanobar takes the color of the navbar, lightened; the dropdowns in it keep the colors of the page.
34
+
35
+ ```html
36
+ <a class="sidebar-brand sidebar-brand-colored theme-primary" href="/">…</a>
37
+ <header class="navbar navbar-expand-md navbar-content navbar-bar navbar-colored theme-primary sticky-top">…</header>
38
+ ```
39
+
40
+ The demo has a *Customize* panel to try them.
41
+
42
+ Below `md`, where the sidebar is hidden, `navbar-brand-mobile` shows the brand in the navbar (as its first item; only the logo on phones under 360px); the open sidebar covers it with its own brand at the same place.
43
+
44
+ The layout with a navbar over the whole width (`wrapper-navbar-used wrapper-navbar-fixed`, `navbar fixed-top`) works too.
45
+
46
+ ## Sidebar
47
+
48
+ The sidebar is the element `#navigation`, its toggle button is `#sidebar`. On small screens it opens as an overlay over the page and takes the focus; closed, it stands outside the window and is `inert`, so the keyboard and a screen reader skip its links. The backdrop, a click on it, Escape and the focus that leaves it (Tab after its last link) close it, and the toggle reports its state in `aria-expanded`. From the `md` breakpoint up it stays in the layout.
49
+
50
+ | Description | Class |
51
+ |----------------------------------------------------|-----------------------------|
52
+ | Layout without a navbar | `wrapper` |
53
+ | Layout with a navbar | `wrapper-navbar-used` |
54
+ | Layout with a fixed navbar | `wrapper-navbar-fixed` |
55
+ | Rounded top right corner of the sidebar | `sidebar-rounded-top-right` |
56
+ | Fixed menu in the sidebar | `sidebar-menu-fixed` |
57
+ | Toggle visible on small screens (used by `Sidebar`) | `sidebar-toggle` |
58
+ | Toggle visible on all screens | `sidebar-toggle-visible` |
59
+
60
+ ## Sidebar menu
61
+
62
+ `SidebarMenuApp.init()` can be called again after menu items are added. It sets `aria-expanded` and `aria-controls` on submenu links, `aria-current="page"` on the current link, and opens a submenu at once; only its arrow rotates. Set `SidebarMenu.slideDuration = 200` (ms) before `init()` to slide submenus open instead; the slide is skipped when reduced motion is requested.
63
+
64
+ | Description | Class |
65
+ |-------------------------|----------------|
66
+ | Current item | `link-current` |
67
+ | Link with a submenu (without `href`, it becomes a button) | `link-arrow` |
68
+ | Hidden submenu | `list-hidden` |
69
+ | Shaking icon on hover | `bell` |
70
+
71
+ The colors of the menu come from the body color of Bootstrap (titles at 60 %, icons at 60 %, arrows at 85 %), so both themes work without settings; they can be changed by the `--sm-*` CSS variables, the sizes by the Sass variables in `src/scss/_variables.scss`. The pills of the links have `--sm-pill-border-radius`, `--sm-pill-icon-color`, `--sm-pill-link-bg` (the current page) and `--sm-pill-hover-bg` (a hovered link, a bit weaker).
72
+
73
+ ### Compact sidebar
74
+
75
+ From the `md` breakpoint up the sidebar can be narrowed to the icons of the first level (`$sm-compact-width`, 72px); a phone keeps its sliding menu. A button with `data-sidebar-compact` switches the class `sidebar-compact` of `<html>`, keeps its `aria-pressed` in line and remembers the choice in `localStorage` (`sidebar-compact`); it is handled by `Sidebar.init()`. In the compact sidebar:
76
+
77
+ - the brand shows only its logo, a section title becomes a short line, badges and submenus are hidden (a group holding the current page gets its pill);
78
+ - the name of a hovered or focused link is shown next to it in the colors of the tooltip;
79
+ - a link with a submenu opens its links in a menu of the theme next to the icon (the group name over them, the current page marked); it is closed by another click on the icon, a click outside, Esc or a scroll, and works by the keyboard like a dropdown (Enter or Space moves the focus into it, the arrows between the links, Tab leaves it to the next icon).
80
+
81
+ ```html
82
+ <html class="…">
83
+ <head>
84
+ <!-- the remembered compact sidebar before the page is drawn, so the menu does not jump -->
85
+ <script>try { if (localStorage.getItem('sidebar-compact') === '1') document.documentElement.classList.add('sidebar-compact'); } catch (e) { }</script>
86
+ </head>
87
+ …
88
+ <button type="button" class="navbar-icon" data-sidebar-compact aria-pressed="false" aria-label="Compact menu" data-tooltip="bottom">
89
+ <i class="bi bi-layout-sidebar" aria-hidden="true"></i>
90
+ </button>
91
+ ```
92
+
93
+ `Sidebar.setCompact(true|false)` sets it from a script, `Sidebar.isCompact()` tells whether the compact sidebar is shown.
94
+
95
+ ## Navbar
96
+
97
+ Icon buttons on the right of the navbar (module `dashboard`): `navbar-icon` is a quiet square for an icon, an icon with a short text (`navbar-icon-text`, e.g. the code of the language) widens it; tinted on hover and while its dropdown is open. A `status-dot` (module `elements`) marks that something waits; `status-dot-pulse` makes it pulse.
98
+
99
+ ```html
100
+ <button type="button" class="navbar-icon" aria-label="Toggle theme" data-tooltip="bottom" data-theme-switcher
101
+ data-theme-light-icon="bi bi-sun" data-theme-dark-icon="bi bi-moon"><i data-theme-switcher-icon class="bi bi-moon"></i></button>
102
+
103
+ <div class="dropdown">
104
+ <button type="button" class="navbar-icon" data-bs-toggle="dropdown" aria-label="Notifications">
105
+ <i class="bi bi-bell"></i><span class="status-dot status-dot-pulse theme-danger"></span>
106
+ <span class="navbar-icon-text d-none d-lg-inline">Notifications</span>
107
+ </button>
108
+ <ul class="dropdown-menu dropdown-menu-end">…</ul>
109
+ </div>
110
+
111
+ <div class="dropdown">
112
+ <button type="button" class="navbar-icon" data-bs-toggle="dropdown"><i class="bi bi-translate" aria-hidden="true"></i><span class="visually-hidden">Language: </span><span class="navbar-icon-text">EN</span></button>
113
+ <ul class="dropdown-menu dropdown-menu-end">
114
+ <li><a class="dropdown-item" href="...">Čeština</a></li>
115
+ <li><a class="dropdown-item active" href="..." aria-current="true">English</a></li>
116
+ </ul>
117
+ </div>
118
+ ```
119
+
120
+ The user sits in the navbar as `navbar-user`: an `avatar` (initials or a photo in a circle, in a `theme-*` color; `avatar-sm`, `avatar-lg`) with the name and the role, the account in its dropdown.
121
+
122
+ ## Content boxes and the older navbar
123
+
124
+ The navbar `navbar fixed-top` gets the page background, `navbar-nav-breadcrumb` separates its items by an arrow, and `content-box` is a box of the page content on the surface color.
125
+
126
+ ## Datagrid tables
127
+
128
+ A table of a datagrid stands in a `table-responsive`, so it scrolls inside its box on a narrow screen. The wrapper is `<div class="table-responsive" tabindex="0" role="region" aria-label="Articles">` (the name of the table): with `tabindex` the keyboard can scroll it in every browser, the role and the name tell a screen reader what the focused box is. The actions of a row are a menu: three vertical dots open a dropdown with the items, delete last after a divider. The button needs `data-bs-popper-config='{"strategy":"fixed"}'`, or the scrolling wrapper cuts the menu off.
129
+
130
+ ```html
131
+ <td class="text-end">
132
+ <div class="dropdown">
133
+ <button type="button" class="btn btn-xs btn-icon btn-text" data-bs-toggle="dropdown" data-bs-popper-config='{"strategy":"fixed"}' aria-expanded="false" aria-label="Actions"><i class="bi bi-three-dots-vertical" aria-hidden="true"></i></button>
134
+ <ul class="dropdown-menu dropdown-menu-end">
135
+ <li><a class="dropdown-item" href="..."><i class="bi bi-pencil me-2" aria-hidden="true"></i>Edit</a></li>
136
+ <li><hr class="dropdown-divider"></li>
137
+ <li><a class="dropdown-item text-danger" href="..."><i class="bi bi-trash me-2" aria-hidden="true"></i>Delete</a></li>
138
+ </ul>
139
+ </div>
140
+ </td>
141
+ ```
142
+
143
+ A datagrid can also open an item by a click on its row (`datagrid-row-clickable` on the `tr` and `row-click.js` of drago-ex/datagrid; compostrap has no script for it). Use it only with icon buttons as the row actions (`btn btn-xs btn-icon` with a `data-tooltip`), never with the menu of three dots: a click that misses the small button of the menu lands on the row and opens the item instead of the menu.
@@ -0,0 +1,59 @@
1
+ # Sortable
2
+
3
+ [← Compostrap](../readme.md#documentation)
4
+
5
+ Items of a list moved by a handle of dots: by the mouse, a finger or the keyboard. Made for the order of the menu of the administration (the links the packages add, put in order by the user), the photos of a product or any rows of a list.
6
+
7
+ - `sortable` is the list, its direct children `sortable-item` are the items. A `list-group` of Bootstrap gives the rows their look; the module only lays out an item as a row (the handle, then the content).
8
+ - `sortable-handle` is a button with six dots, drawn by the module (no icon font). Only the handle starts a move, so the rest of an item stays a link, a text to select or a form.
9
+ - `data-sortable-group` lets the items move between all lists of the same group (the sections of the menu). A list without a group keeps its items.
10
+ - `sortable-nested` is a list inside an item, one level deeper (the links of a group of the menu). An item that holds a nested list is not dropped into another nested list, so there are at most two levels.
11
+ - `data-sortable-empty` is the text of an empty list, which stays a place to drop on.
12
+ - `data-id` of an item is what `SortableList.serialize()` returns.
13
+
14
+ While moving, the item stays in the list as a tinted place with a dashed line (`sortable-placeholder`) and a copy follows the pointer (`sortable-ghost`); the other items slide to their new places. An item grabbed by the keyboard is `sortable-grabbed` and its handle `aria-pressed="true"`.
15
+
16
+ ```html
17
+ <ul class="list-group sortable" data-sortable-group="menu" data-sortable-empty="Drop a link here">
18
+ <li class="list-group-item sortable-item" data-id="blog">
19
+ <button type="button" class="sortable-handle" aria-label="Move Blog"></button>
20
+ <i class="bi bi-journal-text" aria-hidden="true"></i>
21
+ <span class="list-row-text">Blog</span>
22
+ <ul class="list-group sortable sortable-nested" data-sortable-group="menu" data-sortable-empty="Drop a link here">
23
+ <li class="list-group-item sortable-item" data-id="blog.articles">
24
+ <button type="button" class="sortable-handle" aria-label="Move Articles"></button>
25
+ <span class="list-row-text">Articles</span>
26
+ </li>
27
+ </ul>
28
+ </li>
29
+ <li class="list-group-item sortable-item" data-id="pages">
30
+ <button type="button" class="sortable-handle" aria-label="Move Pages"></button>
31
+ <i class="bi bi-file-earmark-text" aria-hidden="true"></i>
32
+ <span class="list-row-text">Pages</span>
33
+ </li>
34
+ </ul>
35
+ ```
36
+
37
+ ## JavaScript
38
+
39
+ ```js
40
+ import { SortableList } from 'compostrap'; // or 'compostrap/sortable'
41
+
42
+ SortableList.init();
43
+
44
+ document.addEventListener('change.bs.sortable', (event) => {
45
+ const { item, from, to, oldIndex, newIndex } = event.detail;
46
+ // e.g. send the new order: SortableList.serialize(list)
47
+ });
48
+ ```
49
+
50
+ - `SortableList.init()` once; it listens on the document, so lists drawn later (an AJAX snippet) need nothing more.
51
+ - `change.bs.sortable` bubbles from the moved item after a drop that changed the order (not after a drop at the same place or a cancel).
52
+ - `SortableList.serialize(list)` gives the order as `[{ id: 'blog', children: [{ id: 'blog.articles' }] }, { id: 'pages' }]`.
53
+ - Keyboard: Space or Enter on a handle grabs the item, the arrows move it (at the end of a list into the next or the previous list of its group), Space or Enter drops it, Escape puts it back, Tab away drops it where it is. Escape also cancels a drag of the mouse.
54
+ - Screen readers hear every step from a live region (`sortable-live`). The texts are in `SortableList.messages` (`{item}`, `{position}`, `{count}`); the name of an item is its `data-sortable-label`, or the `aria-label` of its handle without the word Move, or its text.
55
+ - `SortableList.duration` is the time of the sliding of the other items (150 ms, 0 turns it off; nothing slides with reduced motion), `SortableList.scrollEdge` the distance from the edge of the window where it scrolls while dragging (48 px).
56
+
57
+ ## Variables
58
+
59
+ `--sortable-handle-size`, `--sortable-handle-color`, `--sortable-place-bg`, `--sortable-place-line` (the tint and the line of the place and of a grabbed item) and `--sortable-indent` (the indent of a nested list) are set on `.sortable`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "compostrap",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "description": "Bootstrap 5 for administrations and websites: a theme with the look and classes of Bootstrap 6, a layout with a sidebar, a multi-level menu and a navbar, and components Bootstrap does not have (datepicker, charts, gallery, lightbox, dropzone, sign-in pages, shop, blog).",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -52,6 +52,7 @@
52
52
  "./number-input": "./dist/js/number-input.js",
53
53
  "./otp-input": "./dist/js/otp-input.js",
54
54
  "./selection": "./dist/js/selection.js",
55
+ "./sortable": "./dist/js/sortable.js",
55
56
  "./datepicker": "./dist/js/datepicker.js",
56
57
  "./chart": "./dist/js/chart.js",
57
58
  "./spinner": "./dist/js/spinner.js",