feat: initial commit with Taro + React project
This commit is contained in:
BIN
src/pages/index/hook.png
Normal file
BIN
src/pages/index/hook.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
4
src/pages/index/index.config.ts
Normal file
4
src/pages/index/index.config.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export default {
|
||||
navigationBarTitleText: 'Taro-hooks',
|
||||
enableShareAppMessage: true,
|
||||
};
|
||||
56
src/pages/index/index.css
Normal file
56
src/pages/index/index.css
Normal file
@@ -0,0 +1,56 @@
|
||||
page {
|
||||
background-color: white;
|
||||
padding : 14px;
|
||||
box-sizing : border-box;
|
||||
color : #333;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
display : flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.logo {
|
||||
display: block;
|
||||
width : 270px;
|
||||
height : 270px;
|
||||
margin : 0 auto;
|
||||
}
|
||||
|
||||
.title,
|
||||
.desc {
|
||||
text-align: center;
|
||||
font-size : 32px;
|
||||
}
|
||||
|
||||
.desc {
|
||||
margin : 20px 0;
|
||||
font-size: 28px;
|
||||
color : rgba(0, 0, 0, .85);
|
||||
}
|
||||
|
||||
.list {
|
||||
padding : 24px 0;
|
||||
font-size : 32px;
|
||||
display : flex;
|
||||
align-items : center;
|
||||
border-color: rgba(51, 51, 51, .1);
|
||||
border-style: solid;
|
||||
border-width: 1px 0 1px 0;
|
||||
}
|
||||
|
||||
.list:not(:first-child) {
|
||||
border-top-width: 0;
|
||||
}
|
||||
|
||||
.label {
|
||||
flex: 0.4;
|
||||
}
|
||||
|
||||
.button {
|
||||
display : block;
|
||||
width : 100%;
|
||||
background-color: transparent;
|
||||
border-radius : 2px;
|
||||
margin-top : 20px;
|
||||
}
|
||||
47
src/pages/index/index.tsx
Normal file
47
src/pages/index/index.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import React, { useCallback } from "react";
|
||||
import { View, Text, Button, Image } from "@tarojs/components";
|
||||
import { useEnv, useNavigationBar, useModal, useToast } from "taro-hooks";
|
||||
import logo from "./hook.png";
|
||||
|
||||
import './index.css'
|
||||
|
||||
const Index = () => {
|
||||
const env = useEnv();
|
||||
const { setTitle } = useNavigationBar({ title: "Taro Hooks" });
|
||||
const showModal = useModal({
|
||||
title: "Taro Hooks Canary!",
|
||||
showCancel: false,
|
||||
confirmColor: "#8c2de9",
|
||||
confirmText: "支持一下"
|
||||
});
|
||||
const { show } = useToast({ mask: true });
|
||||
|
||||
const handleModal = useCallback(() => {
|
||||
showModal({ content: "不如给一个star⭐️!" }).then(() => {
|
||||
show({ title: "点击了支持!" });
|
||||
});
|
||||
}, [show, showModal]);
|
||||
|
||||
return (
|
||||
<View className="wrapper">
|
||||
<Image className="logo" src={logo} />
|
||||
<Text className="title">为Taro而设计的Hooks Library</Text>
|
||||
<Text className="desc">
|
||||
目前覆盖70%官方API. 抹平部分API在H5端短板. 提供近40+Hooks!
|
||||
并结合ahook适配Taro! 更多信息可以查看新版文档: https://next-version-taro-hooks.vercel.app/
|
||||
</Text>
|
||||
<View className="list">
|
||||
<Text className="label">运行环境</Text>
|
||||
<Text className="note">{env}</Text>
|
||||
</View>
|
||||
<Button className="button" onClick={() => setTitle("Taro Hooks Nice!")}>
|
||||
设置标题
|
||||
</Button>
|
||||
<Button className="button" onClick={handleModal}>
|
||||
使用Modal
|
||||
</Button>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default Index;
|
||||
Reference in New Issue
Block a user