-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
10,501 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// babel-preset-taro 更多选项和默认值: | ||
// https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md | ||
module.exports = { | ||
presets: [ | ||
[ | ||
'taro', | ||
{ | ||
framework: 'react', | ||
ts: true, | ||
}, | ||
], | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const path = require('path') | ||
const pkg = require('./package.json') | ||
|
||
module.exports = [ | ||
'import', | ||
{ | ||
libraryName: pkg.name, | ||
customName: path.resolve(__dirname, './customName.js'), | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import WebpackChain from 'webpack-chain' | ||
import { IProjectConfig } from '@tarojs/taro/types/compile' | ||
import { TaroProvidePlugin } from '@tarojsx/polyfill/dist/plugins' | ||
|
||
const config: IProjectConfig = { | ||
projectName: 'test', | ||
date: '2020-2-22', | ||
designWidth: 750, | ||
deviceRatio: { 750: 1 }, | ||
sourceRoot: 'test/src', | ||
outputRoot: 'test/dist', | ||
framework: 'react', | ||
mini: { | ||
webpackChain(chain: WebpackChain) { | ||
chain.plugin('taroProvidePlugin').use(TaroProvidePlugin) | ||
}, | ||
}, | ||
} | ||
|
||
export default function (merge) { | ||
if (process.env.NODE_ENV === 'development') { | ||
return merge({}, config, { env: { NODE_ENV: '"development"' } }) | ||
} | ||
return merge({}, config, { env: { NODE_ENV: '"production"' } }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const path = require('path') | ||
const fs = require('fs') | ||
const glob = require('glob') | ||
const pkg = require('./package.json') | ||
|
||
const prefix = path.join(pkg.name, 'dist') | ||
|
||
const files = glob.sync('**/*.js', { cwd: path.join(__dirname, 'dist') }) | ||
|
||
console.log(files) | ||
|
||
module.exports = function customName(name) { | ||
return `antd/lib/${name}` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
"miniprogramRoot": "test/dist/", | ||
"projectname": "tarojsx-library-test", | ||
"appid": "touristappid", | ||
"compileType": "miniprogram", | ||
"simulatorType": "wechat", | ||
"simulatorPluginLibVersion": {}, | ||
"setting": { | ||
"urlCheck": false, | ||
"es6": false, | ||
"enhance": false, | ||
"postcss": false, | ||
"preloadBackgroundData": false, | ||
"minified": false, | ||
"newFeature": true, | ||
"coverView": true, | ||
"nodeModules": false, | ||
"autoAudits": false, | ||
"showShadowRootInWxmlPanel": true, | ||
"scopeDataCheck": false, | ||
"uglifyFileName": false, | ||
"checkInvalidKey": true, | ||
"checkSiteMap": false, | ||
"uploadWithSourceMap": true, | ||
"compileHotReLoad": false, | ||
"babelSetting": { | ||
"ignore": [], | ||
"disablePlugins": [], | ||
"outputPath": "" | ||
}, | ||
"useIsolateContext": true, | ||
"useCompilerModule": false, | ||
"userConfirmedUseCompilerModuleSwitch": false | ||
}, | ||
"condition": { | ||
"search": { | ||
"current": -1, | ||
"list": [] | ||
}, | ||
"conversation": { | ||
"current": -1, | ||
"list": [] | ||
}, | ||
"plugin": { | ||
"current": -1, | ||
"list": [] | ||
}, | ||
"game": { | ||
"current": -1, | ||
"list": [] | ||
}, | ||
"gamePlugin": { | ||
"current": -1, | ||
"list": [] | ||
}, | ||
"miniprogram": { | ||
"current": -1, | ||
"list": [ | ||
{ | ||
"id": -1, | ||
"name": "AntV F2", | ||
"pathName": "pages/antv-f2", | ||
"scene": null | ||
}, | ||
{ | ||
"id": 0, | ||
"name": "React Spring", | ||
"pathName": "pages/react-spring", | ||
"scene": null | ||
}, | ||
{ | ||
"id": 0, | ||
"name": "React Use Gesture", | ||
"pathName": "pages/react-use-gesture", | ||
"scene": null | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { AppConfig } from '@tarojs/taro' | ||
|
||
export default { | ||
pages: ['pages/index', 'pages/antv-f2', 'pages/react-spring', 'pages/react-use-gesture'], | ||
} as AppConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react' | ||
|
||
export default class App extends React.Component { | ||
render() { | ||
return this.props.children | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React, { useState, useEffect } from 'react' | ||
import { View } from '@tarojs/components' | ||
import { F2 } from '../../../src/antv' | ||
|
||
const f2style: React.CSSProperties = { width: '100vw', height: '50vh' } | ||
|
||
export default () => { | ||
const [data1, setData1] = useState([ | ||
{ genre: 'Sports', sold: 275 }, | ||
{ genre: 'Strategy', sold: 115 }, | ||
{ genre: 'Action', sold: 120 }, | ||
{ genre: 'Shooter', sold: 350 }, | ||
{ genre: 'Other', sold: 150 }, | ||
]) | ||
const [data2, setData2] = useState([ | ||
{ year: '2001', population: 41.8 }, | ||
{ year: '2002', population: 25.8 }, | ||
{ year: '2003', population: 31.7 }, | ||
{ year: '2004', population: 46 }, | ||
{ year: '2005', population: 28 }, | ||
]) | ||
|
||
useEffect(() => { | ||
const timer = setInterval(() => { | ||
setData1((prev) => prev.map(({ genre }) => ({ genre, sold: Math.round(Math.random() * 100) }))) | ||
setData2((prev) => prev.map(({ year }) => ({ year, population: Math.round(Math.random() * 10) }))) | ||
}, 2000) | ||
|
||
return () => clearInterval(timer) | ||
}, []) | ||
|
||
return ( | ||
<View style={{ display: 'flex', flexWrap: 'wrap' }}> | ||
<F2 | ||
style={f2style} | ||
// F2 对数据源格式的要求,仅仅是 JSON 数组,数组的每个元素是一个标准 JSON 对象。 | ||
data={data1} | ||
> | ||
{ | ||
// Step 1: 接收 Chart 对象 | ||
({ chart, data }) => { | ||
// Step 2: 载入数据源 | ||
chart.source(data) | ||
|
||
// Step 3:创建图形语法,绘制柱状图,由 genre 和 sold 两个属性决定图形位置,genre 映射至 x 轴,sold 映射至 y 轴 | ||
chart.interval().position('genre*sold').color('genre') | ||
|
||
// Step 4: 渲染图表 | ||
chart.render() | ||
} | ||
} | ||
</F2> | ||
|
||
<F2 | ||
style={f2style} | ||
data={data2} | ||
> | ||
{({ chart, data }) => { | ||
chart.source(data) | ||
chart.coord('polar') | ||
chart.legend({ | ||
position: 'right', | ||
}) | ||
chart.axis(false) | ||
chart.interval().position('year*population').color('year').style({ | ||
lineWidth: 1, | ||
stroke: '#fff', | ||
}) | ||
chart.render() | ||
}} | ||
</F2> | ||
</View> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react' | ||
import Taro from '@tarojs/taro' | ||
import { View, Button } from '@tarojs/components' | ||
|
||
const btnStyle: React.CSSProperties = { margin: 30 } | ||
|
||
export default () => ( | ||
<View> | ||
<Button style={btnStyle} onClick={() => Taro.navigateTo({ url: '/pages/antv-f2' })}> | ||
AntV F2 | ||
</Button> | ||
<Button style={btnStyle} onClick={() => Taro.navigateTo({ url: '/pages/react-spring' })}> | ||
React Spring | ||
</Button> | ||
<Button style={btnStyle} onClick={() => Taro.navigateTo({ url: '/pages/react-use-gesture' })}> | ||
React Use Gesture | ||
</Button> | ||
</View> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from 'react' | ||
import { View } from '@tarojs/components' | ||
import { useSpring, animated } from 'react-spring' | ||
import { a } from '../../../src/react-spring' | ||
|
||
const AnimatedView = animated(View) | ||
|
||
export default () => { | ||
const numberSpring = useSpring({ number: 1, from: { number: 0 } }) | ||
|
||
const opacitySpring = useSpring({ opacity: 1, from: { opacity: 0 } }) | ||
|
||
const scriptSpring = useSpring({ | ||
from: { | ||
position: 'relative', | ||
willChange: 'width, height, left, top', | ||
left: '0%', | ||
top: '0%', | ||
width: '0%', | ||
height: '0%', | ||
background: 'lightgreen', | ||
}, | ||
to: async (next) => { | ||
while (1) { | ||
await next({ left: '0%', top: '0%', width: '100%', height: '100%', background: 'lightblue' }) | ||
await next({ height: '50%', background: 'lightgreen' }) | ||
await next({ width: '50%', left: '50%', background: 'lightgoldenrodyellow' }) | ||
await next({ top: '0%', height: '100%', background: 'lightpink' }) | ||
await next({ top: '50%', height: '50%', background: 'lightsalmon' }) | ||
await next({ width: '100%', left: '0%', background: 'lightcoral' }) | ||
await next({ width: '50%', background: 'lightseagreen' }) | ||
await next({ top: '0%', height: '100%', background: 'lightskyblue' }) | ||
await next({ width: '100%', background: 'lightslategrey' }) | ||
} | ||
}, | ||
}) | ||
|
||
return ( | ||
<View> | ||
<AnimatedView id="number">{numberSpring.number}</AnimatedView> | ||
|
||
<AnimatedView style={opacitySpring}>我闪现至此</AnimatedView> | ||
|
||
<View | ||
style={{ | ||
position: 'relative', | ||
overflow: 'hidden', | ||
width: '100vw', | ||
height: '100vw', | ||
backgroundColor: '#f0f0f0', | ||
}} | ||
> | ||
<a.View style={scriptSpring as any} /> | ||
</View> | ||
</View> | ||
) | ||
} |
Oops, something went wrong.