@c2n/overlay 0.0.6
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/LICENSE +21 -0
- package/README.md +26 -0
- package/dist/overlay.js +1287 -0
- package/package.json +60 -0
- package/types/src/overlay.d.ts +62 -0
- package/types/src/overlay.d.ts.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Nguyen Thai Vinh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @c2n/overlay
|
|
2
|
+
|
|
3
|
+
Anchored popup built on the browser Popover API and positioned with floating-ui, built with Lit.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @c2n/overlay
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<script type="module">
|
|
11
|
+
import '@c2n/overlay'
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<button popovertarget="menu">Open</button>
|
|
15
|
+
<c2-overlay id="menu" placement="bottom-start">
|
|
16
|
+
<div class="menu">…your surface…</div>
|
|
17
|
+
</c2-overlay>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
- **Native behaviour**: the overlay is a `popover="auto"` element in the top layer: Escape and clicking outside close it, `toggle` / `beforetoggle` fire, and the `open` attribute mirrors the state (set it to open or close programmatically). Use `popover="manual"` to opt out of light dismiss.
|
|
21
|
+
- **Anchor**: the `anchor` property (an element) or attribute (an id), or the element whose `popovertarget` is the overlay's `id`.
|
|
22
|
+
- **Placement**: any floating-ui placement (`bottom-start`, `top`, `right-end`, …). It flips and shifts to stay on screen; the placement in use is reflected as `current-placement`, and `--c2-overlay--available-height` / `--available-width` tell the content how much room there is on that side.
|
|
23
|
+
- **Sizing**: at least as wide as the anchor by default; `fit-anchor` matches the width exactly, `free-width` sizes by content.
|
|
24
|
+
- **Spacing and motion**: `--c2-overlay--offset-y`, `--offset-x`, `--viewport-padding` and `--transition-duration`; `__backdrop--background` tints the page behind it.
|
|
25
|
+
|
|
26
|
+
The overlay is a positioning shell: the slotted content owns its own background, border and shadow.
|