Skip to content

Commit f3645e3

Browse files
committed
Merge branch 'dev' of https://github.com/uiwjs/react-native-uiw into dev
2 parents e0e8de4 + 507337c commit f3645e3

File tree

8 files changed

+85
-60
lines changed

8 files changed

+85
-60
lines changed

packages/core/src/Empty/index.tsx

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@ import React, { Component } from 'react';
22
import { StyleSheet, Text, TextProps } from 'react-native';
33
import Icon from '../Icon';
44
import Flex, { FlexProps } from '../Flex';
5+
import { iconStr } from './svg';
56

6-
const iconStr = `
7-
<svg width="64" height="41" viewBox="0 0 64 41">
8-
<g transform="translate(0 1)" fill="none" fill-rule="evenodd">
9-
<ellipse fill="#F5F5F5" cx="32" cy="33" rx="32" ry="7"></ellipse>
10-
<g fill-rule="nonzero" stroke="#D9D9D9">
11-
<path fill="#FFF" d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path>
12-
<path fill="#FAFAFA" d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z"></path>
13-
</g>
14-
</g>
15-
</svg>
16-
`;
7+
// export const iconStr = `
8+
// <svg width="64" height="41" viewBox="0 0 64 41">
9+
// <g transform="translate(0 1)" fill="none" fill-rule="evenodd">
10+
// <ellipse fill="#F5F5F5" cx="32" cy="33" rx="32" ry="7"></ellipse>
11+
// <g fill-rule="nonzero" stroke="#D9D9D9">
12+
// <path fill="#FFF" d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path>
13+
// <path fill="#FAFAFA" d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z"></path>
14+
// </g>
15+
// </g>
16+
// </svg>
17+
// `;
1718

1819
export interface EmptyProps extends FlexProps {
1920
/**
@@ -38,24 +39,17 @@ export interface EmptyProps extends FlexProps {
3839
children?: React.ReactNode;
3940
}
4041

41-
export default class Empty extends Component<EmptyProps> {
42-
static defaultProps: EmptyProps = {
43-
size: 64,
44-
label: '暂无数据',
45-
xml: iconStr,
46-
};
47-
render() {
48-
const { size, label, xml, labelStyle, children, ...props } = this.props;
49-
return (
50-
<Flex direction="column" justify="center" align="center" {...props}>
51-
{xml && <Icon xml={xml} size={size} />}
52-
{!!children
53-
? children
54-
: label &&
55-
typeof label === 'string' && <Text style={StyleSheet.flatten([styles.label, labelStyle])}>{label}</Text>}
56-
</Flex>
57-
);
58-
}
42+
export default function Empty(props: EmptyProps) {
43+
const { size = 64, label = '暂无数据', xml = iconStr, labelStyle, children, ...otherProps } = props;
44+
return (
45+
<Flex direction="column" justify="center" align="center" {...otherProps}>
46+
{xml && <Icon xml={xml} size={size} />}
47+
{!!children
48+
? children
49+
: label &&
50+
typeof label === 'string' && <Text style={StyleSheet.flatten([styles.label, labelStyle])}>{label}</Text>}
51+
</Flex>
52+
);
5953
}
6054

6155
const styles = StyleSheet.create({

packages/core/src/Empty/svg.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export const iconStr = `
2+
<svg width="64" height="41" viewBox="0 0 64 41">
3+
<g transform="translate(0 1)" fill="none" fill-rule="evenodd">
4+
<ellipse fill="#F5F5F5" cx="32" cy="33" rx="32" ry="7"></ellipse>
5+
<g fill-rule="nonzero" stroke="#D9D9D9">
6+
<path fill="#FFF" d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path>
7+
<path fill="#FAFAFA" d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z"></path>
8+
</g>
9+
</g>
10+
</svg>
11+
`;

packages/core/src/WingBlank/README.md

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ import React,{Component} from 'react';
1111
import { Text } from 'react-native';
1212
import { WingBlank } from '@uiw/react-native';
1313

14-
class Demo extends Component {
15-
render() {
16-
return (
17-
<WingBlank>
18-
<Text>两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留两翼留白两翼留白两翼留白两翼留白</Text>
19-
</WingBlank>
20-
);
21-
}
14+
function Demo() {
15+
return (
16+
<WingBlank>
17+
<Text>两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留白两翼留两翼留白两翼留白两翼留白两翼留白</Text>
18+
</WingBlank>
19+
);
2220
}
2321
export default Demo
2422
```
@@ -30,22 +28,20 @@ import React,{Component,Fragment} from 'react';
3028
import { Text } from 'react-native';
3129
import { WingBlank } from '@uiw/react-native';
3230

33-
class Demo extends Component {
34-
render() {
35-
return (
36-
<Fragment>
37-
<WingBlank size='small'>
38-
<Text>两翼留白两翼留白</Text>
39-
</WingBlank>
40-
<WingBlank size='default'>
41-
<Text>两翼留白两翼留白</Text>
42-
</WingBlank>
43-
<WingBlank size='large'>
44-
<Text>两翼留白两翼留白</Text>
45-
</WingBlank>
46-
</Fragment>
47-
);
48-
}
31+
function Demo() {
32+
return (
33+
<Fragment>
34+
<WingBlank size='small'>
35+
<Text>两翼留白两翼留白</Text>
36+
</WingBlank>
37+
<WingBlank size='default'>
38+
<Text>两翼留白两翼留白</Text>
39+
</WingBlank>
40+
<WingBlank size='large'>
41+
<Text>两翼留白两翼留白</Text>
42+
</WingBlank>
43+
</Fragment>
44+
);
4945
}
5046
export default Demo
5147
```

test-ci/src/__tests__/empty.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ import React from 'react';
77
import Empty from '../lib/Empty';
88
// Note: test renderer must be required after react-native.
99
import renderer from 'react-test-renderer';
10+
import { iconStr } from '../lib/Empty/svg';
1011

1112
it('Empty', () => {
1213
const component = renderer.create(
13-
<Empty label="冇得数据咯" size={120} labelStyle={{ color: 'red' }}>冇得数据咯</Empty>
14+
<Empty label="冇得数据咯" size={120} labelStyle={{ color: 'red' }} xml={iconStr}>
15+
冇得数据咯
16+
</Empty>,
1417
);
1518
expect(component.root.props.label).toBe('冇得数据咯');
1619
expect(component.root.props.size).toBe(120);
1720
expect(component.root.props.labelStyle).toBeTruthy();
18-
expect(component.root.props.xml).toBeTruthy();
21+
expect(component.root.props.xml).toStrictEqual(iconStr);
1922
expect(component.root.props.children).toBe('冇得数据咯');
20-
21-
});
23+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### 快速上手
2+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Preview from 'src/component/Preview';
2+
import md from './README.md';
3+
4+
const transformImageUri = (url: string) => {
5+
const reqImage = (require as any).context!('./', true, /\.(png|gif|jpg|svg)$/);
6+
const urlAddr = reqImage(url);
7+
return urlAddr;
8+
};
9+
10+
const DEMO = () => (
11+
<Preview
12+
{...md}
13+
transformImageUri={transformImageUri}
14+
path="website/src/pages/docs/react-native-template/quickstart/README.md"
15+
/>
16+
);
17+
18+
export default DEMO;

website/src/routes/menus.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,13 @@ export const docsMenus: MenuData[] = [
8686
{ divider: true, name: 'APP 打包' },
8787
{ path: '/docs/unpack/ios', name: 'iOS 打包' },
8888
{ path: '/docs/unpack/android', name: 'Android(Mac) 打包' },
89+
{ divider: true, name: 'React Native Template' },
90+
{ path: '/docs/react-native-template/quickstart', name: '快速开始' },
8991
{ divider: true, name: '发布应用商店' },
9092
{ path: '/docs/app-store/ios', name: '发布 iOS 应用商店' },
9193
{ path: '/docs/app-store/android', name: '发布 Android 应用商店' },
9294
{ divider: true, name: '其它' },
93-
{ path: '/docs/react-native-template', name: 'React Native Template' },
95+
// { path: '/docs/react-native-template', name: 'React Native Template' },
9496
{ path: '/docs/awesome-react-native', name: 'Awesome React Native' },
9597
{ href: 'https://github.com/facebook/react', target: '_blank', name: 'React 官方文档' },
9698
{ href: 'https://github.com/facebook/react-native', target: '_blank', name: 'React Native 官方文档' },

website/src/routes/router.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ export const routeData = [
6262
component: lazy(() => import('../pages/docs/awesome-react-native')),
6363
},
6464
{
65-
path: '/docs/react-native-template',
66-
component: lazy(() => import('../pages/docs/react-native-template')),
65+
path: '/docs/react-native-template/quickstart',
66+
component: lazy(() => import('../pages/docs/react-native-template/quickstart')),
6767
},
6868
{
6969
path: '/components/about',

0 commit comments

Comments
 (0)