Skip to content
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
14 changes: 12 additions & 2 deletions apps/theming/src/components/UserPrimaryColor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,23 @@ export default defineComponent({
methods: {
t,

numberToHex(numeric: string) {
const parsed = Number.parseInt(numeric)
return parsed.toString(16).padStart(2, '0')
},

/**
* Global styles are reloaded so we might need to update the current value
*/
reload() {
const trigger = this.$refs.trigger as HTMLButtonElement
const newColor = window.getComputedStyle(trigger).backgroundColor
if (newColor.toLowerCase() !== this.primaryColor) {
let newColor = window.getComputedStyle(trigger).backgroundColor
// sometimes the browser returns the color in the "rgb(255, 132, 234)" format
const rgbMatch = newColor.replaceAll(/\s/g, '').match(/^rgba?\((\d+),(\d+),(\d+)/)
if (rgbMatch) {
newColor = `#${this.numberToHex(rgbMatch[1])}${this.numberToHex(rgbMatch[2])}${this.numberToHex(rgbMatch[3])}`
}
if (newColor.toLowerCase() !== this.primaryColor.toLowerCase()) {
this.primaryColor = newColor
}
},
Expand Down
4 changes: 2 additions & 2 deletions dist/theming-personal-theming.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/theming-personal-theming.js.map

Large diffs are not rendered by default.

Loading