-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Showing
4 changed files
with
73 additions
and
71 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,70 @@ | ||
import { DynamicScheme, MaterialDynamicColors } from "@material/material-color-utilities"; | ||
import type { Color, SerializedScheme } from "./utils"; | ||
|
||
export const pairs = [ | ||
["primary", "onPrimary"], | ||
["primaryContainer", "onPrimaryContainer"], | ||
["secondary", "onSecondary"], | ||
["secondaryContainer", "onSecondaryContainer"], | ||
["tertiary", "onTertiary"], | ||
["tertiaryContainer", "onTertiaryContainer"], | ||
["background", "onBackground"], | ||
["surface", "onSurface"], | ||
["inverseSurface", "inverseOnSurface"], | ||
["surfaceVariant", "onSurfaceVariant"], | ||
["error", "onError"], | ||
["errorContainer", "onErrorContainer"], | ||
]; | ||
|
||
export const colors: Color[] = [ | ||
"primary", | ||
"onPrimary", | ||
"primaryContainer", | ||
"onPrimaryContainer", | ||
"inversePrimary", | ||
"secondary", | ||
"onSecondary", | ||
"secondaryContainer", | ||
"onSecondaryContainer", | ||
"tertiary", | ||
"onTertiary", | ||
"tertiaryContainer", | ||
"onTertiaryContainer", | ||
"error", | ||
"onError", | ||
"errorContainer", | ||
"onErrorContainer", | ||
"background", | ||
"onBackground", | ||
"surface", | ||
"onSurface", | ||
"surfaceVariant", | ||
"onSurfaceVariant", | ||
"inverseSurface", | ||
"inverseOnSurface", | ||
"outline", | ||
"outlineVariant", | ||
"shadow", | ||
"scrim", | ||
"surfaceDim", | ||
"surfaceBright", | ||
"surfaceContainerLowest", | ||
"surfaceContainerLow", | ||
"surfaceContainer", | ||
"surfaceContainerHigh", | ||
"surfaceContainerHighest", | ||
"surfaceTint", | ||
]; | ||
|
||
/** | ||
* @description Serializes the {@link DynamicScheme} so that it can be used by {@link StyleFromScheme} and {@link genCSS}. | ||
* @param scheme The theme generated by material-color-utils. | ||
* */ | ||
|
||
export const serializeScheme = (scheme: DynamicScheme) => { | ||
const out: Record<string, number> = {}; | ||
for (const color of colors) { | ||
out[color] = MaterialDynamicColors[color].getArgb(scheme); | ||
} | ||
return out as SerializedScheme; | ||
}; |
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