-
Notifications
You must be signed in to change notification settings - Fork 733
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ref #807 We are gonna consolidate design token styles and local styles. On build (project) level there will be list of styles and list of style sources which are basically a group of styles to be referenced. These style sources can be local with mandatory tree id or token with optional tree id to scope a token on specific page instead of whole project. Tree will get new list of references to style sources. Here resulting types ```ts // Stored as Build.styles type StylesItem = { // same as before but instead of instanceId style is referenced through style source styleSourceId: string, breakpointId, property, value } type StyleSourcesToken = { type: token id: string treeId?: string name: string } type StyleSourcesLocal = { type: local id: string treeId: string name: string } // Stored as Build.styleSources type StyleSourcesItem = StyleSourcesToken | StyleSourcesLocal // Stored as Tree.styleRefs type StyleRefsItem = { instanceId: string, values: StyleSourcesItem['id'] } ```
- Loading branch information
Showing
4 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
packages/prisma-client/prisma/migrations/20230127120101_style_sources/migration.sql
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,8 @@ | ||
-- AlterTable | ||
ALTER TABLE "Build" | ||
ADD COLUMN "styleSources" TEXT NOT NULL DEFAULT '[]', | ||
ADD COLUMN "styles" TEXT NOT NULL DEFAULT '[]'; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Tree" | ||
ADD COLUMN "styleSelections" TEXT NOT NULL DEFAULT '[]'; |
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,4 +1,5 @@ | ||
export * from "./schema/instances"; | ||
export * from "./schema/props"; | ||
export * from "./schema/styles"; | ||
export * from "./schema/style-sources"; | ||
export * from "./types"; |
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,36 @@ | ||
import { z } from "zod"; | ||
|
||
const StyleSourceId = z.string(); | ||
|
||
const StyleSourceToken = z.object({ | ||
type: z.literal("token"), | ||
id: StyleSourceId, | ||
treeId: z.string().optional(), | ||
name: z.string(), | ||
}); | ||
|
||
const StyleSourceLocal = z.object({ | ||
type: z.literal("local"), | ||
id: StyleSourceId, | ||
treeId: z.string(), | ||
name: z.string(), | ||
}); | ||
|
||
export const StyleSource = z.union([StyleSourceToken, StyleSourceLocal]); | ||
|
||
export type StyleSource = z.infer<typeof StyleSource>; | ||
|
||
export const StyleSources = z.array(StyleSource); | ||
|
||
export type StyleSources = z.infer<typeof StyleSources>; | ||
|
||
export const StyleSourceSelection = z.object({ | ||
instanceId: z.string(), | ||
values: z.array(StyleSourceId), | ||
}); | ||
|
||
export type StyleSourceSelection = z.infer<typeof StyleSourceSelection>; | ||
|
||
export const StyleSourceSelections = z.array(StyleSourceSelection); | ||
|
||
export type StyleSourceSelections = z.infer<typeof StyleSourceSelections>; |