@crowdin/themes-converter
Advanced tools
Comparing version
import { Theme } from './models'; | ||
import * as Color from 'color'; | ||
export { Theme } from './models'; | ||
export { validate } from './validate'; | ||
export declare const convert: (theme: Theme) => { | ||
@@ -29,4 +31,4 @@ '--crowdin-backgrounds-color': string; | ||
'--crowdin-checked-item-bg': string; | ||
'--crowdin-border-color': string; | ||
'--crowdin-dark-border-color': string; | ||
'--crowdin-border-color': string | Color<string>; | ||
'--crowdin-dark-border-color': string | Color<string>; | ||
'--crowdin-icons-color': string; | ||
@@ -100,2 +102,4 @@ '--crowdin-primary-blue-gray-05': string; | ||
'--crowdin-find-replace-highlight-bg': string; | ||
'--crowdin-special-light-color': string; | ||
'--crowdin-special-light-bg': string; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.convert = void 0; | ||
exports.convert = exports.validate = void 0; | ||
const polished_1 = require("polished"); | ||
const validate_1 = require("./validate"); | ||
const Color = require("color"); | ||
var validate_2 = require("./validate"); | ||
Object.defineProperty(exports, "validate", { enumerable: true, get: function () { return validate_2.validate; } }); | ||
const convert = (theme) => { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38; | ||
try { | ||
@@ -36,2 +38,4 @@ (0, validate_1.validate)(theme); | ||
const findAndReplaceHighlightBg = Color(theme.base.highlights.findAndReplaceHighlightBg); | ||
const specialLightColor = Color(theme.base.highlights.specialLightColor); | ||
const specialLightBg = Color(theme.base.highlights.specialLightBg); | ||
return { | ||
@@ -48,27 +52,31 @@ '--crowdin-backgrounds-color': `${baseBackground.red()}, ${baseBackground.green()}, ${baseBackground.blue()}`, | ||
'--crowdin-body-bg': 'var(--crowdin-level-1-bg)', | ||
'--crowdin-scrollbar-thumb-bg': 'var(--crowdin-level-3-bg)', | ||
'--crowdin-scrollbar-track-bg': 'var(--crowdin-level-1-bg)', | ||
'--crowdin-tooltip-bg': 'var(--crowdin-level-0-bg)', | ||
'--crowdin-header-bg': ((_b = theme.base.commonUi) === null || _b === void 0 ? void 0 : _b.headerBackground) | ||
? Color(theme.base.commonUi.headerBackground).hex() | ||
'--crowdin-scrollbar-thumb-bg': ((_b = theme.base.scrollBars) === null || _b === void 0 ? void 0 : _b.thumbColor) | ||
? Color(theme.base.scrollBars.thumbColor).hex() | ||
: 'var(--crowdin-level-3-bg)', | ||
'--crowdin-subheader-bg': ((_c = theme.base.commonUi) === null || _c === void 0 ? void 0 : _c.subHeaderBackground) | ||
? Color(theme.base.commonUi.subHeaderBackground).hex() | ||
'--crowdin-scrollbar-track-bg': ((_c = theme.base.scrollBars) === null || _c === void 0 ? void 0 : _c.trackColor) | ||
? Color(theme.base.scrollBars.trackColor).hex() | ||
: 'var(--crowdin-level-1-bg)', | ||
'--crowdin-tooltip-bg': 'var(--crowdin-mask-080)', | ||
'--crowdin-header-bg': ((_d = theme.base.commonUi) === null || _d === void 0 ? void 0 : _d.headerBackground) | ||
? theme.base.commonUi.headerBackground | ||
: 'var(--crowdin-level-3-bg)', | ||
'--crowdin-subheader-bg': ((_e = theme.base.commonUi) === null || _e === void 0 ? void 0 : _e.subHeaderBackground) | ||
? theme.base.commonUi.subHeaderBackground | ||
: 'var(--crowdin-level-2-bg)', | ||
'--crowdin-strings-panel-bg': ((_d = theme.base.commonUi) === null || _d === void 0 ? void 0 : _d.checkedStringBackground) | ||
'--crowdin-strings-panel-bg': ((_f = theme.base.commonUi) === null || _f === void 0 ? void 0 : _f.mainContentBackground) | ||
? theme.base.commonUi.mainContentBackground | ||
: 'var(--crowdin-level-1-bg)', | ||
'--crowdin-checked-string-bg': ((_g = theme.base.commonUi) === null || _g === void 0 ? void 0 : _g.checkedStringBackground) | ||
? Color(theme.base.commonUi.checkedStringBackground).hex() | ||
: 'var(--crowdin-level-1-bg)', | ||
'--crowdin-checked-string-bg': ((_e = theme.base.commonUi) === null || _e === void 0 ? void 0 : _e.mainContentBackground) | ||
? Color(theme.base.commonUi.mainContentBackground).hex() | ||
: 'var(--crowdin-level-3-bg)', | ||
'--crowdin-title-color': ((_f = theme.base.typeface) === null || _f === void 0 ? void 0 : _f.baseColor) | ||
'--crowdin-title-color': ((_h = theme.base.typeface) === null || _h === void 0 ? void 0 : _h.baseColor) | ||
? Color(theme.base.typeface.baseColor).hex() | ||
: 'rgba(var(--crowdin-typeface-color), 1)', | ||
'--crowdin-body-color': ((_g = theme.base.typeface) === null || _g === void 0 ? void 0 : _g.bodyColor) | ||
'--crowdin-body-color': ((_j = theme.base.typeface) === null || _j === void 0 ? void 0 : _j.bodyColor) | ||
? Color(theme.base.typeface.bodyColor).hex() | ||
: 'rgba(var(--crowdin-typeface-color), .87)', | ||
'--crowdin-text-muted': ((_h = theme.base.typeface) === null || _h === void 0 ? void 0 : _h.mutedColor) | ||
'--crowdin-text-muted': ((_k = theme.base.typeface) === null || _k === void 0 ? void 0 : _k.mutedColor) | ||
? Color(theme.base.typeface.mutedColor).hex() | ||
: 'rgba(var(--crowdin-typeface-color), .54)', | ||
'--crowdin-text-disabled': ((_j = theme.base.typeface) === null || _j === void 0 ? void 0 : _j.disabledColor) | ||
'--crowdin-text-disabled': ((_l = theme.base.typeface) === null || _l === void 0 ? void 0 : _l.disabledColor) | ||
? Color(theme.base.typeface.disabledColor).hex() | ||
@@ -80,5 +88,9 @@ : 'rgba(var(--crowdin-typeface-color), .3)', | ||
'--crowdin-checked-item-bg': 'var(--crowdin-dropdown-hover-bg)', | ||
'--crowdin-border-color': 'var(--crowdin-gray-01)', | ||
'--crowdin-dark-border-color': 'rgba(var(--crowdin-blacks), .12)', | ||
'--crowdin-icons-color': ((_k = theme.base.typeface) === null || _k === void 0 ? void 0 : _k.iconsColor) | ||
'--crowdin-border-color': ((_m = theme.base.borders) === null || _m === void 0 ? void 0 : _m.borderColor) | ||
? Color(theme.base.borders.borderColor) | ||
: 'var(--crowdin-gray-01)', | ||
'--crowdin-dark-border-color': ((_o = theme.base.borders) === null || _o === void 0 ? void 0 : _o.darkBorderColor) | ||
? Color(theme.base.borders.darkBorderColor) | ||
: 'rgba(var(--crowdin-blacks), .12)', | ||
'--crowdin-icons-color': ((_p = theme.base.typeface) === null || _p === void 0 ? void 0 : _p.iconsColor) | ||
? Color(theme.base.typeface.iconsColor).hex() | ||
@@ -110,9 +122,9 @@ : 'var(--crowdin-title-color)', | ||
? Color(theme.accents.danger.backgroundColor).hex() | ||
: `rgba(${dangerAccent.rgb()}, .1)`, | ||
'--crowdin-danger-bg-level-1': `rgba(${dangerAccent.rgb()}, .15)`, | ||
'--crowdin-danger-bg-level-2': `rgba(${dangerAccent.rgb()}, .30)`, | ||
: `rgba(${dangerAccent.rgb().array()}, .1)`, | ||
'--crowdin-danger-bg-level-1': `rgba(${dangerAccent.rgb().array()}, .15)`, | ||
'--crowdin-danger-bg-level-2': `rgba(${dangerAccent.rgb().array()}, .30)`, | ||
'--crowdin-info': infoAccent.hex(), | ||
'--crowdin-info-bg': theme.accents.info.backgroundColor | ||
? Color(theme.accents.info.backgroundColor).hex() | ||
: `rgba(${infoAccent.rgb()}, .1)`, | ||
: `rgba(${infoAccent.rgb().array()}, .1)`, | ||
'--crowdin-info-link': (0, polished_1.lighten)(0.1, infoAccent.hex()), | ||
@@ -122,3 +134,3 @@ '--crowdin-warning': warningAccent.hex(), | ||
? Color(theme.accents.warning.backgroundColor).hex() | ||
: `rgba(${warningAccent.rgb()}, .2)`, | ||
: `rgba(${warningAccent.rgb().array()}, .2)`, | ||
'--crowdin-warning-link': (0, polished_1.lighten)(0.1, warningAccent.hex()), | ||
@@ -128,76 +140,76 @@ '--crowdin-success': successAccent.hex(), | ||
? Color(theme.accents.success.backgroundColor).hex() | ||
: `rgba(${successAccent.rgb()}, .12)`, | ||
: `rgba(${successAccent.rgb().array()}, .12)`, | ||
'--crowdin-success-link': (0, polished_1.lighten)(0.1, successAccent.hex()), | ||
'--crowdin-btn-color': ((_m = (_l = theme.button) === null || _l === void 0 ? void 0 : _l.default) === null || _m === void 0 ? void 0 : _m.btnColor) | ||
'--crowdin-btn-color': ((_r = (_q = theme.button) === null || _q === void 0 ? void 0 : _q.default) === null || _r === void 0 ? void 0 : _r.btnColor) | ||
? Color(theme.button.default.btnColor).hex() | ||
: 'var(--crowdin-text-muted)', | ||
'--crowdin-btn-hover-color': ((_p = (_o = theme.button) === null || _o === void 0 ? void 0 : _o.default) === null || _p === void 0 ? void 0 : _p.btnHoverColor) | ||
'--crowdin-btn-hover-color': ((_t = (_s = theme.button) === null || _s === void 0 ? void 0 : _s.default) === null || _t === void 0 ? void 0 : _t.btnHoverColor) | ||
? Color(theme.button.default.btnHoverColor).hex() | ||
: 'var(--crowdin-body-color)', | ||
'--crowdin-btn-border': ((_r = (_q = theme.button) === null || _q === void 0 ? void 0 : _q.default) === null || _r === void 0 ? void 0 : _r.btnBorder) | ||
'--crowdin-btn-border': ((_v = (_u = theme.button) === null || _u === void 0 ? void 0 : _u.default) === null || _v === void 0 ? void 0 : _v.btnBorder) | ||
? Color(theme.button.default.btnBorder).hex() | ||
: 'rgba(var(--crowdin-blacks), .1)', | ||
'--crowdin-btn-modal-border': ((_t = (_s = theme.button) === null || _s === void 0 ? void 0 : _s.default) === null || _t === void 0 ? void 0 : _t.btnModalBorder) | ||
'--crowdin-btn-modal-border': ((_x = (_w = theme.button) === null || _w === void 0 ? void 0 : _w.default) === null || _x === void 0 ? void 0 : _x.btnModalBorder) | ||
? Color(theme.button.default.btnModalBorder).hex() | ||
: 'var(--crowdin-btn-border)', | ||
'--crowdin-btn-hover-border': ((_v = (_u = theme.button) === null || _u === void 0 ? void 0 : _u.default) === null || _v === void 0 ? void 0 : _v.btnHoverBorder) | ||
'--crowdin-btn-hover-border': ((_z = (_y = theme.button) === null || _y === void 0 ? void 0 : _y.default) === null || _z === void 0 ? void 0 : _z.btnHoverBorder) | ||
? Color(theme.button.default.btnHoverBorder).hex() | ||
: 'var(--crowdin-btn-border)', | ||
'--crowdin-btn-active-border': ((_x = (_w = theme.button) === null || _w === void 0 ? void 0 : _w.default) === null || _x === void 0 ? void 0 : _x.btnActiveBorder) | ||
'--crowdin-btn-active-border': ((_1 = (_0 = theme.button) === null || _0 === void 0 ? void 0 : _0.default) === null || _1 === void 0 ? void 0 : _1.btnActiveBorder) | ||
? Color(theme.button.default.btnActiveBorder).hex() | ||
: 'var(--crowdin-btn-border)', | ||
'--crowdin-btn-disabled-border': ((_z = (_y = theme.button) === null || _y === void 0 ? void 0 : _y.default) === null || _z === void 0 ? void 0 : _z.btnDisabledBorder) | ||
'--crowdin-btn-disabled-border': ((_3 = (_2 = theme.button) === null || _2 === void 0 ? void 0 : _2.default) === null || _3 === void 0 ? void 0 : _3.btnDisabledBorder) | ||
? Color(theme.button.default.btnDisabledBorder).hex() | ||
: 'var(--crowdin-btn-hover-border)', | ||
'--crowdin-btn-bg': ((_1 = (_0 = theme.button) === null || _0 === void 0 ? void 0 : _0.default) === null || _1 === void 0 ? void 0 : _1.btnBg) | ||
'--crowdin-btn-bg': ((_5 = (_4 = theme.button) === null || _4 === void 0 ? void 0 : _4.default) === null || _5 === void 0 ? void 0 : _5.btnBg) | ||
? Color(theme.button.default.btnBg).hex() | ||
: 'var(--crowdin-level-3-bg)', | ||
'--crowdin-btn-hover-bg': ((_3 = (_2 = theme.button) === null || _2 === void 0 ? void 0 : _2.default) === null || _3 === void 0 ? void 0 : _3.btnHoverBg) | ||
'--crowdin-btn-hover-bg': ((_7 = (_6 = theme.button) === null || _6 === void 0 ? void 0 : _6.default) === null || _7 === void 0 ? void 0 : _7.btnHoverBg) | ||
? Color(theme.button.default.btnHoverBg).hex() | ||
: 'var(--crowdin-gray-005)', | ||
'--crowdin-btn-active-bg': ((_5 = (_4 = theme.button) === null || _4 === void 0 ? void 0 : _4.default) === null || _5 === void 0 ? void 0 : _5.btnActiveBg) | ||
'--crowdin-btn-active-bg': ((_9 = (_8 = theme.button) === null || _8 === void 0 ? void 0 : _8.default) === null || _9 === void 0 ? void 0 : _9.btnActiveBg) | ||
? Color(theme.button.default.btnActiveBg).hex() | ||
: 'rgba(var(--crowdin-blacks), .15)', | ||
'--crowdin-btn-disabled-bg': ((_7 = (_6 = theme.button) === null || _6 === void 0 ? void 0 : _6.default) === null || _7 === void 0 ? void 0 : _7.btnDisabledBg) | ||
'--crowdin-btn-disabled-bg': ((_11 = (_10 = theme.button) === null || _10 === void 0 ? void 0 : _10.default) === null || _11 === void 0 ? void 0 : _11.btnDisabledBg) | ||
? Color(theme.button.default.btnDisabledBg).hex() | ||
: 'var(--crowdin-checked-item-bg)', | ||
'--crowdin-primary-btn-color': ((_9 = (_8 = theme.button) === null || _8 === void 0 ? void 0 : _8.primary) === null || _9 === void 0 ? void 0 : _9.btnColor) | ||
'--crowdin-primary-btn-color': ((_13 = (_12 = theme.button) === null || _12 === void 0 ? void 0 : _12.primary) === null || _13 === void 0 ? void 0 : _13.btnColor) | ||
? Color(theme.button.primary.btnColor).hex() | ||
: 'var(--crowdin-white-primary-mix, var(--crowdin-white))', | ||
'--crowdin-primary-btn-border': ((_11 = (_10 = theme.button) === null || _10 === void 0 ? void 0 : _10.primary) === null || _11 === void 0 ? void 0 : _11.btnBorder) | ||
'--crowdin-primary-btn-border': ((_15 = (_14 = theme.button) === null || _14 === void 0 ? void 0 : _14.primary) === null || _15 === void 0 ? void 0 : _15.btnBorder) | ||
? Color(theme.button.primary.btnBorder).hex() | ||
: 'var(--crowdin-primary)', | ||
'--crowdin-primary-btn-bg': ((_13 = (_12 = theme.button) === null || _12 === void 0 ? void 0 : _12.primary) === null || _13 === void 0 ? void 0 : _13.btnBg) | ||
'--crowdin-primary-btn-bg': ((_17 = (_16 = theme.button) === null || _16 === void 0 ? void 0 : _16.primary) === null || _17 === void 0 ? void 0 : _17.btnBg) | ||
? Color(theme.button.primary.btnBg).hex() | ||
: 'var(--crowdin-primary)', | ||
'--crowdin-primary-btn-hover-bg': ((_15 = (_14 = theme.button) === null || _14 === void 0 ? void 0 : _14.primary) === null || _15 === void 0 ? void 0 : _15.btnHoverBg) | ||
'--crowdin-primary-btn-hover-bg': ((_19 = (_18 = theme.button) === null || _18 === void 0 ? void 0 : _18.primary) === null || _19 === void 0 ? void 0 : _19.btnHoverBg) | ||
? Color(theme.button.primary.btnHoverBg).hex() | ||
: 'color-mix(in srgb, var(--crowdin-primary-btn-bg) 90%, var(--crowdin-white))', | ||
'--crowdin-primary-btn-active-bg': ((_17 = (_16 = theme.button) === null || _16 === void 0 ? void 0 : _16.primary) === null || _17 === void 0 ? void 0 : _17.btnActiveBg) | ||
'--crowdin-primary-btn-active-bg': ((_21 = (_20 = theme.button) === null || _20 === void 0 ? void 0 : _20.primary) === null || _21 === void 0 ? void 0 : _21.btnActiveBg) | ||
? Color(theme.button.primary.btnActiveBg).hex() | ||
: 'color-mix(in srgb, var(--crowdin-primary-btn-bg) 90%, var(--crowdin-black))', | ||
'--crowdin-danger-btn-bg': ((_19 = (_18 = theme.button) === null || _18 === void 0 ? void 0 : _18.danger) === null || _19 === void 0 ? void 0 : _19.btnBg) | ||
'--crowdin-danger-btn-bg': ((_23 = (_22 = theme.button) === null || _22 === void 0 ? void 0 : _22.danger) === null || _23 === void 0 ? void 0 : _23.btnBg) | ||
? Color(theme.button.danger.btnBg).hex() | ||
: (0, polished_1.darken)(0.1, dangerAccent.hex()), | ||
'--crowdin-danger-btn-hover-bg': ((_21 = (_20 = theme.button) === null || _20 === void 0 ? void 0 : _20.danger) === null || _21 === void 0 ? void 0 : _21.btnHoverBg) | ||
'--crowdin-danger-btn-hover-bg': ((_25 = (_24 = theme.button) === null || _24 === void 0 ? void 0 : _24.danger) === null || _25 === void 0 ? void 0 : _25.btnHoverBg) | ||
? Color(theme.button.danger.btnHoverBg).hex() | ||
: 'var(--crowdin-danger)', | ||
'--crowdin-danger-btn-border': ((_23 = (_22 = theme.button) === null || _22 === void 0 ? void 0 : _22.danger) === null || _23 === void 0 ? void 0 : _23.btnBorder) | ||
'--crowdin-danger-btn-border': ((_27 = (_26 = theme.button) === null || _26 === void 0 ? void 0 : _26.danger) === null || _27 === void 0 ? void 0 : _27.btnBorder) | ||
? Color(theme.button.danger.btnBorder).hex() | ||
: (0, polished_1.darken)(0.3, dangerAccent.hex()), | ||
'--crowdin-danger-btn-hover-border': ((_25 = (_24 = theme.button) === null || _24 === void 0 ? void 0 : _24.danger) === null || _25 === void 0 ? void 0 : _25.btnHoverBorder) | ||
'--crowdin-danger-btn-hover-border': ((_29 = (_28 = theme.button) === null || _28 === void 0 ? void 0 : _28.danger) === null || _29 === void 0 ? void 0 : _29.btnHoverBorder) | ||
? Color(theme.button.danger.btnHoverBorder).hex() | ||
: 'var(--crowdin-danger-btn-border)', | ||
'--crowdin-icon-btn-bg': ((_27 = (_26 = theme.button) === null || _26 === void 0 ? void 0 : _26.icon) === null || _27 === void 0 ? void 0 : _27.btnBg) ? Color(theme.button.icon.btnBg).hex() : 'transparent', | ||
'--crowdin-icon-btn-border': ((_29 = (_28 = theme.button) === null || _28 === void 0 ? void 0 : _28.icon) === null || _29 === void 0 ? void 0 : _29.btnBorder) | ||
'--crowdin-icon-btn-bg': ((_31 = (_30 = theme.button) === null || _30 === void 0 ? void 0 : _30.icon) === null || _31 === void 0 ? void 0 : _31.btnBg) ? Color(theme.button.icon.btnBg).hex() : 'transparent', | ||
'--crowdin-icon-btn-border': ((_33 = (_32 = theme.button) === null || _32 === void 0 ? void 0 : _32.icon) === null || _33 === void 0 ? void 0 : _33.btnBorder) | ||
? Color(theme.button.icon.btnBorder).hex() | ||
: 'transparent', | ||
'--crowdin-icon-btn-hover-border': ((_31 = (_30 = theme.button) === null || _30 === void 0 ? void 0 : _30.icon) === null || _31 === void 0 ? void 0 : _31.btnHoverBorder) | ||
'--crowdin-icon-btn-hover-border': ((_35 = (_34 = theme.button) === null || _34 === void 0 ? void 0 : _34.icon) === null || _35 === void 0 ? void 0 : _35.btnHoverBorder) | ||
? Color(theme.button.icon.btnHoverBorder).hex() | ||
: 'var(--crowdin-btn-hover-border)', | ||
'--crowdin-icon-btn-active-border': ((_33 = (_32 = theme.button) === null || _32 === void 0 ? void 0 : _32.icon) === null || _33 === void 0 ? void 0 : _33.btnActiveBorder) | ||
'--crowdin-icon-btn-active-border': ((_37 = (_36 = theme.button) === null || _36 === void 0 ? void 0 : _36.icon) === null || _37 === void 0 ? void 0 : _37.btnActiveBorder) | ||
? Color(theme.button.icon.btnActiveBorder).hex() | ||
: 'var(--crowdin-btn-active-border)', | ||
'--crowdin-main-menu-bg': ((_34 = theme.base.commonUi) === null || _34 === void 0 ? void 0 : _34.mainMenuBackground) | ||
? Color(theme.base.commonUi.mainMenuBackground).hex() | ||
'--crowdin-main-menu-bg': ((_38 = theme.base.commonUi) === null || _38 === void 0 ? void 0 : _38.mainMenuBackground) | ||
? theme.base.commonUi.mainMenuBackground | ||
: 'var(--crowdin-level-3-bg)', | ||
@@ -218,4 +230,6 @@ '--crowdin-tab-active-bg': 'rgba(var(--crowdin-primaries-color), .5)', | ||
'--crowdin-find-replace-highlight-bg': findAndReplaceHighlightBg.hex(), | ||
'--crowdin-special-light-color': specialLightColor.hex(), | ||
'--crowdin-special-light-bg': specialLightBg.hex(), | ||
}; | ||
}; | ||
exports.convert = convert; |
export interface Theme { | ||
themeMode: 'light' | 'dark'; | ||
primaryAccent: string; | ||
@@ -14,2 +15,4 @@ base: BaseTheme; | ||
commonUi?: CommonUi; | ||
scrollBars?: ScrollBars; | ||
borders?: Borders; | ||
} | ||
@@ -30,2 +33,10 @@ interface Typeface { | ||
} | ||
interface ScrollBars { | ||
thumbColor?: string; | ||
trackColor?: string; | ||
} | ||
interface Borders { | ||
borderColor?: string; | ||
darkBorderColor?: string; | ||
} | ||
interface StringStatus { | ||
@@ -44,2 +55,4 @@ translated: string; | ||
findAndReplaceHighlightBg: string; | ||
specialLightColor: string; | ||
specialLightBg: string; | ||
tagColorHover?: string; | ||
@@ -46,0 +59,0 @@ tagBgHover?: string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validate = void 0; | ||
const Color = require("color"); | ||
const excludePaths = [ | ||
'themeMode', | ||
'base.commonUi.headerBackground', | ||
'base.commonUi.subHeaderBackground', | ||
'base.commonUi.mainContentBackground', | ||
'base.commonUi.mainMenuBackground', | ||
]; | ||
const isValidColor = (value) => { | ||
try { | ||
Color(value); | ||
return true; | ||
} | ||
catch (e) { | ||
return false; | ||
} | ||
}; | ||
const validateThemeColors = (obj, path = '') => { | ||
for (const key in obj) { | ||
const currentPath = path ? `${path}.${key}` : key; | ||
if (excludePaths.includes(currentPath)) { | ||
continue; | ||
} | ||
if (typeof obj[key] === 'string') { | ||
if (!isValidColor(obj[key])) { | ||
throw new Error(`Invalid color found at ${currentPath}: ${obj[key]}`); | ||
} | ||
} | ||
else if (typeof obj[key] === 'object') { | ||
validateThemeColors(obj[key], currentPath); | ||
} | ||
} | ||
}; | ||
const validate = (theme) => { | ||
@@ -8,2 +41,5 @@ if (!theme) { | ||
} | ||
if (!theme.themeMode) { | ||
throw new Error('themeMode is required.'); | ||
} | ||
if (!theme.primaryAccent) { | ||
@@ -52,2 +88,8 @@ throw new Error('primaryAccent is required.'); | ||
} | ||
if (!theme.base.highlights.specialLightColor) { | ||
throw new Error('base.highlights.specialLightColor is required.'); | ||
} | ||
if (!theme.base.highlights.specialLightBg) { | ||
throw new Error('base.highlights.specialLightBg is required.'); | ||
} | ||
} | ||
@@ -72,3 +114,4 @@ } | ||
} | ||
validateThemeColors(theme); | ||
}; | ||
exports.validate = validate; |
{ | ||
"name": "@crowdin/themes-converter", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Converting json theme declaration to css variables", | ||
@@ -28,5 +28,2 @@ "main": "dist/index.js", | ||
"license": "ISC", | ||
"publishConfig": { | ||
"access": "restricted" | ||
}, | ||
"dependencies": { | ||
@@ -33,0 +30,0 @@ "color": "^4.2.3", |
@@ -135,2 +135,13 @@ # Crowdin theme converter | ||
} | ||
``` | ||
## Advanced Background Customization | ||
Certain properties within our theming configuration are designed to support a wide array of CSS background values. This includes not only standard and custom colors but also more complex definitions such as gradients, images, and other CSS background properties. | ||
``` | ||
'base.commonUi.headerBackground', | ||
'base.commonUi.subHeaderBackground', | ||
'base.commonUi.mainContentBackground', | ||
'base.commonUi.mainMenuBackground', | ||
``` |
34034
10.85%536
16.02%146
8.15%