@@ -10,8 +10,11 @@ OF ANY KIND, either express or implied. See the License for the specific languag
10
10
governing permissions and limitations under the License.
11
11
*/
12
12
13
- import { html , TemplateResult } from '@spectrum-web-components/base' ;
14
- import { ifDefined } from '@spectrum-web-components/base/src/directives.js' ;
13
+ import { html , nothing , TemplateResult } from '@spectrum-web-components/base' ;
14
+ import {
15
+ ifDefined ,
16
+ unsafeHTML ,
17
+ } from '@spectrum-web-components/base/src/directives.js' ;
15
18
import '@spectrum-web-components/action-group/sp-action-group.js' ;
16
19
import '@spectrum-web-components/icon/sp-icon.js' ;
17
20
import '@spectrum-web-components/icons-workflow/icons/sp-icon-edit.js' ;
@@ -28,13 +31,17 @@ export interface Properties {
28
31
size ?: 's' | 'm' | 'l' | 'xl' ;
29
32
staticColor ?: 'white' | 'black' ;
30
33
holdAffordance ?: boolean ;
31
- icon ?: TemplateResult ;
34
+ icon ?: string ;
32
35
label ?: string ;
33
36
[ prop : string ] : unknown ;
34
37
href : undefined ;
35
38
}
36
39
37
- export function renderButton ( properties : Properties ) : TemplateResult {
40
+ export function renderButton ( {
41
+ icon,
42
+ label,
43
+ ...properties
44
+ } : Properties ) : TemplateResult {
38
45
return html `
39
46
< sp-action-button
40
47
href =${ ifDefined ( properties . href ) }
@@ -48,17 +55,15 @@ export function renderButton(properties: Properties): TemplateResult {
48
55
?hold-affordance=${ ! ! properties . holdAffordance }
49
56
?active=${ ! ! properties . active }
50
57
>
51
- ${ properties . icon } ${ properties . label }
58
+ ${ icon ? unsafeHTML ( icon ) : nothing } ${ label }
52
59
</ sp-action-button >
53
60
` ;
54
61
}
55
62
56
63
function renderGroup ( properties : Properties ) : TemplateResult {
57
64
const label = 'Edit' ;
58
65
const holdAffordance = true ;
59
- const icon = html `
60
- < sp-icon-edit slot ="icon "> </ sp-icon-edit >
61
- ` ;
66
+ const icon = `<sp-icon-edit slot="icon"></sp-icon-edit>` ;
62
67
return html `
63
68
< sp-action-group
64
69
?quiet ="${ ! ! properties . quiet } "
@@ -89,27 +94,23 @@ function renderGroup(properties: Properties): TemplateResult {
89
94
}
90
95
91
96
export function renderButtons ( properties : Properties ) : TemplateResult {
92
- const selected = true ;
93
- const disabled = true ;
94
97
return html `
95
98
< div
96
99
style ="display: flex; flex-direction: column; gap: calc(var(--spectrum-spacing-100) * var(--swc-scale-factor)); "
97
100
>
101
+ ${ renderGroup ( properties ) }
98
102
${ renderGroup ( {
99
103
...properties ,
104
+ selected : true ,
100
105
} ) }
101
106
${ renderGroup ( {
102
107
...properties ,
103
- selected,
104
- } ) }
105
- ${ renderGroup ( {
106
- ...properties ,
107
- disabled,
108
+ disabled : true ,
108
109
} ) }
109
110
${ renderGroup ( {
110
111
...properties ,
111
- disabled,
112
- selected,
112
+ disabled : true ,
113
+ selected : true ,
113
114
} ) }
114
115
</ div >
115
116
` ;
0 commit comments