Skip to content

feat(underlay)!: diy migration #2096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/dialog/stories/dialog.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default {
},
parameters: {
actions: {
handles: [],
handles: ["click .spectrum-Dialog button"],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

},
status: {
type: process.env.MIGRATED_PACKAGES.includes("dialog")
Expand Down
36 changes: 31 additions & 5 deletions components/dialog/stories/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { html } from "lit";
import { classMap } from "lit/directives/class-map.js";
import { ifDefined } from "lit/directives/if-defined.js";
import { when } from "lit/directives/when.js";
import { useArgs } from "@storybook/client-api";

import { Template as Underlay } from '@spectrum-css/underlay/stories/template.js';
import { Template as Modal } from "@spectrum-css/modal/stories/template.js";
import { Template as Divider } from "@spectrum-css/divider/stories/template.js";
import { Template as CloseButton } from "@spectrum-css/closebutton/stories/template.js";
import { Template as Button } from '@spectrum-css/button/stories/template.js';

import "../index.css";
import "../skin.css";
Expand All @@ -18,10 +21,13 @@ export const Template = ({
heading,
content = [],
customClasses = [],
onclick,
id,
...globals
}) => {
const { scale } = globals;
const [_, updateArgs] = useArgs();

const Dialog = html`
<div
class=${classMap({
Expand Down Expand Up @@ -49,18 +55,38 @@ export const Template = ({
CloseButton({
customClasses: [`${rootClass}-closeButton`],
...globals,
onclick: () => {
updateArgs({ isOpen: !isOpen });
},
})
)}
</div>
</div>
`;

if (showModal) {
return Modal({
...globals,
isOpen,
content: Dialog,
});
return html`
${Underlay({
...globals,
isOpen,
})}
${Button({
...globals,
size: "m",
variant: "secondary",
label: "Click to open Dialog",
treatment: "outline",
customClasses: ['spectrum-CSSExample-overlayShowButton'],
onclick: () => {
updateArgs({ isOpen: !isOpen });
},
})}
${Modal({
...globals,
isOpen,
content: Dialog,
})}
`
} else {
return Dialog;
}
Expand Down
2 changes: 1 addition & 1 deletion components/underlay/gulpfile.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require("@spectrum-css/component-builder");
module.exports = require("@spectrum-css/component-builder-simple");
35 changes: 24 additions & 11 deletions components/underlay/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,47 @@ governing permissions and limitations under the License.
@import '../overlay/index.css';

.spectrum-Underlay {
/* Bug: this must be 0ms, not 0 */
--spectrum-dialog-confirm-background-entry-animation-delay: 0ms;
--spectrum-dialog-confirm-background-exit-animation-ease: cubic-bezier(0.5, 0, 1, 1); /* wrong in DNA */
--spectrum-dialog-confirm-background-entry-animation-ease: cubic-bezier(0, 0, 0.40, 1); /* wrong in DNA */
--spectrum-underlay-background-entry-animation-delay: var(--spectrum-animation-duration-0);
--spectrum-underlay-background-exit-animation-ease: var(--spectrum-animation-ease-in);
--spectrum-underlay-background-entry-animation-ease: var(--spectrum-animation-ease-out);
--spectrum-underlay-background-exit-animation-duration: var(--spectrum-animation-duration-100);
--spectrum-underlay-background-entry-animation-duration: var(--spectrum-animation-duration-600);
--spectrum-underlay-background-exit-animation-duration: var(--spectrum-animation-duration-300);
--spectrum-underlay-background-exit-animation-delay: var(--spectrum-animation-duration-200);

/* TODO update to --spectrum-overlay-color token once an RGB stripped value is available */
--spectrum-underlay-background-color: rgba(var(--spectrum-black-rgb), var(--spectrum-overlay-opacity));;
}

.spectrum-Underlay {
@inherit: %spectrum-overlay;

position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
inset-block: 0;
inset-inline: 0;

background-color: var(--mod-underlay-background-color, var(--spectrum-underlay-background-color));

/* Float above things by default */
z-index: 1;

overflow: hidden;

/* Exit animations */
transition: opacity var(--spectrum-dialog-confirm-background-exit-animation-duration) var(--spectrum-dialog-confirm-background-exit-animation-ease) var(--spectrum-dialog-confirm-background-exit-animation-delay),
visibility 0ms linear calc(var(--spectrum-dialog-confirm-background-exit-animation-delay) + var(--spectrum-dialog-confirm-background-exit-animation-duration));
transition: opacity var(--mod-underlay-background-exit-animation-duration, var(--spectrum-underlay-background-exit-animation-duration))
var(--mod-underlay-background-exit-animation-ease, var(--spectrum-underlay-background-exit-animation-ease))
var(--mod-underlay-background-exit-animation-delay, var(--spectrum-underlay-background-exit-animation-delay)),
visibility 0ms
linear calc(
var(--mod-underlay-background-exit-animation-delay, var(--spectrum-underlay-background-exit-animation-delay)) +
var(--mod-underlay-background-exit-animation-duration, var(--spectrum-underlay-background-exit-animation-duration)));
}

.spectrum-Underlay.is-open {
@inherit: %spectrum-overlay--open;

/* Entry animations */
transition: opacity var(--spectrum-dialog-confirm-background-entry-animation-duration) var(--spectrum-dialog-confirm-background-entry-animation-ease) var(--spectrum-dialog-confirm-background-entry-animation-delay);
transition: opacity var(--mod-underlay-background-entry-animation-duration, var(--spectrum-underlay-background-entry-animation-duration))
var(--mod-underlay-background-entry-animation-ease, var(--spectrum-underlay-background-entry-animation-ease))
var(--mod-underlay-background-entry-animation-delay, var(--spectrum-underlay-background-entry-animation-delay));
}
9 changes: 9 additions & 0 deletions components/underlay/metadata/mods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
| Modifiable Custom Properties |
| ---------------------------------------------------- |
| `--mod-underlay-background-color` |
| `--mod-underlay-background-entry-animation-delay` |
| `--mod-underlay-background-entry-animation-duration` |
| `--mod-underlay-background-entry-animation-ease` |
| `--mod-underlay-background-exit-animation-delay` |
| `--mod-underlay-background-exit-animation-duration` |
| `--mod-underlay-background-exit-animation-ease` |
8 changes: 4 additions & 4 deletions components/underlay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spectrum-css/underlay",
"version": "2.1.0",
"version": "3.0.0-beta.0",
"description": "The Spectrum CSS underlay component",
"license": "Apache-2.0",
"author": "Adobe",
Expand All @@ -18,11 +18,11 @@
"build": "gulp"
},
"peerDependencies": {
"@spectrum-css/vars": ">=9"
"@spectrum-css/tokens": ">=11"
},
"devDependencies": {
"@spectrum-css/component-builder": "^4.0.14",
"@spectrum-css/vars": "^9.0.8",
"@spectrum-css/component-builder-simple": "^2.0.16",
"@spectrum-css/tokens": "^11.2.0",
"gulp": "^4.0.0"
},
"publishConfig": {
Expand Down
1 change: 0 additions & 1 deletion components/underlay/stories/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { classMap } from 'lit-html/directives/class-map.js';
import { styleMap } from 'lit-html/directives/style-map.js';

import "../index.css";
import "../skin.css";

export const Template = ({
rootClass = "spectrum-Underlay",
Expand Down
1 change: 1 addition & 0 deletions components/underlay/stories/underlay.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default {

export const Default = Template.bind({});
Default.args = {
isOpen: true,
content: [
"This is a underlay. Don't use it like this. Use it with a Modal and a Dialog.",
],
Expand Down
12 changes: 12 additions & 0 deletions components/underlay/themes/express.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*!
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

@container (--system: express) {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ Copyright 2023 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

.spectrum-Underlay {
/* TODO update to --spectrum-overlay-color token once an RGB stripped value is available */
background: rgba(var(--spectrum-black-rgb), var(--spectrum-overlay-opacity));
}
@container (--system: spectrum) {}