-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #286 from torusresearch/feat/add-whitelabel-palett…
…e-generation-algorithm Create new whitelabel palette generation algorithm
- Loading branch information
Showing
12 changed files
with
5,203 additions
and
6,220 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"$schema": "node_modules/lerna/schemas/lerna-schema.json", | ||
"version": "6.2.3", | ||
"version": "6.2.5", | ||
"npmClient": "npm" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Color from "color"; | ||
|
||
import { type WHITE_LABEL_THEME } from "./interfaces"; | ||
|
||
function getColorsList(colorsAmount = 3, colorsShiftAmount = 50, mixColor = "black", rotate = 0, saturation = 20, mainColor = "#0346ff") { | ||
const colorsList = []; | ||
|
||
let step; | ||
for (step = 0; step < colorsAmount; step += 1) { | ||
colorsList.push( | ||
Color(mainColor) | ||
.rotate(((step + 1) / colorsAmount) * -rotate) | ||
.saturate(((step + 1) / colorsAmount) * (saturation / 100)) | ||
.mix(Color(mixColor), ((colorsShiftAmount / 100) * (step + 1)) / colorsAmount) | ||
.hex() | ||
); | ||
} | ||
|
||
return colorsList; | ||
} | ||
|
||
function generateWhiteLabelTheme(primary: string) { | ||
const darkSet = getColorsList(3, 50, "black", 0, 20, primary); | ||
const lightSet = getColorsList(6, 85, "white", 0, 20, primary); | ||
return [...darkSet.reverse(), ...[primary], ...lightSet]; | ||
} | ||
|
||
function applyWhiteLabelTheme(rootElement: HTMLElement, theme: WHITE_LABEL_THEME) { | ||
if (theme.primary) { | ||
const themeSet = generateWhiteLabelTheme(theme.primary); | ||
|
||
rootElement.style.setProperty("--app-primary-900", themeSet[0]); | ||
rootElement.style.setProperty("--app-primary-800", themeSet[1]); | ||
rootElement.style.setProperty("--app-primary-700", themeSet[2]); | ||
rootElement.style.setProperty("--app-primary-600", themeSet[3]); | ||
rootElement.style.setProperty("--app-primary-500", themeSet[4]); | ||
rootElement.style.setProperty("--app-primary-400", themeSet[5]); | ||
rootElement.style.setProperty("--app-primary-300", themeSet[6]); | ||
rootElement.style.setProperty("--app-primary-200", themeSet[7]); | ||
rootElement.style.setProperty("--app-primary-100", themeSet[8]); | ||
rootElement.style.setProperty("--app-primary-50", themeSet[9]); | ||
} | ||
|
||
if (theme.onPrimary) { | ||
rootElement.style.setProperty("--app-on-primary", theme.onPrimary); | ||
} | ||
} | ||
|
||
export { applyWhiteLabelTheme }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters