Skip to content

Commit a3d5636

Browse files
committed
feat: add size sample
1 parent 8b5e635 commit a3d5636

File tree

8 files changed

+114
-1
lines changed

8 files changed

+114
-1
lines changed

src/app.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default {
1313
'pages/global/pages/hooks/page',
1414
'pages/global/pages/lifecycle/page',
1515
'pages/global/pages/router/index',
16+
'pages/global/pages/styles/size',
1617
// 全局相关 end
1718
// 组件相关 start
1819
'pages/components/index',

src/assets/iconpark/font-size.png

2.71 KB
Loading

src/pages/about/index.scss

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
.page-footer {
5151
margin-top: 40px;
5252
align-items: center;
53+
text-align: center;
5354
&-text {
5455
padding: 20px;
5556
font-size: $font-size-sm;

src/pages/about/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,15 @@ export default class Index extends Component<any, any> {
110110
)
111111
})}
112112
</View>
113-
{isRN && <View className='page-footer' onClick={() => {
113+
{isRN ? <View className='page-footer' onClick={() => {
114114
Taro.navigateTo({
115115
url: '/pages/about/dep'
116116
})
117117
}}
118118
>
119119
<Text className='page-footer-text'>Taro: {taroVersion}, React Native: {rnVersion}, Taro Playground: {playgroundVersion}</Text>
120+
</View> : <View className='page-footer'>
121+
<Text className='page-footer-text'>Taro: {taroVersion}</Text>
120122
</View>}
121123
</View>
122124
)

src/pages/global/index.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import { View, Image, Text, ScrollView } from "@tarojs/components";
44
import hooksPng from "@/assets/iconpark/aiming.png";
55
import routerPng from "@/assets/iconpark/navigation.png";
66
import lifecyclePng from "@/assets/iconpark/cycle-arrow.png";
7+
import stylesPng from "@/assets/iconpark/font-size.png";
78

89
import "./index.scss";
910

1011
const PNGS = {
1112
hooksPng,
1213
routerPng,
1314
lifecyclePng,
15+
stylesPng
1416
};
1517

1618
export default class Index extends Component<never, any> {
@@ -50,6 +52,17 @@ export default class Index extends Component<never, any> {
5052
name: '页面跳转',
5153
}
5254
]
55+
},
56+
{
57+
id: "styles",
58+
name: "样式",
59+
open: false,
60+
pages: [
61+
{
62+
id: 'size',
63+
name: '尺寸'
64+
}
65+
]
5366
}
5467
]
5568
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
navigationBarTitleText: '尺寸',
3+
}
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.fs30px {
2+
font-size: 30px;
3+
}
4+
.fs60px {
5+
font-size: 60px;
6+
}
7+
.fs15-px {
8+
font-size: 15PX;
9+
}
10+
.fs30-px {
11+
font-size: 30PX;
12+
}
13+
.fs1rem {
14+
font-size: 1rem;
15+
}
16+
.fs2rem {
17+
font-size: 2rem;
18+
}
19+
.fs30rpx {
20+
font-size: 30rpx;
21+
}
22+
.fs15rpx {
23+
font-size: 15rpx;
24+
}
25+
.w-30 {
26+
height: 100px;
27+
width: 30%;
28+
background-color: cyan;
29+
}
30+
.w-60 {
31+
height: 100px;
32+
width: 60%;
33+
background-color: orange;
34+
}
+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { View } from "@tarojs/components";
2+
import { pxTransform } from "@tarojs/taro";
3+
import Header from "@/components/head/head";
4+
5+
import './size.scss'
6+
7+
export default function Size() {
8+
return <View className="global-page">
9+
<View className="global-page__header">
10+
<Header title="尺寸"></Header>
11+
</View>
12+
<View className="global-page__body">
13+
<View className="global-page__body-example example">
14+
<View className='example-header'>
15+
px
16+
</View>
17+
<View className='example-body'>
18+
<View className="fs30px">font-size: 30px</View>
19+
<View className="fs60px">font-size: 60px</View>
20+
</View>
21+
<View className='example-header'>
22+
PX
23+
</View>
24+
<View className='example-body'>
25+
<View className="fs15-px">font-size: 15PX</View>
26+
<View className="fs30-px">font-size: 30PX</View>
27+
</View>
28+
<View className='example-header'>
29+
rem
30+
</View>
31+
<View className='example-body'>
32+
<View className="fs1rem">font-size: 1rem</View>
33+
<View className="fs2rem">font-size: 2rem</View>
34+
</View>
35+
<View className='example-header'>
36+
rpx (不建议使用)
37+
</View>
38+
<View className='example-body'>
39+
<View className="fs15rpx">font-size: 15rpx</View>
40+
<View className="fs30rpx">font-size: 30rpx</View>
41+
</View>
42+
<View className='example-header'>
43+
pxTransform
44+
</View>
45+
<View className='example-body'>
46+
<View style={{fontSize: pxTransform(30)}}>pxTransform(30)</View>
47+
<View style={{fontSize: pxTransform(60)}}>pxTransform(60)</View>
48+
</View>
49+
<View className='example-header'>
50+
%
51+
</View>
52+
<View className='example-body'>
53+
<View className="w-30">width: 30%</View>
54+
<View className="w-60">width: 60%</View>
55+
</View>
56+
</View>
57+
</View>
58+
</View>
59+
}

0 commit comments

Comments
 (0)