-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba93778
commit daa0b1c
Showing
6 changed files
with
97 additions
and
27 deletions.
There are no files selected for viewing
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,43 @@ | ||
import { colord } from 'colord' | ||
import type { UmbraInput, Accent } from './types' | ||
|
||
interface HydrateProps { | ||
input: UmbraInput | ||
adjusted: { | ||
background: string | ||
foreground: string | ||
accents: (Accent | string)[] | ||
} | ||
generated: { | ||
name: string | ||
background: string | ||
foreground: string | ||
shades: string[] | ||
}[] | ||
} | ||
|
||
export function dehydrateOutput(output: any) { | ||
return JSON.stringify(output) | ||
} | ||
|
||
function rehydrateColord(color: string) { | ||
const parsed = JSON.parse(color) | ||
return colord(`rgb(${parsed.r}, ${parsed.g}, ${parsed.b})`) | ||
} | ||
|
||
export function hydrateOutput({ input, adjusted, generated }: HydrateProps) { | ||
return { | ||
input, | ||
adjusted: { | ||
background: rehydrateColord(adjusted.background), | ||
foreground: rehydrateColord(adjusted.foreground), | ||
accents: adjusted.accents | ||
}, | ||
generated: generated.map((gen) => ({ | ||
name: gen.name, | ||
background: rehydrateColord(gen.background), | ||
foreground: rehydrateColord(gen.foreground), | ||
shades: gen.shades.map(rehydrateColord) | ||
})) | ||
} | ||
} |
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