mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-29 20:13:43 +03:00
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import * as styledComponents from 'styled-components';
|
|
|
|
import { ThemeInterface } from './theme';
|
|
|
|
export type StyledFunction<T> = styledComponents.ThemedStyledFunction<T, ThemeInterface>;
|
|
|
|
function withProps<T, U extends HTMLElement = HTMLElement>(
|
|
styledFunction: StyledFunction<React.HTMLProps<U>>,
|
|
): StyledFunction<T & React.HTMLProps<U>> {
|
|
return styledFunction;
|
|
}
|
|
|
|
const {
|
|
default: styled,
|
|
css,
|
|
injectGlobal,
|
|
keyframes,
|
|
ThemeProvider,
|
|
withTheme,
|
|
} = (styledComponents as styledComponents.ThemedStyledComponentsModule<
|
|
any
|
|
>) as styledComponents.ThemedStyledComponentsModule<ThemeInterface>;
|
|
|
|
export const media = {
|
|
lessThan(breakpoint) {
|
|
return (...args) => css`
|
|
@media (max-width: ${props => props.theme.breakpoints[breakpoint]}) {
|
|
${(css as any)(...args)};
|
|
}
|
|
`;
|
|
},
|
|
|
|
greaterThan(breakpoint) {
|
|
return (...args) => css`
|
|
@media (min-width: ${props => props.theme.breakpoints[breakpoint]}) {
|
|
${(css as any)(...args)};
|
|
}
|
|
`;
|
|
},
|
|
|
|
between(firstBreakpoint, secondBreakpoint) {
|
|
return (...args) => css`
|
|
@media (min-width: ${props => props.theme.breakpoints[firstBreakpoint]}) and (max-width: ${props => props.theme.breakpoints[
|
|
secondBreakpoint
|
|
]}) {
|
|
${(css as any)(...args)};
|
|
}
|
|
`;
|
|
},
|
|
};
|
|
|
|
export { css, injectGlobal, keyframes, ThemeProvider, withTheme, withProps };
|
|
export default styled;
|