3
0

Add darkmode on customCSS

This commit is contained in:
Mumbi Francis 2024-01-17 17:44:26 +03:00
parent cbcf3dd422
commit 88608fbb08
2 changed files with 10 additions and 1 deletions

View File

@ -58,7 +58,7 @@ func DefaultCSS(log *zap.Logger, customCSS string) string {
func Transpile(transpiler *godartsass.Transpiler, log *zap.Logger, themeID, themeSASS, customCSS, sassDirPath string) (err error) {
// process root section
err = processSass(transpiler, log, SectionRoot, themeID, themeSASS, customCSS, sassDirPath)
err = processSass(transpiler, log, SectionRoot, themeID, themeSASS, "", sassDirPath)
if err != nil {
return err
}

View File

@ -65,10 +65,19 @@ func GenerateCSS(settings *types.AppSettings, sassDirPath string, log *zap.Logge
func processCustomCSS(themeID string, customCSSMap map[string]string) (customCSS string) {
var stringsBuilder strings.Builder
// add theme mode on customCSS
if themeID == sass.DarkTheme {
stringsBuilder.WriteString(fmt.Sprintf("\n[data-color-mode=\"%s\"] {\n", themeID))
}
stringsBuilder.WriteString(customCSSMap[sass.GeneralTheme])
stringsBuilder.WriteString("\n")
stringsBuilder.WriteString(customCSSMap[themeID])
if themeID == sass.DarkTheme {
stringsBuilder.WriteString("}\n")
}
return stringsBuilder.String()
}