Skip to content

Commit

Permalink
Support Upload & Radio (#74)
Browse files Browse the repository at this point in the history
* support radio component

* support upload component

* upgrade checkbox-group component
  • Loading branch information
dolymood authored Jan 18, 2018
1 parent 35248d0 commit cdc3d2a
Show file tree
Hide file tree
Showing 35 changed files with 2,345 additions and 47 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build/*.js
config/*.js
example/modules/*.js
44 changes: 22 additions & 22 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
extends: 'standard',
// required to lint *.vue files
plugins: [
'html'
],
// add your custom rules here
'rules': {
// allow paren-less arrow functions
'arrow-parens': 0,
// allow async-await
'generator-star-spacing': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'no-tabs': 0,
'space-before-function-paren': 0
}
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
extends: 'standard',
// required to lint *.vue files
plugins: [
'html'
],
// add your custom rules here
'rules': {
// allow paren-less arrow functions
'arrow-parens': 0,
// allow async-await
'generator-star-spacing': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'no-tabs': 0,
'space-before-function-paren': 0
}
}
14 changes: 14 additions & 0 deletions document/common/config/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"button": "Button",
"checkbox": "Checkbox",
"checkbox-group": "CheckboxGroup",
"radio": "Radio",
"loading": "Loading",
"tip": "Tip"
}
Expand All @@ -42,6 +43,12 @@
"slide": "Slide",
"index-list": "IndexList"
}
},
"advanced": {
"name": "Advanced",
"subList": {
"upload": "Upload"
}
}
}
},
Expand Down Expand Up @@ -74,6 +81,7 @@
"button": "Button",
"checkbox": "Checkbox",
"checkbox-group": "CheckboxGroup",
"radio": "Radio",
"loading": "Loading",
"tip": "Tip"
}
Expand All @@ -97,6 +105,12 @@
"slide": "Slide",
"index-list": "IndexList"
}
},
"advanced": {
"name": "高级",
"subList": {
"upload": "Upload"
}
}
}
},
Expand Down
48 changes: 45 additions & 3 deletions document/components/docs/en-US/checkbox-group.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,43 @@

The value of `checkList` is an array, which represents the set of the values of `label` in selected checkboxs.

- Set options

Set options to generate checkboxes.

```html
<cube-checkbox-group v-model="checkList" :options="options" />
```
```js
export default {
data() {
return {
checkList: ['1', '4'],
options: [
{
label: 'Option1',
value: '1'
},
{
label: 'Option2',
value: '2'
},
{
label: 'Option3',
value: '3',
disabled: true
},
{
label: 'Option4',
value: '4',
disabled: true
}
]
}
}
}
```

- Horizontal order

You can set `horizontal` to change the style to horizontal order.
Expand All @@ -45,9 +82,14 @@
| Attribute | Description | Type | Accepted Values | Default |
| - | - | - | - | - |
| horizontal | whether in horizontal order | Boolean | true/false | false |
| options | array of checkbox options | Array | - | - |

### Events
* `options` sub configuration

| Event Name | Description | Parameters |
| Attribute | Description | Type |
| - | - | - |
| input | triggers when the selecting state in the group changes | the set of values of selected checkboxs, which type is Array |
| label | label content | String |
| value | checkbox item value | String/Number |
| disabled | whether disabled | Boolean |

Note: each `options` item can be an string value, now both the`label` and `value` values are the string value.
9 changes: 1 addition & 8 deletions document/components/docs/en-US/checkbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,5 @@
| Attribute | Description | Type | Accepted Values | Default |
| - | - | - | - | - |
| disabled | whether disabled | Boolean | true/false | false |
| position | position | String | left/right | left |
| position | icon position | String | left/right | left |
| label | if selected, then map the value to v-model | Boolean/String | - | '' |

### Events

| Event Name | Description | Parameters |
| - | - | - |
| input | triggers when the selecting state changes | the value of label if setted or boolean value which represents whether selected |

5 changes: 5 additions & 0 deletions document/components/docs/en-US/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ cube-ui is an elegant mobile component library based on Vue.js.
- [Button](#/en-US/docs/button)
- [Checkbox](#/en-US/docs/checkbox)
- [CheckboxGroup](#/en-US/docs/checkbox-group)
- [Radio](#/zh-CN/docs/radio)
- [Loading](#/en-US/docs/loading)
- [Tip](#/en-US/docs/tip)

Expand Down Expand Up @@ -99,6 +100,10 @@ Pay attention that the name of the API is `$create` + `${component name}`. For e

Scroll Components are all implemented based on [better-scroll](https://github.com/ustbhuangyi/better-scroll) and `Scroll` Component is the encapsulation of better-scroll.

#### Advanced

- [Upload](#/en-US/docs/upload)

### Modules

cube-ui has some special modules besides components.
Expand Down
107 changes: 107 additions & 0 deletions document/components/docs/en-US/radio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
## Radio

Radio component. You could set the options and the position of the radio's icon.

### Example

- Basic usage

```html
<cube-radio v-model="selected" :options="options" />
```
```js
export default {
data() {
return {
selected: '',
options: ['Option1', 'Option2']
}
}
}
```

The value of `options` is an array. The default `selected` value is `''`, which means no option will be selected by defaut. If you clicked one radio option, the `selected` will be set as the value of this option.

- Configure the label, value, disabled state of options and the position of icon.

```html
<cube-radio v-model="selected2" :options="options2" position="right" />
```
```js
export default {
data() {
return {
selected2: '3',
options2: [
{
label: 'Option1',
value: '1'
},
{
label: 'Option2',
value: '2'
},
{
label: 'Option3',
value: '3',
disabled: true
}
]
}
}
}
```

The `options` value can be an array which has some object items. You can set `label` and `value` in each item, and use `disabled` to configure whether the radio item's state is disabled.

If the `position` is set as `'right'`, the radio's icon will be posited at the right of the label.

- Horizontal order

```html
<cube-radio v-model="selected3" :options="options3" :horizontal="true" />
```
```js
export default {
data() {
return {
selected3: '3',
options3: [
{
label: '1',
value: '1'
},
{
label: '2',
value: '2'
},
{
label: '3',
value: '3',
disabled: true
}
]
}
}
}
```

You can use `horizontal` to configure the style to horizontal layout.

### Props configuration

| Attribute | Description | Type | Accepted Values | Default |
| - | - | - | - | - |
| options | the array of radio options | Array | - | - |
| position | icon position | String | left/right | left |
| horizontal | whether use horizontal layout | Boolean | true/false | false |

* `options` sub configuration

| Attribute | Description | Type |
| - | - | - |
| label | the text of label | String |
| value | the value of radio item | String/Number |
| disabled | whether the item is disabled | Boolean |

Note: Each item of `options` can be an string, Which means both the `label` and `value` will be set as this string.
Loading

0 comments on commit cdc3d2a

Please sign in to comment.