Skip to content

Commit 8428cad

Browse files
authored
fix(toast): switches toast[open] to use visibility hidden to fix overlay handling (#3511)
* fix(toast): switches toast[open] to use visibility hidden to fix overlay handling (#3510) * fix(toast): switches overlaid story to click rather than hover * fix(toast): update vrt cache key
1 parent ed44c2b commit 8428cad

File tree

3 files changed

+95
-3
lines changed

3 files changed

+95
-3
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ executors:
1010
parameters:
1111
current_golden_images_hash:
1212
type: string
13-
default: d159cee8aebe6bc8c08c163aecc068ec8df3ccf0
13+
default: 592bdbdf7b59f9b27fade2d47a56e1f63dba3f6f
1414
wireit_cache_name:
1515
type: string
1616
default: wireit

packages/toast/src/toast.css

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@ governing permissions and limitations under the License.
1212

1313
@import './spectrum-toast.css';
1414

15-
:host(:not([open])) {
16-
display: none;
15+
:host {
16+
--spectrum-overlay-animation-distance: 6px;
17+
--spectrum-overlay-animation-duration: var(
18+
--spectrum-animation-duration-100
19+
);
20+
21+
opacity: 0;
22+
pointer-events: none;
23+
transition: transform var(--spectrum-overlay-animation-duration) ease-in-out,
24+
opacity var(--spectrum-overlay-animation-duration) ease-in-out,
25+
visibility 0s linear var(--spectrum-overlay-animation-duration);
26+
visibility: hidden;
27+
}
28+
29+
:host([open]) {
30+
opacity: 1;
31+
pointer-events: auto;
32+
transition-delay: 0s;
33+
visibility: visible;
1734
}

packages/toast/stories/toast.stories.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import { html, TemplateResult } from '@spectrum-web-components/base';
1414
import '@spectrum-web-components/toast/sp-toast.js';
1515
import '@spectrum-web-components/button/sp-button.js';
1616

17+
import { Placement } from '@spectrum-web-components/overlay';
18+
import '@spectrum-web-components/overlay/overlay-trigger.js';
19+
import { ifDefined } from '@spectrum-web-components/base/src/directives.js';
20+
1721
const toast = ({
1822
variant = '',
1923
open = true,
@@ -104,3 +108,74 @@ export const Negative = (args: Properties): TemplateResult =>
104108

105109
export const Info = (args: Properties): TemplateResult =>
106110
variantDemo({ ...args, variant: 'info' });
111+
112+
const overlayStyles = html`
113+
<style>
114+
html,
115+
body,
116+
#root,
117+
#root-inner,
118+
sp-story-decorator {
119+
height: 100%;
120+
margin: 0;
121+
}
122+
123+
sp-story-decorator > div {
124+
display: contents;
125+
}
126+
127+
sp-story-decorator::part(container) {
128+
display: flex;
129+
flex-direction: column;
130+
width: 100%;
131+
height: 100%;
132+
align-items: center;
133+
justify-content: center;
134+
}
135+
136+
overlay-trigger {
137+
flex: none;
138+
margin: 24px 0;
139+
}
140+
141+
.self-managed:nth-child(3) {
142+
margin-left: 50px;
143+
}
144+
</style>
145+
`;
146+
147+
const overlaid = (openPlacement: Placement): TemplateResult => {
148+
return html`
149+
${overlayStyles}
150+
${(
151+
[
152+
['bottom', ''],
153+
['left', 'negative'],
154+
['right', 'positive'],
155+
['top', 'info'],
156+
] as [Placement, string][]
157+
).map(([placement, variant]) => {
158+
return html`
159+
<overlay-trigger
160+
placement=${placement}
161+
open=${ifDefined(
162+
openPlacement === placement ? 'click' : undefined
163+
)}
164+
>
165+
<sp-button label="${placement} test" slot="trigger">
166+
Click for ${variant ? variant : 'toast'} on the
167+
${placement}
168+
</sp-button>
169+
<sp-toast slot="click-content" variant=${variant}>
170+
${placement}
171+
</sp-toast>
172+
</overlay-trigger>
173+
`;
174+
})}
175+
`;
176+
};
177+
178+
export const overlaidTop = (): TemplateResult => overlaid('top');
179+
export const overlaidRight = (): TemplateResult => overlaid('right');
180+
export const overlaidBottom = (): TemplateResult => overlaid('bottom');
181+
export const overlaidLeft = (): TemplateResult => overlaid('left');

0 commit comments

Comments
 (0)