Skip to content

Commit

Permalink
增加组件:Media
Browse files Browse the repository at this point in the history
  • Loading branch information
skyvow committed Jul 8, 2018
1 parent ded9e5f commit 17d8c38
Show file tree
Hide file tree
Showing 21 changed files with 416 additions and 0 deletions.
25 changes: 25 additions & 0 deletions dist/media/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Component({
externalClasses: ['wux-class'],
properties: {
thumb: {
type: String,
value: '',
},
thumbStyle: {
type: String,
value: '',
},
title: {
type: String,
value: '',
},
label: {
type: String,
value: '',
},
align: {
type: String,
value: 'center',
},
},
})
3 changes: 3 additions & 0 deletions dist/media/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"component": true
}
10 changes: 10 additions & 0 deletions dist/media/index.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<view class="wux-class wux-media {{ align ? 'wux-media--align-' + align : '' }}">
<view class="wux-media__hd">
<image class="wux-media__thumb" src="{{ thumb }}" mode="aspectFit" style="{{ thumbStyle }}" wx:if="{{ thumb }}" />
</view>
<view class="wux-media__bd">
<view class="wux-media__title" wx:if="{{ title }}">{{ title }}</view>
<view class="wux-media__desc" wx:if="{{ label }}">{{ label }}</view>
<slot></slot>
</view>
</view>
69 changes: 69 additions & 0 deletions dist/media/index.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
.wux-media {
position: relative;
display: -webkit-box;
display: -webkit-flex;
display: flex;
padding: 30rpx;
overflow: hidden;
}
.wux-media--align-flex-start {
-webkit-box-align: start;
-webkit-align-items: flex-start;
align-items: flex-start;
}
.wux-media--align-flex-end {
-webkit-box-align: end;
-webkit-align-items: flex-end;
align-items: flex-end;
}
.wux-media--align-center {
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
}
.wux-media--align-stretch {
-webkit-box-align: stretch;
-webkit-align-items: stretch;
align-items: stretch;
}
.wux-media--align-baseline {
-webkit-box-align: baseline;
-webkit-align-items: baseline;
align-items: baseline;
}
.wux-media__hd {
margin-right: .8em;
text-align: center;
}
.wux-media__thumb {
width: 120rpx;
height: 120rpx;
display: inline-block;
overflow: hidden;
vertical-align: top;
}
.wux-media__bd {
-webkit-box-flex: 1;
-webkit-flex: 1;
flex: 1;
min-width: 0;
}
.wux-media__title {
font-weight: 400;
font-size: 34rpx;
width: auto;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
word-wrap: normal;
}
.wux-media__desc {
color: #808080;
font-size: 26rpx;
line-height: 1.2;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
Binary file added docs/_media/media.mp4
Binary file not shown.
1 change: 1 addition & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* [Grid 栅格布局](grid.md)
* [InputNumber 数字输入框](input-number.md)
* [List 列表](list.md)
* [Media 媒体对象](media.md)
* [Prompt 提示消息](prompt.md)
* [Qrcode 二维码](qrcode.md)
* [Radio 单选框](radio.md)
Expand Down
61 changes: 61 additions & 0 deletions docs/media.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Media 媒体对象

用于在一个内容块的左边或右边展示一个多媒体内容。

## 使用指南

### 在 page.json 中引入组件

```json
{
"navigationBarTitleText": "Media",
"usingComponents": {
"wux-media": "../../dist/media/index"
}
}
```

### 示例

```html
<view class="page">
<view class="page__hd">
<view class="page__title">Media</view>
<view class="page__desc">媒体对象</view>
</view>
<view class="page__bd">
<view class="title">Default</view>
<wux-media title="标题一" label="由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。"></wux-media>
<view class="title">Thumb</view>
<wux-media thumb="{{ thumb }}" title="标题一" label="由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。"></wux-media>
<view class="title">Custom thumb style</view>
<wux-media thumb="{{ thumb }}" thumb-style="border-radius: 50%" title="标题一" label="由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。"></wux-media>
<view class="title">Nesting</view>
<wux-media align="flex-start" thumb="{{ thumb }}" title="标题一" label="由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。">
<wux-media align="flex-start" thumb="{{ thumb }}" title="标题一" label="由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。"></wux-media>
</wux-media>
</view>
</view>
```

```js
Page({
data: {
thumb: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC4AAAAuCAMAAABgZ9sFAAAAVFBMVEXx8fHMzMzr6+vn5+fv7+/t7e3d3d2+vr7W1tbHx8eysrKdnZ3p6enk5OTR0dG7u7u3t7ejo6PY2Njh4eHf39/T09PExMSvr6+goKCqqqqnp6e4uLgcLY/OAAAAnklEQVRIx+3RSRLDIAxE0QYhAbGZPNu5/z0zrXHiqiz5W72FqhqtVuuXAl3iOV7iPV/iSsAqZa9BS7YOmMXnNNX4TWGxRMn3R6SxRNgy0bzXOW8EBO8SAClsPdB3psqlvG+Lw7ONXg/pTld52BjgSSkA3PV2OOemjIDcZQWgVvONw60q7sIpR38EnHPSMDQ4MjDjLPozhAkGrVbr/z0ANjAF4AcbXmYAAAAASUVORK5CYII=',
},
})
```

## 视频演示

[Media](./_media/media.mp4 ':include :type=iframe width=375px height=667px')

## API

| 参数 | 类型 | 描述 | 默认值 |
| --- | --- | --- | --- |
| title | <code>string</code> | 标题 | - |
| thumb | <code>string</code> | 标题图片 | - |
| thumbStyle | <code>string</code> | 标题图片样式 | - |
| label | <code>string</code> | 标题辅助内容 | - |
| align | <code>string</code> | 对齐方式,可选值为 start、center、end、baseline、stretch | center |
1 change: 1 addition & 0 deletions example/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"pages/toast/index",
"pages/dialog/index",
"pages/loading/index",
"pages/media/index",
"pages/backdrop/index",
"pages/badge/index",
"pages/toptips/index",
Expand Down
25 changes: 25 additions & 0 deletions example/dist/media/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Component({
externalClasses: ['wux-class'],
properties: {
thumb: {
type: String,
value: '',
},
thumbStyle: {
type: String,
value: '',
},
title: {
type: String,
value: '',
},
label: {
type: String,
value: '',
},
align: {
type: String,
value: 'center',
},
},
})
3 changes: 3 additions & 0 deletions example/dist/media/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"component": true
}
10 changes: 10 additions & 0 deletions example/dist/media/index.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<view class="wux-class wux-media {{ align ? 'wux-media--align-' + align : '' }}">
<view class="wux-media__hd">
<image class="wux-media__thumb" src="{{ thumb }}" mode="aspectFit" style="{{ thumbStyle }}" wx:if="{{ thumb }}" />
</view>
<view class="wux-media__bd">
<view class="wux-media__title" wx:if="{{ title }}">{{ title }}</view>
<view class="wux-media__desc" wx:if="{{ label }}">{{ label }}</view>
<slot></slot>
</view>
</view>
69 changes: 69 additions & 0 deletions example/dist/media/index.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
.wux-media {
position: relative;
display: -webkit-box;
display: -webkit-flex;
display: flex;
padding: 30rpx;
overflow: hidden;
}
.wux-media--align-flex-start {
-webkit-box-align: start;
-webkit-align-items: flex-start;
align-items: flex-start;
}
.wux-media--align-flex-end {
-webkit-box-align: end;
-webkit-align-items: flex-end;
align-items: flex-end;
}
.wux-media--align-center {
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
}
.wux-media--align-stretch {
-webkit-box-align: stretch;
-webkit-align-items: stretch;
align-items: stretch;
}
.wux-media--align-baseline {
-webkit-box-align: baseline;
-webkit-align-items: baseline;
align-items: baseline;
}
.wux-media__hd {
margin-right: .8em;
text-align: center;
}
.wux-media__thumb {
width: 120rpx;
height: 120rpx;
display: inline-block;
overflow: hidden;
vertical-align: top;
}
.wux-media__bd {
-webkit-box-flex: 1;
-webkit-flex: 1;
flex: 1;
min-width: 0;
}
.wux-media__title {
font-weight: 400;
font-size: 34rpx;
width: auto;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
word-wrap: normal;
}
.wux-media__desc {
color: #808080;
font-size: 26rpx;
line-height: 1.2;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
5 changes: 5 additions & 0 deletions example/pages/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ Page({
remark: '列表',
url: '/pages/list/index',
},
{
title: 'Media',
remark: '媒体对象',
url: '/pages/media/index',
},
{
title: 'Prompt',
remark: '提示消息',
Expand Down
5 changes: 5 additions & 0 deletions example/pages/media/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Page({
data: {
thumb: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC4AAAAuCAMAAABgZ9sFAAAAVFBMVEXx8fHMzMzr6+vn5+fv7+/t7e3d3d2+vr7W1tbHx8eysrKdnZ3p6enk5OTR0dG7u7u3t7ejo6PY2Njh4eHf39/T09PExMSvr6+goKCqqqqnp6e4uLgcLY/OAAAAnklEQVRIx+3RSRLDIAxE0QYhAbGZPNu5/z0zrXHiqiz5W72FqhqtVuuXAl3iOV7iPV/iSsAqZa9BS7YOmMXnNNX4TWGxRMn3R6SxRNgy0bzXOW8EBO8SAClsPdB3psqlvG+Lw7ONXg/pTld52BjgSSkA3PV2OOemjIDcZQWgVvONw60q7sIpR38EnHPSMDQ4MjDjLPozhAkGrVbr/z0ANjAF4AcbXmYAAAAASUVORK5CYII=',
},
})
6 changes: 6 additions & 0 deletions example/pages/media/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"navigationBarTitleText": "Media",
"usingComponents": {
"wux-media": "../../dist/media/index"
}
}
18 changes: 18 additions & 0 deletions example/pages/media/index.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<view class="page">
<view class="page__hd">
<view class="page__title">Media</view>
<view class="page__desc">媒体对象</view>
</view>
<view class="page__bd">
<view class="title">Default</view>
<wux-media title="标题一" label="由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。"></wux-media>
<view class="title">Thumb</view>
<wux-media thumb="{{ thumb }}" title="标题一" label="由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。"></wux-media>
<view class="title">Custom thumb style</view>
<wux-media thumb="{{ thumb }}" thumb-style="border-radius: 50%" title="标题一" label="由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。"></wux-media>
<view class="title">Nesting</view>
<wux-media align="flex-start" thumb="{{ thumb }}" title="标题一" label="由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。">
<wux-media align="flex-start" thumb="{{ thumb }}" title="标题一" label="由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。"></wux-media>
</wux-media>
</view>
</view>
8 changes: 8 additions & 0 deletions example/pages/media/index.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* pages/media/index.wxss */
.title {
padding: 30rpx 30rpx 18rpx;
font-size: 28rpx;
color: #888;
width: 100%;
box-sizing: border-box;
}
25 changes: 25 additions & 0 deletions src/media/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Component({
externalClasses: ['wux-class'],
properties: {
thumb: {
type: String,
value: '',
},
thumbStyle: {
type: String,
value: '',
},
title: {
type: String,
value: '',
},
label: {
type: String,
value: '',
},
align: {
type: String,
value: 'center',
},
},
})
3 changes: 3 additions & 0 deletions src/media/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"component": true
}
Loading

0 comments on commit 17d8c38

Please sign in to comment.