Skip to content

Commit 49f9f17

Browse files
Alpsli彧衡
andauthored
feat(icon): click support to copy icon Type (#54)
Co-authored-by: 彧衡 <[email protected]>
1 parent ecb74c6 commit 49f9f17

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

config/config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ export default {
3232
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
3333
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
3434
})(window,document,'script','dataLayer','GTM-WWGN4HC');
35+
`,
36+
`
37+
if(window.location.pathname==='/components/icon'){
38+
window.addEventListener('message', async (e) => {
39+
if(e.data.iconType) {
40+
await navigator.clipboard.writeText(e.data.iconType);
41+
}
42+
})
43+
}
3544
`
3645
],
3746
styles: [`

demo/pages/Icon/index.acss

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,25 @@
55
.sum {
66
padding: 24rpx;
77
}
8-
.sum > text {
8+
9+
.sum>text {
910
color: red;
1011
}
12+
1113
.list-title {
1214
color: red;
1315
font-size: 32rpx;
1416
font-weight: bold;
1517
padding: 24rpx;
1618
}
19+
1720
.icon-list {
1821
display: flex;
1922
flex-wrap: wrap;
2023
padding: 24rpx;
2124
background: #fff;
2225
}
26+
2327
.icon-item {
2428
display: flex;
2529
flex-direction: row;
@@ -41,3 +45,11 @@
4145
word-wrap: break-word;
4246
word-break: break-all;
4347
}
48+
49+
.icon-item-wrapper {
50+
display: flex;
51+
flex-direction: row;
52+
align-items: flex-start;
53+
justify-content: center;
54+
flex-wrap: wrap;
55+
}

demo/pages/Icon/index.axml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
<view class="demo">
22
<search-bar placeholder="搜索" onInput="handleSearchChange" borderColor="#1677ff" />
33
<view class="sum" a:if="{{!searchValue}}">
4-
目前共有<text>{{iconTypes.length}}</text>个图标类型
4+
目前共有
5+
<text>{{iconTypes.length}}</text>个图标类型
56
</view>
67
<view class="list-title">
78
线框风格
89
</view>
910
<view class="icon-list">
1011
<view class="icon-item" a:for="{{iconTypes}}" a:if="{{item.indexOf('Outline') > 1&&item.toUpperCase().indexOf(searchValue.toUpperCase())>-1}}">
11-
<am-icon type="{{item}}" color="#1677ff" size="small" onTap="handleClickIcon" data-info="{{item}}" />
12-
<text class="icon-desc">{{item}}</text>
12+
<view class="icon-item-wrapper" onTap="handleClickIcon" data-info="{{item}}">
13+
<am-icon type="{{item}}" color="#1677ff" size="small" />
14+
<text class="icon-desc">{{item}}</text>
15+
</view>
1316
</view>
1417
</view>
1518
<view class="list-title">
1619
实底风格
1720
</view>
1821
<view class="icon-list">
1922
<view class="icon-item" a:for="{{iconTypes}}" a:if="{{item.indexOf('Fill') > 1&&item.toUpperCase().indexOf(searchValue.toUpperCase())>-1}}">
20-
<am-icon type="{{item}}" color="#1677ff" size="small" onTap="handleClickIcon" data-info="{{item}}" />
21-
<text class="icon-desc">{{item}}</text>
23+
<view class="icon-item-wrapper" onTap="handleClickIcon" data-info="{{item}}">
24+
<am-icon type="{{item}}" color="#1677ff" size="small" onTap="handleClickIcon" data-info="{{item}}" />
25+
<text class="icon-desc">{{item}}</text>
26+
</view>
2227
</view>
2328
</view>
2429

demo/pages/Icon/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,12 @@ Page({
160160
this.setData({ searchValue: value });
161161
},
162162
handleClickIcon(e) {
163+
const { info } = e.target.dataset;
164+
165+
top.postMessage({ iconType: info }, '*');
166+
163167
my.showToast({
164-
content: `click ${e.currentTarget.dataset.info}`,
168+
content: `${info} 已复制到剪贴板`,
165169
});
166170
},
167171
});

0 commit comments

Comments
 (0)