polished css,CSS3网格布局(grid)模板在线构建工具

这是一个使用polished css和React实现的CSS3网格布局模板在线构建工具。用户可以编辑模板字符串,拖动预览区域调整布局,实时查看模板变化。
摘要由CSDN通过智能技术生成

JavaScript

语言:

JaveScriptBabelCoffeeScript

确定

const {render} = ReactDOM;

const {Component, PropTypes} = React;

const {h1, h2, div, input, textarea, a, svg, g, line, text} = styled.default;

const {darken, lighten, transparentize} = polished;

const {grid, template} = GridTemplateParser;

// helpers

const clamp = (value, min, max) => Math.min(Math.max(value, min), max);

// styles

const colors = {

primary: '#263238',

secondary: '#1DE9B6',

};

const StyledApp = div`

display: grid;

grid-template-columns: 25rem auto;

grid-template-rows: auto;

grid-template-areas: "sidebar main";

width: 100%;

height: 100vh;

`;

const StyledSidebar = div`

display: flex;

flex-direction: column;

grid-area: sidebar;

background: ${darken(.1, colors.primary)};

overflow: hidden;

`;

const StyledMain = div`

display: flex;

flex-direction: column;

grid-area: main;

padding: 2rem;

background: ${darken(.05, colors.primary)};

`;

const StyledMainInner = div`

flex: 1;

position: relative;

`;

const StyledGrid = svg`

position: absolute;

top: 0;

right: 0;

bottom: 0;

left: 0;

width: 100%;

height: 100%;

`;

const StyledGridText = text`

font-family: 'Roboto Mono', monospace;

font-weight: 500;

font-size: 1rem;

text-anchor: middle;

alignment-baseline: middle;

fill: ${transparentize(.75, colors.secondary)};

`;

const StyledGridLine = line`

stroke: ${darken(.01, colors.primary)};

stroke-width: 1px;

`;

const StyledPreview = div`

z-index: 5;

position: relative;

display: grid;

grid-template-columns: repeat(${props => props.width}, 1fr);

grid-template-rows: repeat(${props => props.height}, 1fr);

grid-template-areas: ${props => props.tpl};

width: 100%;

height: 100%;

`;

const StyledTrack = div`

position: relative;

grid-area: ${props => props.area};

cursor: ${props =>

props.grabbing ? 'grabbing' : 'grab'};

background: ${transparentize(.97, colors.secondary)};

`;

const StyledHandler = div`

position: absolute;

top: ${({position}) =>

position === 'bottom' ? 'auto' : 0};

right: ${({position}) =>

position === 'left' ? 'auto' : 0};

bottom: ${({position}) =>

position === 'top' ? 'auto' : 0};

left: ${({position}) =>

position === 'right' ? 'auto' : 0};

width: ${({position, size}) =>

position === 'left' || position === 'right' ? size : '100%'};

height: ${({position, size}) =>

position === 'top' || position === 'bottom' ? size : '100%'};

cursor: ${({position}) =>

position === 'left' || position === 'right' ? 'col-resize' : 'row-resize'};

background: ${colors.secondary};

`;

const StyledHint = div`

padding: 2rem;

`;

const StyledHintTitle = h1`

padding-bottom: 1rem;

font-weight: 500;

font-size: 1.5rem;

color: ${colors.secondary};

`;

const StyledHintDescription = div`

line-height: 1.6;

font-size: 1rem;

color: ${lighten(.6, colors.primary)};

`;

const StyledTemplate = div`

flex: 1;

display: flex;

flex-direction: column;

padding: 2rem;

`;

const StyledTemplateTitle = h2`

padding-bottom: 1.5rem;

text-transform: uppercase;

font-size: .85rem;<

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值