Skip to content

Commit

Permalink
fix(core): branding css cannot override PatternFly styles with :root …
Browse files Browse the repository at this point in the history
…selector

Fix #787
  • Loading branch information
tadayosi committed Feb 21, 2024
1 parent 470a6cb commit db6e857
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
19 changes: 19 additions & 0 deletions app/public/branding-example.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,27 @@
.pf-c-login,
.pf-c-about-modal-box__hero {
background-image: url(img/background.svg) !important;
background-size: cover;
}

#hawtio-header-brand .pf-c-brand {
height: 50px;
}

/* Example of global style overrides:
:root {
--pf-global--primary-color--100: #b21054;
--pf-global--primary-color--200: #b24e78;
--pf-global--primary-color--light-100: #b24e78;
--pf-global--primary-color--dark-100: #b21054;
--pf-global--active-color--100: #b21054;
--pf-global--active-color--200: #b24e78;
--pf-global--active-color--300: #b24e78;
--pf-global--active-color--400: #b24e78;
--pf-global--link--Color: #b21054;
--pf-global--link--Color--hover: #b24e78;
--pf-v5-global--primary-color--100: #b21054;
--pf-v5-global--primary-color--200: #b24e78;
--pf-v5-global--link--Color: var(--pf-v5-global--danger-color--100);
}
*/
11 changes: 8 additions & 3 deletions packages/hawtio/src/core/config-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ class ConfigManager {
applied = true
}
if (branding.css) {
this.updateHref('#branding', branding.css)
// Branding css should be pushed to last to override the builtin PatternFly styles
this.updateHref('#branding', branding.css, true)
applied = true
}
if (branding.favicon) {
Expand All @@ -189,11 +190,15 @@ class ConfigManager {
return applied
}

private updateHref(id: string, path: string): void {
log.info('Updating href for', id, '-', path)
private updateHref(id: string, path: string, moveToLast: boolean = false): void {
log.info('Updating href for', id, '-', path, moveToLast)
const elm = $(id)
elm.prop('disabled', true)
elm.attr({ href: path })
if (moveToLast) {
elm.remove()
$('head').append(elm)
}
elm.prop('disabled', false)
}

Expand Down

0 comments on commit db6e857

Please sign in to comment.