Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

clearfy media-query break point #158

Open
mydearxym opened this issue Jun 30, 2018 · 1 comment
Open

clearfy media-query break point #158

mydearxym opened this issue Jun 30, 2018 · 1 comment
Assignees
Labels

Comments

@mydearxym
Copy link
Member

image

see reference

@mydearxym mydearxym self-assigned this Jun 30, 2018
@mydearxym
Copy link
Member Author

a styled-compoentn example:

const sizes = {
  desktop: 992,
  tablet: 768,
  phone: 376
}

// Iterate through the sizes and create a media template
const media = Object.keys(sizes).reduce((acc, label) => {
  acc[label] = (...args) => css`
    @media (max-width: ${sizes[label] / 16}em) {
      ${css(...args)}
    }
  `

  return acc
}, {})

const Content = styled.div`
  height: 3em;
  width: 3em;
  background: papayawhip;

  /* Now we have our methods on media and can use them instead of raw queries */
  ${media.desktop`background: dodgerblue;`}
  ${media.tablet`background: mediumseagreen;`}
  ${media.phone`background: palevioletred;`}
`;

render(
  <Content />
);

@mydearxym mydearxym added the TODO label Jun 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant