@@ -5,6 +5,8 @@ import { htmlSafe } from '@ember/template';
5
5
import Component from ' @glimmer/component' ;
6
6
7
7
import ColorPicker from ' ../color-picker/index.gts' ;
8
+ import IconTrash from ' ../../icons/icon-trash.gts' ;
9
+ import IconButton from ' ../icon-button/index.gts' ;
8
10
9
11
interface Signature {
10
12
Args: {
@@ -40,16 +42,31 @@ export default class ColorPalette extends Component<Signature> {
40
42
41
43
<template >
42
44
<div class =' color-palette-container' ...attributes >
43
- <div class =' color-palette' >
44
- {{#each this . colors as | color | }}
45
- <button
46
- type =' button'
47
- class =' swatch {{if ( eq color @ color) " selected" }} '
48
- style ={{htmlSafe ( concat ' --swatch-color: ' color ) }}
49
- {{on ' click' ( fn @ onChange color ) }}
50
- title ={{color }}
51
- />
52
- {{/each }}
45
+ <div class =' palette-group' >
46
+ <div class =' color-palette' >
47
+ {{#each this . colors as | color | }}
48
+ <button
49
+ type =' button'
50
+ class =' swatch {{if ( eq color @ color) " selected" }} '
51
+ style ={{htmlSafe ( concat ' --swatch-color: ' color ) }}
52
+ {{on ' click' ( fn @ onChange color ) }}
53
+ title ={{color }}
54
+ />
55
+ {{/each }}
56
+ </div >
57
+ {{#if @ color }}
58
+ <div >
59
+ <code class =' selected-color' >{{@ color }} </code >
60
+ <IconButton
61
+ @ icon ={{IconTrash }}
62
+ @ width =' 16px'
63
+ @ height =' 16px'
64
+ class =' remove'
65
+ {{on ' click' ( fn @ onChange ' ' ) }}
66
+ aria-label =' Unset color'
67
+ />
68
+ </div >
69
+ {{/if }}
53
70
</div >
54
71
55
72
<label class =' color-picker-container' >
@@ -65,12 +82,25 @@ export default class ColorPalette extends Component<Signature> {
65
82
}
66
83
67
84
.color-palette-container {
85
+ --boxel-icon-button-width : var (--boxel-icon-sm );
86
+ --boxel-icon-button-height : var (--boxel-icon-sm );
68
87
display : flex ;
69
88
gap : var (--boxel-sp );
70
89
align-items : flex-start ;
71
90
flex-direction : column ;
72
91
}
73
92
93
+ .palette-group {
94
+ display : flex ;
95
+ gap : var (--boxel-sp ) var (--boxel-sp-lg );
96
+ align-items : center ;
97
+ flex-wrap : wrap ;
98
+ }
99
+
100
+ .selected-color {
101
+ text-transform : uppercase ;
102
+ }
103
+
74
104
.color-picker-container {
75
105
--swatch-size : 1.8rem ;
76
106
border : 1px solid var (--boxel-border-color );
@@ -100,7 +130,7 @@ export default class ColorPalette extends Component<Signature> {
100
130
.swatch {
101
131
width : var (--swatch-size );
102
132
height : var (--swatch-size );
103
- border : 1 px solid transparent ;
133
+ border : 2 px solid transparent ;
104
134
border-radius : 50% ;
105
135
padding : 2px ;
106
136
cursor : pointer ;
@@ -143,6 +173,16 @@ export default class ColorPalette extends Component<Signature> {
143
173
border : 1px solid transparent ;
144
174
border-radius : 50% ;
145
175
}
176
+
177
+ .remove {
178
+ vertical-align : text-bottom ;
179
+ margin-left : var (--boxel-sp-xxxs );
180
+ }
181
+ .remove :focus ,
182
+ .remove :hover {
183
+ --icon-color : var (--boxel-red );
184
+ outline : 0 ;
185
+ }
146
186
< /style >
147
187
</template >
148
188
}
0 commit comments