Skip to content

Commit 4ec3708

Browse files
committed
feat(CapsuleBar): 新增 CapsuleBar 组件
1 parent 7efdac1 commit 4ec3708

20 files changed

Lines changed: 597 additions & 29 deletions

File tree

commitlint.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ module.exports = {
6464
'Counter',
6565
'SearchBar',
6666
'IndexList',
67-
'Behavior'
67+
'Behavior',
68+
'CapsuleBar'
6869
]
6970
]
7071
}

examples/app.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@
8383
"pages/tabs/index",
8484
"pages/tabbar/index",
8585
"pages/combined-tabs/index",
86-
"pages/segment/index"
86+
"pages/segment/index",
87+
"pages/capsule-bar/index"
8788
]
8889
},
8990
{
@@ -140,4 +141,4 @@
140141
"content-card": "/components/content-card/index"
141142
},
142143
"sitemapLocation": "sitemap.json"
143-
}
144+
}
23.7 KB
Loading
1.34 KB
Loading
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import navigationBarUtil from '../../../../../dist/navigation-bar/navigation-bar-util';
2+
3+
Page({
4+
5+
/**
6+
* 页面的初始数据
7+
*/
8+
data: {
9+
// Star 数量
10+
starCount: null
11+
},
12+
13+
onLoad(query) {
14+
this.getStarCount()
15+
},
16+
17+
onShareAppMessage: function () {
18+
19+
},
20+
21+
/**
22+
* 获取 Star 数量,有些网络无法访问,暂时不用
23+
*/
24+
getStarCount() {
25+
const that = this
26+
wx.request({
27+
url: 'https://api.github.com/repos/TaleLin/lin-ui',
28+
success(res) {
29+
let starCount = res.data.stargazers_count
30+
starCount = (starCount / 1000).toFixed(1)
31+
that.setData({starCount})
32+
}
33+
})
34+
},
35+
36+
/**
37+
* 监听:长按左侧按钮
38+
*/
39+
onLongPressLeft() {
40+
wx.vibrateShort()
41+
wx.showModal({
42+
title: '提示',
43+
content: '长按左侧按钮事件被触发'
44+
})
45+
},
46+
47+
/**
48+
* 监听:长按右侧按钮
49+
*/
50+
onLongPressRight() {
51+
wx.vibrateShort()
52+
wx.showModal({
53+
title: '提示',
54+
content: '长按右侧按钮事件被触发'
55+
})
56+
},
57+
58+
/**
59+
* 监听:点击 Star 卡片
60+
*/
61+
onTapStarCard() {
62+
wx.vibrateShort()
63+
wx.setClipboardData({
64+
data: 'https://github.com/TaleLin/lin-ui'
65+
})
66+
},
67+
68+
/**
69+
* 监听:点击公众号卡片
70+
*/
71+
onTapPublicCard() {
72+
wx.vibrateShort()
73+
wx.setClipboardData({
74+
data: '林间有风'
75+
})
76+
}
77+
})
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"usingComponents": {
3+
"l-capsule-bar":"/dist/capsule-bar/index"
4+
},
5+
"navigationStyle":"custom",
6+
"navigationBarTextStyle":"white"
7+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<l-capsule-bar catch:linrightlongpress="onLongPressRight"
2+
catch:linleftlongpress="onLongPressLeft"
3+
capsule-color="white"
4+
title-color="white"
5+
bg-color="#3963bc"
6+
home-page='/pages/navigator/index/index'
7+
title="林间有风">
8+
<image src="bg.png" class="background-head"></image>
9+
<view class="text-head">
10+
<view>顶部左侧胶囊按钮可返回上一页和首页</view>
11+
<view>长按胶囊按钮可以触发相应事件</view>
12+
</view>
13+
14+
<view class="body-container">
15+
<view class="navigation-bar-text">胶囊栏组件适合页面顶部有背景图片的情况下使用,同时会在左侧添加用于返回上一页面和首页的按钮。</view>
16+
<view class="center-container">
17+
<view class="center-card" catch:tap="onTapStarCard">
18+
<view class="center-card-icon-wrapper">
19+
<image style="width: 44rpx;height: 42rpx" src="star.png"></image>
20+
<view>1.6 K</view>
21+
</view>
22+
<view class="center-card-detail">
23+
你的每一颗 Star 都是我们持续更新的动力,点击复制 Github 链接,为我们点亮那颗支撑我们前行的星星!
24+
</view>
25+
</view>
26+
<view class="center-card">
27+
<view class="center-card-icon-wrapper">
28+
<image style="width: 44rpx;height: 44rpx" src="download.png"></image>
29+
<view>14 K</view>
30+
</view>
31+
<view class="center-card-detail">
32+
Lin UI 迄今为止已拥有 14 K 的下载量,并经过长达 2 年时间的打磨,稳定性和易用性都已达到前所未有的水平。
33+
</view>
34+
</view>
35+
</view>
36+
37+
<view catch:tap="onTapPublicCard" class="bottom-container">
38+
<image style="width: 538rpx;height: 278rpx" src="qrcode.png"></image>
39+
</view>
40+
</view>
41+
</l-capsule-bar>
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
page{
2+
background-color: #f5f6fa;
3+
}
4+
5+
.background-head{
6+
width: 100%;
7+
height: 232rpx;
8+
position: absolute;
9+
top: 0;
10+
left: 0;
11+
z-index: -9;
12+
}
13+
14+
.text-head{
15+
font-size:32rpx;
16+
line-height:58rpx;
17+
color:rgba(255,255,255,1);
18+
margin-top: 20rpx;
19+
margin-bottom: 20rpx;
20+
margin-left: 32rpx;
21+
}
22+
23+
.body-container{
24+
width:100%;
25+
padding: 60rpx;
26+
box-sizing: border-box;
27+
background:linear-gradient(180deg,rgba(232,237,244,1) 0%,rgba(245,246,250,1) 5%,rgba(245,246,250,1) 100%);
28+
opacity:1;
29+
border-radius:30rpx 30rpx 0px 0px;
30+
display: flex;
31+
flex-direction: column;
32+
}
33+
34+
.navigation-bar-text{
35+
width:628rpx;
36+
background:rgba(255,255,255,1);
37+
box-shadow:0px 2rpx 12rpx rgba(0,0,0,0.02);
38+
border-radius:20rpx;
39+
40+
font-size:28rpx;
41+
line-height:40rpx;
42+
color:rgba(0,0,0,1);
43+
letter-spacing:6rpx;
44+
45+
padding: 30rpx;
46+
box-sizing: border-box;
47+
text-align: justify;
48+
margin-bottom: 60rpx;
49+
}
50+
51+
.center-container{
52+
display: flex;
53+
}
54+
55+
.center-card{
56+
width:272rpx;
57+
background:rgba(255,255,255,1);
58+
box-shadow:0px 2rpx 12rpx rgba(0,0,0,0.02);
59+
border-radius:20rpx;
60+
padding: 26rpx;
61+
display: flex;
62+
flex-direction: column;
63+
align-items: center;
64+
}
65+
66+
.center-card:not(:last-child){
67+
margin-right: 84rpx;
68+
}
69+
70+
.center-card-icon-wrapper{
71+
display: flex;
72+
align-items: center;
73+
}
74+
75+
.center-card-icon-wrapper>view{
76+
font-size:28rpx;
77+
line-height:1;
78+
color:rgba(0,0,0,1);
79+
letter-spacing:2rpx;
80+
margin-left: 16rpx;
81+
}
82+
83+
.center-card-detail{
84+
margin-top: 40rpx;
85+
font-size:24rpx;
86+
line-height:40rpx;
87+
color:rgba(0,0,0,1);
88+
text-align: justify;
89+
}
90+
91+
.bottom-container{
92+
margin-top: 60rpx;
93+
width:628rpx;
94+
height:316rpx;
95+
background:rgba(255,255,255,1);
96+
box-shadow:0px 2rpx 12rpx rgba(0,0,0,0.02);
97+
border-radius:20rpx;
98+
display: flex;
99+
justify-content: center;
100+
align-items: center;
101+
}
35.3 KB
Loading
1.53 KB
Loading

0 commit comments

Comments
 (0)