library
Prebuilt pebble components: drop-in custom elements, no compiler needed
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runAucun
0Étoiles
0Forks
2Issues
| 1 | /* More: the "load more" link of <pebble-more>, as a full-width button under |
| 2 | the feed, and the spinner that stands in for it while the next page loads. |
| 3 | |
| 4 | One sheet, two uses: the element adopts it as is (define's scoped: false), |
| 5 | and dist/more.css is the same rules raw, for the page to <link> so the link |
| 6 | looks right without JS. So every selector starts at the tag: |
| 7 | that is its scope (inside @scope (tag) the tag itself would not match). |
| 8 | |
| 9 | State is attributes: [data-loading] (the link is hidden, the spinner |
| 10 | shows), [data-error] (the last load failed; the link is back), [data-done] |
| 11 | (the end of the feed: nothing visible is left) on the host. The live |
| 12 | region (part "status") is visually hidden. |
| 13 | |
| 14 | Theming: every value is a --pebble-more-* custom property with a fallback, |
| 15 | light and dark defaults chosen by prefers-color-scheme; page tokens |
| 16 | (--accent) inherit in. */ |
| 17 | |
| 18 | pebble-more { |
| 19 | --_ink: var(--pebble-more-ink, #1a1a1a); |
| 20 | --_surface: var(--pebble-more-surface, #ffffff); |
| 21 | --_border: var(--pebble-more-border, #d0d0d0); |
| 22 | --_error: var(--pebble-more-error, #c92a2a); |
| 23 | --_focus: var(--pebble-more-focus, var(--accent, #1971c2)); |
| 24 | |
| 25 | display: flex; |
| 26 | justify-content: center; |
| 27 | padding-block: var(--pebble-more-padding, 1rem); |
| 28 | } |
| 29 | |
| 30 | @media (prefers-color-scheme: dark) { |
| 31 | pebble-more { |
| 32 | --_ink: var(--pebble-more-ink, #f1f3f5); |
| 33 | --_surface: var(--pebble-more-surface, #1f1f1f); |
| 34 | --_border: var(--pebble-more-border, #495057); |
| 35 | --_error: var(--pebble-more-error, #ff8787); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | pebble-more a[data-more] { |
| 40 | display: inline-flex; |
| 41 | align-items: center; |
| 42 | justify-content: center; |
| 43 | box-sizing: border-box; |
| 44 | width: 100%; |
| 45 | max-width: var(--pebble-more-max-width, 24rem); |
| 46 | min-height: var(--pebble-more-size, 44px); |
| 47 | padding: 0.5rem 1rem; |
| 48 | border: 1px solid var(--_border); |
| 49 | border-radius: var(--pebble-more-radius, 999px); |
| 50 | background: var(--_surface); |
| 51 | color: var(--_ink); |
| 52 | font-weight: 600; |
| 53 | text-decoration: none; |
| 54 | |
| 55 | &:focus-visible { |
| 56 | outline: 3px solid var(--_focus); |
| 57 | outline-offset: 2px; |
| 58 | } |
| 59 | |
| 60 | &[hidden] { |
| 61 | display: none; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | pebble-more[data-error] a[data-more] { |
| 66 | border-color: var(--_error); |
| 67 | } |
| 68 | |
| 69 | pebble-more[data-loading]::after { |
| 70 | content: ""; |
| 71 | box-sizing: border-box; |
| 72 | width: var(--pebble-more-spinner-size, 1.75rem); |
| 73 | height: var(--pebble-more-spinner-size, 1.75rem); |
| 74 | margin-block: calc((var(--pebble-more-size, 44px) - var(--pebble-more-spinner-size, 1.75rem)) / 2); |
| 75 | border: 3px solid var(--_border); |
| 76 | border-top-color: var(--_focus); |
| 77 | border-radius: 50%; |
| 78 | animation: pebble-more-spin 800ms linear infinite; |
| 79 | } |
| 80 | |
| 81 | pebble-more[data-done] { |
| 82 | padding: 0; |
| 83 | } |
| 84 | |
| 85 | pebble-more .status { |
| 86 | position: absolute; |
| 87 | width: 1px; |
| 88 | height: 1px; |
| 89 | margin: -1px; |
| 90 | padding: 0; |
| 91 | overflow: hidden; |
| 92 | clip-path: inset(50%); |
| 93 | white-space: nowrap; |
| 94 | border: 0; |
| 95 | } |
| 96 | |
| 97 | @media (prefers-reduced-motion: reduce) { |
| 98 | pebble-more[data-loading]::after { |
| 99 | animation: none; |
| 100 | border-color: var(--_focus); |
| 101 | opacity: 0.6; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | /* Named for the component: if an engine hoists keyframes out of @scope, the |
| 106 | name still cannot collide with a page's. */ |
| 107 | @keyframes pebble-more-spin { |
| 108 | to { |
| 109 | transform: rotate(1turn); |
| 110 | } |
| 111 | } |