Skip to content

Commit

Permalink
👍 增加radio组件水平显示样式
Browse files Browse the repository at this point in the history
  • Loading branch information
monw3c committed Aug 2, 2018
1 parent 7af471d commit 14f68bb
Show file tree
Hide file tree
Showing 26 changed files with 184 additions and 22 deletions.
6 changes: 3 additions & 3 deletions docs/components/form.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ checkbox的另一种表现,有```value```属性

## radio
###### 基础用法
需配合 xm-radio-group 使用,通过```color```属性改变 √ 颜色,```disabled```禁止选中
``` html
需配合 xm-radio-group 使用,通过```color```属性改变 √ 颜色,```disabled```禁止选中,```hor```为水平单选框,默认不填为垂直
```html
<xm-radio-group v-model="radio" color="#4cd864">
<xm-radio value="巴士"></xm-radio>
<xm-radio value="火车"></xm-radio>
Expand All @@ -156,7 +156,7 @@ export default {
|---------- |-------- |---------- |------------- |-------- |
| color | 设置颜色 | String |||
| disabled | 禁止选中 | Boolean || false |

| hor | 水平显示 | Boolean || false |

## checkbox
###### 基础用法
Expand Down
2 changes: 1 addition & 1 deletion docs/dist/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1"><title>xmui - 基于vue2,可复用UI组件</title><link href=./static/css/app.d3b5058372ea2f8b3df034641c430bdc.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.3eca77b76cc3bdfd2514.js></script><script type=text/javascript src=./static/js/vendor.c7ad6fdac84180d296de.js></script><script type=text/javascript src=./static/js/app.dd7d721cd309220695bc.js></script></body></html>
<!DOCTYPE html><html><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1"><title>xmui - 基于vue2,可复用UI组件</title><link href=./static/css/app.1a6913976475e8fd73c957dcbb6a9f91.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.1427bbba43ff028fa4f9.js></script><script type=text/javascript src=./static/js/vendor.c7ad6fdac84180d296de.js></script><script type=text/javascript src=./static/js/app.22d1c3bc6de09a946866.js></script></body></html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

2 changes: 2 additions & 0 deletions docs/dist/static/js/0.266fd9072fbe6c37ac38.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/dist/static/js/0.266fd9072fbe6c37ac38.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docs/dist/static/js/0.7067f52b699bbcd49756.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/dist/static/js/0.7067f52b699bbcd49756.js.map

This file was deleted.

2 changes: 2 additions & 0 deletions docs/dist/static/js/app.22d1c3bc6de09a946866.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/dist/static/js/app.22d1c3bc6de09a946866.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docs/dist/static/js/app.dd7d721cd309220695bc.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/dist/static/js/app.dd7d721cd309220695bc.js.map

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "x-m-ui",
"version": "0.1.41",
"version": "0.1.42",
"description": "UI components base on Vue 2.x",
"author": "mon <[email protected]>",
"main": "package/xmui.min.js",
Expand Down
4 changes: 4 additions & 0 deletions package/comps/components/radio/radio-group.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export default {
color: {
type: String,
default: '#4CD864'
},
hor: {
type: Boolean,
default: false
}
},
data () {
Expand Down
62 changes: 62 additions & 0 deletions package/comps/components/radio/radio.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
position: relative;
vertical-align: middle;
line-height: normal;
text-align: left;

& .xm__radio {
width: 100%;
Expand Down Expand Up @@ -53,7 +54,68 @@
transform: scaleY(1) scaleX(2);
transform-origin: 0 0;
}

&.horizontal{
display: inline-flex;
padding-right: 10px;
width: auto;
white-space: nowrap;


& .xm__radio--text-horizontal{
font-size: $font-size-base;
margin-left: .2rem;
}

& .xm__icon--radio-horizontal{
border-radius: 50%;
display: inline-block;
position: relative;
z-index: 10;
vertical-align: middle;
pointer-events: none;
width: $font-size-big;
height: $font-size-big;
// margin-top: -4px;
}

& > input[type=radio] {
position: absolute;
left: -9999em;

& + .xm__icon--radio-horizontal:before {
color: #ccc;
display: inline;
content: "\E668";
font-size: $font-size-base*1.5;
right: 0;
// top: -18px;
position: absolute;
}

&:checked + .xm__icon--radio-horizontal:before {
color: currentColor;
content: "\E730";
}

}

&.disabled {

& .xm__radio--text-horizontal {
color: #ccc;
}

& > input[type=radio] + .xm__icon--radio-horizontal:before{
color: #efefef;
}

}

&:not(:last-child):after {
border-bottom: none;
}
}
}

}
Expand Down
11 changes: 10 additions & 1 deletion package/comps/components/radio/radio.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
<template>
<label class="xm__radio" :class="[{'disabled':disabled}]">
<label class="xm__radio" :class="[{'disabled':disabled,'horizontal':$parent.hor}]">
<!-- 水平显示 -->
<template v-if="$parent.hor">
<input type="radio" @change="onChange" :disabled="disabled" :checked="checked"/>
<span class=" xm__icon--radio-horizontal" :style="[{'color': $parent.color}]"></span>
<span class="xm__radio--text-horizontal"><slot>{{value}}</slot></span>
</template>
<!-- 垂直显示 -->
<template v-else>
<span class="xm__radio--text"><slot>{{value}}</slot></span>
<input type="radio" @change="onChange" :disabled="disabled" :checked="checked"/>
<span class="xm__radio--icon xm__icon--radio" :style="[{'color': $parent.color}]"></span>
</template>
</label>
</template>

Expand Down
2 changes: 1 addition & 1 deletion package/xmui.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package/xmui.min.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package/xmui.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/comps/components/radio/radio-group.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export default {
color: {
type: String,
default: '#4CD864'
},
hor: {
type: Boolean,
default: false
}
},
data () {
Expand Down
62 changes: 62 additions & 0 deletions src/comps/components/radio/radio.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
position: relative;
vertical-align: middle;
line-height: normal;
text-align: left;

& .xm__radio {
width: 100%;
Expand Down Expand Up @@ -53,7 +54,68 @@
transform: scaleY(1) scaleX(2);
transform-origin: 0 0;
}

&.horizontal{
display: inline-flex;
padding-right: 10px;
width: auto;
white-space: nowrap;


& .xm__radio--text-horizontal{
font-size: $font-size-base;
margin-left: .2rem;
}

& .xm__icon--radio-horizontal{
border-radius: 50%;
display: inline-block;
position: relative;
z-index: 10;
vertical-align: middle;
pointer-events: none;
width: $font-size-big;
height: $font-size-big;
// margin-top: -4px;
}

& > input[type=radio] {
position: absolute;
left: -9999em;

& + .xm__icon--radio-horizontal:before {
color: #ccc;
display: inline;
content: "\E668";
font-size: $font-size-base*1.5;
right: 0;
// top: -18px;
position: absolute;
}

&:checked + .xm__icon--radio-horizontal:before {
color: currentColor;
content: "\E730";
}

}

&.disabled {

& .xm__radio--text-horizontal {
color: #ccc;
}

& > input[type=radio] + .xm__icon--radio-horizontal:before{
color: #efefef;
}

}

&:not(:last-child):after {
border-bottom: none;
}
}
}

}
Expand Down
11 changes: 10 additions & 1 deletion src/comps/components/radio/radio.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
<template>
<label class="xm__radio" :class="[{'disabled':disabled}]">
<label class="xm__radio" :class="[{'disabled':disabled,'horizontal':$parent.hor}]">
<!-- 水平显示 -->
<template v-if="$parent.hor">
<input type="radio" @change="onChange" :disabled="disabled" :checked="checked"/>
<span class=" xm__icon--radio-horizontal" :style="[{'color': $parent.color}]"></span>
<span class="xm__radio--text-horizontal"><slot>{{value}}</slot></span>
</template>
<!-- 垂直显示 -->
<template v-else>
<span class="xm__radio--text"><slot>{{value}}</slot></span>
<input type="radio" @change="onChange" :disabled="disabled" :checked="checked"/>
<span class="xm__radio--icon xm__icon--radio" :style="[{'color': $parent.color}]"></span>
</template>
</label>
</template>

Expand Down
12 changes: 12 additions & 0 deletions src/views/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@
</xm-cell-item>
</xm-cell-group>

<xm-cell-group title="单选" class="xm-radio-group" style="background: #fff;margin-bottom: 20px;text-align: center;">
<xm-cell-item>
<xm-radio-group slot="right" v-model="radio" color="#ed3f14" hor>
<xm-radio value="巴士"></xm-radio>
<xm-radio value="火车"></xm-radio>
<xm-radio value="飞机" disabled>飞机--disabled</xm-radio>
<xm-radio value="单车">单车</xm-radio>
</xm-radio-group>
</xm-cell-item>
</xm-cell-group>


<xm-cell-group title="复选" class="xm-checkbox-group" >
<xm-cell-item>
<xm-checkbox-group slot="right" v-model="checkbox" color="#4cd864">
Expand Down

0 comments on commit 14f68bb

Please sign in to comment.