// d2themes defines themes to make d2 diagrams pretty // Color codes: darkest (N1) -> lightest (N7)
package d2themes import ( ) type Theme struct { ID int64 `json:"id"` Name string `json:"name"` Colors ColorPalette `json:"colors"` SpecialRules SpecialRules `json:"specialRules,omitempty"` } type SpecialRules struct { Mono bool `json:"mono"` NoCornerRadius bool `json:"noCornerRadius"` OuterContainerDoubleBorder bool `json:"outerContainerDoubleBorder"` ContainerDots bool `json:"containerDots"` CapsLock bool `json:"capsLock"` AllPaper bool `json:"allPaper"` } func ( *Theme) () bool { return .ID >= 200 && .ID < 300 } func ( *Theme) ( *d2target.ThemeOverrides) { if == nil { return } if .B1 != nil { .Colors.B1 = *.B1 } if .B2 != nil { .Colors.B2 = *.B2 } if .B3 != nil { .Colors.B3 = *.B3 } if .B4 != nil { .Colors.B4 = *.B4 } if .B5 != nil { .Colors.B5 = *.B5 } if .B5 != nil { .Colors.B5 = *.B5 } if .B6 != nil { .Colors.B6 = *.B6 } if .AA2 != nil { .Colors.AA2 = *.AA2 } if .AA4 != nil { .Colors.AA4 = *.AA4 } if .AA5 != nil { .Colors.AA5 = *.AA5 } if .AB4 != nil { .Colors.AB4 = *.AB4 } if .AB5 != nil { .Colors.AB5 = *.AB5 } if .N1 != nil { .Colors.Neutrals.N1 = *.N1 } if .N2 != nil { .Colors.Neutrals.N2 = *.N2 } if .N3 != nil { .Colors.Neutrals.N3 = *.N3 } if .N4 != nil { .Colors.Neutrals.N4 = *.N4 } if .N5 != nil { .Colors.Neutrals.N5 = *.N5 } if .N6 != nil { .Colors.Neutrals.N6 = *.N6 } if .N7 != nil { .Colors.Neutrals.N7 = *.N7 } } type Neutral struct { N1 string `json:"n1"` N2 string `json:"n2"` N3 string `json:"n3"` N4 string `json:"n4"` N5 string `json:"n5"` N6 string `json:"n6"` N7 string `json:"n7"` } type ColorPalette struct { Neutrals Neutral `json:"neutrals"` // Base Colors: used for containers B1 string `json:"b1"` B2 string `json:"b2"` B3 string `json:"b3"` B4 string `json:"b4"` B5 string `json:"b5"` B6 string `json:"b6"` // Alternative colors A AA2 string `json:"aa2"` AA4 string `json:"aa4"` AA5 string `json:"aa5"` // Alternative colors B AB4 string `json:"ab4"` AB5 string `json:"ab5"` } var CoolNeutral = Neutral{ N1: "#0A0F25", N2: "#676C7E", N3: "#9499AB", N4: "#CFD2DD", N5: "#DEE1EB", N6: "#EEF1F8", N7: "#FFFFFF", } var WarmNeutral = Neutral{ N1: "#170206", N2: "#535152", N3: "#787777", N4: "#CCCACA", N5: "#DFDCDC", N6: "#ECEBEB", N7: "#FFFFFF", } var DarkNeutral = Neutral{ N1: "#F4F6FA", N2: "#BBBEC9", N3: "#868A96", N4: "#676D7D", N5: "#3A3D49", N6: "#191C28", N7: "#000410", } var DarkMauveNeutral = Neutral{ N1: "#CDD6F4", N2: "#BAC2DE", N3: "#A6ADC8", N4: "#585B70", N5: "#45475A", N6: "#313244", N7: "#1E1E2E", } func ( Theme, string) string { if !color.IsThemeColor() { return } switch { case "N1": return .Colors.Neutrals.N1 case "N2": return .Colors.Neutrals.N2 case "N3": return .Colors.Neutrals.N3 case "N4": return .Colors.Neutrals.N4 case "N5": return .Colors.Neutrals.N5 case "N6": return .Colors.Neutrals.N6 case "N7": return .Colors.Neutrals.N7 case "B1": return .Colors.B1 case "B2": return .Colors.B2 case "B3": return .Colors.B3 case "B4": return .Colors.B4 case "B5": return .Colors.B5 case "B6": return .Colors.B6 case "AA2": return .Colors.AA2 case "AA4": return .Colors.AA4 case "AA5": return .Colors.AA5 case "AB4": return .Colors.AB4 case "AB5": return .Colors.AB5 default: return "" } }