Created
December 16, 2018 15:02
-
-
Save esmevane/8a75cc697436d51e741fc241d29aba14 to your computer and use it in GitHub Desktop.
[ Themes / Typescript ]: Hierarchical theme type & helper functions
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
// tslint:disable:object-literal-sort-keys | |
interface MinorHierarchy<T> { | |
one: T | |
two: T | |
three: T | |
four: T | |
} | |
export const createMinorHierarchy = <T>( | |
one: T, | |
two: T, | |
three: T, | |
four: T | |
): MinorHierarchy<T> => ({ | |
one, | |
two, | |
three, | |
four, | |
}) | |
interface MajorHierarchy<T> extends MinorHierarchy<T> { | |
five: T | |
six: T | |
seven: T | |
eight: T | |
nine: T | |
} | |
export const createMajorHierarchy = <T>( | |
one: T, | |
two: T, | |
three: T, | |
four: T, | |
five: T, | |
six: T, | |
seven: T, | |
eight: T, | |
nine: T | |
): MajorHierarchy<T> => ({ | |
one, | |
two, | |
three, | |
four, | |
five, | |
six, | |
seven, | |
eight, | |
nine, | |
}) | |
interface HierarchicalTheme { | |
margin: MajorHierarchy<string> | |
padding: MajorHierarchy<string> | |
width: MajorHierarchy<string> | |
height: MajorHierarchy<string> | |
opacity: MajorHierarchy<string> | |
border: { | |
radius: MinorHierarchy<string> | |
width: MinorHierarchy<string> | |
} | |
colors: { | |
neutral: MajorHierarchy<string> | |
primary: MajorHierarchy<string> | |
supporting: { | |
accent: MajorHierarchy<string> | |
success: MajorHierarchy<string> | |
destructive: MajorHierarchy<string> | |
warning: MajorHierarchy<string> | |
} | |
} | |
icons: { | |
size: MinorHierarchy<string> | |
} | |
font: { | |
serif: string | |
sans: string | |
weight: MajorHierarchy<string> | |
size: MajorHierarchy<string> | |
lineHeight: MajorHierarchy<string> | |
} | |
shadows: { | |
drop: MinorHierarchy<string> | |
inset: MinorHierarchy<string> | |
} | |
} | |
export const createHierarchy = (hierarchical: HierarchicalTheme) => hierarchical |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment