Skip to content

Instantly share code, notes, and snippets.

@DexterHuang
Created May 4, 2018 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DexterHuang/fab0f39084691bd9b645508ca5e1b1bc to your computer and use it in GitHub Desktop.
Save DexterHuang/fab0f39084691bd9b645508ca5e1b1bc to your computer and use it in GitHub Desktop.
import { CSSProperties } from "react";
export class ResponsiveHandler {
static getStyle(dis: any): CSSProperties {
const { xs, sm, md, lg, style } = dis.props;
const { width } = dis.state;
if (width < 767 && xs) {
return { ...style, ...xs };
}
if (width < 991 && sm) {
return { ...style, ...sm };
}
if (width < 1199 && md) {
return { ...style, ...md };
}
return { ...style, ...lg };
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment