Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use js default theme #191

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 13 additions & 32 deletions ui/vuetify/fix-vuetifyjs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package vuetify

import (
"embed"
"fmt"
"net/http"
"strings"

Expand All @@ -15,6 +16,9 @@ var assetsbox embed.FS
//go:embed vuetifyjs/dist
var vuetifyjs embed.FS

//go:embed vuetifyjs/src/plugins/theme.js
var themeFs embed.FS

var customizeVuetifyCSS = osenv.GetBool("CUSTOMIZE_VUETIFY_CSS", "Use customized styles for vuetify", true)

func JSComponentsPack() web.ComponentsPack {
Expand All @@ -25,6 +29,14 @@ func JSComponentsPack() web.ComponentsPack {
return web.ComponentsPack(v)
}

func theme() string {
v, err := themeFs.ReadFile("vuetifyjs/src/plugins/theme.js")
if err != nil {
panic(err)
}
return fmt.Sprintf(`{ theme: %s }`, strings.Replace(string(v), "export default", "", 1))
}

func cssComponentsPack() web.ComponentsPack {
var v []byte
var err error
Expand Down Expand Up @@ -95,40 +107,9 @@ window.__goplaidVueComponentRegisters.push(function(app, vueOptions) {
});
`

const defaultVuetifyOpts = `{
icons: {
// defaultSet: 'md', // 'mdi' || 'mdiSvg' || 'md' || 'fa' || 'fa4'
},
theme: {
themes: {
qor5: {
dark: false,
colors: {
primary: "#3E63DD",
secondary: "#5B6471",
accent: "#82B1FF",
error: "#82B1FF",
info: "#0091FF",
success: "#30A46C",
warning: "#F76808",
}
},
},
},
}`

var vuetifyOpts string

func ChangeVuetifyOpts(opts string) {
vuetifyOpts = opts
}

func Vuetify() web.ComponentsPack {
if vuetifyOpts == "" {
vuetifyOpts = defaultVuetifyOpts
}
return web.ComponentsPack(
strings.NewReplacer("{{vuetifyOpts}}", vuetifyOpts).
strings.NewReplacer("{{vuetifyOpts}}", theme()).
Replace(initVuetify),
)
}
Loading
Loading