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