Skip to content

Commit

Permalink
fix: layout增加点击事件,骨架屏增加组合形式demo,textarea autosize 问题优化 (jd-opensource…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ymm0008 authored Apr 14, 2022
1 parent 05ce195 commit 96b417d
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 16 deletions.
12 changes: 9 additions & 3 deletions src/packages/__VUE/col/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<view :class="classes" :style="style">
<view :class="classes" :style="style" @click="handleClick">
<slot></slot>
</view>
</template>
Expand All @@ -19,7 +19,8 @@ export default create({
default: '0'
}
},
setup(props) {
emits: ['click'],
setup(props, { emit }) {
const prefixCls = componentName;
const gutter = inject('gutter') as number;
const classes = computed(() => {
Expand All @@ -36,9 +37,14 @@ export default create({
paddingRight: gutter / 2 + 'px'
};
});
const handleClick = (evt: MouseEvent) => {
evt.stopPropagation();
emit('click', evt);
};
return {
classes,
style
style,
handleClick
};
}
});
Expand Down
11 changes: 11 additions & 0 deletions src/packages/__VUE/layout/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,14 @@ app.use(Col);
| span | 列元素宽度(共分为24份,例如设置一行3个,那么span值为8) | String、Number | 24
| offset | 列元素偏移距离 | String、Number | 0

### row events

| 字段 | 说明 | 回调参数
|----- | ----- | -----
| click | 点击时触发 | event: MouseEvent

### col events

| 字段 | 说明 | 回调参数
|----- | ----- | -----
| click | 点击时触发 | event: MouseEvent
19 changes: 10 additions & 9 deletions src/packages/__VUE/row/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<view :class="getClasses()">
<view :class="getClasses()" @click="handleClick">
<slot></slot>
</view>
</template>
Expand Down Expand Up @@ -31,15 +31,12 @@ export default create({
default: 'nowrap'
}
},
setup(props) {
emits: ['click'],
setup(props, { emit }) {
const prefixCls = componentName;
provide('gutter', props.gutter);
const getClass = (prefix: string, type: string) => {
return prefix
? type
? `nut-row-${prefix}-${type}`
: ''
: `nut-row-${type}`;
return prefix ? (type ? `nut-row-${prefix}-${type}` : '') : `nut-row-${type}`;
};
const getClasses = () => {
return `
Expand All @@ -50,9 +47,13 @@ export default create({
${prefixCls}
`;
};
const handleClick = (evt: MouseEvent) => {
evt.stopPropagation();
emit('click', evt);
};
return {
getClasses
getClasses,
handleClick
};
}
});
Expand Down
15 changes: 15 additions & 0 deletions src/packages/__VUE/skeleton/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
<h2>标题段落圆角风格</h2>
<nut-skeleton width="250px" height="15px" animated round></nut-skeleton>

<h2>图片组合</h2>

<div class="pic-compose">
<nut-skeleton width="250px" height="15px" title animated row="3" class="item"> </nut-skeleton>
<nut-skeleton width="250px" height="15px" title animated row="3" class="item"> </nut-skeleton>
</div>

<h2>显示子组件</h2>

<view class="content">
Expand Down Expand Up @@ -56,6 +63,7 @@ export default createDemo({

<style lang="scss">
.content {
margin-bottom: 20px;
.nut-switch {
display: flex;
margin: 0 16px 8px 0;
Expand All @@ -79,4 +87,11 @@ export default createDemo({
}
}
}
.pic-compose {
display: flex;
justify-content: space-between;
.item {
width: 47%;
}
}
</style>
2 changes: 1 addition & 1 deletion src/packages/__VUE/textarea/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<h2>显示字数统计</h2>
<nut-textarea v-model="value2" limit-show max-length="20" />
<h2>高度自定义,拉伸</h2>
<nut-textarea v-model="value3" autosize />
<nut-textarea v-model="value3" />
<h2>只读</h2>
<nut-textarea readonly model-value="textarea只读状态" />
<h2>禁用</h2>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/__VUE/textarea/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default {
| v-model | 输入值,支持双向绑定 | String | - |
| placeholder | 设置占位提示文字 | String | `'请输入内容'` |
| max-length | 限制最长输入字符 | String、Number | - |
| rows | textarea的高度 | String、Number | `2` |
| rows | textarea的高度,优先级高于autosize属性 | String、Number | `2` |
| limit-show | textarea是否展示输入字符。须配合`max-length`使用 | Boolean | `false` |
| autosize | 是否自适应内容高度,也可传入对象, 如 { maxHeight: 200, minHeight: 100 },单位为px | Boolean 、{maxHeight?: number; minHeight?: number} | `false` |
| text-align | 文本位置,可选值`left`,`center`,`right` | String | `left` |
Expand Down
4 changes: 2 additions & 2 deletions src/packages/__VUE/textarea/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default create({
default: false
},
autosize: {
type: Boolean,
type: [Boolean, Object],
default: false
},
autofocus: {
Expand Down Expand Up @@ -109,7 +109,7 @@ export default create({
height = Math.max(height, minHeight);
}
}
if (height) {
if (height && props.rows == '') {
textarea.style.height = height + 'px';
}
};
Expand Down
14 changes: 14 additions & 0 deletions src/sites/mobile-taro/vue/src/exhibition/pages/skeleton/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
<h2>标题段落圆角风格</h2>
<nut-skeleton width="250px" height="15px" animated round></nut-skeleton>

<h2>图片组合</h2>

<div class="pic-compose">
<nut-skeleton width="250px" height="15px" title animated row="3" class="item"> </nut-skeleton>
<nut-skeleton width="250px" height="15px" title animated row="3" class="item"> </nut-skeleton>
</div>

<h2>显示子组件</h2>
<view class="content">
<nut-switch v-model="checked" size="15px" />
Expand Down Expand Up @@ -71,4 +78,11 @@ export default {
}
}
}
.pic-compose {
display: flex;
justify-content: space-between;
.item {
width: 47%;
}
}
</style>

0 comments on commit 96b417d

Please sign in to comment.