@visitwonders/assembly 0.10.0 → 0.10.1
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/README.md +83 -0
- package/dist/layout/panel.css +10 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,89 @@
|
|
|
13
13
|
ember install @visitwonders/assembly
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
## Setup
|
|
17
|
+
|
|
18
|
+
Overlay components (`Popover`, `Tooltip`, `Modal`, `Drawer`, `Blanket`,
|
|
19
|
+
`Toast`) render through `ember-primitives`' `<Portal>`. The consuming
|
|
20
|
+
app must mount `<PortalTargets />` once — typically in the application
|
|
21
|
+
template — so that Assembly overlays can find their portal
|
|
22
|
+
destinations:
|
|
23
|
+
|
|
24
|
+
```gts
|
|
25
|
+
import { PortalTargets } from '@visitwonders/assembly/overlay';
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
{{outlet}}
|
|
29
|
+
<PortalTargets />
|
|
30
|
+
</template>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`<PortalTargets />` renders three empty `<div>` elements as portal
|
|
34
|
+
destinations. Its position in the template is layout-neutral —
|
|
35
|
+
overlays use fixed/absolute positioning and don't affect document
|
|
36
|
+
flow.
|
|
37
|
+
|
|
38
|
+
Without this, the first overlay you open will throw an assertion:
|
|
39
|
+
`Could not find element by the given name: ember-primitives__portal-targets__popover`.
|
|
40
|
+
|
|
41
|
+
### Integration tests
|
|
42
|
+
|
|
43
|
+
`setupRenderingTest` does not render the application template, so
|
|
44
|
+
rendering tests that exercise any component containing an overlay
|
|
45
|
+
(directly or transitively — e.g. `SelectField`, `DatePickerField`,
|
|
46
|
+
`MultiSelect`, anything that uses a dropdown or a tooltip-on-label)
|
|
47
|
+
need portal destinations inside `#ember-testing`. The cleanest
|
|
48
|
+
pattern is to inject them in your shared `setupRenderingTest`
|
|
49
|
+
wrapper so every rendering test gets them automatically — no
|
|
50
|
+
per-test boilerplate, no wrapper around `render`:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
// tests/helpers/index.ts
|
|
54
|
+
import { setupRenderingTest as upstreamSetupRenderingTest } from 'ember-qunit';
|
|
55
|
+
import type { SetupTestOptions } from 'ember-qunit';
|
|
56
|
+
|
|
57
|
+
const PORTAL_TARGET_NAMES = [
|
|
58
|
+
'ember-primitives__portal-targets__popover',
|
|
59
|
+
'ember-primitives__portal-targets__tooltip',
|
|
60
|
+
'ember-primitives__portal-targets__modal',
|
|
61
|
+
] as const;
|
|
62
|
+
|
|
63
|
+
export function setupRenderingTest(
|
|
64
|
+
hooks: NestedHooks,
|
|
65
|
+
options?: SetupTestOptions,
|
|
66
|
+
) {
|
|
67
|
+
upstreamSetupRenderingTest(hooks, options);
|
|
68
|
+
|
|
69
|
+
hooks.beforeEach(function () {
|
|
70
|
+
const root = document.getElementById('ember-testing');
|
|
71
|
+
if (!root) return;
|
|
72
|
+
for (const name of PORTAL_TARGET_NAMES) {
|
|
73
|
+
const target = document.createElement('div');
|
|
74
|
+
target.setAttribute('data-portal-name', name);
|
|
75
|
+
target.setAttribute('data-test-portal-target', '');
|
|
76
|
+
root.appendChild(target);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
hooks.afterEach(function () {
|
|
81
|
+
const root = document.getElementById('ember-testing');
|
|
82
|
+
if (!root) return;
|
|
83
|
+
for (const target of root.querySelectorAll('[data-test-portal-target]')) {
|
|
84
|
+
target.remove();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
This works because `@ember/test-helpers`' `setupRenderingContext`
|
|
91
|
+
appends (rather than replaces) the Ember outlet view inside
|
|
92
|
+
`#ember-testing`, so sibling elements injected here survive every
|
|
93
|
+
`render()` call and are still reachable by `Portal`'s
|
|
94
|
+
`findNearestTarget` walk. Tests can keep importing `render` from
|
|
95
|
+
`@ember/test-helpers` unchanged. Application tests
|
|
96
|
+
(`setupApplicationTest`) are unaffected — they pick up
|
|
97
|
+
`<PortalTargets />` from the application template automatically.
|
|
98
|
+
|
|
16
99
|
## Usage
|
|
17
100
|
|
|
18
101
|
[Longer description of how to use the addon in apps.]
|
package/dist/layout/panel.css
CHANGED
|
@@ -227,3 +227,13 @@
|
|
|
227
227
|
.panel_efcbf2ade[data-variant="filled"][data-tone="neutral"] > .panel-footer_efcbf2ade {
|
|
228
228
|
border-top-color: rgba(0, 0, 0, 0.1);
|
|
229
229
|
}
|
|
230
|
+
|
|
231
|
+
/* Strip separators at the structural edge — a header-only or
|
|
232
|
+
footer-only Panel has nothing to separate. */
|
|
233
|
+
.panel_efcbf2ade > .panel-header_efcbf2ade:last-child {
|
|
234
|
+
border-bottom: none;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.panel_efcbf2ade > .panel-footer_efcbf2ade:first-child {
|
|
238
|
+
border-top: none;
|
|
239
|
+
}
|