Skip to content

Commit

Permalink
fix(styles): introduce site colors as CSS variables (#1503)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcshzj authored Sep 19, 2023
1 parent 2aeeeb1 commit 0d951b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"sass": "^1.51.0",
"sgds-govtech": "^1.3.16",
"slugify": "^1.6.5",
"tinycolor2": "^1.6.0",
"toml": "^3.0.0",
"turndown": "^7.1.1",
"turndown-plugin-gfm": "^1.0.2",
Expand Down
7 changes: 7 additions & 0 deletions src/utils/siteColorUtils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from "axios"
import tinycolor from "tinycolor2"

// axios settings
axios.defaults.withCredentials = true
Expand Down Expand Up @@ -31,6 +32,7 @@ const createPageStyleSheet = (repoName, primaryColor, secondaryColor) => {
styleElement.setAttribute("title", styleTitle)
document.head.appendChild(styleElement)

const secondaryColorHover = tinycolor(secondaryColor).lighten(10).toString()
const customStyleSheet = getStyleSheet(styleTitle)

// breadcrumb - primary color
Expand Down Expand Up @@ -130,6 +132,11 @@ const createPageStyleSheet = (repoName, primaryColor, secondaryColor) => {
`.sgds-icon.bx-chevron-down:before { color: ${secondaryColor} !important;}`,
0
)

customStyleSheet.insertRule(
`:root { --site-primary-color: ${primaryColor} !important; --site-secondary-color: ${secondaryColor} !important; --site-secondary-color-hover: ${secondaryColorHover} !important;}`,
0
)
}

const getSiteColors = async (siteName) => {
Expand Down

0 comments on commit 0d951b0

Please sign in to comment.