Skip to content

Commit

Permalink
feat(components): add radio & checkbox components
Browse files Browse the repository at this point in the history
  • Loading branch information
ysfscream committed Apr 20, 2021
1 parent fee8930 commit 3828a3d
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 0 deletions.
13 changes: 13 additions & 0 deletions example/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@
</template>
</emqx-avatar>
</div>
<h2>Checkbox</h2>
<div class="show-item">
<emqx-checkbox v-model="checked">备选项</emqx-checkbox>
</div>
<h2>Radio</h2>
<div class="show-item">
<emqx-radio v-model="radio" label="1">备选项1</emqx-radio>
<emqx-radio v-model="radio" label="2">备选项2</emqx-radio>
</div>
</template>

<script lang="ts">
Expand Down Expand Up @@ -266,6 +275,8 @@ export default defineComponent({
}, 2000)
})
}
const checked = ref(true)
const radio = ref('1')
return {
testInput,
testSelect,
Expand All @@ -285,6 +296,8 @@ export default defineComponent({
tagOptions,
fakeRequestToAddTag,
jsonValue,
checked,
radio,
}
},
})
Expand Down
8 changes: 8 additions & 0 deletions packages/Checkbox/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { App } from 'vue'
import Checkbox from './src/checkbox.vue'

Checkbox.install = (Vue: App): void => {
Vue.component(Checkbox.name, Checkbox)
}

export default Checkbox
17 changes: 17 additions & 0 deletions packages/Checkbox/src/checkbox.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<el-checkbox class="emqx-checkbox">
<slot></slot>
</el-checkbox>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { ElCheckbox } from 'element-plus'
export default defineComponent({
name: 'EmqxCheckbox',
components: {
ElCheckbox,
},
})
</script>
8 changes: 8 additions & 0 deletions packages/Radio/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { App } from 'vue'
import Radio from './src/radio.vue'

Radio.install = (Vue: App): void => {
Vue.component(Radio.name, Radio)
}

export default Radio
17 changes: 17 additions & 0 deletions packages/Radio/src/radio.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<el-radio class="emqx-radio">
<slot></slot>
</el-radio>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { ElRadio } from 'element-plus'
export default defineComponent({
name: 'EmqxRadio',
components: {
ElRadio,
},
})
</script>
6 changes: 6 additions & 0 deletions packages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import Tags from './Tags'
import KeyValueEditor from './KeyValueEditor'
import Loading from './Loading'
import Avatar from './Avatar'
import Checkbox from './Checkbox'
import Radio from './Radio'

import lang from 'element-plus/lib/locale/lang/zh-cn'
import locale from 'element-plus/lib/locale'
Expand Down Expand Up @@ -69,6 +71,8 @@ const components = [
Tags,
KeyValueEditor,
Avatar,
Checkbox,
Radio,
]

const plugins = [Loading]
Expand Down Expand Up @@ -115,6 +119,8 @@ const packages = {
Tags,
KeyValueEditor,
Avatar,
Checkbox,
Radio,
}

export const EmqxMessage = Message
Expand Down

0 comments on commit 3828a3d

Please sign in to comment.