packages/ui: remove theme prop from Components
This commit is contained in:
parent
b77f54e815
commit
6f31814513
@ -8,19 +8,19 @@ type WithArrayType<T> = {
|
||||
|
||||
type AllowedProps = Omit<HTMLDivElement['style'], 'color' | 'translate'>;
|
||||
|
||||
export type GridProps = Partial<WithArrayType<AllowedProps>> & { theme: Theme };
|
||||
export type GridProps = Partial<WithArrayType<AllowedProps>>;
|
||||
export const Grid = styled.div<GridProps>`
|
||||
display: grid;
|
||||
${({ theme, ...props }: GridProps) => getStyles(props, theme)}
|
||||
${({ theme, ...props }: GridProps & { theme: Theme }) => getStyles(props, theme)}
|
||||
`;
|
||||
|
||||
export type FlexProps = GridProps;
|
||||
export const Flex = styled.div<GridProps>`
|
||||
display: flex;
|
||||
${({ theme, ...props }: GridProps) => getStyles(props, theme)}
|
||||
${({ theme, ...props }: GridProps & { theme: Theme }) => getStyles(props, theme)}
|
||||
`;
|
||||
|
||||
export type BoxProps = GridProps;
|
||||
export const Box = styled.div<GridProps>`
|
||||
${({ theme, ...props }: GridProps) => getStyles(props, theme)}
|
||||
${({ theme, ...props }: GridProps & { theme: Theme }) => getStyles(props, theme)}
|
||||
`;
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
import { dash, omit } from 'radash';
|
||||
|
||||
export type Theme = { breakpoints: string[] };
|
||||
|
||||
function min(breakpoint: string, style: string) {
|
||||
return `@media (min-width: ${breakpoint})
|
||||
{
|
||||
${style}
|
||||
}`;
|
||||
}
|
||||
|
||||
export function getStyles<T>(props: Record<string, T | T[]>, theme: Theme) {
|
||||
const cleanProps = omit(props, ['children', 'id', 'key', 'className']);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user