mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-29 20:13:43 +03:00
63 lines
1.6 KiB
TypeScript
63 lines
1.6 KiB
TypeScript
import * as React from 'react';
|
|
import * as styledComponents from 'styled-components';
|
|
|
|
import { ResolvedThemeInterface } from './theme';
|
|
|
|
export { ResolvedThemeInterface };
|
|
|
|
type WithProps<
|
|
C extends keyof JSX.IntrinsicElements | React.ComponentType<any>,
|
|
T extends object
|
|
> = styledComponents.ThemedStyledFunction<C, ResolvedThemeInterface, T>;
|
|
|
|
const {
|
|
default: styled,
|
|
css,
|
|
createGlobalStyle,
|
|
keyframes,
|
|
ThemeProvider,
|
|
} = (styledComponents as any) as styledComponents.ThemedStyledComponentsModule<
|
|
ResolvedThemeInterface
|
|
>;
|
|
|
|
export const media = {
|
|
lessThan(breakpoint, print?: boolean) {
|
|
return (...args) => css`
|
|
@media ${print ? 'print, ' : ''} screen and (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, createGlobalStyle, keyframes, ThemeProvider, WithProps };
|
|
export default styled;
|
|
|
|
export function extensionsHook(styledName: string) {
|
|
return props => {
|
|
if (!props.theme.extensionsHook) {
|
|
return;
|
|
}
|
|
return props.theme.extensionsHook(styledName, props);
|
|
};
|
|
}
|