From e8814ecbe70b97dfa0de0f51b6a3b7e7fcd89ea2 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Tue, 6 Nov 2018 13:52:16 -0800 Subject: proof of concept working --- packages/instant/src/components/sandbox.tsx | 5 ----- .../src/components/zero_ex_instant_container.tsx | 3 ++- packages/instant/src/style/media.ts | 23 +++++++++++++++++++--- 3 files changed, 22 insertions(+), 9 deletions(-) (limited to 'packages') diff --git a/packages/instant/src/components/sandbox.tsx b/packages/instant/src/components/sandbox.tsx index 04e4c7935..b574fd35c 100644 --- a/packages/instant/src/components/sandbox.tsx +++ b/packages/instant/src/components/sandbox.tsx @@ -3,11 +3,6 @@ import * as React from 'react'; import { MediaChoice, stylesForMedia } from '../style/media'; import { styled } from '../style/theme'; -// export const Sandbox: React.StatelessComponent<{}> = props => { -// return
Hi
; -// }; - -// TODO: handle string too interface SandboxProps { width: MediaChoice; } diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx index 8fd4d56c3..c60a9c40e 100644 --- a/packages/instant/src/components/zero_ex_instant_container.tsx +++ b/packages/instant/src/components/zero_ex_instant_container.tsx @@ -28,7 +28,8 @@ export class ZeroExInstantContainer extends React.Component - Test + {/* Test */} + Test diff --git a/packages/instant/src/style/media.ts b/packages/instant/src/style/media.ts index 5a0cba668..84b85a2a8 100644 --- a/packages/instant/src/style/media.ts +++ b/packages/instant/src/style/media.ts @@ -21,12 +21,29 @@ export const media = { }; /// media helper -export interface MediaChoice { - sm: string; +export interface ScreenSpecifications { + default: string; + sm?: string; md?: string; lg?: string; } +export type MediaChoice = string | ScreenSpecifications; // TODO: handle string too export const stylesForMedia = (choice: MediaChoice): InterpolationValue[] => { - return media.small`width: ${choice.sm}`; + let res: InterpolationValue[]; + if (typeof choice === 'string') { + res = css` + width: ${choice}; + `; + } else { + res = css` + width: ${choice.default}; + ${choice.lg && media.large`width: ${choice.lg}`} + ${choice.md && media.medium`width: ${choice.md}`} + ${choice.sm && media.small`width: ${choice.sm}`} + `; + } + + console.log(res.toString()); + return res; }; -- cgit v1.2.3