update grid
parent
615c72091e
commit
f0a9c28ebc
|
@ -1,12 +1,18 @@
|
|||
|
||||
const parseStyleText = (cssText = '') => {
|
||||
const camelizeRE = /-(\w)/g
|
||||
const camelize = (str) => {
|
||||
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '')
|
||||
}
|
||||
const parseStyleText = (cssText = '', camel) => {
|
||||
const res = {}
|
||||
const listDelimiter = /;(?![^(]*\))/g
|
||||
const propertyDelimiter = /:(.+)/
|
||||
cssText.split(listDelimiter).forEach(function (item) {
|
||||
if (item) {
|
||||
const tmp = item.split(propertyDelimiter)
|
||||
tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim())
|
||||
if (tmp.length > 1) {
|
||||
const k = camel ? camelize(tmp[0].trim()) : tmp[0].trim()
|
||||
res[k] = tmp[1].trim()
|
||||
}
|
||||
}
|
||||
})
|
||||
return res
|
||||
|
@ -39,6 +45,18 @@ const getSlotOptions = (ele) => {
|
|||
return componentOptions ? componentOptions.Ctor.options || {} : {}
|
||||
}
|
||||
const getOptionProps = (instance) => {
|
||||
if (instance.componentOptions) {
|
||||
const componentOptions = instance.componentOptions
|
||||
const { propsData = {}, Ctor = {}} = componentOptions
|
||||
const props = (Ctor.options || {}).props || {}
|
||||
const res = {}
|
||||
for (const [k, v] of Object.entries(props)) {
|
||||
if (v.default !== undefined) {
|
||||
res[k] = v
|
||||
}
|
||||
}
|
||||
return { ...res, ...propsData }
|
||||
}
|
||||
const { $options = {}, $props = {}} = instance
|
||||
return filterProps($props, $options.propsData)
|
||||
}
|
||||
|
@ -120,7 +138,7 @@ export function getClass (ele) {
|
|||
}
|
||||
return cls
|
||||
}
|
||||
export function getStyle (ele) {
|
||||
export function getStyle (ele, camel) {
|
||||
let data = {}
|
||||
if (ele.data) {
|
||||
data = ele.data
|
||||
|
@ -129,7 +147,11 @@ export function getStyle (ele) {
|
|||
}
|
||||
let style = data.style || data.staticStyle
|
||||
if (typeof style === 'string') {
|
||||
style = parseStyleText(style)
|
||||
style = parseStyleText(style, camel)
|
||||
} else if (camel && style) { // 驼峰化
|
||||
const res = {}
|
||||
Object.keys(style).forEach(k => (res[camelize(k)] = style[k]))
|
||||
return res
|
||||
}
|
||||
return style
|
||||
}
|
||||
|
|
|
@ -4,29 +4,17 @@
|
|||
## 栅格卡片
|
||||
</md>
|
||||
<div style="background: #ECECEC; padding: 30px">
|
||||
<Row :gutter="16">
|
||||
<Col :span="8">
|
||||
<Card title="Card title" :bordered="false">Card content</Card>
|
||||
</Col>
|
||||
<Col :span="8">
|
||||
<Card title="Card title" :bordered="false">Card content</Card>
|
||||
</Col>
|
||||
<Col :span="8">
|
||||
<Card title="Card title" :bordered="false">Card content</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="8">
|
||||
<a-card title="Card title" :bordered="false">Card content</a-card>
|
||||
</a-col>
|
||||
<a-col :span="8">
|
||||
<a-card title="Card title" :bordered="false">Card content</a-card>
|
||||
</a-col>
|
||||
<a-col :span="8">
|
||||
<a-card title="Card title" :bordered="false">Card content</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import '../style'
|
||||
import { Card, Col, Row } from 'antd'
|
||||
export default {
|
||||
components: {
|
||||
Card,
|
||||
Col,
|
||||
Row,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,83 +1,72 @@
|
|||
<script>
|
||||
// Equal or Larger Than 0
|
||||
function elt0 (value) {
|
||||
return value >= 0
|
||||
}
|
||||
// equal to 0(default) or more
|
||||
const DEFAULT_0_OR_MORE = {
|
||||
'default': 0,
|
||||
validator: elt0,
|
||||
}
|
||||
import PropTypes from '../_util/vue-types'
|
||||
|
||||
export default {
|
||||
name: 'Ant-Col',
|
||||
props: {
|
||||
prefixCls: {
|
||||
'default': 'ant-col',
|
||||
type: String,
|
||||
},
|
||||
span: Number,
|
||||
order: DEFAULT_0_OR_MORE,
|
||||
offset: DEFAULT_0_OR_MORE,
|
||||
push: DEFAULT_0_OR_MORE,
|
||||
pull: DEFAULT_0_OR_MORE,
|
||||
xs: [Number, Object],
|
||||
sm: [Number, Object],
|
||||
md: [Number, Object],
|
||||
lg: [Number, Object],
|
||||
xl: [Number, Object],
|
||||
},
|
||||
inject: {
|
||||
parentRow: { 'default': undefined },
|
||||
},
|
||||
computed: {
|
||||
classes () {
|
||||
const { prefixCls, span, order, offset, push, pull } = this
|
||||
let sizeClassObj = {};
|
||||
['xs', 'sm', 'md', 'lg', 'xl'].forEach(size => {
|
||||
let sizeProps = {}
|
||||
if (typeof this[size] === 'number') {
|
||||
sizeProps.span = this[size]
|
||||
} else if (typeof this[size] === 'object') {
|
||||
sizeProps = this[size] || {}
|
||||
}
|
||||
const stringOrNumber = PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
||||
|
||||
sizeClassObj = {
|
||||
...sizeClassObj,
|
||||
[`${prefixCls}-${size}-${sizeProps.span}`]: sizeProps.span !== undefined,
|
||||
[`${prefixCls}-${size}-order-${sizeProps.order}`]: sizeProps.order || sizeProps.order === 0,
|
||||
[`${prefixCls}-${size}-offset-${sizeProps.offset}`]: sizeProps.offset || sizeProps.offset === 0,
|
||||
[`${prefixCls}-${size}-push-${sizeProps.push}`]: sizeProps.push || sizeProps.push === 0,
|
||||
[`${prefixCls}-${size}-pull-${sizeProps.pull}`]: sizeProps.pull || sizeProps.pull === 0,
|
||||
}
|
||||
})
|
||||
return {
|
||||
[`${prefixCls}`]: true,
|
||||
[`${prefixCls}-${span}`]: span !== undefined,
|
||||
[`${prefixCls}-order-${order}`]: order,
|
||||
[`${prefixCls}-offset-${offset}`]: offset,
|
||||
[`${prefixCls}-push-${push}`]: push,
|
||||
[`${prefixCls}-pull-${pull}`]: pull,
|
||||
...sizeClassObj,
|
||||
}
|
||||
},
|
||||
gutter () {
|
||||
const parent = this.parentRow
|
||||
return parent ? +parent.gutter : 0
|
||||
},
|
||||
},
|
||||
render (h) {
|
||||
const style = {}
|
||||
if (this.gutter) {
|
||||
style.paddingLeft = this.gutter / 2 + 'px'
|
||||
style.paddingRight = style.paddingLeft
|
||||
export const ColSize = PropTypes.shape({
|
||||
span: stringOrNumber,
|
||||
order: stringOrNumber,
|
||||
offset: stringOrNumber,
|
||||
push: stringOrNumber,
|
||||
pull: stringOrNumber,
|
||||
}).loose
|
||||
|
||||
const objectOrNumber = PropTypes.oneOfType([PropTypes.number, ColSize])
|
||||
|
||||
export const ColProps = {
|
||||
span: objectOrNumber,
|
||||
order: objectOrNumber,
|
||||
offset: objectOrNumber,
|
||||
push: objectOrNumber,
|
||||
pull: objectOrNumber,
|
||||
xs: PropTypes.oneOfType([PropTypes.number, ColSize]),
|
||||
sm: PropTypes.oneOfType([PropTypes.number, ColSize]),
|
||||
md: PropTypes.oneOfType([PropTypes.number, ColSize]),
|
||||
lg: PropTypes.oneOfType([PropTypes.number, ColSize]),
|
||||
xl: PropTypes.oneOfType([PropTypes.number, ColSize]),
|
||||
xxl: PropTypes.oneOfType([PropTypes.number, ColSize]),
|
||||
prefixCls: PropTypes.string,
|
||||
}
|
||||
|
||||
export default {
|
||||
props: ColProps,
|
||||
name: 'Col',
|
||||
render () {
|
||||
const { span, order, offset, push, pull, prefixCls = 'ant-col', $slots, $attrs, $listeners } = this
|
||||
let sizeClassObj = {};
|
||||
['xs', 'sm', 'md', 'lg', 'xl', 'xxl'].forEach(size => {
|
||||
let sizeProps = {}
|
||||
if (typeof this[size] === 'number') {
|
||||
sizeProps.span = this[size]
|
||||
} else if (typeof this[size] === 'object') {
|
||||
sizeProps = this[size] || {}
|
||||
}
|
||||
// why only unnamed slots
|
||||
return h('div', {
|
||||
'class': this.classes,
|
||||
style,
|
||||
}, this.$slots['default'])
|
||||
},
|
||||
}
|
||||
|
||||
sizeClassObj = {
|
||||
...sizeClassObj,
|
||||
[`${prefixCls}-${size}-${sizeProps.span}`]: sizeProps.span !== undefined,
|
||||
[`${prefixCls}-${size}-order-${sizeProps.order}`]: sizeProps.order || sizeProps.order === 0,
|
||||
[`${prefixCls}-${size}-offset-${sizeProps.offset}`]: sizeProps.offset || sizeProps.offset === 0,
|
||||
[`${prefixCls}-${size}-push-${sizeProps.push}`]: sizeProps.push || sizeProps.push === 0,
|
||||
[`${prefixCls}-${size}-pull-${sizeProps.pull}`]: sizeProps.pull || sizeProps.pull === 0,
|
||||
}
|
||||
})
|
||||
const classes = {
|
||||
[`${prefixCls}-${span}`]: span !== undefined,
|
||||
[`${prefixCls}-order-${order}`]: order,
|
||||
[`${prefixCls}-offset-${offset}`]: offset,
|
||||
[`${prefixCls}-push-${push}`]: push,
|
||||
[`${prefixCls}-pull-${pull}`]: pull,
|
||||
...sizeClassObj,
|
||||
}
|
||||
const divProps = {
|
||||
on: $listeners,
|
||||
attrs: $attrs,
|
||||
class: classes,
|
||||
}
|
||||
return <div {...divProps}>{$slots.default}</div>
|
||||
},
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,84 +1,151 @@
|
|||
<template>
|
||||
<div :class="classes" :style="modifiedStyle">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'Ant-Row',
|
||||
props: {
|
||||
prefixCls: {
|
||||
'default': 'ant-row',
|
||||
type: String,
|
||||
import PropTypes from '../_util/vue-types'
|
||||
import BaseMixin from '../_util/BaseMixin'
|
||||
import { cloneElement } from '../_util/vnode'
|
||||
import { isEmptyElement, getStyle, getOptionProps } from '../_util/props-util'
|
||||
// matchMedia polyfill for
|
||||
// https://github.com/WickyNilliams/enquire.js/issues/82
|
||||
let enquire = null
|
||||
if (typeof window !== 'undefined') {
|
||||
const matchMediaPolyfill = (mediaQuery) => {
|
||||
return {
|
||||
media: mediaQuery,
|
||||
matches: false,
|
||||
addListener () {
|
||||
},
|
||||
type: {
|
||||
validator (value) {
|
||||
// flex can't work before IE11
|
||||
if (document.all && document.compatMode) {
|
||||
console.error('you cannot use flex in the old browser')
|
||||
return false
|
||||
}
|
||||
return ['flex', ''].includes(value)
|
||||
},
|
||||
removeListener () {
|
||||
},
|
||||
gutter: {
|
||||
'default': 0,
|
||||
validator: k => k >= 0,
|
||||
},
|
||||
align: {
|
||||
'default': 'top',
|
||||
validator (value) {
|
||||
return ['top', 'middle', 'bottom'].includes(value)
|
||||
},
|
||||
},
|
||||
justify: {
|
||||
'default': 'start',
|
||||
validator (value) {
|
||||
return ['start', 'end', 'center', 'space-around', 'space-between'].includes(value)
|
||||
},
|
||||
},
|
||||
},
|
||||
data () {
|
||||
const half = this.gutter / 2
|
||||
return {
|
||||
modifiedStyle: {
|
||||
'margin-left': -half + 'px',
|
||||
'margin-right': -half + 'px',
|
||||
},
|
||||
}
|
||||
},
|
||||
provide() {
|
||||
return {
|
||||
parentRow: this,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
classes () {
|
||||
const { prefixCls, type, align, justify } = this
|
||||
return {
|
||||
[`${prefixCls}`]: true,
|
||||
[`${prefixCls}-${type}`]: type,
|
||||
[`${prefixCls}-${type}-${justify}`]: type && justify,
|
||||
[`${prefixCls}-${type}-${align}`]: type && align,
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
handleClick (event) {
|
||||
if (this.clicked) {
|
||||
return
|
||||
}
|
||||
this.clicked = true
|
||||
clearTimeout(this.timeout)
|
||||
this.timeout = setTimeout(() => (this.clicked = false), 500)
|
||||
this.$emit('click', event)
|
||||
},
|
||||
},
|
||||
beforeDestroy () {
|
||||
if (this.timeout) {
|
||||
clearTimeout(this.timeout)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
window.matchMedia = window.matchMedia || matchMediaPolyfill
|
||||
enquire = require('enquire.js')
|
||||
}
|
||||
|
||||
const BreakpointMap = PropTypes.shape({
|
||||
xs: PropTypes.string,
|
||||
sm: PropTypes.string,
|
||||
md: PropTypes.string,
|
||||
lg: PropTypes.string,
|
||||
xl: PropTypes.string,
|
||||
xxl: PropTypes.strin,
|
||||
}).loose
|
||||
|
||||
const RowProps = {
|
||||
gutter: PropTypes.oneOfType([PropTypes.number, BreakpointMap]),
|
||||
type: PropTypes.oneOf(['flex']),
|
||||
align: PropTypes.oneOf(['top', 'middle', 'bottom']),
|
||||
justify: PropTypes.oneOf(['start', 'end', 'center', 'space-around', 'space-between']),
|
||||
prefixCls: PropTypes.string,
|
||||
}
|
||||
|
||||
const responsiveArray = ['xxl', 'xl', 'lg', 'md', 'sm', 'xs']
|
||||
|
||||
const responsiveMap = {
|
||||
xs: '(max-width: 575px)',
|
||||
sm: '(min-width: 576px)',
|
||||
md: '(min-width: 768px)',
|
||||
lg: '(min-width: 992px)',
|
||||
xl: '(min-width: 1200px)',
|
||||
xxl: '(min-width: 1600px)',
|
||||
}
|
||||
|
||||
export default {
|
||||
name: 'Row',
|
||||
mixins: [BaseMixin],
|
||||
props: {
|
||||
...RowProps,
|
||||
gutter: PropTypes.oneOfType([PropTypes.number, BreakpointMap]).def(0),
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
screens: {},
|
||||
}
|
||||
},
|
||||
|
||||
mounted () {
|
||||
this.$nextTick(() => {
|
||||
Object.keys(responsiveMap)
|
||||
.map((screen) => enquire.register(responsiveMap[screen], {
|
||||
match: () => {
|
||||
if (typeof this.gutter !== 'object') {
|
||||
return
|
||||
}
|
||||
this.setState((prevState) => ({
|
||||
screens: {
|
||||
...prevState.screens,
|
||||
[screen]: true,
|
||||
},
|
||||
}))
|
||||
},
|
||||
unmatch: () => {
|
||||
if (typeof this.gutter !== 'object') {
|
||||
return
|
||||
}
|
||||
this.setState((prevState) => ({
|
||||
screens: {
|
||||
...prevState.screens,
|
||||
[screen]: false,
|
||||
},
|
||||
}))
|
||||
},
|
||||
// Keep a empty destory to avoid triggering unmatch when unregister
|
||||
destroy () {},
|
||||
},
|
||||
))
|
||||
})
|
||||
},
|
||||
beforeDestroy () {
|
||||
Object.keys(responsiveMap)
|
||||
.map((screen) => enquire.unregister(responsiveMap[screen]))
|
||||
},
|
||||
methods: {
|
||||
getGutter () {
|
||||
const { gutter } = this
|
||||
if (typeof gutter === 'object') {
|
||||
for (let i = 0; i <= responsiveArray.length; i++) {
|
||||
const breakpoint = responsiveArray[i]
|
||||
if (this.state.screens[breakpoint] && gutter[breakpoint] !== undefined) {
|
||||
return gutter[breakpoint]
|
||||
}
|
||||
}
|
||||
}
|
||||
return gutter
|
||||
},
|
||||
},
|
||||
|
||||
render () {
|
||||
const {
|
||||
type, justify, align,
|
||||
prefixCls = 'ant-row', $slots,
|
||||
} = this
|
||||
const gutter = this.getGutter()
|
||||
const classes = {
|
||||
[prefixCls]: !type,
|
||||
[`${prefixCls}-${type}`]: type,
|
||||
[`${prefixCls}-${type}-${justify}`]: type && justify,
|
||||
[`${prefixCls}-${type}-${align}`]: type && align,
|
||||
}
|
||||
const rowStyle = gutter > 0 ? {
|
||||
marginLeft: `${gutter / -2}px`,
|
||||
marginRight: `${gutter / -2}px`,
|
||||
} : {}
|
||||
const cols = ($slots.default || []).map((col) => {
|
||||
if (isEmptyElement(col)) {
|
||||
return null
|
||||
}
|
||||
if (getOptionProps(col) && gutter > 0) {
|
||||
return cloneElement(col, {
|
||||
style: {
|
||||
paddingLeft: `${gutter / 2}px`,
|
||||
paddingRight: `${gutter / 2}px`,
|
||||
...getStyle(col, true),
|
||||
},
|
||||
})
|
||||
}
|
||||
return col
|
||||
})
|
||||
return <div class={classes} style={rowStyle}>{cols}</div>
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
<template>
|
||||
<div class="grid">
|
||||
<ant-row type="flex" justify="center" align="top">
|
||||
<ant-col :span="4" class="color1"><DemoBox :value="100">col-4</DemoBox></ant-col>
|
||||
<ant-col :span="4" class="color2"><DemoBox :value="50">col-4</DemoBox></ant-col>
|
||||
<ant-col :span="4" class="color1"><DemoBox :value="120">col-4</DemoBox></ant-col>
|
||||
<ant-col :span="4" class="color2"><DemoBox :value="80">col-4</DemoBox></ant-col>
|
||||
</ant-row>
|
||||
|
||||
<p>Align Center</p>
|
||||
<ant-row type="flex" justify="space-around" align="middle">
|
||||
<ant-col :span="4" class="color1"><DemoBox :value="100">col-4</DemoBox></ant-col>
|
||||
<ant-col :span="4" class="color2"><DemoBox :value="50">col-4</DemoBox></ant-col>
|
||||
<ant-col :span="4" class="color1"><DemoBox :value="120">col-4</DemoBox></ant-col>
|
||||
<ant-col :span="4" class="color2"><DemoBox :value="80">col-4</DemoBox></ant-col>
|
||||
</ant-row>
|
||||
|
||||
<p>Align Bottom</p>
|
||||
<ant-row type="flex" justify="space-between" align="bottom">
|
||||
<ant-col :span="4" class="color1"><DemoBox :value="100">col-4</DemoBox></ant-col>
|
||||
<ant-col :span="4" class="color2"><DemoBox :value="50">col-4</DemoBox></ant-col>
|
||||
<ant-col :span="4" class="color1"><DemoBox :value="120">col-4</DemoBox></ant-col>
|
||||
<ant-col :span="4" class="color2"><DemoBox :value="80">col-4</DemoBox></ant-col>
|
||||
</ant-row>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import Vue from 'vue'
|
||||
import { Grid } from 'antd'
|
||||
const { Row, Col } = Grid
|
||||
const DemoBox = Vue.component('DemoBox', {
|
||||
props: ['value'],
|
||||
template: `<p :style="{height: value + 'px'}">{{value}}</p>`,
|
||||
})
|
||||
export default {
|
||||
components: {
|
||||
AntRow: Row,
|
||||
AntCol: Col,
|
||||
DemoBox,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
<style lang="less">
|
||||
.grid div {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
line-height: 40px;
|
||||
}
|
||||
.color1 {
|
||||
background: rgb(0, 191, 255);
|
||||
color: white;
|
||||
}
|
||||
.color2 {
|
||||
background: #0e77ca;
|
||||
color: white;
|
||||
}
|
||||
.height-100 {
|
||||
height: 100px;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,35 @@
|
|||
<cn>
|
||||
#### 基础栅格
|
||||
从堆叠到水平排列。
|
||||
使用单一的一组 `Row` 和 `Col` 栅格组件,就可以创建一个基本的栅格系统,所有列(Col)必须放在 `Row` 内。
|
||||
</cn>
|
||||
|
||||
<us>
|
||||
#### Basic Grid
|
||||
From the stack to the horizontal arrangement.
|
||||
You can create a basic grid system by using a single set of `Row` and `Col` grid assembly, all of the columns (Col) must be placed in `Row`.
|
||||
</us>
|
||||
|
||||
```html
|
||||
<template>
|
||||
<div>
|
||||
<a-row>
|
||||
<a-col :span="12">col-12</a-col>
|
||||
<a-col :span="12">col-12</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="8">col-8</a-col>
|
||||
<a-col :span="8">col-8</a-col>
|
||||
<a-col :span="8">col-8</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="6">col-6</a-col>
|
||||
<a-col :span="6">col-6</a-col>
|
||||
<a-col :span="6">col-6</a-col>
|
||||
<a-col :span="6">col-6</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
</template>
|
||||
```
|
||||
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
<template>
|
||||
<div class="basic">
|
||||
<ant-row>
|
||||
<ant-col class="color1" :span="24" >100%</ant-col>
|
||||
</ant-row>
|
||||
<ant-row>
|
||||
<ant-col class="color1" :span="6" >25%</ant-col>
|
||||
<ant-col class="color1" :span="6" :offset="6" >25%</ant-col>
|
||||
</ant-row>
|
||||
<ant-row>
|
||||
<ant-col class="color1" :span="8" >33.33%</ant-col>
|
||||
<ant-col class="color1" :span="8" :offset="8" >33.33%</ant-col>
|
||||
</ant-row>
|
||||
<ant-row>
|
||||
<ant-col class="color1" :span="12" >50%</ant-col>
|
||||
</ant-row>
|
||||
<ant-row>
|
||||
<ant-col class="color1" :span="18" >66.66%</ant-col>
|
||||
</ant-row>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { Grid } from 'antd'
|
||||
const { Row, Col } = Grid
|
||||
export default {
|
||||
components: {
|
||||
AntRow: Row,
|
||||
AntCol: Col
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.basic {
|
||||
background: linear-gradient(90deg,#f5f5f5 4.16666667%,transparent 0,transparent 8.33333333%,#f5f5f5 0,#f5f5f5 12.5%,transparent 0,transparent 16.66666667%,#f5f5f5 0,#f5f5f5 20.83333333%,transparent 0,transparent 25%,#f5f5f5 0,#f5f5f5 29.16666667%,transparent 0,transparent 33.33333333%,#f5f5f5 0,#f5f5f5 37.5%,transparent 0,transparent 41.66666667%,#f5f5f5 0,#f5f5f5 45.83333333%,transparent 0,transparent 50%,#f5f5f5 0,#f5f5f5 54.16666667%,transparent 0,transparent 58.33333333%,#f5f5f5 0,#f5f5f5 62.5%,transparent 0,transparent 66.66666667%,#f5f5f5 0,#f5f5f5 70.83333333%,transparent 0,transparent 75%,#f5f5f5 0,#f5f5f5 79.16666667%,transparent 0,transparent 83.33333333%,#f5f5f5 0,#f5f5f5 87.5%,transparent 0,transparent 91.66666667%,#f5f5f5 0,#f5f5f5 95.83333333%,transparent 0);
|
||||
}
|
||||
.basic div {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
line-height: 40px;
|
||||
}
|
||||
.show-block {
|
||||
margin: 20px 0;
|
||||
}
|
||||
.color1 {
|
||||
background: rgba(0, 191, 255, 0.52);
|
||||
color: white;
|
||||
}
|
||||
</style>
|
|
@ -1,34 +0,0 @@
|
|||
<template>
|
||||
<div class="grid">
|
||||
<ant-row>
|
||||
<ant-col :xs="{ span: 5, offset: 1 }" :lg="{ span: 6, offset: 2 }" class="color1">Col</ant-col>
|
||||
<ant-col :xs="{ span: 11, offset: 1 }" :lg="{ span: 6, offset: 2 }" class="color2">Col</ant-col>
|
||||
<ant-col :xs="{ span: 5, offset: 1 }" :lg="{ span: 6, offset: 2 }" class="color1">Col</ant-col>
|
||||
</ant-row>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { Grid } from 'antd'
|
||||
const { Row, Col } = Grid
|
||||
export default {
|
||||
components: {
|
||||
AntRow: Row,
|
||||
AntCol: Col
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="less">
|
||||
.grid div {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
line-height: 40px;
|
||||
}
|
||||
.color1 {
|
||||
background: rgb(0, 191, 255);
|
||||
color: white;
|
||||
}
|
||||
.color2 {
|
||||
background: #0e77ca;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,41 @@
|
|||
<cn>
|
||||
#### Flex 对齐
|
||||
Flex 子元素垂直对齐。
|
||||
</cn>
|
||||
|
||||
<us>
|
||||
#### Flex Alignment
|
||||
Flex child elements vertically aligned.
|
||||
</us>
|
||||
|
||||
```html
|
||||
<template>
|
||||
<div>
|
||||
<p>Align Top</p>
|
||||
<a-row type="flex" justify="center" align="top">
|
||||
<a-col :span="4"><p class="height-100">col-4</p></a-col>
|
||||
<a-col :span="4"><p class="height-50">col-4</p></a-col>
|
||||
<a-col :span="4"><p class="height-120">col-4</p></a-col>
|
||||
<a-col :span="4"><p class="height-80">col-4</p></a-col>
|
||||
</a-row>
|
||||
|
||||
<p>Align Center</p>
|
||||
<a-row type="flex" justify="space-around" align="middle">
|
||||
<a-col :span="4"><p class="height-100">col-4</p></a-col>
|
||||
<a-col :span="4"><p class="height-50">col-4</p></a-col>
|
||||
<a-col :span="4"><p class="height-120">col-4</p></a-col>
|
||||
<a-col :span="4"><p class="height-80">col-4</p></a-col>
|
||||
</a-row>
|
||||
|
||||
<p>Align Bottom</p>
|
||||
<a-row type="flex" justify="space-between" align="bottom">
|
||||
<a-col :span="4"><p class="height-100">col-4</p></a-col>
|
||||
<a-col :span="4"><p class="height-50">col-4</p></a-col>
|
||||
<a-col :span="4"><p class="height-120">col-4</p></a-col>
|
||||
<a-col :span="4"><p class="height-80">col-4</p></a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
</template>
|
||||
```
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<cn>
|
||||
#### Flex 排序
|
||||
从堆叠到水平排列。
|
||||
通过 Flex 布局的 Order 来改变元素的排序。
|
||||
</cn>
|
||||
|
||||
<us>
|
||||
#### Flex Order
|
||||
To change the element sort by Flex layout order.
|
||||
</us>
|
||||
|
||||
```html
|
||||
<template>
|
||||
<div>
|
||||
<a-row type="flex">
|
||||
<a-col :span="6" :order="4">1 col-order-4</a-col>
|
||||
<a-col :span="6" :order="3">2 col-order-3</a-col>
|
||||
<a-col :span="6" :order="2">3 col-order-2</a-col>
|
||||
<a-col :span="6" :order="1">4 col-order-1</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
</template>
|
||||
```
|
||||
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
<template>
|
||||
<div class="grid">
|
||||
<ant-row type="flex">
|
||||
<ant-col :span="6" :order="4" class="color1">1 col-order-4</ant-col>
|
||||
<ant-col :span="6" :order="3" class="color2">2 col-order-3</ant-col>
|
||||
<ant-col :span="6" :order="2" class="color1">3 col-order-2</ant-col>
|
||||
<ant-col :span="6" :order="1" class="color2">4 col-order-1</ant-col>
|
||||
</ant-row>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { Grid } from 'antd'
|
||||
const { Row, Col } = Grid
|
||||
export default {
|
||||
components: {
|
||||
AntRow: Row,
|
||||
AntCol: Col
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="less">
|
||||
.grid div {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
line-height: 40px;
|
||||
}
|
||||
.color1 {
|
||||
background: rgb(0, 191, 255);
|
||||
color: white;
|
||||
}
|
||||
.color2 {
|
||||
background: #0e77ca;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,58 @@
|
|||
<cn>
|
||||
#### Flex 布局
|
||||
Flex 布局基础。
|
||||
使用 `row-flex` 定义 `flex` 布局,其子元素根据不同的值 `start`,`center`,`end`,`space-between`,`space-around`,分别定义其在父节点里面的排版方式。
|
||||
</cn>
|
||||
|
||||
<us>
|
||||
#### Flex Layout
|
||||
Use `row-flex` define `flex` layout, its child elements depending on the value of the `start`,` center`, `end`,` space-between`, `space-around`, which are defined in its parent node layout mode.
|
||||
</us>
|
||||
|
||||
```html
|
||||
<template>
|
||||
<div>
|
||||
<p>sub-element align left</p>
|
||||
<a-row type="flex" justify="start">
|
||||
<a-col :span="4">col-4</a-col>
|
||||
<a-col :span="4">col-4</a-col>
|
||||
<a-col :span="4">col-4</a-col>
|
||||
<a-col :span="4">col-4</a-col>
|
||||
</a-row>
|
||||
|
||||
<p>sub-element align center</p>
|
||||
<a-row type="flex" justify="center">
|
||||
<a-col :span="4">col-4</a-col>
|
||||
<a-col :span="4">col-4</a-col>
|
||||
<a-col :span="4">col-4</a-col>
|
||||
<a-col :span="4">col-4</a-col>
|
||||
</a-row>
|
||||
|
||||
<p>sub-element align right</p>
|
||||
<a-row type="flex" justify="end">
|
||||
<a-col :span="4">col-4</a-col>
|
||||
<a-col :span="4">col-4</a-col>
|
||||
<a-col :span="4">col-4</a-col>
|
||||
<a-col :span="4">col-4</a-col>
|
||||
</a-row>
|
||||
|
||||
<p>sub-element monospaced arrangement</p>
|
||||
<a-row type="flex" justify="space-between">
|
||||
<a-col :span="4">col-4</a-col>
|
||||
<a-col :span="4">col-4</a-col>
|
||||
<a-col :span="4">col-4</a-col>
|
||||
<a-col :span="4">col-4</a-col>
|
||||
</a-row>
|
||||
|
||||
<p>sub-element align full</p>
|
||||
<a-row type="flex" justify="space-around">
|
||||
<a-col :span="4">col-4</a-col>
|
||||
<a-col :span="4">col-4</a-col>
|
||||
<a-col :span="4">col-4</a-col>
|
||||
<a-col :span="4">col-4</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
</template>
|
||||
```
|
||||
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
<template>
|
||||
<div class="grid">
|
||||
<p>sub-element align left</p>
|
||||
<ant-row type="flex" justify="start">
|
||||
<ant-col :span="4" class="color1">col-4</ant-col>
|
||||
<ant-col :span="4" class="color2">col-4</ant-col>
|
||||
<ant-col :span="4" class="color1">col-4</ant-col>
|
||||
<ant-col :span="4" class="color2">col-4</ant-col>
|
||||
</ant-row>
|
||||
|
||||
<p>sub-element align center</p>
|
||||
<ant-row type="flex" justify="center">
|
||||
<ant-col :span="4" class="color1">col-4</ant-col>
|
||||
<ant-col :span="4" class="color2">col-4</ant-col>
|
||||
<ant-col :span="4" class="color1">col-4</ant-col>
|
||||
<ant-col :span="4" class="color2">col-4</ant-col>
|
||||
</ant-row>
|
||||
|
||||
<p>sub-element align right</p>
|
||||
<ant-row type="flex" justify="end">
|
||||
<ant-col :span="4" class="color1">col-4</ant-col>
|
||||
<ant-col :span="4" class="color2">col-4</ant-col>
|
||||
<ant-col :span="4" class="color1">col-4</ant-col>
|
||||
<ant-col :span="4" class="color2">col-4</ant-col>
|
||||
</ant-row>
|
||||
|
||||
<p>sub-element monospaced arrangement</p>
|
||||
<ant-row type="flex" justify="space-between">
|
||||
<ant-col :span="4" class="color1">col-4</ant-col>
|
||||
<ant-col :span="4" class="color2">col-4</ant-col>
|
||||
<ant-col :span="4" class="color1">col-4</ant-col>
|
||||
<ant-col :span="4" class="color2">col-4</ant-col>
|
||||
</ant-row>
|
||||
|
||||
<p>sub-element align full</p>
|
||||
<ant-row type="flex" justify="space-around">
|
||||
<ant-col :span="4" class="color1">col-4</ant-col>
|
||||
<ant-col :span="4" class="color2">col-4</ant-col>
|
||||
<ant-col :span="4" class="color1">col-4</ant-col>
|
||||
<ant-col :span="4" class="color2">col-4</ant-col>
|
||||
</ant-row>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { Grid } from 'antd'
|
||||
const { Row, Col } = Grid
|
||||
export default {
|
||||
components: {
|
||||
AntRow: Row,
|
||||
AntCol: Col
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="less">
|
||||
.grid div {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
line-height: 40px;
|
||||
}
|
||||
.color1 {
|
||||
background: rgb(0, 191, 255);
|
||||
color: white;
|
||||
}
|
||||
.color2 {
|
||||
background: #0e77ca;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
|
@ -1,34 +0,0 @@
|
|||
<template>
|
||||
<div class="grid">
|
||||
<ant-row>
|
||||
<ant-col :xs="2" :sm="4" :md="6" :lg="8" :xl="10" class="color1">Col</ant-col>
|
||||
<ant-col :xs="20" :sm="16" :md="12" :lg="8" :xl="4" class="color2">Col</ant-col>
|
||||
<ant-col :xs="2" :sm="4" :md="6" :lg="8" :xl="10" class="color1">Col</ant-col>
|
||||
</ant-row>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { Grid } from 'antd'
|
||||
const { Row, Col } = Grid
|
||||
export default {
|
||||
components: {
|
||||
AntRow: Row,
|
||||
AntCol: Col
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="less">
|
||||
.grid div {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
line-height: 40px;
|
||||
}
|
||||
.color1 {
|
||||
background: rgb(0, 191, 255);
|
||||
color: white;
|
||||
}
|
||||
.color2 {
|
||||
background: #0e77ca;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,44 @@
|
|||
<cn>
|
||||
#### 区块间隔
|
||||
栅格常常需要和间隔进行配合,你可以使用 `Row` 的 `gutter` 属性,我们推荐使用 `(16+8n)px` 作为栅格间隔。(n 是自然数)
|
||||
如果要支持响应式,可以写成 `{ xs: 8, sm: 16, md: 24, lg: 32 }`。
|
||||
</cn>
|
||||
|
||||
<us>
|
||||
#### Grid Gutter
|
||||
You can use the `gutter` property of `Row` as grid spacing, we recommend set it to `(16 + 8n) px`. (`n` stands for natural number.)
|
||||
You can set it to a object like `{ xs: 8, sm: 16, md: 24, lg: 32 }` for responsive design.
|
||||
</us>
|
||||
|
||||
```html
|
||||
<template>
|
||||
<div class="gutter-example">
|
||||
<a-row :gutter="16">
|
||||
<a-col class="gutter-row" :span="6">
|
||||
<div class="gutter-box">col-6</div>
|
||||
</a-col>
|
||||
<a-col class="gutter-row" :span="6">
|
||||
<div class="gutter-box">col-6</div>
|
||||
</a-col>
|
||||
<a-col class="gutter-row" :span="6">
|
||||
<div class="gutter-box">col-6</div>
|
||||
</a-col>
|
||||
<a-col class="gutter-row" :span="6">
|
||||
<div class="gutter-box">col-6</div>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
</template>
|
||||
<style>
|
||||
.gutter-example .ant-row > div {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
}
|
||||
.gutter-box {
|
||||
background: #00A0E9;
|
||||
padding: 5px 0;
|
||||
}
|
||||
</style>
|
||||
```
|
||||
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
<template>
|
||||
<div class="grid" style="overflow: hidden;">
|
||||
<ant-row :gutter="24">
|
||||
<ant-col :span="6"><div class="color2">col-6</div></ant-col>
|
||||
<ant-col :span="6"><div class="color2">col-6</div></ant-col>
|
||||
<ant-col :span="6"><div class="color2">col-6</div></ant-col>
|
||||
<ant-col :span="6"><div class="color2">col-6</div></ant-col>
|
||||
</ant-row>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { Grid } from 'antd'
|
||||
const { Row, Col } = Grid
|
||||
export default {
|
||||
components: {
|
||||
AntRow: Row,
|
||||
AntCol: Col
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="less">
|
||||
.grid div {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
line-height: 40px;
|
||||
}
|
||||
.color1 {
|
||||
background: rgb(0, 191, 255);
|
||||
color: white;
|
||||
}
|
||||
.color2 {
|
||||
background: #0e77ca;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
|
@ -1,75 +1,137 @@
|
|||
<template>
|
||||
<div class="topLevel">
|
||||
<h1>基础布局</h1>
|
||||
<basic/>
|
||||
<h1>恩。基础</h1>
|
||||
<layout/>
|
||||
<h1>区块间隔</h1>
|
||||
<gutter/>
|
||||
<h1>偏移</h1>
|
||||
<offset/>
|
||||
<h1>栅格排序</h1>
|
||||
<pull/>
|
||||
<h1>FLEX</h1>
|
||||
<flex/>
|
||||
<h1>对齐</h1>
|
||||
<align/>
|
||||
<h1>Flex排序</h1>
|
||||
<flex-order/>
|
||||
<h1>响应式设计</h1>
|
||||
<flexible/>
|
||||
<h1>复杂一点</h1>
|
||||
<complex/>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { Grid } from 'antd'
|
||||
const { Row, Col } = Grid
|
||||
import Basic from './basic.vue'
|
||||
import Layout from './layout.vue'
|
||||
import Gutter from './gutter.vue'
|
||||
import Offset from './offset.vue'
|
||||
import Pull from './pull.vue'
|
||||
import Flex from './flex.vue'
|
||||
import Align from './align.vue'
|
||||
import FlexOrder from './flex-order.vue'
|
||||
import Flexible from './flexible.vue'
|
||||
import Complex from './complex.vue'
|
||||
import Basic from './basic'
|
||||
import FlexAlign from './flex-align'
|
||||
import FlexOrder from './flex-order'
|
||||
import Flex from './flex'
|
||||
import Gutter from './gutter'
|
||||
import Offset from './offset'
|
||||
import ResponsiveMore from './responsive-more'
|
||||
import Responsive from './responsive'
|
||||
import Sort from './sort'
|
||||
import CN from '../index.zh-CN.md'
|
||||
import US from '../index.en-US.md'
|
||||
const md = {
|
||||
cn: `# Grid 栅格
|
||||
24 栅格系统。
|
||||
## 设计理念
|
||||
`,
|
||||
us: `# Grid
|
||||
24 Grids System。
|
||||
## Design concept`,
|
||||
}
|
||||
const md2 = {
|
||||
cn: `
|
||||
在多数业务情况下,Ant Design需要在设计区域内解决大量信息收纳的问题,因此在 12 栅格系统的基础上,我们将整个设计建议区域按照 24 等分的原则进行划分。
|
||||
划分之后的信息区块我们称之为『盒子』。建议横向排列的盒子数量最多四个,最少一个。『盒子』在整个屏幕上占比见上图。设计部分基于盒子的单位定制盒子内部的排版规则,以保证视觉层面的舒适感。
|
||||
## 概述
|
||||
布局的栅格化系统,我们是基于行(row)和列(col)来定义信息区块的外部框架,以保证页面的每个区域能够稳健地排布起来。下面简单介绍一下它的工作原理:
|
||||
- 通过\`row\`在水平方向建立一组\`column\`(简写col)
|
||||
- 你的内容应当放置于\`col\`内,并且,只有\`col\`可以作为\`row\`的直接元素
|
||||
- 栅格系统中的列是指1到24的值来表示其跨越的范围。例如,三个等宽的列可以使用\`.col-8\`来创建
|
||||
- 如果一个\`row\`中的\`col\`总和超过 24,那么多余的\`col\`会作为一个整体另起一行排列
|
||||
## Flex 布局
|
||||
我们的栅格化系统支持 Flex 布局,允许子元素在父节点内的水平对齐方式 - 居左、居中、居右、等宽排列、分散排列。子元素与子元素之间,支持顶部对齐、垂直居中对齐、底部对齐的方式。同时,支持使用 order 来定义元素的排列顺序。
|
||||
Flex 布局是基于 24 栅格来定义每一个『盒子』的宽度,但排版则不拘泥于栅格。
|
||||
## 代码演示
|
||||
`,
|
||||
us: `
|
||||
In most business situations, Ant Design needs to solve a lot of information storage problems within the design area, so based on 12 Grids System, we divided the design area into 24 aliquots.
|
||||
|
||||
We name the divided area 'box'. We suggest four boxes for horizontal arrangement at most, one at least. Boxes are proportional to the entire screen as shown in the picture above. To ensure a high level of visual comfort, we customize the typography inside of the box based on the box unit.
|
||||
|
||||
## Outline
|
||||
|
||||
In the grid system, we define the frame outside the information area based on \`row\` and \`column\`, to ensure that every area can have stable arrangement.
|
||||
|
||||
Following is a brief look at how it works:
|
||||
|
||||
- Establish a set of \`column\` in the horizontal space defined by \`row\` (abbreviated col)
|
||||
- Your content elements should be placed directly in the \`col\`, and only \`col\` should be placed directly in \`row\`
|
||||
- The column grid system is a value of 1-24 to represent its range spans. For example, three columns of equal width can be created by \`.col-8\` (\`span=8\`).
|
||||
- If the sum of \`col\` spans in a \`row\` are more than 24, then the overflowing \`col\` as a whole will start a new line arrangement.
|
||||
|
||||
## Flex layout
|
||||
Our grid systems support Flex layout to allow the elements within the parent to be aligned horizontally - left, center, right, wide arrangement, and decentralized arrangement. The Grid system also supports vertical alignment - top aligned, vertically centered, bottom-aligned. You can also define the order of elements by using \`order\`.
|
||||
Flex layout uses a 24 grid layout to define the width of each "box", but does not rigidly adhere to the grid layout.
|
||||
`,
|
||||
}
|
||||
export default {
|
||||
components: {
|
||||
AntRow: Row,
|
||||
AntCol: Col,
|
||||
Basic,
|
||||
Layout,
|
||||
Gutter,
|
||||
Offset,
|
||||
Pull,
|
||||
Flex,
|
||||
Align,
|
||||
FlexOrder,
|
||||
Flexible,
|
||||
Complex,
|
||||
category: 'Components',
|
||||
subtitle: '栅格',
|
||||
type: 'Layout',
|
||||
cols: 1,
|
||||
title: 'Grid',
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
<md cn={md.cn} us={md.us}/>
|
||||
<div class='grid-demo'>
|
||||
<div class='ant-row demo-row'>
|
||||
<div class='ant-col-24 demo-col demo-col-1'>
|
||||
100%
|
||||
</div>
|
||||
</div>
|
||||
<div class='ant-row demo-row'>
|
||||
<div class='ant-col-6 demo-col demo-col-2'>
|
||||
25%
|
||||
</div>
|
||||
<div class='ant-col-6 demo-col demo-col-3'>
|
||||
25%
|
||||
</div>
|
||||
<div class='ant-col-6 demo-col demo-col-2'>
|
||||
25%
|
||||
</div>
|
||||
<div class='ant-col-6 demo-col demo-col-3'>
|
||||
25%
|
||||
</div>
|
||||
</div>
|
||||
<div class='ant-row demo-row'>
|
||||
<div class='ant-col-8 demo-col demo-col-4'>
|
||||
33.33%
|
||||
</div>
|
||||
<div class='ant-col-8 demo-col demo-col-5'>
|
||||
33.33%
|
||||
</div>
|
||||
<div class='ant-col-8 demo-col demo-col-4'>
|
||||
33.33%
|
||||
</div>
|
||||
</div>
|
||||
<div class='ant-row demo-row'>
|
||||
<div class='ant-col-12 demo-col demo-col-1'>
|
||||
50%
|
||||
</div>
|
||||
<div class='ant-col-12 demo-col demo-col-3'>
|
||||
50%
|
||||
</div>
|
||||
</div>
|
||||
<div class='ant-row demo-row'>
|
||||
<div class='ant-col-16 demo-col demo-col-4'>
|
||||
66.66%
|
||||
</div>
|
||||
<div class='ant-col-8 demo-col demo-col-5'>
|
||||
33.33%
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<md cn={md2.cn} us={md2.us}/>
|
||||
<div id='components-grid-demo-all'>
|
||||
<Basic/>
|
||||
<FlexAlign/>
|
||||
<FlexOrder/>
|
||||
<Flex/>
|
||||
<Gutter/>
|
||||
<Offset/>
|
||||
<ResponsiveMore/>
|
||||
<Responsive/>
|
||||
<Sort/>
|
||||
</div>
|
||||
<api>
|
||||
<CN slot='cn' />
|
||||
<US/>
|
||||
</api>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="less">
|
||||
.topLevel .ant-row{
|
||||
margin: 10px 0;
|
||||
}
|
||||
.grid div {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
line-height: 40px;
|
||||
}
|
||||
.show-block {
|
||||
margin: 20px 0;
|
||||
}
|
||||
.color1 {
|
||||
background: #00bfff;
|
||||
color: white;
|
||||
}
|
||||
.color2 {
|
||||
background: #0e77ca;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
<template>
|
||||
<div class="grid">
|
||||
<ant-row>
|
||||
<ant-col class="color1" :span="12" >col-12</ant-col>
|
||||
<ant-col class="color2" :span="12" >col-12</ant-col>
|
||||
</ant-row>
|
||||
<ant-row>
|
||||
<ant-col class="color1" :span="8" >col-8</ant-col>
|
||||
<ant-col class="color2" :span="8" >col-8</ant-col>
|
||||
<ant-col class="color1" :span="8" >col-8</ant-col>
|
||||
</ant-row>
|
||||
<ant-row>
|
||||
<ant-col class="color1" :span="6" >col-6</ant-col>
|
||||
<ant-col class="color2" :span="6" >col-6</ant-col>
|
||||
<ant-col class="color1" :span="6" >col-6</ant-col>
|
||||
<ant-col class="color2" :span="6" >col-6</ant-col>
|
||||
</ant-row>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { Grid } from 'antd'
|
||||
const { Row, Col } = Grid
|
||||
export default {
|
||||
components: {
|
||||
AntRow: Row,
|
||||
AntCol: Col
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="less">
|
||||
.grid div {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
line-height: 40px;
|
||||
}
|
||||
.color1 {
|
||||
background: rgb(0, 191, 255);
|
||||
color: white;
|
||||
}
|
||||
.color2 {
|
||||
background: #0e77ca;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,30 @@
|
|||
<cn>
|
||||
#### 左右偏移
|
||||
列偏移。
|
||||
使用 `offset` 可以将列向右侧偏。例如,`:offset="4"` 将元素向右侧偏移了 4 个列(column)的宽度。
|
||||
</cn>
|
||||
|
||||
<us>
|
||||
#### a-column offset
|
||||
`Offset` can set the column to the right side. For example, using `offset = {4}` can set the element shifted to the right four columns width.
|
||||
</us>
|
||||
|
||||
```html
|
||||
<template>
|
||||
<div>
|
||||
<a-row>
|
||||
<a-col :span="8">col-8</a-col>
|
||||
<a-col :span="8" :offset="8">col-8</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="6" :offset="6">col-6 col-offset-6</a-col>
|
||||
<a-col :span="6" :offset="6">col-6 col-offset-6</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="12" :offset="6">col-12 col-offset-6</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
</template>
|
||||
```
|
||||
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
<template>
|
||||
<div class="grid">
|
||||
<ant-row>
|
||||
<ant-col :span="8" class="color1">col-8</ant-col>
|
||||
<ant-col :span="8" :offset="8" class="color2">col-8</ant-col>
|
||||
</ant-row>
|
||||
<ant-row>
|
||||
<ant-col :span="6" :offset="6" class="color1">col-6 col-offset-6</ant-col>
|
||||
<ant-col :span="6" :offset="6" class="color2">col-6 col-offset-6</ant-col>
|
||||
</ant-row>
|
||||
<ant-row>
|
||||
<ant-col :span="12" :offset="6" class="color1">col-12 col-offset-6</ant-col>
|
||||
</ant-row>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { Grid } from 'antd'
|
||||
const { Row, Col } = Grid
|
||||
export default {
|
||||
components: {
|
||||
AntRow: Row,
|
||||
AntCol: Col
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="less">
|
||||
.grid div {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
line-height: 40px;
|
||||
}
|
||||
.color1 {
|
||||
background: rgb(0, 191, 255);
|
||||
color: white;
|
||||
}
|
||||
.color2 {
|
||||
background: #0e77ca;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
|
@ -1,33 +0,0 @@
|
|||
<template>
|
||||
<div class="grid">
|
||||
<ant-row>
|
||||
<ant-col :span="18" :push="6" class="color1">col-18 col-push-6</ant-col>
|
||||
<ant-col :span="6" :pull="18" class="color2">col-6 col-pull-18</ant-col>
|
||||
</ant-row>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { Grid } from 'antd'
|
||||
const { Row, Col } = Grid
|
||||
export default {
|
||||
components: {
|
||||
AntRow: Row,
|
||||
AntCol: Col
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="less">
|
||||
.grid div {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
line-height: 40px;
|
||||
}
|
||||
.color1 {
|
||||
background: rgb(0, 191, 255);
|
||||
color: white;
|
||||
}
|
||||
.color2 {
|
||||
background: #0e77ca;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,23 @@
|
|||
<cn>
|
||||
#### 其他属性的响应式
|
||||
`span` `pull` `push` `offset` `order` 属性可以通过内嵌到 `xs` `sm` `md` `lg` `xl` `xxl` 属性中来使用。
|
||||
其中 `:xs="6"` 相当于 `:xs="{ span: 6 }"`。
|
||||
</cn>
|
||||
|
||||
<us>
|
||||
#### More responsive
|
||||
`span` `pull` `push` `offset` `order` property can be embedded into `xs` `sm` `md` `lg` `xl` properties to use,
|
||||
where `:xs="6"` is equivalent to `:xs="{span: 6}"`.
|
||||
</us>
|
||||
|
||||
```html
|
||||
<template>
|
||||
<a-row>
|
||||
<a-col :xs="{ span: 5, offset: 1 }" :lg="{ span: 6, offset: 2 }">Col</a-col>
|
||||
<a-col :xs="{ span: 11, offset: 1 }" :lg="{ span: 6, offset: 2 }">Col</a-col>
|
||||
<a-col :xs="{ span: 5, offset: 1 }" :lg="{ span: 6, offset: 2 }">Col</a-col>
|
||||
</a-row>
|
||||
</template>
|
||||
```
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<cn>
|
||||
#### 响应式布局
|
||||
参照 Bootstrap 的 [响应式设计](http://getbootstrap.com/css/#grid-media-queries),预设五个响应尺寸:`xs` `sm` `md` `lg` `xl` `xxl`。
|
||||
</cn>
|
||||
|
||||
<us>
|
||||
#### 响应式布局
|
||||
Referring to the Bootstrap [responsive design] (http://getbootstrap.com/css/#grid-media-queries), here preset five dimensions: `xs` `sm` `md` `lg` `xl`.
|
||||
</us>
|
||||
|
||||
```html
|
||||
<template>
|
||||
<a-row>
|
||||
<a-col :xs="2" :sm="4" :md="6" :lg="8" :xl="10">Col</a-col>
|
||||
<a-col :xs="20" :sm="16" :md="12" :lg="8" :xl="4">Col</a-col>
|
||||
<a-col :xs="2" :sm="4" :md="6" :lg="8" :xl="10">Col</a-col>
|
||||
</a-row>
|
||||
</template>
|
||||
```
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<cn>
|
||||
#### 栅格排序
|
||||
列排序。
|
||||
通过使用 `push` 和 `pull` 类就可以很容易的改变列(column)的顺序。
|
||||
</cn>
|
||||
|
||||
<us>
|
||||
#### Grid sort
|
||||
By using `push` and` pull` class you can easily change column order.
|
||||
</us>
|
||||
|
||||
```html
|
||||
<template>
|
||||
<div>
|
||||
<a-row>
|
||||
<a-col :span="18" :push="6">col-18 col-push-6</a-col>
|
||||
<a-col :span="6" :pull="18">col-6 col-pull-18</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
</template>
|
||||
```
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
## API
|
||||
|
||||
### Row
|
||||
|
||||
| Property | Description | Type | Default |
|
||||
| -------- | ----------- | ---- | ------- |
|
||||
| align | the vertical alignment of the flex layout: `top` `middle` `bottom` | string | `top` |
|
||||
| gutter | spacing between grids, could be a number or a object like `{ xs: 8, sm: 16, md: 24}` | number/object | 0 |
|
||||
| justify | horizontal arrangement of the flex layout: `start` `end` `center` `space-around` `space-between` | string | `start` |
|
||||
| type | layout mode, optional `flex`, [browser support](http://caniuse.com/#search=flex) | string | |
|
||||
|
||||
### Col
|
||||
|
||||
| Property | Description | Type | Default |
|
||||
| -------- | ----------- | ---- | ------- |
|
||||
| offset | the number of cells to offset Col from the left | number | 0 |
|
||||
| order | raster order, used in `flex` layout mode | number | 0 |
|
||||
| pull | the number of cells that raster is moved to the left | number | 0 |
|
||||
| push | the number of cells that raster is moved to the right | number | 0 |
|
||||
| span | raster number of cells to occupy, 0 corresponds to `display: none` | number | none |
|
||||
| xs | `<576px` and also default setting, could be a `span` value or an object containing above props | number\|object | - |
|
||||
| sm | `≥576px`, could be a `span` value or an object containing above props | number\|object | - |
|
||||
| md | `≥768px`, could be a `span` value or an object containing above props | number\|object | - |
|
||||
| lg | `≥992px`, could be a `span` value or an object containing above props | number\|object | - |
|
||||
| xl | `≥1200px`, could be a `span` value or an object containing above props | number\|object | - |
|
||||
| xxl | `≥1600px`, could be a `span` value or an object containing above props | number\|object | - |
|
||||
|
||||
The breakpoints of responsive grid follow [BootStrap 4 media queries rules](https://getbootstrap.com/docs/4.0/layout/overview/#responsive-breakpoints)(not including `occasionally part`).
|
|
@ -1,6 +1,7 @@
|
|||
import Row from './Row.vue'
|
||||
import Col from './Col.vue'
|
||||
import Row from './Row'
|
||||
import Col from './Col'
|
||||
|
||||
export default {
|
||||
Col, Row,
|
||||
export {
|
||||
Row,
|
||||
Col,
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
## API
|
||||
|
||||
### Row
|
||||
|
||||
| 成员 | 说明 | 类型 | 默认值 |
|
||||
| --- | --- | --- | --- |
|
||||
| align | flex 布局下的垂直对齐方式:`top` `middle` `bottom` | string | `top` |
|
||||
| gutter | 栅格间隔,可以写成像素值或支持响应式的对象写法 `{ xs: 8, sm: 16, md: 24}` | number/object | 0 |
|
||||
| justify | flex 布局下的水平排列方式:`start` `end` `center` `space-around` `space-between` | string | `start` |
|
||||
| type | 布局模式,可选 `flex`,[现代浏览器](http://caniuse.com/#search=flex) 下有效 | string | |
|
||||
|
||||
### Col
|
||||
|
||||
| 成员 | 说明 | 类型 | 默认值 |
|
||||
| --- | --- | --- | --- |
|
||||
| offset | 栅格左侧的间隔格数,间隔内不可以有栅格 | number | 0 |
|
||||
| order | 栅格顺序,`flex` 布局模式下有效 | number | 0 |
|
||||
| pull | 栅格向左移动格数 | number | 0 |
|
||||
| push | 栅格向右移动格数 | number | 0 |
|
||||
| span | 栅格占位格数,为 0 时相当于 `display: none` | number | - |
|
||||
| xs | `<576px` 响应式栅格,可为栅格数或一个包含其他属性的对象 | number\|object | - |
|
||||
| sm | `≥576px` 响应式栅格,可为栅格数或一个包含其他属性的对象 | number\|object | - |
|
||||
| md | `≥768px` 响应式栅格,可为栅格数或一个包含其他属性的对象 | number\|object | - |
|
||||
| lg | `≥992px` 响应式栅格,可为栅格数或一个包含其他属性的对象 | number\|object | - |
|
||||
| xl | `≥1200px` 响应式栅格,可为栅格数或一个包含其他属性的对象 | number\|object | - |
|
||||
| xxl | `≥1600px` 响应式栅格,可为栅格数或一个包含其他属性的对象 | number\|object | - |
|
||||
|
||||
响应式栅格的断点扩展自 [BootStrap 4 的规则](https://getbootstrap.com/docs/4.0/layout/overview/#responsive-breakpoints)(不包含链接里 `occasionally` 的部分)。
|
|
@ -13,7 +13,11 @@ const RadioGroup = Radio.Group
|
|||
const RadioButton = Radio.Button
|
||||
export { Radio, RadioGroup, RadioButton }
|
||||
|
||||
export { default as Grid } from './grid'
|
||||
import { Row, Col } from './grid'
|
||||
export {
|
||||
Row,
|
||||
Col,
|
||||
}
|
||||
|
||||
export { default as Rate } from './rate'
|
||||
|
||||
|
@ -21,10 +25,6 @@ export { default as Tooltip } from './tooltip'
|
|||
|
||||
export { default as Pagination } from './pagination'
|
||||
|
||||
export { default as Row } from './grid/Row'
|
||||
|
||||
export { default as Col } from './grid/Col'
|
||||
|
||||
export { default as Tag } from './tag'
|
||||
|
||||
export { default as Avatar } from './avatar'
|
||||
|
|
|
@ -33,8 +33,7 @@ Carousel
|
|||
Mention
|
||||
|
||||
##万
|
||||
Grid
|
||||
Col
|
||||
Grid | done slider完成后补全playground demo
|
||||
Layout
|
||||
Anchor
|
||||
Tree
|
||||
|
|
|
@ -3,7 +3,7 @@ const AsyncComp = () => {
|
|||
const hashs = window.location.hash.split('/')
|
||||
const d = hashs[hashs.length - 1]
|
||||
return {
|
||||
component: import(`../components/alert/demo/${d}`),
|
||||
component: import(`../components/grid/demo/${d}`),
|
||||
}
|
||||
}
|
||||
export default [
|
||||
|
|
|
@ -94,6 +94,7 @@
|
|||
"css-animation": "^1.4.1",
|
||||
"dom-align": "^1.6.7",
|
||||
"dom-scroll-into-view": "^1.2.1",
|
||||
"enquire.js": "^2.1.6",
|
||||
"eslint-plugin-vue": "^3.13.0",
|
||||
"lodash.clonedeep": "^4.5.0",
|
||||
"lodash.debounce": "^4.0.8",
|
||||
|
|
Loading…
Reference in New Issue