moey-ui 0.1.0 → 0.2.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/CHANGELOG.md +12 -3
- package/README.md +3 -3
- package/dist/ai-rules.md +2 -2
- package/dist/llms-full.txt +73 -16
- package/dist/moey.css +36 -17
- package/dist/moey.js +104 -15
- package/dist/moey.min.css +1 -1
- package/dist/moey.min.js +86 -15
- package/package.json +3 -2
- package/src/css/card.css +5 -2
- package/src/css/dialog.css +10 -8
- package/src/css/gallery.css +15 -2
- package/src/css/keyboard.css +2 -1
- package/src/css/reboot.css +3 -3
- package/src/js/moey.js +102 -13
package/CHANGELOG.md
CHANGED
|
@@ -2,18 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to Moey. The format follows [Keep a Changelog](https://keepachangelog.com/), and versions follow [Semantic Versioning](https://semver.org/) (before 1.0, a minor version may change things that already exist).
|
|
4
4
|
|
|
5
|
-
## 0.
|
|
5
|
+
## 0.2.0 - 2026-11-26
|
|
6
|
+
|
|
7
|
+
- **Masonry places items exactly.** Each item gets its own position (the shortest column so far) instead of 1px grid rows. It measures the real layout size, so zoom, scaling or an entrance animation no longer makes items overlap; gaps stay exact on long pages; and very long feeds work in every browser (Firefox stops 1px grid rows at about 10,000px).
|
|
8
|
+
- **New items glide in:** `data-moey-enter` (`="fade"`, `="zoom"`) on any list or grid animates items added later, such as infinite scroll and "Load more". Items that only move don't animate.
|
|
9
|
+
- **`.dialog-fullscreen-phone`:** a normal dialog on larger screens, the whole screen on phones instead of a bottom sheet.
|
|
10
|
+
- **Page-wide dialog colors:** `--mo-dialog-bg` and the new `--mo-dialog-fg` can be set on `:root` and every dialog, drawer and sheet follows (before, each dialog set its own `--mo-dialog-bg`, so a page-level value was ignored).
|
|
11
|
+
- **Stat tiles fit small phones.** Two to a row at 280px, the value no longer gets cut off and the icon no longer hangs over the next tile: the value scales down a little on small screens, and the icon moves under the label when they don't fit side by side.
|
|
12
|
+
- **Smooth scrolling only for in-page links.** `html` no longer has `scroll-behavior: smooth`; moey.js turns it on just for a click on a `#link`. Scripts that scroll the page (`scrollTo`, `scrollIntoView`) land at once again.
|
|
13
|
+
|
|
14
|
+
## 0.1.0 - 2026-11-24
|
|
6
15
|
|
|
7
16
|
The first release.
|
|
8
17
|
|
|
9
18
|
- **One stylesheet, one script, no dependencies.** `dist/moey.css` (cascade layers: tokens, reboot, layout, content, forms, components, helpers, utilities) and `dist/moey.js`, plus minified copies. Inter and JetBrains Mono are bundled and self-hosted.
|
|
10
19
|
- **Mobile first.** Every page works down to 280px wide with no sideways scrolling; menus and dialogs become bottom sheets on phones and sit on the on-screen keyboard; fields never zoom the page.
|
|
11
|
-
- **Colors and themes.** 14 named colors × 12 shades, six strengths per component, painted areas (`theme-<color>-<strength>`), light and dark mode, and a brand switch (`data-mo-brand`)
|
|
20
|
+
- **Colors and themes.** 14 named colors × 12 shades, six strengths per component, painted areas (`theme-<color>-<strength>`), light and dark mode, and a brand switch (`data-mo-brand`), black "tuxedo" by default. Contrast checked to WCAG AA in both modes.
|
|
12
21
|
- **Layout.** Containers, a 12-column grid, CSS grid with `grid-cols-*` and `grid-min-*`, masonry, an app shell and sidebar, container queries, right-to-left.
|
|
13
22
|
- **Forms.** Fields, Moey dropdowns for every select, checkboxes, switches (also with a word inside), range, color picker, input groups, floating labels, chips, combobox, datepicker, time picker, OTP, password strength, validation, and rich text with the Mob editor.
|
|
14
23
|
- **Components.** Accordion, alert, avatar, badge, bottom sheet, breadcrumb, button, card, carousel, dialog, drawer, list group, menu, nav, navbar, tab bar, pagination, popover, progress, scrollspy, spinner, tabs, toasts, tooltip and more.
|
|
15
24
|
- **Work-app extras.** Data tables you edit in place (virtual scrolling, expandable, tree and grouped rows), charts, Kanban, split view, calendar, chat (with files, pictures and voice notes), keyboard shortcuts, tours, command palette, notification center, swipe actions, pull to refresh, sortable lists, filter & sort, infinite scroll, lightbox, audio and video player, click-to-load embeds.
|
|
16
|
-
- **Utilities.** Display, flex, grid, spacing (the number × 4px), sizing, text, colors, backgrounds, borders, effects, position, overflow, aspect ratio, interactions
|
|
25
|
+
- **Utilities.** Display, flex, grid, spacing (the number × 4px), sizing, text, colors, backgrounds, borders, effects, position, overflow, aspect ratio, interactions. Phone first, with responsive prefixes.
|
|
17
26
|
- **Accessible by default.** Keyboard support, focus rings, screen-reader roles and announcements, reduced motion.
|
|
18
27
|
- **Smaller builds.** `node build.mjs --without=… --breakpoints=… --out=…`.
|
|
19
28
|
- **For AI assistants.** `dist/ai-rules.md`, and `docs/llms.txt` / `docs/llms-full.txt`.
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<img src="https://cdn.jsdelivr.net/npm/moey-ui@0.
|
|
1
|
+
<img src="https://cdn.jsdelivr.net/npm/moey-ui@0.2.0/brand/moey-icon.svg" width="64" height="64" alt="Moey logo">
|
|
2
2
|
|
|
3
3
|
# Moey
|
|
4
4
|
|
|
@@ -22,9 +22,9 @@ Moey takes the best ideas from the popular frameworks (Tailwind, Bulma, Bootstra
|
|
|
22
22
|
From a CDN (nothing to download):
|
|
23
23
|
|
|
24
24
|
```html
|
|
25
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/moey-ui@0.
|
|
25
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/moey-ui@0.2.0/dist/moey.min.css">
|
|
26
26
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/moey-icons@1.0.0/dist/moey-icons.min.css">
|
|
27
|
-
<script src="https://cdn.jsdelivr.net/npm/moey-ui@0.
|
|
27
|
+
<script src="https://cdn.jsdelivr.net/npm/moey-ui@0.2.0/dist/moey.min.js" defer></script>
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
Or from npm — `npm i moey-ui moey-icons` — and link the same files from `node_modules/moey-ui/dist/` (or copy `dist/` into your site). Keep `dist/fonts/` next to the stylesheet: Inter and JetBrains Mono are self-hosted (no Google Fonts, no outside requests), and browsers only download the language subsets a page uses.
|
package/dist/ai-rules.md
CHANGED
|
@@ -120,7 +120,7 @@ Stat tile: `<div class="card"><div class="card-body stat"><span class="stat-labe
|
|
|
120
120
|
```
|
|
121
121
|
Form layouts: `form-stack` · `form-inline` · `form-section` (+`form-section-header`, `form-section-body`) · `form-actions`. `<form data-moey-dirty>` tracks unsaved changes.
|
|
122
122
|
|
|
123
|
-
**Dialog / sheet / drawer** (native `<dialog>`; on phones a dialog becomes a bottom sheet)
|
|
123
|
+
**Dialog / sheet / drawer** (native `<dialog>`; on phones a dialog becomes a bottom sheet: `.dialog-center` keeps it centered, `.dialog-fullscreen-phone` covers the screen instead; page-wide colors: `--mo-dialog-bg` / `--mo-dialog-fg` on `:root`)
|
|
124
124
|
```html
|
|
125
125
|
<button class="btn" data-moey-open="#invite">Invite</button>
|
|
126
126
|
<dialog class="dialog" id="invite" aria-labelledby="invite-title">
|
|
@@ -194,7 +194,7 @@ On phones (below 1024px, or 768px with `navbar-expand-md`; `navbar-expand` never
|
|
|
194
194
|
|
|
195
195
|
**Data table, more**: `data-moey-virtual` / `virtual: true` for thousands of rows; `detail: (row) => html` or `<template data-moey-detail>` for expandable rows; `children: [...]` or `<tr data-parent="id">` for tree rows; `groupBy: 'status'` / `data-moey-group-by` with `sum: true` / `data-moey-sum` for grouped rows. Never put a table inside a table cell.
|
|
196
196
|
|
|
197
|
-
**Masonry**: `<div class="masonry grid-cols-2 md:grid-cols-4 gap-3" data-moey-masonry>…items…</div>` (images need width/height); `span-2` wide items, `.masonry-dense` fills holes, add `data-moey-sortable` to rearrange. `.gallery-tile` + `.gallery-caption` for picture tiles.
|
|
197
|
+
**Masonry**: `<div class="masonry grid-cols-2 md:grid-cols-4 gap-3" data-moey-masonry>…items…</div>` (images need width/height); `span-2` wide items, `.masonry-dense` fills holes, add `data-moey-sortable` to rearrange, `data-moey-enter` (any list or grid) animates items added later. `.gallery-tile` + `.gallery-caption` for picture tiles.
|
|
198
198
|
|
|
199
199
|
**Filter & sort**: buttons in `<div data-moey-filters="#items">` with `data-moey-filter="tag"` (`"*"` = all) and `data-moey-sort-by="date"` (+ `data-moey-sort-dir="desc"`); items carry `data-tags="a b"` and `data-date`…; `data-moey-filter-search="#items"`, `data-moey-filter-count="#items"`, a `.filter-empty` inside.
|
|
200
200
|
|
package/dist/llms-full.txt
CHANGED
|
@@ -120,7 +120,7 @@ Stat tile: `<div class="card"><div class="card-body stat"><span class="stat-labe
|
|
|
120
120
|
```
|
|
121
121
|
Form layouts: `form-stack` · `form-inline` · `form-section` (+`form-section-header`, `form-section-body`) · `form-actions`. `<form data-moey-dirty>` tracks unsaved changes.
|
|
122
122
|
|
|
123
|
-
**Dialog / sheet / drawer** (native `<dialog>`; on phones a dialog becomes a bottom sheet)
|
|
123
|
+
**Dialog / sheet / drawer** (native `<dialog>`; on phones a dialog becomes a bottom sheet: `.dialog-center` keeps it centered, `.dialog-fullscreen-phone` covers the screen instead; page-wide colors: `--mo-dialog-bg` / `--mo-dialog-fg` on `:root`)
|
|
124
124
|
```html
|
|
125
125
|
<button class="btn" data-moey-open="#invite">Invite</button>
|
|
126
126
|
<dialog class="dialog" id="invite" aria-labelledby="invite-title">
|
|
@@ -194,7 +194,7 @@ On phones (below 1024px, or 768px with `navbar-expand-md`; `navbar-expand` never
|
|
|
194
194
|
|
|
195
195
|
**Data table, more**: `data-moey-virtual` / `virtual: true` for thousands of rows; `detail: (row) => html` or `<template data-moey-detail>` for expandable rows; `children: [...]` or `<tr data-parent="id">` for tree rows; `groupBy: 'status'` / `data-moey-group-by` with `sum: true` / `data-moey-sum` for grouped rows. Never put a table inside a table cell.
|
|
196
196
|
|
|
197
|
-
**Masonry**: `<div class="masonry grid-cols-2 md:grid-cols-4 gap-3" data-moey-masonry>…items…</div>` (images need width/height); `span-2` wide items, `.masonry-dense` fills holes, add `data-moey-sortable` to rearrange. `.gallery-tile` + `.gallery-caption` for picture tiles.
|
|
197
|
+
**Masonry**: `<div class="masonry grid-cols-2 md:grid-cols-4 gap-3" data-moey-masonry>…items…</div>` (images need width/height); `span-2` wide items, `.masonry-dense` fills holes, add `data-moey-sortable` to rearrange, `data-moey-enter` (any list or grid) animates items added later. `.gallery-tile` + `.gallery-caption` for picture tiles.
|
|
198
198
|
|
|
199
199
|
**Filter & sort**: buttons in `<div data-moey-filters="#items">` with `data-moey-filter="tag"` (`"*"` = all) and `data-moey-sort-by="date"` (+ `data-moey-sort-dir="desc"`); items carry `data-tags="a b"` and `data-date`…; `data-moey-filter-search="#items"`, `data-moey-filter-count="#items"`, a `.filter-empty` inside.
|
|
200
200
|
|
|
@@ -244,13 +244,13 @@ On phones (below 1024px, or 768px with `navbar-expand-md`; `navbar-expand` never
|
|
|
244
244
|
|
|
245
245
|
---
|
|
246
246
|
|
|
247
|
-
# Moey documentation (v0.
|
|
247
|
+
# Moey documentation (v0.2.0)
|
|
248
248
|
|
|
249
249
|
Every page of the docs, in order.
|
|
250
250
|
|
|
251
251
|
# Overview (Getting started)
|
|
252
252
|
|
|
253
|
-
v0.
|
|
253
|
+
v0.2.0 · MIT · no dependencies
|
|
254
254
|
Apps that feel native on every screen.
|
|
255
255
|
|
|
256
256
|
Moey is a clean, mobile-first front-end framework for admin dashboards, productivity apps and websites. Plain HTML, one stylesheet and one script — flat, accessible, light and dark, right to left.
|
|
@@ -317,9 +317,9 @@ Not just buttons and cards: the pieces productivity apps are made of, each worki
|
|
|
317
317
|
## Overview
|
|
318
318
|
|
|
319
319
|
```html
|
|
320
|
-
<link rel="stylesheet" href="dist/moey.min.css">
|
|
321
|
-
<link rel="stylesheet" href="moey-icons.min.css">
|
|
322
|
-
<script src="dist/moey.min.js" defer></script>
|
|
320
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/moey-ui@0.2.0/dist/moey.min.css">
|
|
321
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/moey-icons@1.0.0/dist/moey-icons.min.css">
|
|
322
|
+
<script src="https://cdn.jsdelivr.net/npm/moey-ui@0.2.0/dist/moey.min.js" defer></script>
|
|
323
323
|
```
|
|
324
324
|
|
|
325
325
|
### Cascade layers
|
|
@@ -406,9 +406,9 @@ Moey is one stylesheet and one script, with no dependencies and no build step. L
|
|
|
406
406
|
Link the files straight from jsDelivr (the version in the address never changes, so it can be cached for a year):
|
|
407
407
|
|
|
408
408
|
```html
|
|
409
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/moey-ui@0.
|
|
409
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/moey-ui@0.2.0/dist/moey.min.css">
|
|
410
410
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/moey-icons@1.0.0/dist/moey-icons.min.css">
|
|
411
|
-
<script src="https://cdn.jsdelivr.net/npm/moey-ui@0.
|
|
411
|
+
<script src="https://cdn.jsdelivr.net/npm/moey-ui@0.2.0/dist/moey.min.js" defer></script>
|
|
412
412
|
```
|
|
413
413
|
|
|
414
414
|
### npm
|
|
@@ -440,9 +440,9 @@ The `viewport` line matters: it makes the page fit a phone. The small script bef
|
|
|
440
440
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
441
441
|
<title>My app</title>
|
|
442
442
|
<script>try { const t = localStorage.getItem('moey-theme'); if (t) document.documentElement.dataset.moTheme = t; } catch {}</script>
|
|
443
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/moey-ui@0.
|
|
443
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/moey-ui@0.2.0/dist/moey.min.css">
|
|
444
444
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/moey-icons@1.0.0/dist/moey-icons.min.css">
|
|
445
|
-
<script src="https://cdn.jsdelivr.net/npm/moey-ui@0.
|
|
445
|
+
<script src="https://cdn.jsdelivr.net/npm/moey-ui@0.2.0/dist/moey.min.js" defer></script>
|
|
446
446
|
</head>
|
|
447
447
|
<body>
|
|
448
448
|
<main class="container py-8">
|
|
@@ -465,6 +465,16 @@ The `viewport` line matters: it makes the page fit a phone. The small script bef
|
|
|
465
465
|
|
|
466
466
|
---
|
|
467
467
|
|
|
468
|
+
# Changelog (Getting started)
|
|
469
|
+
|
|
470
|
+
## Changelog
|
|
471
|
+
|
|
472
|
+
What changed in each version of Moey. A link with a version in it (`moey-ui@0.1.0`) always serves exactly that version, so your pages never change until you change the link.
|
|
473
|
+
|
|
474
|
+
{{changelog}}
|
|
475
|
+
|
|
476
|
+
---
|
|
477
|
+
|
|
468
478
|
# Examples (Getting started)
|
|
469
479
|
|
|
470
480
|
## Examples
|
|
@@ -1062,7 +1072,7 @@ Generated from Moey's own CSS, so this list is always complete. Click a componen
|
|
|
1062
1072
|
| Data table | `--mo-datatable-height` |
|
|
1063
1073
|
| Datepicker | `--mo-dp-cell` |
|
|
1064
1074
|
| Description list | `--mo-dl-label` `--mo-dl-gap` |
|
|
1065
|
-
| Dialog / drawer / sheet | `--mo-dialog-padding` `--mo-dialog-footer-padding` `--mo-dialog-bg` `--mo-dialog-duration` `--mo-dialog-width` `--mo-sheet-height` `--mo-sheet-max-width` `--mo-drawer-size` |
|
|
1075
|
+
| Dialog / drawer / sheet | `--mo-dialog-padding` `--mo-dialog-footer-padding` `--mo-dialog-bg` `--mo-dialog-fg` `--mo-dialog-duration` `--mo-dialog-width` `--mo-sheet-height` `--mo-sheet-max-width` `--mo-drawer-size` |
|
|
1066
1076
|
| Divider | `--mo-divider-color` `--mo-divider-space` `--mo-divider-style` |
|
|
1067
1077
|
| Dropzone | `--mo-dropzone-min-height` |
|
|
1068
1078
|
| Floating labels | `--mo-floating-height` `--mo-floating-scale` |
|
|
@@ -1627,9 +1637,9 @@ Items of different heights packed into columns with no holes — photo galleries
|
|
|
1627
1637
|
|
|
1628
1638
|
- **Any items:** pictures, cards, notes. Give images their `width` and `height` so the space is kept before they load.
|
|
1629
1639
|
|
|
1630
|
-
- **Moey packs them:** each item
|
|
1640
|
+
- **Moey packs them:** each item goes to the column that is shortest so far, at its exact height, so the columns fill with no holes. It packs again when an image loads, the window changes or items come and go, and it measures each item's real size, so zoom or an entrance animation never makes items overlap.
|
|
1631
1641
|
|
|
1632
|
-
- **Reading order stays:** items stay in the page's order, left to right, so the keyboard and screen readers go through them sensibly. In browsers with built-in CSS masonry, Moey just uses that.
|
|
1642
|
+
- **Reading order stays:** items stay in the page's order, roughly left to right, so the keyboard and screen readers go through them sensibly. In browsers with built-in CSS masonry, Moey just uses that.
|
|
1633
1643
|
|
|
1634
1644
|
### Cards, not just pictures
|
|
1635
1645
|
|
|
@@ -1654,6 +1664,17 @@ Items of different heights packed into columns with no holes — photo galleries
|
|
|
1654
1664
|
|
|
1655
1665
|
With `.masonry-dense` the order on screen can differ from the page's — fine for pictures, but keep it off when the order matters (news, steps).
|
|
1656
1666
|
|
|
1667
|
+
### New items glide in
|
|
1668
|
+
|
|
1669
|
+
Add `data-moey-enter` and items added later (infinite scroll, "Load more", a new post) fade up into place, one after another. Items that only move (sorting, dragging, filters) don't. It works on any list or grid, not only masonry, and nothing moves for visitors who turned motion off.
|
|
1670
|
+
|
|
1671
|
+
```html
|
|
1672
|
+
<div class="masonry gap-3" data-moey-masonry data-moey-enter>…</div>
|
|
1673
|
+
|
|
1674
|
+
<!-- data-moey-enter="fade": fade only · ="zoom": grow from 96% -->
|
|
1675
|
+
<!-- your own: [data-moey-enter] > .is-entering { animation: … } (--mo-enter-index: 0, 1, 2… for a stagger) -->
|
|
1676
|
+
```
|
|
1677
|
+
|
|
1657
1678
|
### Reference
|
|
1658
1679
|
|
|
1659
1680
|
| Class / attribute | What it does |
|
|
@@ -1662,6 +1683,7 @@ With `.masonry-dense` the order on screen can differ from the page's — fine fo
|
|
|
1662
1683
|
| `grid-cols-*` · `md:grid-cols-*` · `gap-*` | Columns and spacing (else automatic: `--mo-masonry-min`, 14rem) |
|
|
1663
1684
|
| `span-2` · `span-3` | An item across two or three columns |
|
|
1664
1685
|
| `.masonry-dense` | Later items fill holes (order on screen may change) |
|
|
1686
|
+
| `data-moey-enter` · `="fade"` · `="zoom"` | Items added later animate in (any list or grid); they get `.is-entering` and `--mo-enter-index` while they do |
|
|
1665
1687
|
| `.gallery-tile` + `.gallery-caption` / `figcaption` | A rounded picture tile with a caption on hover (always shown on touch) |
|
|
1666
1688
|
| `Moey.masonry(el).layout()` | Pack again (after changing items from code — usually automatic) |
|
|
1667
1689
|
|
|
@@ -2009,6 +2031,10 @@ Code is set in **JetBrains Mono**, self-hosted with Moey like Inter — nothing
|
|
|
2009
2031
|
|
|
2010
2032
|
Ligatures are off, so `=>` and `!=` show exactly as typed (turn them on with `font-variant-ligatures: normal`). Prefer another code font? Set `--mo-font-mono`.
|
|
2011
2033
|
|
|
2034
|
+
### Scrolling
|
|
2035
|
+
|
|
2036
|
+
A link to a spot on the same page (`href="#shipping"`) glides there, unless the visitor turned motion off. Only those links glide: when your own script moves the page (`scrollTo()`, `scrollIntoView()`, "jump to post"), it lands at once, exactly where you aimed. Want a scroll area that always glides? Add `scroll-smooth` to it.
|
|
2037
|
+
|
|
2012
2038
|
---
|
|
2013
2039
|
|
|
2014
2040
|
# Typography (Content)
|
|
@@ -5553,7 +5579,7 @@ With `moey.js` it all works on its own:
|
|
|
5553
5579
|
|
|
5554
5580
|
- **Focus** — goes to the dialog itself, or to the element with `autofocus` (e.g. the first input of a form).
|
|
5555
5581
|
|
|
5556
|
-
- **On phones** — it becomes a bottom sheet with a handle you can drag down to close. Want a sheet on every screen size? Use `.sheet`.
|
|
5582
|
+
- **On phones** — it becomes a bottom sheet with a handle you can drag down to close. Want a sheet on every screen size? Use `.sheet`. Rather have it cover the phone's screen? Add `.dialog-fullscreen-phone`.
|
|
5557
5583
|
|
|
5558
5584
|
| Class | What it does |
|
|
5559
5585
|
| --- | --- |
|
|
@@ -5566,8 +5592,37 @@ With `moey.js` it all works on its own:
|
|
|
5566
5592
|
| `data-moey-close-outside="true"` | A click outside closes it (off by default). On `<body>` it sets the page default. |
|
|
5567
5593
|
| `data-moey-static` | Only your own buttons close it |
|
|
5568
5594
|
| `.dialog-center` | Stays centered on phones instead of becoming a bottom sheet |
|
|
5595
|
+
| `.dialog-fullscreen-phone` | A normal dialog on larger screens, the whole screen on phones (under 576px) instead of a bottom sheet: a post, a long form, a reader |
|
|
5569
5596
|
| `.dialog-icon` + `theme-*` | Round icon for confirm dialogs |
|
|
5570
5597
|
| `--mo-dialog-padding` · `--mo-dialog-footer-padding` | Inner spacing (24px) · space above and below the footer buttons (14px) |
|
|
5598
|
+
| `--mo-dialog-bg` · `--mo-dialog-fg` | Background and text of dialogs, drawers and sheets. Set them on `:root` to give every one your page's colors (a theme with its own palette), or on one dialog |
|
|
5599
|
+
|
|
5600
|
+
### Full screen on phones
|
|
5601
|
+
|
|
5602
|
+
A post, an article or a long form reads better on the whole screen of a phone than in a sheet. `.dialog-fullscreen-phone` keeps a normal dialog on larger screens and covers the screen under 576px (clearing the notch and home bar). Make the window narrow to see it switch:
|
|
5603
|
+
|
|
5604
|
+
## Packing day
|
|
5605
|
+
|
|
5606
|
+
Posted by the studio · 4 min read
|
|
5607
|
+
|
|
5608
|
+
Every Friday the whole week's orders go out at once. The totes are folded in thirds, the mugs get a paper sleeve, and every box gets a handwritten note.
|
|
5609
|
+
|
|
5610
|
+
On a phone this dialog fills the screen like a page of its own; on a laptop it stays a dialog over the page.
|
|
5611
|
+
|
|
5612
|
+
Done
|
|
5613
|
+
|
|
5614
|
+
```html
|
|
5615
|
+
<dialog class="dialog dialog-lg dialog-fullscreen-phone" id="post" aria-labelledby="post-title">…</dialog>
|
|
5616
|
+
```
|
|
5617
|
+
|
|
5618
|
+
Your page has its own colors (a theme, a blog)? Give the dialogs the same ones, once, for the whole page:
|
|
5619
|
+
|
|
5620
|
+
```css
|
|
5621
|
+
:root {
|
|
5622
|
+
--mo-dialog-bg: #fbf7f0; /* dialogs, drawers and sheets */
|
|
5623
|
+
--mo-dialog-fg: #2b2622;
|
|
5624
|
+
}
|
|
5625
|
+
```
|
|
5571
5626
|
|
|
5572
5627
|
### Clicking outside
|
|
5573
5628
|
|
|
@@ -9867,7 +9922,7 @@ gallery.addEventListener('moey:filter', (e) => console.log(e.detail.shown, 'of',
|
|
|
9867
9922
|
The next items load as you reach the end of the list — feeds, galleries, search results. After a few loads it waits for a "Load more" button, so people can still get to your footer; it says when it's loading and when there's nothing more.
|
|
9868
9923
|
|
|
9869
9924
|
```html
|
|
9870
|
-
<div class="masonry" id="feed" data-moey-masonry data-moey-infinite>
|
|
9925
|
+
<div class="masonry" id="feed" data-moey-masonry data-moey-infinite data-moey-enter>
|
|
9871
9926
|
…the first items…
|
|
9872
9927
|
</div>
|
|
9873
9928
|
|
|
@@ -9898,6 +9953,8 @@ The next items load as you reach the end of the list — feeds, galleries, searc
|
|
|
9898
9953
|
|
|
9899
9954
|
- It works with masonry, filters, list groups and cards; new items join the layout and the current filter.
|
|
9900
9955
|
|
|
9956
|
+
- Add `data-moey-enter` and the new items fade up into place, one after another (more).
|
|
9957
|
+
|
|
9901
9958
|
- Screen readers hear "Loading…", "8 more loaded" and "That's everything".
|
|
9902
9959
|
|
|
9903
9960
|
- Keep links to items working: give the items real URLs so people can come back to them.
|
package/dist/moey.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Moey v0.
|
|
1
|
+
/*! Moey v0.2.0 | MIT License | Inter + JetBrains Mono: SIL OFL 1.1 (dist/fonts/*-OFL.txt) */
|
|
2
2
|
@layer tokens, reboot, layout, content, forms, components, helpers, utilities;
|
|
3
3
|
|
|
4
4
|
@font-face {
|
|
@@ -3377,9 +3377,9 @@
|
|
|
3377
3377
|
/* Mobile first: nothing may push the page wider than the screen */
|
|
3378
3378
|
body { overflow-wrap: break-word; }
|
|
3379
3379
|
img, svg, video, canvas, iframe { max-width: 100%; }
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
}
|
|
3380
|
+
/* Smooth scrolling only for in-page links (moey.js turns it on for that one jump), so scripts that
|
|
3381
|
+
move the page (scrollTo, scrollIntoView, "jump to post") land at once, exactly where they aimed */
|
|
3382
|
+
html.mo-smooth-scroll { scroll-behavior: smooth; }
|
|
3383
3383
|
|
|
3384
3384
|
body {
|
|
3385
3385
|
margin: 0;
|
|
@@ -6107,17 +6107,19 @@
|
|
|
6107
6107
|
<div class="stat-value">$48,210</div>
|
|
6108
6108
|
<div class="stat-trend theme-green"><i class="mi mi-trending-up"></i> 12.4% <span>vs last month</span></div>
|
|
6109
6109
|
</div></div> */
|
|
6110
|
-
.stat { display: grid; gap: .25rem; align-content: start; }
|
|
6110
|
+
.stat { display: grid; gap: .25rem; align-content: start; min-width: 0; }
|
|
6111
6111
|
.stat-label {
|
|
6112
6112
|
display: flex;
|
|
6113
|
+
flex-wrap: wrap; /* a narrow tile (two on a small phone): the icon moves under the label */
|
|
6113
6114
|
align-items: center;
|
|
6114
6115
|
gap: .5rem;
|
|
6116
|
+
min-width: 0;
|
|
6115
6117
|
font-size: var(--mo-font-size-sm);
|
|
6116
6118
|
font-weight: var(--mo-font-weight-medium);
|
|
6117
6119
|
color: var(--mo-fg-3);
|
|
6118
6120
|
}
|
|
6119
6121
|
.stat-value {
|
|
6120
|
-
font-size: 1.75rem;
|
|
6122
|
+
font-size: clamp(1.125rem, 7vw, 1.75rem); /* a little smaller on small phones, so $48,210 fits two to a row at 280px */
|
|
6121
6123
|
font-weight: var(--mo-font-weight-semibold);
|
|
6122
6124
|
line-height: 1.2;
|
|
6123
6125
|
letter-spacing: -.025em;
|
|
@@ -6140,6 +6142,7 @@
|
|
|
6140
6142
|
place-items: center;
|
|
6141
6143
|
width: 2.25rem;
|
|
6142
6144
|
height: 2.25rem;
|
|
6145
|
+
flex: none;
|
|
6143
6146
|
margin-inline-start: auto;
|
|
6144
6147
|
font-size: 1.125rem;
|
|
6145
6148
|
color: var(--mo-theme-fg-emphasis);
|
|
@@ -6806,7 +6809,9 @@
|
|
|
6806
6809
|
|
|
6807
6810
|
moey.js: opens with data-moey-open, closes on .btn-close / data-moey-dismiss /
|
|
6808
6811
|
outside click / Esc (data-moey-static keeps it open).
|
|
6809
|
-
On phones a .dialog becomes a bottom sheet (.dialog-center keeps it centered
|
|
6812
|
+
On phones a .dialog becomes a bottom sheet (.dialog-center keeps it centered,
|
|
6813
|
+
.dialog-fullscreen-phone makes it cover the screen there instead).
|
|
6814
|
+
A page can set --mo-dialog-bg / --mo-dialog-fg (on :root, say) to color every dialog, drawer and sheet.
|
|
6810
6815
|
========================================================================== */
|
|
6811
6816
|
|
|
6812
6817
|
/* Lock page scrolling while a modal is open */
|
|
@@ -6816,13 +6821,12 @@
|
|
|
6816
6821
|
:is(.dialog, .drawer, .sheet) {
|
|
6817
6822
|
--mo-dialog-padding: 1.5rem;
|
|
6818
6823
|
--mo-dialog-footer-padding: .875rem; /* space above & below the footer buttons */
|
|
6819
|
-
--mo-dialog-bg: var(--mo-bg-raised);
|
|
6820
6824
|
--mo-dialog-duration: .22s;
|
|
6821
6825
|
max-width: none;
|
|
6822
6826
|
max-height: none;
|
|
6823
6827
|
padding: 0;
|
|
6824
|
-
color: var(--mo-fg-body);
|
|
6825
|
-
background: var(--mo-dialog-bg);
|
|
6828
|
+
color: var(--mo-dialog-fg, var(--mo-fg-body)); /* --mo-dialog-bg / -fg: set them on the page to recolor them all */
|
|
6829
|
+
background: var(--mo-dialog-bg, var(--mo-bg-raised));
|
|
6826
6830
|
border: 0;
|
|
6827
6831
|
box-shadow: var(--mo-shadow-overlay);
|
|
6828
6832
|
}
|
|
@@ -6907,9 +6911,10 @@
|
|
|
6907
6911
|
/* Fullscreen: covers the whole screen (content clears the notch / home bar) */
|
|
6908
6912
|
.dialog-fullscreen { inset-inline: 0 auto; width: 100vw; max-width: none; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
|
|
6909
6913
|
|
|
6910
|
-
/* Phones: dialogs become bottom sheets (unless .dialog-center / .dialog-fullscreen) */
|
|
6914
|
+
/* Phones: dialogs become bottom sheets (unless .dialog-center / .dialog-fullscreen / .dialog-fullscreen-phone) */
|
|
6911
6915
|
@media (width < 576px) {
|
|
6912
|
-
.dialog:
|
|
6916
|
+
.dialog-fullscreen-phone { inset-inline: 0 auto; width: 100vw; max-width: none; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
|
|
6917
|
+
.dialog:not(.dialog-center, .dialog-fullscreen, .dialog-fullscreen-phone) {
|
|
6913
6918
|
inset-inline: 0 auto;
|
|
6914
6919
|
width: 100vw;
|
|
6915
6920
|
max-width: none;
|
|
@@ -7071,9 +7076,9 @@
|
|
|
7071
7076
|
@keyframes mo-sheet-bump { 50% { translate: 0 -.5rem; } }
|
|
7072
7077
|
|
|
7073
7078
|
@media (width < 576px) {
|
|
7074
|
-
.dialog:not(.dialog-center, .dialog-fullscreen):not([open]) { scale: 1; translate: 0 100%; }
|
|
7079
|
+
.dialog:not(.dialog-center, .dialog-fullscreen, .dialog-fullscreen-phone):not([open]) { scale: 1; translate: 0 100%; }
|
|
7075
7080
|
@starting-style {
|
|
7076
|
-
.dialog:not(.dialog-center, .dialog-fullscreen)[open] { scale: 1; translate: 0 100%; }
|
|
7081
|
+
.dialog:not(.dialog-center, .dialog-fullscreen, .dialog-fullscreen-phone)[open] { scale: 1; translate: 0 100%; }
|
|
7077
7082
|
}
|
|
7078
7083
|
}
|
|
7079
7084
|
|
|
@@ -7977,7 +7982,8 @@
|
|
|
7977
7982
|
html.mo-keyboard .dialog:modal:not(.sheet) { max-height: calc(var(--mo-vv-h) - 1rem); }
|
|
7978
7983
|
html.mo-keyboard .dialog-fullscreen:modal { height: var(--mo-vv-h); max-height: var(--mo-vv-h); padding-bottom: 0; }
|
|
7979
7984
|
@media (width < 576px) {
|
|
7980
|
-
html.mo-keyboard .dialog:modal:
|
|
7985
|
+
html.mo-keyboard .dialog-fullscreen-phone:modal { height: var(--mo-vv-h); max-height: var(--mo-vv-h); padding-bottom: 0; }
|
|
7986
|
+
html.mo-keyboard .dialog:modal:not(.dialog-center, .dialog-fullscreen, .dialog-fullscreen-phone) { max-height: calc(var(--mo-vv-h) - 2.5rem); padding-bottom: 0; }
|
|
7981
7987
|
}
|
|
7982
7988
|
|
|
7983
7989
|
/* Drawers: as tall as what's visible */
|
|
@@ -13264,15 +13270,28 @@
|
|
|
13264
13270
|
}
|
|
13265
13271
|
/* the grid-cols-* utilities set --mo-columns (phone first: grid-cols-2 md:grid-cols-4) */
|
|
13266
13272
|
.masonry[class*="grid-cols-"] { grid-template-columns: repeat(var(--mo-columns, 3), minmax(0, 1fr)); }
|
|
13267
|
-
.
|
|
13273
|
+
/* moey.js gives each item its exact place (is-ready): the grid only supplies the columns and gaps */
|
|
13274
|
+
.masonry.is-ready { position: relative; }
|
|
13275
|
+
.masonry.is-ready > * { position: absolute; box-sizing: border-box; }
|
|
13268
13276
|
.masonry > * { min-width: 0; margin: 0; }
|
|
13269
13277
|
.masonry > .span-2 { grid-column: span 2; }
|
|
13270
13278
|
.masonry > .span-3 { grid-column: span 3; }
|
|
13271
13279
|
.masonry-dense { grid-auto-flow: row dense; }
|
|
13272
13280
|
@supports (grid-template-rows: masonry) {
|
|
13273
13281
|
.masonry { grid-template-rows: masonry; }
|
|
13274
|
-
.masonry.is-ready { grid-auto-rows: auto; row-gap: revert-layer; }
|
|
13275
13282
|
}
|
|
13283
|
+
|
|
13284
|
+
/* New items glide in: data-moey-enter on any list or grid (masonry, infinite scroll, a feed).
|
|
13285
|
+
Items added later get .is-entering and --mo-enter-index (0, 1, 2… in each batch, for a stagger).
|
|
13286
|
+
data-moey-enter="fade" fades only; "zoom" grows from 96%. Your own: style [data-moey-enter] > .is-entering. */
|
|
13287
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
13288
|
+
[data-moey-enter] > .is-entering { animation: mo-enter-up .45s var(--mo-ease) both; animation-delay: calc(min(var(--mo-enter-index, 0), 10) * 60ms); }
|
|
13289
|
+
[data-moey-enter="fade"] > .is-entering { animation-name: mo-enter-fade; }
|
|
13290
|
+
[data-moey-enter="zoom"] > .is-entering { animation-name: mo-enter-zoom; }
|
|
13291
|
+
}
|
|
13292
|
+
@keyframes mo-enter-up { from { opacity: 0; translate: 0 1rem; } }
|
|
13293
|
+
@keyframes mo-enter-fade { from { opacity: 0; } }
|
|
13294
|
+
@keyframes mo-enter-zoom { from { opacity: 0; scale: .96; } }
|
|
13276
13295
|
/* Picture tiles */
|
|
13277
13296
|
.masonry img,
|
|
13278
13297
|
.gallery-tile img { display: block; width: 100%; height: auto; border-radius: var(--mo-radius-card); }
|
package/dist/moey.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Moey v0.
|
|
1
|
+
/*! Moey v0.2.0 | MIT License */
|
|
2
2
|
/* ==========================================================================
|
|
3
3
|
moey.js — Moey's behaviors. Include it once; everything works on its own.
|
|
4
4
|
One listener on the document, so it also works for content added later.
|
|
@@ -26,6 +26,26 @@
|
|
|
26
26
|
setTimeout(finish, ms + 50); // safety net if transitionend never fires
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/* ---- Smooth in-page links ----------------------------------------------------
|
|
30
|
+
A link to a spot on the same page glides there (unless the visitor turned motion off).
|
|
31
|
+
Only that jump is smooth: html.mo-smooth-scroll is on just while it happens, so scripts
|
|
32
|
+
that scroll the page (scrollTo, scrollIntoView) still land at once. */
|
|
33
|
+
doc.addEventListener('click', (e) => {
|
|
34
|
+
const a = e.target.closest?.('a[href*="#"]');
|
|
35
|
+
if (!a || e.defaultPrevented || e.button || e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || reducedMotion()) return;
|
|
36
|
+
if ((a.target && a.target !== '_self') || a.hasAttribute('download') || !a.hash || a.origin !== location.origin ||
|
|
37
|
+
a.pathname !== location.pathname || a.search !== location.search) return;
|
|
38
|
+
const html = doc.documentElement;
|
|
39
|
+
html.classList.add('mo-smooth-scroll');
|
|
40
|
+
let timer = 0;
|
|
41
|
+
const off = () => { clearTimeout(timer); removeEventListener('scrollend', off); html.classList.remove('mo-smooth-scroll'); };
|
|
42
|
+
setTimeout(() => { // after the click: did someone else take it over?
|
|
43
|
+
if (e.defaultPrevented) return off();
|
|
44
|
+
addEventListener('scrollend', off, { once: true });
|
|
45
|
+
timer = setTimeout(off, 1500); // no scroll (already there) or no scrollend: tidy up anyway
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
29
49
|
/* ---- Close ------------------------------------------------------------------
|
|
30
50
|
Automatic: a .btn-close closes the alert or dialog it's in. No attribute needed.
|
|
31
51
|
<div class="alert">… <button class="btn-close" aria-label="Close"></button></div>
|
|
@@ -315,7 +335,7 @@
|
|
|
315
335
|
const PHONE = matchMedia('(width < 576px)');
|
|
316
336
|
const sheetState = new WeakMap(); // dialog -> { snaps: [visible px…], index }
|
|
317
337
|
const isSheet = (d) => d.matches('dialog.sheet') ||
|
|
318
|
-
(PHONE.matches && d.matches('dialog.dialog:not(.dialog-center, .dialog-fullscreen)'));
|
|
338
|
+
(PHONE.matches && d.matches('dialog.dialog:not(.dialog-center, .dialog-fullscreen, .dialog-fullscreen-phone)'));
|
|
319
339
|
const canDrag = (d) => d.open && d.dataset.moeyDrag !== 'false' && isSheet(d);
|
|
320
340
|
|
|
321
341
|
function snapPoints(d) {
|
|
@@ -7929,11 +7949,13 @@
|
|
|
7929
7949
|
const sortHorizontal = (list) => { const its = sortItems(list); if (its.length < 2) return false; const a = its[0].getBoundingClientRect(), b = its[1].getBoundingClientRect(); return Math.abs(a.top - b.top) < a.height / 2; };
|
|
7930
7950
|
let sortFlipUntil = 0; // while items slide to their new places, their positions aren't final yet
|
|
7931
7951
|
function sortFlip(lists, change) {
|
|
7932
|
-
|
|
7952
|
+
const relayout = () => lists.forEach((l) => msStates.has(l) && msLayout(msStates.get(l))); // masonry places its items itself
|
|
7953
|
+
if (reducedMotion()) { change(); relayout(); return; }
|
|
7933
7954
|
sortFlipUntil = performance.now() + 170;
|
|
7934
7955
|
const els = lists.flatMap((l) => sortItems(l)).filter((x) => !x.classList.contains('is-sorting'));
|
|
7935
7956
|
const before = new Map(els.map((x) => [x, x.getBoundingClientRect()]));
|
|
7936
7957
|
change();
|
|
7958
|
+
relayout();
|
|
7937
7959
|
els.forEach((x) => { const a = before.get(x), b = x.getBoundingClientRect(); if (a.left !== b.left || a.top !== b.top) x.animate([{ translate: `${a.left - b.left}px ${a.top - b.top}px` }, { translate: '0 0' }], { duration: 160, easing: 'cubic-bezier(.2,0,0,1)' }); });
|
|
7938
7960
|
}
|
|
7939
7961
|
function sortGroup(list) { const g = list.dataset.moeySortable; return g && g !== '' && g !== 'true' ? [...doc.querySelectorAll(`[data-moey-sortable="${CSS.escape(g)}"]`)] : [list]; }
|
|
@@ -8992,19 +9014,62 @@
|
|
|
8992
9014
|
From code: Moey.masonry(el) → { layout() }. */
|
|
8993
9015
|
const msStates = new WeakMap();
|
|
8994
9016
|
const MS_NATIVE = CSS.supports?.('grid-template-rows', 'masonry');
|
|
9017
|
+
// The real layout size: a transform (an entrance animation, scale) or zoom doesn't change it
|
|
9018
|
+
const msHeight = (it) => {
|
|
9019
|
+
const c = getComputedStyle(it), px = (v) => parseFloat(v) || 0;
|
|
9020
|
+
const box = c.boxSizing === 'border-box' ? 0 : px(c.paddingTop) + px(c.paddingBottom) + px(c.borderTopWidth) + px(c.borderBottomWidth);
|
|
9021
|
+
return px(c.height) + box + px(c.marginTop) + px(c.marginBottom);
|
|
9022
|
+
};
|
|
9023
|
+
// How many columns an item takes: span-2, span-3, grid-column: span N, or 1 / -1 (all)
|
|
9024
|
+
const msSpan = (it, n) => {
|
|
9025
|
+
const c = getComputedStyle(it), m = /span\s+(\d+)/.exec(`${c.gridColumnStart} ${c.gridColumnEnd}`);
|
|
9026
|
+
if (m) return Math.min(n, +m[1]);
|
|
9027
|
+
return c.gridColumnEnd === '-1' ? n : 1;
|
|
9028
|
+
};
|
|
9029
|
+
// Items are placed with exact positions: each goes to the column that is shortest so far (reading
|
|
9030
|
+
// order stays roughly left to right, as in CSS masonry). Wide items sit where their columns are
|
|
9031
|
+
// lowest; with .masonry-dense later items fill the holes this leaves. Columns and gaps come from
|
|
9032
|
+
// the grid's own CSS (grid-cols-*, gap-*), so it reads like any grid.
|
|
8995
9033
|
function msLayout(st) {
|
|
8996
9034
|
const { el } = st;
|
|
8997
9035
|
if (MS_NATIVE) return;
|
|
8998
|
-
el.classList.remove('is-ready'); // read the real row gap first
|
|
8999
|
-
const gap = parseFloat(getComputedStyle(el).rowGap) || 0;
|
|
9000
9036
|
el.classList.add('is-ready');
|
|
9001
|
-
el
|
|
9002
|
-
[
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
|
|
9037
|
+
const cs = getComputedStyle(el);
|
|
9038
|
+
const tracks = (cs.gridTemplateColumns.match(/[\d.]+px/g) || []).map(parseFloat);
|
|
9039
|
+
const n = Math.max(1, tracks.length), colGap = parseFloat(cs.columnGap) || 0, rowGap = parseFloat(cs.rowGap) || 0;
|
|
9040
|
+
if (!tracks.length) tracks.push(el.clientWidth);
|
|
9041
|
+
const xs = tracks.map((_, i) => tracks.slice(0, i).reduce((a, b) => a + b, 0) + colGap * i);
|
|
9042
|
+
const dense = /dense/.test(cs.gridAutoFlow);
|
|
9043
|
+
const padStart = parseFloat(cs.paddingInlineStart) || 0, padTop = parseFloat(cs.paddingTop) || 0;
|
|
9044
|
+
const items = [...el.children].filter((it) => !it.hidden && getComputedStyle(it).display !== 'none');
|
|
9045
|
+
// 1) widths first, 2) then read every height (one layout pass), 3) then place
|
|
9046
|
+
const spans = items.map((it) => {
|
|
9047
|
+
const k = msSpan(it, n);
|
|
9048
|
+
it.style.width = `${tracks.slice(0, k).reduce((a, b) => a + b, 0) + colGap * (k - 1)}px`;
|
|
9049
|
+
return k;
|
|
9007
9050
|
});
|
|
9051
|
+
const heights = items.map(msHeight);
|
|
9052
|
+
const cols = Array(n).fill(0), holes = []; // holes (dense): { c, top, limit } in one column
|
|
9053
|
+
items.forEach((it, i) => {
|
|
9054
|
+
const k = spans[i], h = heights[i];
|
|
9055
|
+
let c = -1, y = 0;
|
|
9056
|
+
if (dense && k === 1) {
|
|
9057
|
+
const hole = holes.filter((o) => o.top + h <= o.limit + .5).sort((a, b) => a.top - b.top || a.c - b.c)[0];
|
|
9058
|
+
if (hole) { c = hole.c; y = hole.top; hole.top += h + rowGap; if (hole.top >= hole.limit) holes.splice(holes.indexOf(hole), 1); }
|
|
9059
|
+
}
|
|
9060
|
+
if (c < 0) {
|
|
9061
|
+
let best = Infinity;
|
|
9062
|
+
for (let j = 0; j + k <= n; j++) { const top = Math.max(...cols.slice(j, j + k)); if (top < best - .5) { best = top; c = j; } }
|
|
9063
|
+
y = best;
|
|
9064
|
+
for (let j = c; j < c + k; j++) { if (dense && cols[j] < y - .5) holes.push({ c: j, top: cols[j], limit: y - rowGap }); cols[j] = y + h + rowGap; }
|
|
9065
|
+
}
|
|
9066
|
+
// (an item placed on grid lines, like 1 / -1, is measured from the content edge; others from the padding edge)
|
|
9067
|
+
it.style.insetInlineStart = `${xs[c] + (/^\d/.test(getComputedStyle(it).gridColumnStart) ? 0 : padStart)}px`;
|
|
9068
|
+
it.style.top = `${y + padTop}px`;
|
|
9069
|
+
});
|
|
9070
|
+
const content = items.length ? Math.max(...cols) - rowGap : 0;
|
|
9071
|
+
const extra = cs.boxSizing === 'border-box' ? (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.paddingBottom) || 0) + (parseFloat(cs.borderTopWidth) || 0) + (parseFloat(cs.borderBottomWidth) || 0) : 0;
|
|
9072
|
+
el.style.height = `${Math.max(0, content) + extra}px`;
|
|
9008
9073
|
}
|
|
9009
9074
|
function setupMasonry(el) {
|
|
9010
9075
|
if (msStates.has(el)) return msStates.get(el).api;
|
|
@@ -9015,8 +9080,8 @@
|
|
|
9015
9080
|
const watch = (it) => { st.ro.observe(it); it.querySelectorAll('img').forEach((img) => { if (!img.complete) img.addEventListener('load', again, { once: true }); }); };
|
|
9016
9081
|
st.ro.observe(el);
|
|
9017
9082
|
[...el.children].forEach(watch);
|
|
9018
|
-
// new items, and items shown or hidden (filters):
|
|
9019
|
-
new MutationObserver((muts) => { muts.forEach((m) => m.addedNodes.forEach((n) => { if (n.nodeType === 1 && n.parentElement === el) watch(n); }));
|
|
9083
|
+
// new items, items moved, and items shown or hidden (filters): place them now, before they're painted
|
|
9084
|
+
new MutationObserver((muts) => { muts.forEach((m) => m.addedNodes.forEach((n) => { if (n.nodeType === 1 && n.parentElement === el) watch(n); })); msLayout(st); })
|
|
9020
9085
|
.observe(el, { childList: true, attributes: true, subtree: true, attributeFilter: ['hidden'] });
|
|
9021
9086
|
st.api = { el, layout: () => msLayout(st) };
|
|
9022
9087
|
msStates.set(el, st);
|
|
@@ -9496,13 +9561,37 @@
|
|
|
9496
9561
|
get index() { return lb.i; },
|
|
9497
9562
|
});
|
|
9498
9563
|
|
|
9564
|
+
/* ---- Entering items ------------------------------------------------------------------------
|
|
9565
|
+
data-moey-enter on a list or grid: children added later (infinite scroll, "load more", a new
|
|
9566
|
+
post) get .is-entering and --mo-enter-index for one entrance animation (CSS: gallery.css).
|
|
9567
|
+
Items that only move (sorting, dragging) don't animate. */
|
|
9568
|
+
const enterSeen = new WeakSet();
|
|
9569
|
+
function setupEnter(box) {
|
|
9570
|
+
if (enterSeen.has(box)) return;
|
|
9571
|
+
enterSeen.add(box);
|
|
9572
|
+
new MutationObserver((muts) => {
|
|
9573
|
+
const moved = new Set(muts.flatMap((m) => [...m.removedNodes]));
|
|
9574
|
+
let i = 0;
|
|
9575
|
+
muts.forEach((m) => m.addedNodes.forEach((n) => {
|
|
9576
|
+
if (n.nodeType !== 1 || n.parentElement !== box || moved.has(n) || n.matches('.filter-empty, .infinite-status, template, script')) return;
|
|
9577
|
+
n.style.setProperty('--mo-enter-index', i++);
|
|
9578
|
+
n.classList.add('is-entering');
|
|
9579
|
+
let t = 0;
|
|
9580
|
+
const done = (e) => { if (e && e.target !== n) return; clearTimeout(t); n.removeEventListener('animationend', done); n.classList.remove('is-entering'); n.style.removeProperty('--mo-enter-index'); };
|
|
9581
|
+
n.addEventListener('animationend', done);
|
|
9582
|
+
t = setTimeout(done, 2000); // no animation (reduced motion, your own CSS): tidy up anyway
|
|
9583
|
+
}));
|
|
9584
|
+
}).observe(box, { childList: true });
|
|
9585
|
+
}
|
|
9586
|
+
|
|
9499
9587
|
const initGallery = () => {
|
|
9500
9588
|
const scan = (root) => {
|
|
9501
9589
|
root.querySelectorAll?.('[data-moey-masonry]').forEach(setupMasonry);
|
|
9502
9590
|
root.querySelectorAll?.('[data-moey-infinite]').forEach(setupInfinite);
|
|
9591
|
+
root.querySelectorAll?.('[data-moey-enter]').forEach(setupEnter);
|
|
9503
9592
|
};
|
|
9504
9593
|
scan(doc);
|
|
9505
|
-
new MutationObserver((muts) => { for (const m of muts) for (const n of m.addedNodes) if (n.nodeType === 1) { if (n.matches('[data-moey-masonry]')) setupMasonry(n); if (n.matches('[data-moey-infinite]')) setupInfinite(n); scan(n); } })
|
|
9594
|
+
new MutationObserver((muts) => { for (const m of muts) for (const n of m.addedNodes) if (n.nodeType === 1) { if (n.matches('[data-moey-masonry]')) setupMasonry(n); if (n.matches('[data-moey-infinite]')) setupInfinite(n); if (n.matches('[data-moey-enter]')) setupEnter(n); scan(n); } })
|
|
9506
9595
|
.observe(doc.body, { childList: true, subtree: true });
|
|
9507
9596
|
};
|
|
9508
9597
|
|
|
@@ -9669,5 +9758,5 @@
|
|
|
9669
9758
|
if (doc.readyState === 'loading') doc.addEventListener('DOMContentLoaded', initLate); else initLate();
|
|
9670
9759
|
|
|
9671
9760
|
// Public API
|
|
9672
|
-
window.Moey = Object.freeze({ version: '0.
|
|
9761
|
+
window.Moey = Object.freeze({ version: '0.2.0', dismiss, open, close, openMenu, closeMenu, tooltip: showTip, toast, tab: (t) => selectTab(t, { focus: false }), paginate, popover, sortTable, palette, collapse, toggle, tags, chips, dropzone, tree, notify, datatable, select, spy, carousel, datepicker, combobox, countdown, confirm: askConfirm, alert: askAlert, prompt: askPrompt, strength, clean, chart, kanban, split, calendar, swipe, refresh, sortable, timepicker, chat, shortcuts, tour, marquee, masonry, filter, infinite, lightbox, player });
|
|
9673
9762
|
})();
|