Skip to content

feat(backgroundlayers): class based implementation #2274

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

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
54849b2
feat!: spectrum 2
pfulton Dec 8, 2023
5ec70af
feat(tokens): use 13.0.0-beta.5
pfulton Dec 11, 2023
bff70aa
fix(stepper): no longer touches InfieldButton classes (#2300)
Dec 11, 2023
5e15717
feat(backgroundlayers): add as component
jenndiaz Nov 7, 2023
2e4abb0
feat(backroundlayers): display each layer
jenndiaz Nov 8, 2023
e061144
feat(backgroundlayers): adds dark values
jenndiaz Nov 8, 2023
7f14e4c
feat(backgroundlayers): add to storybook
jenndiaz Nov 8, 2023
55ac83f
refactor(backgroundlayers): cleans up storybook
jenndiaz Nov 8, 2023
59f4acb
chore(backgroundlayer): hard code token values
jenndiaz Nov 8, 2023
5fd9d8b
refactor(backgroundlayers): use just 1 class
jenndiaz Nov 8, 2023
e317086
feat(backgroundlayers): demo in alert dialog
jenndiaz Nov 8, 2023
7802815
docs(backgroundlayers): style changes
jenndiaz Nov 9, 2023
2540c09
chore(backgroundlayers): remove mods file
jenndiaz Nov 9, 2023
ac1f53f
fix(backgroundlayers): correct typos
jenndiaz Nov 9, 2023
416e5ec
docs(backgroundlayers): add to readme
jenndiaz Nov 9, 2023
68692ee
fix(backgroundlayers): add border to layer 2
jenndiaz Nov 16, 2023
be53447
chore(backgroundlayers): update to beta release tokens
jenndiaz Nov 16, 2023
cdfbd89
fix(backgroundlayers): extra comma in package.json
jenndiaz Nov 16, 2023
94af888
chore(backgroundlayers): yarn install
jenndiaz Nov 16, 2023
5d49521
refactor(backgroundlayers): use box shadow
jenndiaz Dec 11, 2023
2b5aa5d
refactor(backgroundlayers): use context in class names
jenndiaz Dec 12, 2023
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,7 @@ Occasionally, you may want to run a prerelease for an individual package and ski
- You **must** run a build **before** continuing with the prerelease. An npm task for cleaning, building, and beta publishing is available, and it can be run via the following command: `yarn release:beta-from-package`. This command will perform a full `clean` (via the `clean` task), a full `build` (via the `build` task), and will attempt to publish the package (via `lerna publish --conventional-prerelease --preid beta --pre-dist-tag beta --no-private`).
- Depending on the severity of your change(s), and before publishing to npm, Lerna should show a preview of the affected package version number that looks something like: `@spectrum-css/switch: 1.0.23 => 2.0.0-beta.0`. Additionally, at this time, Lerna will ask if you would like to continue with publishing the changes or cancel.
- Selecting `y` to publish will publish the affected package(s) to npm.

## Spectrum 2

More information coming soon!
14 changes: 7 additions & 7 deletions components/alertdialog/metadata/alertdialog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ examples:
markup: |
<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--outline spectrum-Button--staticWhite spectrum-CSSExample-overlayShowButton" onclick="openDialog(this.nextElementSibling)"><span class="spectrum-Button-label">Open Alert Dialog</span></button>
<div class="spectrum-Modal-wrapper spectrum-CSSExample-dialog">
<div class="spectrum-Modal is-open" data-testid="modal">
<div class="spectrum-Modal is-open spectrum-BackgroundLayers--elevated" data-testid="modal">
<section class="spectrum-AlertDialog spectrum-AlertDialog--confirmation" role="dialog" tabindex="-1" aria-modal="true" aria-labelledby="dialog_label">
<div class="spectrum-AlertDialog-grid">
<h1 class="spectrum-AlertDialog-heading" id="dialog_label">Enable Smart Filters?</h1>
Expand All @@ -34,7 +34,7 @@ examples:
<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--outline spectrum-Button--staticWhite spectrum-CSSExample-overlayShowButton" onclick="openDialog(this.nextElementSibling)"><span class="spectrum-Button-label">Open Alert Dialog</span></button>

<div class="spectrum-Modal-wrapper spectrum-CSSExample-dialog">
<div class="spectrum-Modal is-open" data-testid="modal">
<div class="spectrum-Modal is-open spectrum-BackgroundLayers--elevated" data-testid="modal">
<section class="spectrum-AlertDialog spectrum-AlertDialog--information" role="dialog" tabindex="-1" aria-modal="true" aria-labelledby="dialog_label">
<div class="spectrum-AlertDialog-grid">
<h1 class="spectrum-AlertDialog-heading" id="dialog_label">Connect to wifi</h1>
Expand All @@ -60,7 +60,7 @@ examples:
<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--outline spectrum-Button--staticWhite spectrum-CSSExample-overlayShowButton" onclick="openDialog(this.nextElementSibling)"><span class="spectrum-Button-label">Open Alert Dialog</span></button>

<div class="spectrum-Modal-wrapper spectrum-CSSExample-dialog">
<div class="spectrum-Modal is-open" data-testid="modal">
<div class="spectrum-Modal is-open spectrum-BackgroundLayers--elevated" data-testid="modal">
<section class="spectrum-AlertDialog spectrum-AlertDialog--warning" role="dialog" tabindex="-1" aria-modal="true" aria-labelledby="dialog_label">
<div class="spectrum-AlertDialog-grid">
<div class="spectrum-AlertDialog-header">
Expand Down Expand Up @@ -92,7 +92,7 @@ examples:
<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--outline spectrum-Button--staticWhite spectrum-CSSExample-overlayShowButton" onclick="openDialog(this.nextElementSibling)"><span class="spectrum-Button-label">Open Alert Dialog</span></button>

<div class="spectrum-Modal-wrapper spectrum-CSSExample-dialog">
<div class="spectrum-Modal spectrum-AlertDialog-modal is-open" data-testid="modal">
<div class="spectrum-Modal spectrum-AlertDialog-modal is-open spectrum-BackgroundLayers--elevated" data-testid="modal">
<section class="spectrum-AlertDialog spectrum-AlertDialog--error" role="dialog" tabindex="-1" aria-modal="true" aria-labelledby="dialog_label">
<div class="spectrum-AlertDialog-grid">
<div class="spectrum-AlertDialog-header">
Expand Down Expand Up @@ -120,7 +120,7 @@ examples:
<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--outline spectrum-Button--staticWhite spectrum-CSSExample-overlayShowButton" onclick="openDialog(this.nextElementSibling)"><span class="spectrum-Button-label">Open Alert Dialog</span></button>

<div class="spectrum-Modal-wrapper spectrum-CSSExample-dialog">
<div class="spectrum-Modal is-open" data-testid="modal">
<div class="spectrum-Modal is-open spectrum-BackgroundLayers--elevated" data-testid="modal">
<section class="spectrum-AlertDialog spectrum-AlertDialog--destructive" role="dialog" tabindex="-1" aria-modal="true" aria-labelledby="dialog_label">
<div class="spectrum-AlertDialog-grid">
<div class="spectrum-AlertDialog-header">
Expand Down Expand Up @@ -149,7 +149,7 @@ examples:
<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--outline spectrum-Button--staticWhite spectrum-CSSExample-overlayShowButton" onclick="openDialog(this.nextElementSibling)"><span class="spectrum-Button-label">Open Alert Dialog</span></button>

<div class="spectrum-Modal-wrapper spectrum-CSSExample-dialog">
<div class="spectrum-Modal is-open" data-testid="modal">
<div class="spectrum-Modal is-open spectrum-BackgroundLayers--elevated" data-testid="modal">
<section class="spectrum-AlertDialog spectrum-AlertDialog--information" role="dialog" tabindex="-1" aria-modal="true" aria-labelledby="dialog_label">
<div class="spectrum-AlertDialog-grid">
<h1 class="spectrum-AlertDialog-heading" id="dialog_label">Rate this app</h1>
Expand Down Expand Up @@ -177,7 +177,7 @@ examples:
<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--outline spectrum-Button--staticWhite spectrum-CSSExample-overlayShowButton" onclick="openDialog(this.nextElementSibling)"><span class="spectrum-Button-label">Open Alert Dialog</span></button>

<div class="spectrum-Modal-wrapper spectrum-CSSExample-dialog">
<div class="spectrum-Modal is-open" data-testid="modal">
<div class="spectrum-Modal is-open spectrum-BackgroundLayers--elevated" data-testid="modal">
<section class="spectrum-AlertDialog spectrum-AlertDialog--information" role="dialog" tabindex="-1" aria-modal="true" aria-labelledby="dialog_label">
<div class="spectrum-AlertDialog-grid">
<h1 class="spectrum-AlertDialog-heading" id="dialog_label">Lorem Ipsum</h1>
Expand Down
2 changes: 2 additions & 0 deletions components/alertdialog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"clean": "rimraf dist"
},
"peerDependencies": {
"@spectrum-css/backgroundlayers": ">=1",
"@spectrum-css/button": ">=11",
"@spectrum-css/buttongroup": ">=6",
"@spectrum-css/divider": ">=1 <=2",
Expand All @@ -36,6 +37,7 @@
"@spectrum-css/modal": "^4.0.4",
"@spectrum-css/tokens": "^13.0.5",
"@spectrum-css/underlay": "^3.0.12",
"@spectrum-css/backgroundlayers": "^1.0.0-alpha.0",
"gulp": "^4.0.0"
},
"publishConfig": {
Expand Down
21 changes: 21 additions & 0 deletions components/backgroundlayers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# @spectrum-css/backgroundlayers
Copy link
Collaborator

Choose a reason for hiding this comment

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

We're sort of undecided about documentation moving forward (re: migration guidelines convo) but this might be a good place for now to document this class system once we get to a more final place with it... I also think we need documentation in Storybook and the docs site so maybe we can do some brainstorming about what that looks like. Docs site might be more straightforward than Storybook

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did add some documentation to the readme. I'd agree that there is opportunity to keep brain storming what we want documentation to look like.


> The Spectrum CSS background layers is a set of utility classes used to apply Spectrum 2 app framing. Consult design documentation for further usage and infomation.

To use these classes add the approproate layers and contexts class to the element that the background styling should be applied. Make note of the context when determing the correct class to use.

Editing Context Classes:
- `spectrum-BackgroundLayers--elevated`
- `spectrum-BackgroundLayers--layer2`
- `spectrum-BackgroundLayers--layer1`
- `spectrum-BackgroundLayers--pasteboard`

Browsing Context Classes:
- `spectrum-BackgroundLayers--elevated`
- `spectrum-BackgroundLayers--layer1`
- `spectrum-BackgroundLayers--base`


This package is part of the [Spectrum CSS project](https://github.com/adobe/spectrum-css).

See the [Spectrum CSS documentation](https://opensource.adobe.com/spectrum-css/backgroundlayers).
1 change: 1 addition & 0 deletions components/backgroundlayers/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@spectrum-css/component-builder-simple');
86 changes: 86 additions & 0 deletions components/backgroundlayers/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*!
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.
Copy link
Contributor Author

@jenndiaz jenndiaz Nov 9, 2023

Choose a reason for hiding this comment

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

I'm intentionally using a bit of a different structure to the css here so that you can access these by just using one class spectrum-BackgroundLayers--elevated instead of spectrum-BackgroundLayers spectrum-BackgroundLayers--elevated

I am also doing a bit of hard coding, the border color, drop shadow, and dark colors, these would need to replaced with tokens.

*/

/* for use only in editing contexts */
.spectrum-BackgroundLayers-edit-elevated {
--spectrum-backgroundlayers-background-color: var(--spectrum-gray-25);
--spectrum-backgroundlayers-shadow-horizontal: 0;
--spectrum-backgroundlayers-shadow-vertical: 0;
--spectrum-backgroundlayers-shadow-blur: 5px;
--spectrum-backgroundlayers-shadow-color: var(--spectrum-gray-600);

.spectrum--dark & {
--spectrum-backgroundlayers-background-color: var(--spectrum-gray-75);
--spectrum-backgroundlayers-shadow-color: var(--spectrum-gray-100);
}
background-color: var(--spectrum-backgroundlayers-background-color);
box-shadow:
var(--spectrum-backgroundlayers-shadow-horizontal)
var(--spectrum-backgroundlayers-shadow-vertical)
var(--spectrum-backgroundlayers-shadow-blur)
var(--spectrum-backgroundlayers-shadow-color)
}

.spectrum-BackgroundLayers--layer2 {
--spectrum-backgroundlayers-background-color: var(--spectrum-gray-25);

.spectrum--dark & {
--spectrum-backgroundlayers-background-color: var(--spectrum-gray-75);
}
background-color: var(--spectrum-backgroundlayers-background-color);
border: 2px solid rgba(180, 180, 180, 25%);
}

.spectrum-BackgroundLayers-edit-layer1 {
--spectrum-backgroundlayers-background-color: var(--spectrum-gray-50);
background-color: var(--spectrum-backgroundlayers-background-color);
}

.spectrum-BackgroundLayers-edit-pasteboard {
--spectrum-backgroundlayers-background-color: var(--spectrum-gray-100);

.spectrum--dark & {
--spectrum-backgroundlayers-background-color: var(--spectrum-gray-25);
}
background-color: var(--spectrum-backgroundlayers-background-color);
}

/* only used in browsing contexts */
.spectrum-BackgroundLayers-browse-elevated {
--spectrum-backgroundlayers-background-color: var(--spectrum-gray-25);
--spectrum-backgroundlayers-shadow-horizontal: 0;
--spectrum-backgroundlayers-shadow-vertical: 0;
--spectrum-backgroundlayers-shadow-blur: 5px;
--spectrum-backgroundlayers-shadow-color: var(--spectrum-gray-600);

.spectrum--dark & {
--spectrum-backgroundlayers-background-color: var(--spectrum-gray-75);
--spectrum-backgroundlayers-shadow-color: var(--spectrum-gray-100);
}
background-color: var(--spectrum-backgroundlayers-background-color);
box-shadow:
var(--spectrum-backgroundlayers-shadow-horizontal)
var(--spectrum-backgroundlayers-shadow-vertical)
var(--spectrum-backgroundlayers-shadow-blur)
var(--spectrum-backgroundlayers-shadow-color)
}

.spectrum-BackgroundLayers-browse-layer1 {
--spectrum-backgroundlayers-background-color: var(--spectrum-gray-50);
background-color: var(--spectrum-backgroundlayers-background-color);
}

.spectrum-BackgroundLayers-browse-base {
--spectrum-backgroundlayers-background-color: var(--spectrum-gray-25);
border: 2px solid rgba(180, 180, 180, 25%);
background-color: var(--spectrum-backgroundlayers-background-color);
}
28 changes: 28 additions & 0 deletions components/backgroundlayers/metadata/backgroundlayers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Background layers
status: Verified
SpectrumSiteSlug: https://spectrum.adobe.com/page/background-layers/
examples:
- id: backgroundlayers-browsing
name: Browsing Contexts
markup: |
<div class="spectrum-Examples" style="justify-content: flex-start; position: relative; height: 150px;">
<div class="spectrum-BackgroundLayers--elevated" style="inline-size: 100px; block-size: 100px; border-radius: 10px; position: absolute; z-index: 4;">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

using inline styling here to keep these out of the classes

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep that seems like the right move 👍

</div>
<div class="spectrum-BackgroundLayers--layer2" style="inline-size: 100px; block-size: 100px; border-radius: 10px; position: absolute; left: 15px; top: 15px; z-index: 3;">
</div>
<div class="spectrum-BackgroundLayers--layer1" style="inline-size: 100px; block-size: 100px; border-radius: 10px; position: absolute; left: 30px; top: 30px; z-index: 2;">
</div>
<div class="spectrum-BackgroundLayers--pasteboard" style="inline-size: 100px; block-size: 100px; border-radius: 10px; position: absolute; left: 40px; top: 40px; z-index: 1;">
</div>
</div>
- id: backgroundlayers-editing
name: Editing Contexts
markup: |
<div class="spectrum-Examples" style="justify-content: flex-start; position: relative; height: 150px;">
<div class="spectrum-BackgroundLayers--elevated" style="inline-size: 100px; block-size: 100px; border-radius: 10px; position: absolute; z-index: 3;">
</div>
<div class="spectrum-BackgroundLayers--layer1" style="inline-size: 100px; block-size: 100px; border-radius: 10px; position: absolute; left: 15px; top: 15px; z-index: 2;">
</div>
<div class="spectrum-BackgroundLayers--base" style="inline-size: 100px; block-size: 100px; border-radius: 10px; position: absolute; left: 20px; top: 20px; z-index: 1;">
</div>
</div>
35 changes: 35 additions & 0 deletions components/backgroundlayers/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@spectrum-css/backgroundlayers",
"version": "1.0.0-alpha.0",
"description": "The Spectrum CSS backgroundlayers component",
"license": "Apache-2.0",
"author": "Adobe",
"homepage": "https://opensource.adobe.com/spectrum-css/",
"repository": {
"type": "git",
"url": "https://github.com/adobe/spectrum-css.git",
"directory": "components/backgroundlayers"
},
"bugs": {
"url": "https://github.com/adobe/spectrum-css/issues"
},
"main": "dist/index-vars.css",
"scripts": {
"build": "gulp",
"clean": "rimraf dist",
"test": "nx test:scope @spectrum-css/preview backgroundlayers"
},
"peerDependencies": {
"@spectrum-css/tokens": ">=12"
},
"devDependencies": {
"@spectrum-css/component-builder-simple": "^2.0.17",
"@spectrum-css/tokens": "^12.0.0",
"gulp": "^4.0.0",
"nx": "^17.0.3",
"rimraf": "^5.0.1"
},
"publishConfig": {
"access": "public"
}
}
69 changes: 69 additions & 0 deletions components/backgroundlayers/stories/backgroundlayers.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { Template } from "./template";
import { html } from 'lit';

export default {
title: "UtilityClasses/Background layers",
description: "The background layers is a series of classes used to style background layers.",
component: "BackgroundLayers",
argTypes: {},
args: {
rootClass: "spectrum-BackgroundLayers",
},
parameters: {
actions: {
handles: []
},
status: {
type: process.env.MIGRATED_PACKAGES.includes('backgroundlayers') ? 'migrated' : undefined
}
}
};

const EditingContext = ({
}) => {
return html`
<div style="display: flex; justify-content: flex-start; position: relative; block-size: 150px;">
${Template({
style: "z-index: 4; inset-inline-start: 10px; inset-block-start: 10px;",
layer: 'elevated',
})}
${Template({
style: "z-index: 3; inset-inline-start: 20px; inset-block-start: 20px;",
layer: 'layer2',
})}
${Template({
style: "z-index: 2; inset-inline-start: 30px; inset-block-start: 30px;",
layer: 'layer1',
})}
${Template({
style: "z-index: 1; inset-inline-start: 40px; inset-block-start: 40px;",
layer: "pasteboard",
})}
</div>
`;
};

const BrowsingContext = ({
}) => {
return html`
<div style="display: flex; justify-content: flex-start; position: relative; block-size: 150px;">
${Template({
style: "z-index: 3; inset-inline-start: 10px; inset-block-start: 10px;",
layer: 'elevated',
})}
${Template({
style: "z-index: 2; inset-inline-start: 20px; inset-block-start: 20px;",
layer: 'layer1',
})}
${Template({
style: "z-index: 1; inset-inline-start: 30px; inset-block-start: 30px;",
layer: "base",
})}
</div>
`;
};
export const Editing = EditingContext.bind({});
Editing.args = {};

export const Browsing = BrowsingContext.bind({});
Browsing.args = {};
22 changes: 22 additions & 0 deletions components/backgroundlayers/stories/template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { html } from 'lit';
import { classMap } from 'lit/directives/class-map.js';

import "../index.css";

export const Template = ({
rootClass = "spectrum-BackgroundLayers",
style,
layer,
id,
customClasses = [],
}) => {
return html`
<div class=${classMap({
[rootClass]: true,
[`${rootClass}--${layer}`]: true,
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
})}
style="${style} inline-size: 150px; block-size: 150px; border-radius: 10px; position: absolute;">
</div>
`;
}
13 changes: 13 additions & 0 deletions components/backgroundlayers/themes/express.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*!
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) {}
13 changes: 13 additions & 0 deletions components/backgroundlayers/themes/spectrum.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*!
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: spectrum) {}
Loading