5151 height : 100px !important ;
5252 border-radius : 20% 0 0 20% ;
5353 cursor : pointer;
54+ border : none;
55+ z-index : 1 ;
56+ box-shadow : -5px 5px 5px grey;
5457 }
5558
5659 # color-mixer > : nth-child (7 ) {
6568 height : 100px ;
6669 border-radius : 0 20% 20% 0 ;
6770 cursor : pointer;
71+ border : none;
72+ z-index : 1 ;
73+ box-shadow : 5px 5px 5px grey;
6874 }
6975
7076 # color-mixer > : nth-child (9 ) {
7177 grid-area : mix-output-text;
72- margin : 1rem auto;
78+ margin : 1rem auto auto 1 rem ;
7379 font-weight : bold;
7480 font-size : 0.8rem ;
7581 height : 2.5rem ;
8187 display : flex;
8288 }
8389
90+ # percentage-one-label ,
91+ # percentage-two-label {
92+ width : 2rem ;
93+ text-align : end;
94+ }
95+
8496 # color-mixer > : nth-child (11 ) {
8597 grid-area : percent-two;
8698 width : 100% ;
89101
90102 # color-mixer > : nth-child (12 ) {
91103 grid-area : color-space-label;
92- margin : 0 0 0 auto;
104+ margin : 0.5 rem 0 0 auto;
93105 }
94106
95107 # color-mixer > : nth-child (13 ) {
96108 grid-area : color-space;
97- margin : 0 auto 0 1rem ;
109+ margin : 0.5 rem auto 0 1rem ;
98110 }
99111
100112 # color-mixer > : nth-child (14 ) {
101113 grid-area : interpolation-label;
102- margin : 0 0 0 auto;
114+ margin : 0.5 rem 0 0 auto;
103115 }
104116
105117 # color-mixer > : nth-child (15 ) {
106118 grid-area : interpolation;
107- margin : 0 auto 0 1rem ;
119+ margin : 0.5 rem auto 0 1rem ;
108120 }
109121
110122 input [type = "range" ] {
115127 font-family : monospace;
116128 margin : 1rem ;
117129 }
130+
131+ * : focus {
132+ outline : 2px dashed purple;
133+ outline-offset : 1px ;
134+ }
118135 </ style >
119136 </ head >
120137
123140 < h3 > Color mixer</ h3 >
124141 < p > Click on 'color-one' and 'color-two' to select colors.</ p >
125142
126- < div > color-one</ div >
143+ < label > color-one</ label >
127144 < div > mixed-color</ div >
128- < div > color-two</ div >
129-
130- < div id ="color-one " class ="color-one "> </ div >
145+ < label > color-two</ label >
146+
147+ < button
148+ id ="color-one "
149+ type ="button "
150+ class ="color-one "
151+ aria-label ="toggle color picker dialog "
152+ > </ button >
131153 < div id ="mixed-color "> </ div >
132- < div id ="color-two " class ="color-two "> </ div >
154+ < button
155+ id ="color-two "
156+ type ="button "
157+ class ="color-two "
158+ aria-label ="toggle color picker dialog "
159+ > </ button >
133160
134161 < label id ="mix-output-text "> </ label >
135162
@@ -238,10 +265,26 @@ <h3>Color mixer</h3>
238265 pickerOne = Pickr . create ( pickerOptions ) ;
239266 pickerOne . setColor ( "#ff7f50" ) ;
240267 colorOne . style . setProperty ( "background-color" , "#ff7f50" ) ;
241- pickerOne . on ( "change" , ( color , source , instance ) => {
268+ pickerOne . on ( "change" , ( color ) => {
242269 colorOne . style . setProperty ( "background-color" , color . toRGBA ( ) ) ;
243270 updateColorMix ( ) ;
244271 } ) ;
272+ pickerOne . on ( "cancel" , ( instance ) => {
273+ colorOne . style . setProperty (
274+ "background-color" ,
275+ instance . getColor ( ) . toRGBA ( )
276+ ) ;
277+ updateColorMix ( ) ;
278+ } ) ;
279+ pickerOne . on ( "show" , ( _ , instance ) => {
280+ instance
281+ . getRoot ( )
282+ . app . querySelector ( ":is(button, [tabindex])" )
283+ . focus ( ) ;
284+ } ) ;
285+ pickerOne . on ( "hide" , ( instance ) => {
286+ colorOne . focus ( ) ;
287+ } ) ;
245288
246289 pickerOptions . el = ".color-two" ;
247290 pickerOptions . default = "#00ffff" ;
@@ -252,6 +295,22 @@ <h3>Color mixer</h3>
252295 colorTwo . style . setProperty ( "background-color" , color . toRGBA ( ) ) ;
253296 updateColorMix ( ) ;
254297 } ) ;
298+ pickerTwo . on ( "cancel" , ( instance ) => {
299+ colorTwo . style . setProperty (
300+ "background-color" ,
301+ instance . getColor ( ) . toRGBA ( )
302+ ) ;
303+ updateColorMix ( ) ;
304+ } ) ;
305+ pickerTwo . on ( "show" , ( _ , instance ) => {
306+ instance
307+ . getRoot ( )
308+ . app . querySelector ( ":is(button, [tabindex])" )
309+ . focus ( ) ;
310+ } ) ;
311+ pickerTwo . on ( "hide" , ( instance ) => {
312+ colorTwo . focus ( ) ;
313+ } ) ;
255314
256315 percentageOne . addEventListener ( "input" , ( e ) => {
257316 percentageOneLabel . innerText = e . target . value + "%" ;
0 commit comments