@@ -67,30 +67,38 @@ export default {
6767 }))
6868 }
6969 },
70+ watch: {
71+ ' config.theme.colors' : {
72+ deep: true ,
73+ handler () {
74+ this ._applyThemePreview ()
75+ }
76+ }
77+ },
7078 validations: {
7179 config: {
7280 theme: {
7381 colors: {
7482 primary: {
75- required: required (' primary color is required' ),
76- color: color (' color must be in 3 or 6 digit hex format' )
83+ required: required (' Primary color is required' ),
84+ color: color (' Must be in 3 or 6 digit hex format' )
7785 },
7886 sidebar: {
79- required: required (' sidebar color is required' ),
80- color: color (' color must be in 3 or 6 digit hex format' )
87+ required: required (' Sidebar color is required' ),
88+ color: color (' Must be in 3 or 6 digit hex format' )
8189 },
8290 bbb_background: {
8391 required: required (' BBB background color is required' ),
84- color: color (' color must be in 3 or 6 digit hex format' )
92+ color: color (' Must be in 3 or 6 digit hex format' )
8593 },
8694 },
8795 logo: {
8896 url: {
89- url: url (' must be a valid url ' )
97+ url: url (' Must be a valid URL ' )
9098 }
9199 },
92100 streamOfflineImage: {
93- url: url (' must be a valid url ' )
101+ url: url (' Must be a valid URL ' )
94102 }
95103 },
96104 }
@@ -111,6 +119,16 @@ export default {
111119 }
112120 },
113121 methods: {
122+ _applyThemePreview () {
123+ if (! this .config ) return
124+ const themePayload = {
125+ colors: {... DEFAULT_COLORS, ... this .config .theme .colors },
126+ logo: {... DEFAULT_LOGO, ... this .config .theme .logo },
127+ streamOfflineImage: this .config .theme .streamOfflineImage ?? null ,
128+ identicons: {... DEFAULT_IDENTICONS, ... this .config .theme .identicons }
129+ }
130+ applyThemeConfig (themePayload)
131+ },
114132 async save () {
115133 this .v$ .$touch ()
116134 if (this .v$ .$invalid ) return
@@ -127,13 +145,7 @@ export default {
127145 this .saving = true
128146 try {
129147 await api .call (' world.config.patch' , {theme: this .config .theme })
130- const themePayload = {
131- colors: {... DEFAULT_COLORS, ... this .config .theme .colors },
132- logo: {... DEFAULT_LOGO, ... this .config .theme .logo },
133- streamOfflineImage: this .config .theme .streamOfflineImage ?? null ,
134- identicons: {... DEFAULT_IDENTICONS, ... this .config .theme .identicons }
135- }
136- applyThemeConfig (themePayload)
148+ this ._applyThemePreview ()
137149 } catch (error) {
138150 console .error (error .apiError || error)
139151 this .error = error .apiError ? .code || error .message || error .toString ()
0 commit comments