@@ -9,12 +9,14 @@ import {
99 ApplicationContainer ,
1010 Badge ,
1111 Button ,
12+ Checkbox ,
1213 CLASSPREFIX as eccgui ,
1314 COLORMINCONTRAST ,
1415 COLORMINDISTANCE ,
1516 ContextMenu ,
1617 FieldItem ,
1718 FieldItemRow ,
19+ FieldSet ,
1820 FlexibleLayoutContainer ,
1921 FlexibleLayoutItem ,
2022 IconButton ,
@@ -59,6 +61,8 @@ const ColorPaletteConfigurator = ({
5961 const [ minimalDistance , setMinimalDistance ] = React . useState < number > ( distanceMin ) ;
6062 const [ minimalContrast , setMinimalContrast ] = React . useState < number > ( contrastMin ) ;
6163 const [ paletteData , setPaletteData ] = React . useState < object | undefined > ( undefined ) ;
64+ const [ hashtestGroups , setHashtestGroups ] = React . useState < string [ ] > ( [ "layout" ] ) ;
65+ const [ hashtestWeights , setHashtestWeights ] = React . useState < string [ ] > ( [ "100" , "300" , "500" , "700" , "900" ] ) ;
6266 const userPaletteRef = React . useRef < HTMLTextAreaElement | null > ( null ) ;
6367
6468 const createPaletteData = ( csscustomprops : string | undefined ) => {
@@ -112,10 +116,12 @@ const ColorPaletteConfigurator = ({
112116 const createSimpleColorList = ( data : object , checkColorDistance : boolean ) => {
113117 let colorlist = [ ] as Color [ ] ;
114118 for ( const [ group , tints ] of Object . entries ( data ) ) {
115- if ( group === "layout" ) {
119+ if ( hashtestGroups . includes ( group ) ) {
116120 for ( const [ , weights ] of Object . entries ( tints as object ) ) {
117- for ( const [ , value ] of Object . entries ( weights ) ) {
118- colorlist . push ( value as Color ) ;
121+ for ( const [ weight , value ] of Object . entries ( weights ) ) {
122+ if ( hashtestWeights . includes ( weight ) ) {
123+ colorlist . push ( value as Color ) ;
124+ }
119125 }
120126 }
121127 }
@@ -209,6 +215,26 @@ const ColorPaletteConfigurator = ({
209215 }
210216 } , [ paletteData ] ) ;
211217
218+ const updateHashtestGroups = ( group : string , active : boolean ) => {
219+ let updatedGroups ;
220+ if ( active ) {
221+ updatedGroups = [ ...hashtestGroups , group ] ;
222+ } else {
223+ updatedGroups = hashtestGroups . filter ( ( value ) => value !== group ) ;
224+ }
225+ setHashtestGroups ( updatedGroups ) ;
226+ } ;
227+
228+ const updateHashtestWeights = ( weight : string , active : boolean ) => {
229+ let updatedWeights ;
230+ if ( active ) {
231+ updatedWeights = [ ...hashtestWeights , weight ] ;
232+ } else {
233+ updatedWeights = hashtestWeights . filter ( ( value ) => value !== weight ) ;
234+ }
235+ setHashtestWeights ( updatedWeights ) ;
236+ } ;
237+
212238 const fixColorByLuminosity = (
213239 color : Color ,
214240 colorTest : Color ,
@@ -656,6 +682,46 @@ const ColorPaletteConfigurator = ({
656682 title : "Color hashes" ,
657683 panel : (
658684 < div >
685+ < FieldSet title = "Include groups" boxed >
686+ < FieldItemRow >
687+ { [ "identity" , "semantic" , "layout" , "extra" ] . map ( ( group ) => (
688+ < FieldItem >
689+ < Checkbox
690+ value = { group }
691+ onChange = { ( event ) => {
692+ updateHashtestGroups (
693+ event . target . value ,
694+ event . target . checked
695+ ) ;
696+ } }
697+ checked = { hashtestGroups . includes ( group ) }
698+ >
699+ { group }
700+ </ Checkbox >
701+ </ FieldItem >
702+ ) ) }
703+ </ FieldItemRow >
704+ </ FieldSet >
705+ < FieldSet title = "Include weights" boxed >
706+ < FieldItemRow >
707+ { [ "100" , "300" , "500" , "700" , "900" ] . map ( ( weight ) => (
708+ < FieldItem >
709+ < Checkbox
710+ value = { weight }
711+ onChange = { ( event ) => {
712+ updateHashtestWeights (
713+ event . target . value ,
714+ event . target . checked
715+ ) ;
716+ } }
717+ checked = { hashtestWeights . includes ( weight ) }
718+ >
719+ { weight }
720+ </ Checkbox >
721+ </ FieldItem >
722+ ) ) }
723+ </ FieldItemRow >
724+ </ FieldSet >
659725 { Object . values ( currentLayoutColorList ) . length > 0 && (
660726 < >
661727 < Section >
@@ -751,8 +817,9 @@ const ColorPaletteConfigurator = ({
751817 } )
752818 . toString ( )
753819 . split ( " " )
754- . map ( ( text ) => (
820+ . map ( ( text , index ) => (
755821 < Badge
822+ key = { index }
756823 tagProps = { {
757824 large : true ,
758825 backgroundColor : utils . textToColorHash ( {
@@ -786,8 +853,9 @@ const ColorPaletteConfigurator = ({
786853 } )
787854 . toString ( )
788855 . split ( " " )
789- . map ( ( text ) => (
856+ . map ( ( text , index ) => (
790857 < Badge
858+ key = { index }
791859 tagProps = { {
792860 large : true ,
793861 backgroundColor : utils . textToColorHash ( {
0 commit comments