Skip to content

Commit

Permalink
feat(config): Add light and dark colors to configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
sullivanpj committed Apr 13, 2024
1 parent 9821ed5 commit 654cd1d
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pre-commit:
schema-gen:
files: "git diff --name-only HEAD @{push}"
glob: "**/schema.ts"
run: 'nx generate @storm-software/workspace-tools:config-schema --outputFile="packages/config/schema/schema.json"'
run: 'pnpm nx generate @storm-software/workspace-tools:config-schema --outputFile="packages/config/schema/schema.json"'
stage_fixed: true
validate:
glob: "**/*"
Expand Down
2 changes: 1 addition & 1 deletion packages/config-tools/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export { getConfigFile };
/**
* Load the config file values for the current Storm workspace into environment variables
*/
declare function loadStormConfig(workspaceRoot?: string): Promise<void>;
declare function loadStormConfig(workspaceRoot?: string): Promise<StormConfig>;
export { loadStormConfig };

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/config-tools/src/env/get-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export const getConfigEnv = (): DeepPartial<StormConfig> => {
: undefined,
colors: {
primary: process.env[`${prefix}COLOR_PRIMARY`],
background: process.env[`${prefix}COLOR_BACKGROUND`],
dark: process.env[`${prefix}COLOR_DARK`],
light: process.env[`${prefix}COLOR_LIGHT`],
success: process.env[`${prefix}COLOR_SUCCESS`],
info: process.env[`${prefix}COLOR_INFO`],
warning: process.env[`${prefix}COLOR_WARNING`],
Expand Down
7 changes: 5 additions & 2 deletions packages/config-tools/src/env/set-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,11 @@ export const setConfigEnv = (config: StormConfig) => {
if (config.colors.primary) {
process.env[`${prefix}COLOR_PRIMARY`] = config.colors.primary;
}
if (config.colors.background) {
process.env[`${prefix}COLOR_BACKGROUND`] = config.colors.background;
if (config.colors.dark) {
process.env[`${prefix}COLOR_DARK`] = config.colors.dark;
}
if (config.colors.light) {
process.env[`${prefix}COLOR_LIGHT`] = config.colors.light;
}
if (config.colors.success) {
process.env[`${prefix}COLOR_SUCCESS`] = config.colors.success;
Expand Down
3 changes: 2 additions & 1 deletion packages/config-tools/src/utilities/get-default-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { findWorkspaceRoot } from "./find-workspace-root";
*/
export const DEFAULT_COLOR_CONFIG: ColorConfig = {
primary: "#1fb2a6",
background: "#1d232a",
dark: "#1d232a",
light: "#f4f4f5",
success: "#087f5b",
info: "#0ea5e9",
warning: "#fcc419",
Expand Down
3 changes: 2 additions & 1 deletion packages/config/presets/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
],
"colors": {
"primary": "#1fb2a6",
"background": "#1d232a",
"dark": "#1d232a",
"light": "#f4f4f5",
"success": "#087f5b",
"info": "#0ea5e9",
"warning": "#fcc419",
Expand Down
20 changes: 14 additions & 6 deletions packages/config/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,30 @@ import z from "zod";
*/
export const ColorConfigSchema = z
.object({
primary: z
dark: z
.string()
.trim()
.toLowerCase()
.regex(/^#([0-9a-f]{3}){1,2}$/i)
.length(7)
.default("#0ea5e9")
.describe("The primary color of the workspace"),
background: z
.default("#1d232a")
.describe("The dark background color of the workspace"),
light: z
.string()
.trim()
.toLowerCase()
.regex(/^#([0-9a-f]{3}){1,2}$/i)
.length(7)
.default("#1d232a")
.describe("The background color of the workspace"),
.default("#f4f4f5")
.describe("The light background color of the workspace"),
primary: z
.string()
.trim()
.toLowerCase()
.regex(/^#([0-9a-f]{3}){1,2}$/i)
.length(7)
.default("#0ea5e9")
.describe("The primary color of the workspace"),
success: z
.string()
.trim()
Expand Down

0 comments on commit 654cd1d

Please sign in to comment.