Skip to content
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
124 changes: 39 additions & 85 deletions components/closebutton/index.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
Copyright 2023 Adobe. All rights reserved.
Copyright 2024 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
Expand All @@ -18,11 +18,8 @@ governing permissions and limitations under the License.
@import "@spectrum-css/commons/basebutton.css";

.spectrum-CloseButton {
/* Hardcoded tokens */
--spectrum-closebutton-size-300: 24px;
--spectrum-closebutton-size-400: 32px;
--spectrum-closebutton-size-500: 40px;
--spectrum-closebutton-size-600: 48px;
/* TO DO: replace with custom var during corner rounding work */
--spectrum-closebutton-border-radius: 9999px;

/* Cross icon */
--spectrum-closebutton-icon-color-default: var(--spectrum-neutral-content-color-default);
Expand All @@ -31,65 +28,72 @@ governing permissions and limitations under the License.
--spectrum-closebutton-icon-color-focus: var(--spectrum-neutral-content-color-key-focus);
--spectrum-closebutton-icon-color-disabled: var(--spectrum-disabled-content-color);

/* Focus ring */
/* Focus indicator */
--spectrum-closebutton-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness);
--spectrum-closebutton-focus-indicator-gap: var(--spectrum-focus-indicator-gap);
--spectrum-closebutton-focus-indicator-color: var(--spectrum-focus-indicator-color);

/* Size */
--spectrum-closebutton-height: var(--spectrum-component-height-100);
--spectrum-closebutton-width: var(--spectrum-closebutton-height);
--spectrum-closebutton-size: var(--spectrum-closebutton-size-400);
--spectrum-closebutton-border-radius: var(--spectrum-closebutton-size-400);

--spectrum-closebutton-animation-duration: var(--spectrum-animation-duration-100);

/* Background color */
--spectrum-closebutton-background-color-default: transparent;
--spectrum-closebutton-background-color-hover: var(--spectrum-gray-100);
--spectrum-closebutton-background-color-down: var(--spectrum-gray-100);
--spectrum-closebutton-background-color-focus: var(--spectrum-gray-100);
}

.spectrum-Closebutton--sizeS {
--spectrum-closebutton-height: var(--spectrum-component-height-75);
--spectrum-closebutton-width: var(--spectrum-closebutton-height);
--spectrum-closebutton-size: var(--spectrum-closebutton-size-300);
--spectrum-closebutton-border-radius: var(--spectrum-closebutton-size-300);
}

.spectrum-Closebutton--sizeM {
--spectrum-closebutton-height: var(--spectrum-component-height-100);
--spectrum-closebutton-width: var(--spectrum-closebutton-height);
--spectrum-closebutton-size: var(--spectrum-closebutton-size-400);
--spectrum-closebutton-border-radius: var(--spectrum-closebutton-size-400);
}

.spectrum-Closebutton--sizeL {
--spectrum-closebutton-height: var(--spectrum-component-height-200);
--spectrum-closebutton-width: var(--spectrum-closebutton-height);
--spectrum-closebutton-size: var(--spectrum-closebutton-size-500);
--spectrum-closebutton-border-radius: var(--spectrum-closebutton-size-500);
}

.spectrum-Closebutton--sizeXL {
--spectrum-closebutton-height: var(--spectrum-component-height-300);
--spectrum-closebutton-width: var(--spectrum-closebutton-height);
--spectrum-closebutton-size: var(--spectrum-closebutton-size-600);
--spectrum-closebutton-border-radius: var(--spectrum-closebutton-size-600);
}

.spectrum-CloseButton--staticWhite {
--spectrum-closebutton-static-background-color-default: transparent;
--spectrum-closebutton-static-background-color-hover: var(--spectrum-transparent-white-300);
--spectrum-closebutton-static-background-color-down: var(--spectrum-transparent-white-400);
--spectrum-closebutton-static-background-color-focus: var(--spectrum-transparent-white-300);
--spectrum-closebutton-icon-color-default: var(--spectrum-white);
--spectrum-closebutton-icon-color-disabled: var(--spectrum-disabled-static-white-content-color);
/* Cross icon */
--spectrum-closebutton-icon-color-default: var(--spectrum-transparent-white-800);
--spectrum-closebutton-icon-color-hover: var(--spectrum-transparent-white-900);
--spectrum-closebutton-icon-color-down: var(--spectrum-transparent-white-900);
--spectrum-closebutton-icon-color-focus: var(--spectrum-transparent-white-900);
--spectrum-closebutton-icon-color-disabled: var(--spectrum-disabled-static-white-background-color);

/* Background color */
--spectrum-closebutton-background-color-default: transparent;
--spectrum-closebutton-background-color-hover: var(--spectrum-transparent-white-100);
--spectrum-closebutton-background-color-down: var(--spectrum-transparent-white-100);
--spectrum-closebutton-background-color-focus: var(--spectrum-transparent-white-100);

/* Focus indicator */
--spectrum-closebutton-focus-indicator-color: var(--spectrum-static-white-focus-indicator-color);
}

.spectrum-CloseButton--staticBlack {
--spectrum-closebutton-static-background-color-default: transparent;
--spectrum-closebutton-static-background-color-hover: var(--spectrum-transparent-black-300);
--spectrum-closebutton-static-background-color-down: var(--spectrum-transparent-black-400);
--spectrum-closebutton-static-background-color-focus: var(--spectrum-transparent-black-300);
--spectrum-closebutton-icon-color-default: var(--spectrum-black);
--spectrum-closebutton-icon-color-disabled: var(--spectrum-disabled-static-black-content-color);
/* Cross icon */
--spectrum-closebutton-icon-color-default: var(--spectrum-transparent-black-800);
--spectrum-closebutton-icon-color-hover: var(--spectrum-transparent-black-900);
--spectrum-closebutton-icon-color-down: var(--spectrum-transparent-black-900);
--spectrum-closebutton-icon-color-focus: var(--spectrum-transparent-black-900);
--spectrum-closebutton-icon-color-disabled: var(--spectrum-disabled-static-black-background-color);

/* Background color */
--spectrum-closebutton-background-color-default: transparent;
--spectrum-closebutton-background-color-hover: var(--spectrum-transparent-black-100);
--spectrum-closebutton-background-color-down: var(--spectrum-transparent-black-100);
--spectrum-closebutton-background-color-focus: var(--spectrum-transparent-black-100);

/* Focus indicator */
--spectrum-closebutton-focus-indicator-color: var(--spectrum-static-black-focus-indicator-color);
}

Expand Down Expand Up @@ -165,7 +169,7 @@ a.spectrum-CloseButton {
inset-block-end: 0;
inset-block-start: 0;
margin: calc(var(--mod-closebutton-focus-indicator-gap, var(--spectrum-closebutton-focus-indicator-gap)) * -1);
border-radius: calc(var(--mod-closebutton-size, var(--spectrum-closebutton-size)) + var(--mod-closebutton-focus-indicator-gap, var(--spectrum-closebutton-focus-indicator-gap)));
border-radius: calc(var(--mod-closebutton-border-radius, var(--spectrum-closebutton-border-radius)) + var(--mod-closebutton-focus-indicator-gap, var(--spectrum-closebutton-focus-indicator-gap)));
transition: box-shadow var(--mod-closebutton-animation-duration, var(--spectrum-closebutton-animation-duration)) ease-in-out;
}

Expand All @@ -177,7 +181,6 @@ a.spectrum-CloseButton {
box-shadow:
0 0 0 var(--mod-closebutton-focus-indicator-thickness, var(--spectrum-closebutton-focus-indicator-thickness))
var(--highcontrast-closebutton-focus-indicator-color, var(--mod-closebutton-focus-indicator-color, var(--spectrum-closebutton-focus-indicator-color)));

}
}
}
Expand Down Expand Up @@ -231,55 +234,6 @@ a.spectrum-CloseButton {
}
}

/* Modifier Classes */
.spectrum-CloseButton--staticBlack:not(:disabled),
.spectrum-CloseButton--staticWhite:not(:disabled) {
Comment thread
jawinn marked this conversation as resolved.
background-color: var(--highcontrast-closebutton-static-background-color-default, var(--mod-closebutton-static-background-color-default, var(--spectrum-closebutton-static-background-color-default)));

&:hover {
background-color: var(--highcontrast-closebutton-static-background-color-hover, var(--mod-closebutton-static-background-color-hover, var(--spectrum-closebutton-static-background-color-hover)));

.spectrum-CloseButton-UIIcon {
color: var(--highcontrast-closebutton-icon-color-default, var(--mod-closebutton-icon-color-default, var(--spectrum-closebutton-icon-color-default)));
}
}

&:active {
background-color: var(--highcontrast-closebutton-static-background-color-down, var(--mod-closebutton-static-background-color-down, var(--spectrum-closebutton-static-background-color-down)));

.spectrum-CloseButton-UIIcon {
color: var(--highcontrast-closebutton-icon-color-default, var(--mod-closebutton-icon-color-default, var(--spectrum-closebutton-icon-color-default)));
}
}

&:focus-visible,
&.is-keyboardFocused {
background-color: var(--highcontrast-closebutton-static-background-color-focus, var(--mod-closebutton-static-background-color-focus, var(--spectrum-closebutton-static-background-color-focus)));

.spectrum-CloseButton-UIIcon {
color: var(--highcontrast-closebutton-icon-color-default, var(--mod-closebutton-icon-color-default, var(--spectrum-closebutton-icon-color-default)));
}
}

&:focus,
&.is-focused {
.spectrum-CloseButton-UIIcon {
color: var(--highcontrast-closebutton-icon-color-default, var(--mod-closebutton-icon-color-default, var(--spectrum-closebutton-icon-color-default)));
}
}

.spectrum-CloseButton-UIIcon {
color: var(--mod-closebutton-icon-color-default, var(--spectrum-closebutton-icon-color-default));
}
}

.spectrum-CloseButton--staticBlack:disabled,
.spectrum-CloseButton--staticWhite:disabled {
.spectrum-CloseButton-UIIcon {
color: var(--highcontrast-closebutton-icon-disabled, var(--mod-closebutton-icon-color-disabled, var(--spectrum-closebutton-icon-color-disabled)));
}
}

.spectrum-CloseButton-UIIcon {
margin: 0;
}
22 changes: 22 additions & 0 deletions components/closebutton/metadata/closebutton.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@ sections:
This component can be modified via its `--mod-*` prefixed custom properties. A list of those prefixed custom properties can be found <a class="spectrum-Link" href="https://github.com/adobe/spectrum-css/tree/main/components/closebutton/metadata/mods.md">here</a>.
- name: Migration Guide
description: |
### x/x/2024 - Version 5.0.0
#### Spectrum 2 release
Close button now uses Spectrum 2 tokens and specifications. A few notable changes and additions:
* Removes all static-specific `--mod` custom properties since they are no longer needed:
| Removed |
|-----------------------------------------------------|
| `--mod-closebutton-static-background-color-default` |
| `--mod-closebutton-static-background-color-down` |
| `--mod-closebutton-static-background-color-focus` |
| `--mod-closebutton-static-background-color-hover` |

Consumers can use these existing background-color mods instead:
| Use these existing mods instead |
|----------------------------------------------|
| `--mod-closebutton-background-color-default` |
| `--mod-closebutton-background-color-down` |
| `--mod-closebutton-background-color-focus` |
| `--mod-closebutton-background-color-hover` |

* Also removes --mod-closebutton-size since we'll be setting rounded border-radius with a single rounding token, to be formally implemented as part of [S2 Corner Rounding](https://github.com/adobe/spectrum-css/pull/2559/files#diff-d6e9caa794bd8e1c659425d223e23ab53a93a254f00fb11a626e1b7563bd0c61R39-R41).


### Sizing
Close button supports different sized icons. By default, you should use the following icons:

Expand Down
61 changes: 28 additions & 33 deletions components/closebutton/metadata/mods.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
| Modifiable custom properties |
| --------------------------------------------------- |
| `--mod-animation-duration-100` |
| `--mod-button-animation-duration` |
| `--mod-button-font-family` |
| `--mod-button-line-height` |
| `--mod-closebutton-align-self` |
| `--mod-closebutton-animation-duraction` |
| `--mod-closebutton-animation-duration` |
| `--mod-closebutton-background-color-default` |
| `--mod-closebutton-background-color-down` |
| `--mod-closebutton-background-color-focus` |
| `--mod-closebutton-background-color-hover` |
| `--mod-closebutton-border-radius` |
| `--mod-closebutton-focus-indicator-color` |
| `--mod-closebutton-focus-indicator-gap` |
| `--mod-closebutton-focus-indicator-thickness` |
| `--mod-closebutton-height` |
| `--mod-closebutton-icon-color-default` |
| `--mod-closebutton-icon-color-disabled` |
| `--mod-closebutton-icon-color-down` |
| `--mod-closebutton-icon-color-focus` |
| `--mod-closebutton-icon-color-hover` |
| `--mod-closebutton-margin-inline` |
| `--mod-closebutton-margin-top` |
| `--mod-closebutton-size` |
| `--mod-closebutton-static-background-color-default` |
| `--mod-closebutton-static-background-color-down` |
| `--mod-closebutton-static-background-color-focus` |
| `--mod-closebutton-static-background-color-hover` |
Comment thread
jawinn marked this conversation as resolved.
| `--mod-closebutton-width` |
| `--mod-line-height-100` |
| `--mod-sans-font-family-stack` |
| Modifiable custom properties |
| --------------------------------------------- |
| `--mod-animation-duration-100` |
| `--mod-button-animation-duration` |
| `--mod-button-font-family` |
| `--mod-button-line-height` |
| `--mod-closebutton-align-self` |
| `--mod-closebutton-animation-duraction` |
| `--mod-closebutton-animation-duration` |
| `--mod-closebutton-background-color-default` |
| `--mod-closebutton-background-color-down` |
| `--mod-closebutton-background-color-focus` |
| `--mod-closebutton-background-color-hover` |
| `--mod-closebutton-border-radius` |
| `--mod-closebutton-focus-indicator-color` |
| `--mod-closebutton-focus-indicator-gap` |
| `--mod-closebutton-focus-indicator-thickness` |
| `--mod-closebutton-height` |
| `--mod-closebutton-icon-color-default` |
| `--mod-closebutton-icon-color-disabled` |
| `--mod-closebutton-icon-color-down` |
| `--mod-closebutton-icon-color-focus` |
| `--mod-closebutton-icon-color-hover` |
| `--mod-closebutton-margin-inline` |
| `--mod-closebutton-margin-top` |
| `--mod-closebutton-width` |
| `--mod-line-height-100` |
| `--mod-sans-font-family-stack` |
2 changes: 1 addition & 1 deletion components/closebutton/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"main": "dist/index-vars.css",
"peerDependencies": {
"@spectrum-css/icon": ">=4",
"@spectrum-css/tokens": ">=13"
"@spectrum-css/tokens": "^14.0.0-next.0"
},
"devDependencies": {
"@spectrum-css/commons": "^9.1.2",
Expand Down
68 changes: 66 additions & 2 deletions components/closebutton/stories/closebutton.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// Import the component markup template
import { html } from "lit";
import { ifDefined } from "lit/directives/if-defined.js";
import { styleMap } from "lit/directives/style-map.js";
import { when } from "lit/directives/when.js";

import { Template } from "./template";

export default {
Expand Down Expand Up @@ -53,5 +57,65 @@ export default {
},
};

export const Default = Template.bind({});
const CloseButton = ({
staticColor,
...args
}) => {
return html`
<div
style=${ifDefined(styleMap({
padding: "1rem",
backgroundColor: staticColor === "white" ? "rgb(15, 121, 125)" : staticColor === "black" ? "rgb(181, 209, 211)" : undefined,
}))}
>
${Template({...args, staticColor})}
${when(window.isChromatic(), () =>
html`
${Template({
...args,
isDisabled: true,
})}
${html`
<div
style=${ifDefined(styleMap({
padding: "1rem",
backgroundColor: "rgb(15, 121, 125)"
}))}
>
${Template({
...args,
staticColor: "white",
})}
${Template({
...args,
staticColor: "white",
isDisabled: true,
})}
</div>
`}
${html`
<div
style=${ifDefined(styleMap({
padding: "1rem",
backgroundColor: "rgb(181, 209, 211)"
}))}
>
${Template({
...args,
staticColor: "black",
})}
${Template({
...args,
staticColor: "black",
isDisabled: true,
})}
</div>
`}
`
)}
</div>
`;
}

export const Default = CloseButton.bind({});
Default.args = {};
Loading