@@ -42,6 +42,26 @@ import { ColorControl } from "./colorControl";
42
42
import { StringStateControl } from "./codeStateControl" ;
43
43
import { reduceInContext } from "../utils/reduceContext" ;
44
44
45
+ // Tag preset color options
46
+ const TAG_PRESET_COLORS = [
47
+ { label : "Magenta" , value : "magenta" } ,
48
+ { label : "Red" , value : "red" } ,
49
+ { label : "Volcano" , value : "volcano" } ,
50
+ { label : "Orange" , value : "orange" } ,
51
+ { label : "Gold" , value : "gold" } ,
52
+ { label : "Lime" , value : "lime" } ,
53
+ { label : "Green" , value : "green" } ,
54
+ { label : "Cyan" , value : "cyan" } ,
55
+ { label : "Blue" , value : "blue" } ,
56
+ { label : "Geek Blue" , value : "geekblue" } ,
57
+ { label : "Purple" , value : "purple" } ,
58
+ { label : "Success" , value : "success" } ,
59
+ { label : "Processing" , value : "processing" } ,
60
+ { label : "Error" , value : "error" } ,
61
+ { label : "Warning" , value : "warning" } ,
62
+ { label : "Default" , value : "default" } ,
63
+ ] as const ;
64
+
45
65
const OptionTypes = [
46
66
{
47
67
label : trans ( "prop.manual" ) ,
@@ -735,24 +755,68 @@ let ColoredTagOption = new MultiCompBuilder(
735
755
{
736
756
label : StringControl ,
737
757
icon : IconControl ,
738
- color : withDefault ( ColorControl , "" ) ,
758
+ colorType : withDefault ( dropdownControl ( [
759
+ { label : "Preset" , value : "preset" } ,
760
+ { label : "Custom" , value : "custom" } ,
761
+ ] as const , "preset" ) , "preset" ) ,
762
+ presetColor : withDefault ( dropdownControl ( TAG_PRESET_COLORS , "blue" ) , "blue" ) ,
763
+ color : withDefault ( ColorControl , "#1890ff" ) ,
764
+ textColor : withDefault ( ColorControl , "#ffffff" ) ,
765
+ border : withDefault ( ColorControl , "" ) ,
766
+ radius : withDefault ( RadiusControl , "" ) ,
767
+ margin : withDefault ( StringControl , "" ) ,
768
+ padding : withDefault ( StringControl , "" ) ,
739
769
} ,
740
770
( props ) => props
741
771
) . build ( ) ;
742
772
743
773
ColoredTagOption = class extends ColoredTagOption implements OptionCompProperty {
744
774
propertyView ( param : { autoMap ?: boolean } ) {
775
+ const colorType = this . children . colorType . getView ( ) ;
745
776
return (
746
777
< >
747
778
{ this . children . label . propertyView ( { label : trans ( "coloredTagOptionControl.tag" ) } ) }
748
779
{ this . children . icon . propertyView ( { label : trans ( "coloredTagOptionControl.icon" ) } ) }
749
- { this . children . color . propertyView ( { label : trans ( "coloredTagOptionControl.color" ) } ) }
780
+ { this . children . colorType . propertyView ( {
781
+ label : "Color Type" ,
782
+ radioButton : true
783
+ } ) }
784
+ { colorType === "preset" && this . children . presetColor . propertyView ( {
785
+ label : "Preset Color"
786
+ } ) }
787
+ { colorType === "custom" && (
788
+ < >
789
+ { this . children . color . propertyView ( { label : trans ( "coloredTagOptionControl.color" ) } ) }
790
+ { this . children . textColor . propertyView ( { label : "Text Color" } ) }
791
+ </ >
792
+ ) }
793
+ { this . children . border . propertyView ( {
794
+ label : trans ( 'style.border' )
795
+ } ) }
796
+ { this . children . radius . propertyView ( {
797
+ label : trans ( 'style.borderRadius' ) ,
798
+ preInputNode : < StyledIcon as = { IconRadius } title = "" /> ,
799
+ placeholder : '3px' ,
800
+ } ) }
801
+ { this . children . margin . propertyView ( {
802
+ label : trans ( 'style.margin' ) ,
803
+ preInputNode : < StyledIcon as = { ExpandIcon } title = "" /> ,
804
+ placeholder : '3px' ,
805
+ } ) }
806
+ { this . children . padding . propertyView ( {
807
+ label : trans ( 'style.padding' ) ,
808
+ preInputNode : < StyledIcon as = { CompressIcon } title = "" /> ,
809
+ placeholder : '3px' ,
810
+ } ) }
750
811
</ >
751
812
) ;
752
813
}
753
814
} ;
754
815
755
816
export const ColoredTagOptionControl = optionsControl ( ColoredTagOption , {
756
- initOptions : [ { label : "Tag1" , icon : "/icon:solid/tag" , color : "#f50" } , { label : "Tag2" , icon : "/icon:solid/tag" , color : "#2db7f5" } ] ,
817
+ initOptions : [
818
+ { label : "Tag1" , icon : "/icon:solid/tag" , colorType : "preset" , presetColor : "blue" } ,
819
+ { label : "Tag2" , icon : "/icon:solid/tag" , colorType : "preset" , presetColor : "green" }
820
+ ] ,
757
821
uniqField : "label" ,
758
822
} ) ;
0 commit comments