mirror of https://github.com/acid-info/lsd.git
feat: adds spacing array to the theme
This commit is contained in:
parent
0ff0bbcc1e
commit
efa4792a2a
|
@ -8,6 +8,7 @@ const themeProps: CreateThemeProps = {
|
|||
breakpoints: {},
|
||||
palette: {},
|
||||
typographyGlobal: {},
|
||||
spacing: [],
|
||||
}
|
||||
|
||||
const createThemes = () => {
|
||||
|
|
|
@ -201,6 +201,7 @@ export const baseTheme: Theme = {
|
|||
secondary: '255, 255, 255',
|
||||
},
|
||||
},
|
||||
spacing: [4, 8, 16, 24, 32, 40, 64, 80, 96, 120],
|
||||
globalStyles: css``,
|
||||
cssVars: '',
|
||||
}
|
||||
|
|
|
@ -141,6 +141,7 @@ export const createTheme = (
|
|||
palette: createPaletteStyles(props, from),
|
||||
globalStyles: css``,
|
||||
cssVars: '',
|
||||
spacing: props.spacing.length ? props.spacing : from.spacing,
|
||||
}
|
||||
|
||||
const { cssVars, globalStyles } = createThemeGlobalStyles(theme)
|
||||
|
|
|
@ -8,6 +8,7 @@ const lightTheme = createTheme(
|
|||
typography: {},
|
||||
typographyGlobal: {},
|
||||
palette: {},
|
||||
spacing: [],
|
||||
},
|
||||
baseTheme,
|
||||
)
|
||||
|
@ -22,6 +23,7 @@ const darkTheme = createTheme(
|
|||
primary: '255, 255, 255',
|
||||
secondary: '0, 0, 0',
|
||||
},
|
||||
spacing: [],
|
||||
},
|
||||
lightTheme,
|
||||
)
|
||||
|
|
|
@ -87,6 +87,14 @@ const generateThemeGlobalStyles = (theme: Theme) => {
|
|||
)
|
||||
}
|
||||
|
||||
// Spacing-related CSS variable definitions
|
||||
{
|
||||
theme.spacing.map((spacingValue) => {
|
||||
const varName = cssUtils.vars.lsd('spacing', spacingValue.toString())
|
||||
vars.push(cssUtils.define(varName, `${spacingValue}px`))
|
||||
})
|
||||
}
|
||||
|
||||
THEME_BREAKPOINTS.map((breakpoint, index) => {
|
||||
styles.push(`@media (min-width: ${theme.breakpoints[breakpoint].width}px) {
|
||||
:root {
|
||||
|
|
|
@ -77,6 +77,7 @@ export type Theme = {
|
|||
palette: ThemePalette
|
||||
globalStyles: SerializedStyles
|
||||
cssVars: string
|
||||
spacing: number[]
|
||||
}
|
||||
|
||||
export type ThemeOptionBreakpointStyles = Partial<
|
||||
|
@ -100,6 +101,7 @@ export type CreateThemeProps = {
|
|||
typography: ThemeOptionTypography
|
||||
typographyGlobal: Partial<GlobalTypographyStyles>
|
||||
palette: ThemeOptionPalette
|
||||
spacing: number[]
|
||||
}
|
||||
|
||||
export type ThemeContext = {
|
||||
|
|
Loading…
Reference in New Issue