zoukankan      html  css  js  c++  java
  • [React] Styled System with extendable Box element

    You can have a Box element, which just used for create other element or layout:

    // example Box.js
    import styled from 'styled-components'
    import { space, color, layout } from 'styled-system'
    
    const Box = styled.div(
      {
        boxSizing: 'border-box',
        minWidth: 0,
      },
      space,
      color,
      layout
    )
    
    export default Box

    Just put 'space', 'color' and 'layout' so that, you can use it with the component built based on Box.

    import styled from 'styled-components'
    import Box from './Box'
    
    const Grid = styled(Box)({
      display: 'grid'
    })
    
    Grid.propTypes = Box.propTypes
    
    export default Grid;

    Because we have used 'space', 'color' and 'layout' on box, so that we can also do:

    <Grid
      as="footer"
      gridGap={3}
      justifyContent={[null, 'space-between']}
      justifyItems={['center', null]}
      gridAutoFlow={[null, 'column']}
    >
      <Box>© Chuck Norris, 1940</Box>
      <Box>Have a nice day!</Box>
    </Grid>
  • 相关阅读:
    hdu 5902 Seam Carving
    hdu 5091 Beam Cannon
    hdu 1542 Atlantis
    hdu 2196 Computer
    第一个爬虫和测试
    排球比赛规则
    第十周博客作业
    科学计算可视化
    用matplotlib绘制图像
    面对对象学习
  • 原文地址:https://www.cnblogs.com/Answer1215/p/13557508.html
Copyright © 2011-2022 走看看