Skip to content

Commit

Permalink
feat: add size sample
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiqingchen committed Apr 25, 2022
1 parent 8b5e635 commit a3d5636
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
'pages/global/pages/hooks/page',
'pages/global/pages/lifecycle/page',
'pages/global/pages/router/index',
'pages/global/pages/styles/size',
// 全局相关 end
// 组件相关 start
'pages/components/index',
Expand Down
Binary file added src/assets/iconpark/font-size.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/pages/about/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
.page-footer {
margin-top: 40px;
align-items: center;
text-align: center;
&-text {
padding: 20px;
font-size: $font-size-sm;
Expand Down
4 changes: 3 additions & 1 deletion src/pages/about/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,15 @@ export default class Index extends Component<any, any> {
)
})}
</View>
{isRN && <View className='page-footer' onClick={() => {
{isRN ? <View className='page-footer' onClick={() => {
Taro.navigateTo({
url: '/pages/about/dep'
})
}}
>
<Text className='page-footer-text'>Taro: {taroVersion}, React Native: {rnVersion}, Taro Playground: {playgroundVersion}</Text>
</View> : <View className='page-footer'>
<Text className='page-footer-text'>Taro: {taroVersion}</Text>
</View>}
</View>
)
Expand Down
13 changes: 13 additions & 0 deletions src/pages/global/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { View, Image, Text, ScrollView } from "@tarojs/components";
import hooksPng from "@/assets/iconpark/aiming.png";
import routerPng from "@/assets/iconpark/navigation.png";
import lifecyclePng from "@/assets/iconpark/cycle-arrow.png";
import stylesPng from "@/assets/iconpark/font-size.png";

import "./index.scss";

const PNGS = {
hooksPng,
routerPng,
lifecyclePng,
stylesPng
};

export default class Index extends Component<never, any> {
Expand Down Expand Up @@ -50,6 +52,17 @@ export default class Index extends Component<never, any> {
name: '页面跳转',
}
]
},
{
id: "styles",
name: "样式",
open: false,
pages: [
{
id: 'size',
name: '尺寸'
}
]
}
]
};
Expand Down
3 changes: 3 additions & 0 deletions src/pages/global/pages/styles/size.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
navigationBarTitleText: '尺寸',
}
34 changes: 34 additions & 0 deletions src/pages/global/pages/styles/size.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.fs30px {
font-size: 30px;
}
.fs60px {
font-size: 60px;
}
.fs15-px {
font-size: 15PX;
}
.fs30-px {
font-size: 30PX;
}
.fs1rem {
font-size: 1rem;
}
.fs2rem {
font-size: 2rem;
}
.fs30rpx {
font-size: 30rpx;
}
.fs15rpx {
font-size: 15rpx;
}
.w-30 {
height: 100px;
width: 30%;
background-color: cyan;
}
.w-60 {
height: 100px;
width: 60%;
background-color: orange;
}
59 changes: 59 additions & 0 deletions src/pages/global/pages/styles/size.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { View } from "@tarojs/components";
import { pxTransform } from "@tarojs/taro";
import Header from "@/components/head/head";

import './size.scss'

export default function Size() {
return <View className="global-page">
<View className="global-page__header">
<Header title="尺寸"></Header>
</View>
<View className="global-page__body">
<View className="global-page__body-example example">
<View className='example-header'>
px
</View>
<View className='example-body'>
<View className="fs30px">font-size: 30px</View>
<View className="fs60px">font-size: 60px</View>
</View>
<View className='example-header'>
PX
</View>
<View className='example-body'>
<View className="fs15-px">font-size: 15PX</View>
<View className="fs30-px">font-size: 30PX</View>
</View>
<View className='example-header'>
rem
</View>
<View className='example-body'>
<View className="fs1rem">font-size: 1rem</View>
<View className="fs2rem">font-size: 2rem</View>
</View>
<View className='example-header'>
rpx (不建议使用)
</View>
<View className='example-body'>
<View className="fs15rpx">font-size: 15rpx</View>
<View className="fs30rpx">font-size: 30rpx</View>
</View>
<View className='example-header'>
pxTransform
</View>
<View className='example-body'>
<View style={{fontSize: pxTransform(30)}}>pxTransform(30)</View>
<View style={{fontSize: pxTransform(60)}}>pxTransform(60)</View>
</View>
<View className='example-header'>
%
</View>
<View className='example-body'>
<View className="w-30">width: 30%</View>
<View className="w-60">width: 60%</View>
</View>
</View>
</View>
</View>
}

0 comments on commit a3d5636

Please sign in to comment.