-
Notifications
You must be signed in to change notification settings - Fork 244
Expand file tree
/
Copy pathCloseButton.ts
More file actions
87 lines (81 loc) · 2.88 KB
/
CloseButton.ts
File metadata and controls
87 lines (81 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
* Copyright 2025 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.
*/
import {
CSSResultArray,
html,
SizedMixin,
TemplateResult,
} from '@spectrum-web-components/base';
import { property } from '@spectrum-web-components/base/src/decorators.js';
import { StyledButton } from './StyledButton.js';
import buttonStyles from '@spectrum-web-components/close-button/src/close-button.css.js';
import '@spectrum-web-components/icons-ui/icons/sp-icon-cross200.js';
import '@spectrum-web-components/icons-ui/icons/sp-icon-cross300.js';
import '@spectrum-web-components/icons-ui/icons/sp-icon-cross400.js';
import '@spectrum-web-components/icons-ui/icons/sp-icon-cross500.js';
import crossMediumStyles from '@spectrum-web-components/icon/src/spectrum-icon-cross.css.js';
import type { ButtonStaticColors } from './Button.js';
const crossIcon: Record<string, () => TemplateResult> = {
s: () => html`
<sp-icon-cross200
slot="icon"
class="icon spectrum-UIIcon-Cross200"
></sp-icon-cross200>
`,
m: () => html`
<sp-icon-cross300
slot="icon"
class="icon spectrum-UIIcon-Cross300"
></sp-icon-cross300>
`,
l: () => html`
<sp-icon-cross400
slot="icon"
class="icon spectrum-UIIcon-Cross400"
></sp-icon-cross400>
`,
xl: () => html`
<sp-icon-cross500
slot="icon"
class="icon spectrum-UIIcon-Cross500"
></sp-icon-cross500>
`,
};
/**
* @element sp-close-button
*
* @slot - text label of the Close Button
*/
export class CloseButton extends SizedMixin(StyledButton, {
noDefaultSize: true,
}) {
public static override get styles(): CSSResultArray {
return [...super.styles, buttonStyles, crossMediumStyles];
}
/**
* The visual variant to apply to this button.
*/
@property({ reflect: true })
public variant: ButtonStaticColors | '' = '';
@property({ reflect: true, attribute: 'static-color' })
public staticColor?: 'black' | 'white';
protected override get buttonContent(): TemplateResult[] {
return [
crossIcon[this.size](),
html`
<span id="label" class="visually-hidden">
<slot @slotchange=${this.manageTextObservedSlot}></slot>
</span>
`,
];
}
}