Skip to content

Commit

Permalink
chore(ui): compute CSS properties for WDS tokens - WF-149
Browse files Browse the repository at this point in the history
  • Loading branch information
madeindjs committed Dec 16, 2024
1 parent 402d159 commit 3ff5303
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 44 deletions.
3 changes: 2 additions & 1 deletion src/ui/src/builder/BuilderApp.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="BuilderApp" tabindex="-1">
<div class="BuilderApp" tabindex="-1" :style="WDS_CSS_PROPERTIES">
<div
class="mainGrid"
:class="{ openPanels: ssbm.openPanels.value.size > 0 }"
Expand Down Expand Up @@ -81,6 +81,7 @@ import BuilderHeader from "./BuilderHeader.vue";
import BuilderTooltip from "./BuilderTooltip.vue";
import BuilderAsyncLoader from "./BuilderAsyncLoader.vue";
import BuilderPanelSwitcher from "./panels/BuilderPanelSwitcher.vue";
import { WDS_CSS_PROPERTIES } from "@/wds/tokens";
const BuilderSettings = defineAsyncComponent({
loader: () => import("./settings/BuilderSettings.vue"),
Expand Down
1 change: 0 additions & 1 deletion src/ui/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import VueDOMPurifyHTML from "vue-dompurify-html";
import { generateBuilderManager } from "./builder/builderManager.js";
import { generateCore } from "./core";
import "./fonts";
import "./wds/tokens.css";
import injectionKeys from "./injectionKeys";
import { setCaptureTabsDirective } from "./directives.js";

Expand Down
2 changes: 2 additions & 0 deletions src/ui/src/renderer/ComponentRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
changeRouteVarsInHash,
serializeParsedHash,
} from "@/core/navigation";
import { WDS_CSS_PROPERTIES } from "@/wds/tokens";
const wf = inject(injectionKeys.core);
const wfbm = inject(injectionKeys.builderManager);
Expand All @@ -59,6 +60,7 @@ const coreRootFields = templateEvaluator.getEvaluatedFields([
const rootStyle = computed(() => {
return {
...WDS_CSS_PROPERTIES,
"--accentColor": coreRootFields.accentColor?.value,
"--emptinessColor": coreRootFields.emptinessColor?.value,
"--containerBackgroundColor":
Expand Down
40 changes: 0 additions & 40 deletions src/ui/src/wds/tokens.css

This file was deleted.

19 changes: 17 additions & 2 deletions src/ui/src/wds/tokens.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { CSSProperties } from "vue";

/**
* Colors from [Writer's design system](https://www.figma.com/design/jgLDtwVwg3hReC1t4Vw20D/.WDS-Writer-Design-System?node-id=1-2)
*/
export const enum WdsColor {
export enum WdsColor {
White = "#ffffff",
Black = "#000000",

Expand Down Expand Up @@ -41,8 +43,21 @@ export const enum WdsColor {
/**
* Shadows from [Writer's design system](https://www.figma.com/design/jgLDtwVwg3hReC1t4Vw20D/.WDS-Writer-Design-System?node-id=1-14)
*/
export const enum WdsShadow {
export enum WdsShadow {
Box = "0px 2px 0px 0px #f3f3f3",
Menu = "0px 1px 8px 0px #bfcbff40",
Large = "0px 3px 40px 0px #acb9dc66",
}

export const WDS_CSS_PROPERTIES = Object.freeze<CSSProperties>(
Object.fromEntries([
...Object.entries(WdsColor).map(([key, value]) => [
`--wdsColor${key}`,
value,
]),
...Object.entries(WdsShadow).map(([key, value]) => [
`--wdsShadow${key}`,
value,
]),
]),
);

0 comments on commit 3ff5303

Please sign in to comment.