@xhsreds/reds-rn-next 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/benchmarks/out.json +1652 -1025
- package/coverage/.tmp/coverage-0.json +1 -1
- package/coverage/.tmp/coverage-1.json +1 -1
- package/coverage/.tmp/coverage-10.json +1 -1
- package/coverage/.tmp/coverage-11.json +1 -1
- package/coverage/.tmp/coverage-12.json +1 -1
- package/coverage/.tmp/coverage-13.json +1 -1
- package/coverage/.tmp/coverage-14.json +1 -1
- package/coverage/.tmp/coverage-15.json +1 -1
- package/coverage/.tmp/coverage-16.json +1 -1
- package/coverage/.tmp/coverage-17.json +1 -1
- package/coverage/.tmp/coverage-18.json +1 -1
- package/coverage/.tmp/coverage-19.json +1 -1
- package/coverage/.tmp/coverage-2.json +1 -1
- package/coverage/.tmp/coverage-20.json +1 -1
- package/coverage/.tmp/coverage-21.json +1 -1
- package/coverage/.tmp/coverage-22.json +1 -1
- package/coverage/.tmp/coverage-23.json +1 -1
- package/coverage/.tmp/coverage-24.json +1 -1
- package/coverage/.tmp/coverage-25.json +1 -1
- package/coverage/.tmp/coverage-26.json +1 -1
- package/coverage/.tmp/coverage-27.json +1 -1
- package/coverage/.tmp/coverage-28.json +1 -1
- package/coverage/.tmp/coverage-29.json +1 -1
- package/coverage/.tmp/coverage-3.json +1 -1
- package/coverage/.tmp/coverage-30.json +1 -1
- package/coverage/.tmp/coverage-31.json +1 -1
- package/coverage/.tmp/coverage-32.json +1 -1
- package/coverage/.tmp/coverage-33.json +1 -1
- package/coverage/.tmp/coverage-6.json +1 -1
- package/coverage/.tmp/coverage-7.json +1 -1
- package/coverage/.tmp/coverage-8.json +1 -1
- package/coverage/.tmp/coverage-9.json +1 -1
- package/lib/cjs/_chunks/B0pRAs4D.js.map +1 -1
- package/lib/cjs/_chunks/{C61-qTj5.js → BkoO2fb2.js} +7 -22
- package/lib/cjs/_chunks/BkoO2fb2.js.map +1 -0
- package/lib/cjs/_chunks/DHiiOK0R.js.map +1 -1
- package/lib/cjs/_chunks/DhVoC10x.js.map +1 -1
- package/lib/cjs/_chunks/{K-GkcnsQ.js → DtxkCz1y.js} +2 -1
- package/lib/cjs/_chunks/DtxkCz1y.js.map +1 -0
- package/lib/cjs/components/Alert/Alert.js +2 -2
- package/lib/cjs/components/Alert/index.js +2 -2
- package/lib/cjs/components/AvatarGroup/AvatarGroup.js +2 -2
- package/lib/cjs/components/AvatarGroup/index.js +2 -2
- package/lib/cjs/components/ConfigProvider/ConfigProvider.js +15 -14
- package/lib/cjs/components/ConfigProvider/ConfigProvider.js.map +1 -1
- package/lib/cjs/components/ConfigProvider/index.js +2 -2
- package/lib/cjs/components/ConfigProvider/interface/index.js +1 -1
- package/lib/cjs/components/Icon/Icon.js +8 -4
- package/lib/cjs/components/Icon/Icon.js.map +1 -1
- package/lib/cjs/components/Icon/index.js +5 -0
- package/lib/cjs/components/Icon/index.js.map +1 -1
- package/lib/cjs/components/ImagePreview/ImagePreview.js +2 -2
- package/lib/cjs/components/ImagePreview/index.js +2 -2
- package/lib/cjs/components/List/ListItem/ListItem.js +2 -2
- package/lib/cjs/components/List/index.js +2 -2
- package/lib/cjs/components/NavigationBar/NavigationBar.js +5 -0
- package/lib/cjs/components/NavigationBar/NavigationBar.js.map +1 -1
- package/lib/cjs/components/NavigationBar/index.js +5 -0
- package/lib/cjs/components/NavigationBar/index.js.map +1 -1
- package/lib/cjs/components/PullRefresh/PullRefresh.js +2 -2
- package/lib/cjs/components/PullRefresh/PullRefresh.js.map +1 -1
- package/lib/cjs/components/TabBar/TabBar.js +8 -5
- package/lib/cjs/components/TabBar/TabBar.js.map +1 -1
- package/lib/cjs/components/TabBar/index.js +5 -2
- package/lib/cjs/components/TabBar/index.js.map +1 -1
- package/lib/cjs/components/TabBar/interface/index.js +1 -1
- package/lib/cjs/components/Tabs/Tabs.js +5 -1
- package/lib/cjs/components/Tabs/Tabs.js.map +1 -1
- package/lib/cjs/components/Tabs/styles.js +1 -1
- package/lib/cjs/components/Tabs/styles.js.map +1 -1
- package/lib/cjs/components/Toast/Toast.js +2 -2
- package/lib/cjs/components/Toast/api.js +4 -4
- package/lib/cjs/components/Toast/index.js +4 -4
- package/lib/cjs/index.js +2 -2
- package/lib/esm/_chunks/{DKABHJAn.js → BefIgmcR.js} +7 -22
- package/lib/esm/_chunks/BefIgmcR.js.map +1 -0
- package/lib/esm/_chunks/CGzZESdM.js.map +1 -1
- package/lib/esm/_chunks/CZmJhm-r.js.map +1 -1
- package/lib/esm/_chunks/DkKS5ieS.js.map +1 -1
- package/lib/esm/_chunks/{DUTFT_ka.js → PrCkQ_W3.js} +2 -1
- package/lib/esm/_chunks/PrCkQ_W3.js.map +1 -0
- package/lib/esm/components/Alert/Alert.js +2 -2
- package/lib/esm/components/Alert/index.js +2 -2
- package/lib/esm/components/AvatarGroup/AvatarGroup.js +2 -2
- package/lib/esm/components/AvatarGroup/index.js +2 -2
- package/lib/esm/components/ConfigProvider/ConfigProvider.js +15 -14
- package/lib/esm/components/ConfigProvider/ConfigProvider.js.map +1 -1
- package/lib/esm/components/ConfigProvider/index.js +2 -2
- package/lib/esm/components/ConfigProvider/interface/index.js +1 -1
- package/lib/esm/components/Icon/Icon.js +8 -4
- package/lib/esm/components/Icon/Icon.js.map +1 -1
- package/lib/esm/components/Icon/index.js +5 -0
- package/lib/esm/components/Icon/index.js.map +1 -1
- package/lib/esm/components/ImagePreview/ImagePreview.js +2 -2
- package/lib/esm/components/ImagePreview/index.js +2 -2
- package/lib/esm/components/List/ListItem/ListItem.js +2 -2
- package/lib/esm/components/List/index.js +2 -2
- package/lib/esm/components/NavigationBar/NavigationBar.js +5 -0
- package/lib/esm/components/NavigationBar/NavigationBar.js.map +1 -1
- package/lib/esm/components/NavigationBar/index.js +5 -0
- package/lib/esm/components/NavigationBar/index.js.map +1 -1
- package/lib/esm/components/PullRefresh/PullRefresh.js +2 -2
- package/lib/esm/components/PullRefresh/PullRefresh.js.map +1 -1
- package/lib/esm/components/TabBar/TabBar.js +8 -5
- package/lib/esm/components/TabBar/TabBar.js.map +1 -1
- package/lib/esm/components/TabBar/index.js +5 -2
- package/lib/esm/components/TabBar/index.js.map +1 -1
- package/lib/esm/components/TabBar/interface/index.js +1 -1
- package/lib/esm/components/Tabs/Tabs.js +5 -1
- package/lib/esm/components/Tabs/Tabs.js.map +1 -1
- package/lib/esm/components/Tabs/styles.js +1 -1
- package/lib/esm/components/Tabs/styles.js.map +1 -1
- package/lib/esm/components/Toast/Toast.js +2 -2
- package/lib/esm/components/Toast/api.js +4 -4
- package/lib/esm/components/Toast/index.js +4 -4
- package/lib/esm/index.js +2 -2
- package/lib/types/components/ActionSheets/test/spectrum.bench.d.ts +1 -0
- package/lib/types/components/Avatar/test/spectrum.bench.d.ts +1 -0
- package/lib/types/components/AvatarGroup/test/spectrum.bench.d.ts +1 -0
- package/lib/types/components/Badge/test/spectrum.bench.d.ts +1 -0
- package/lib/types/components/BottomBar/test/spectrum.bench.d.ts +1 -0
- package/lib/types/components/Button/test/spectrum.bench.d.ts +1 -0
- package/lib/types/components/ConfigProvider/ConfigProvider.d.ts +2 -2
- package/lib/types/components/ConfigProvider/hooks/ConfigCache/ConfigCache.d.ts +1 -1
- package/lib/types/components/ConfigProvider/hooks/ConfigCache/interface.d.ts +1 -1
- package/lib/types/components/ConfigProvider/interface/index.d.ts +9 -13
- package/lib/types/components/Divider/test/spectrum.bench.d.ts +1 -0
- package/lib/types/components/Empty/test/spectrum.bench.d.ts +1 -0
- package/lib/types/components/Image/test/spectrum.bench.d.ts +1 -0
- package/lib/types/components/List/test/spectrum.bench.d.ts +1 -0
- package/lib/types/components/NavigationBar/test/spectrum.bench.d.ts +1 -0
- package/lib/types/components/Picker/test/spectrum.bench.d.ts +1 -0
- package/lib/types/components/ProgressIndicator/test/spectrum.bench.d.ts +1 -0
- package/lib/types/components/PullRefresh/interface/index.d.ts +2 -2
- package/lib/types/components/Sheets/test/spectrum.bench.d.ts +1 -0
- package/lib/types/components/Silder/test/spectrum.bench.d.ts +1 -0
- package/lib/types/components/Skeleton/test/spectrum.bench.d.ts +1 -0
- package/lib/types/components/Switch/test/spectrum.bench.d.ts +1 -0
- package/lib/types/components/TabBar/TabBar.d.ts +1 -0
- package/lib/types/components/TabBar/interface/index.d.ts +3 -1
- package/lib/types/components/Tag/test/spectrum.bench.d.ts +1 -0
- package/lib/types/components/Toast/test/spectrum.bench.d.ts +1 -0
- package/package.json +5 -4
- package/src/components/ActionSheets/doc/index.mdx +7 -5
- package/src/components/ActionSheets/test/spectrum.bench.tsx +15 -0
- package/src/components/Avatar/test/spectrum.bench.tsx +13 -0
- package/src/components/AvatarGroup/test/spectrum.bench.tsx +30 -0
- package/src/components/Badge/test/spectrum.bench.tsx +13 -0
- package/src/components/BottomBar/test/spectrum.bench.tsx +15 -0
- package/src/components/Button/test/spectrum.bench.tsx +13 -0
- package/src/components/ConfigProvider/ConfigProvider.tsx +10 -26
- package/src/components/ConfigProvider/demo/base.tsx +19 -28
- package/src/components/ConfigProvider/doc/index.mdx +8 -8
- package/src/components/ConfigProvider/hooks/ConfigCache/interface.ts +1 -1
- package/src/components/ConfigProvider/interface/index.ts +13 -21
- package/src/components/ConfigProvider/test/base.tsx +17 -25
- package/src/components/ConfigProvider/test/index.test.tsx +62 -74
- package/src/components/DatePicker/doc/index.mdx +1 -5
- package/src/components/DatePicker/interface/index.ts +1 -3
- package/src/components/Divider/test/spectrum.bench.tsx +13 -0
- package/src/components/DropDown/doc/index.mdx +39 -0
- package/src/components/Empty/test/spectrum.bench.tsx +19 -0
- package/src/components/Icon/Icon.tsx +4 -2
- package/src/components/Image/test/spectrum.bench.tsx +33 -0
- package/src/components/List/test/spectrum.bench.tsx +15 -0
- package/src/components/NavigationBar/test/spectrum.bench.tsx +13 -0
- package/src/components/Picker/test/spectrum.bench.tsx +10 -0
- package/src/components/ProgressIndicator/test/spectrum.bench.tsx +13 -0
- package/src/components/PullRefresh/PullRefresh.tsx +2 -2
- package/src/components/PullRefresh/demo/index.tsx +1 -1
- package/src/components/PullRefresh/doc/index.mdx +10 -10
- package/src/components/PullRefresh/interface/index.ts +2 -2
- package/src/components/Sheets/test/spectrum.bench.tsx +17 -0
- package/src/components/Silder/test/spectrum.bench.tsx +18 -0
- package/src/components/Skeleton/test/spectrum.bench.tsx +25 -0
- package/src/components/Switch/test/spectrum.bench.tsx +14 -0
- package/src/components/TabBar/TabBar.tsx +4 -4
- package/src/components/TabBar/demo/index.tsx +6 -6
- package/src/components/TabBar/doc/index.mdx +9 -8
- package/src/components/TabBar/interface/index.ts +3 -1
- package/src/components/TabBar/test/index.bench.tsx +1 -1
- package/src/components/TabBar/test/index.test.tsx +7 -7
- package/src/components/Tabs/Tabs.tsx +7 -1
- package/src/components/Tabs/demo/index.tsx +55 -19
- package/src/components/Tabs/interface/index.ts +0 -1
- package/src/components/Tabs/styles.ts +1 -1
- package/src/components/Tag/test/spectrum.bench.tsx +13 -0
- package/src/components/Toast/test/spectrum.bench.tsx +13 -0
- package/vitest.config.ts +5 -0
- package/lib/cjs/_chunks/C61-qTj5.js.map +0 -1
- package/lib/cjs/_chunks/K-GkcnsQ.js.map +0 -1
- package/lib/esm/_chunks/DKABHJAn.js.map +0 -1
- package/lib/esm/_chunks/DUTFT_ka.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,7 +3,8 @@ export interface RedsTabBar {
|
|
|
3
3
|
list: DataType[];
|
|
4
4
|
customTabBar?: DataType;
|
|
5
5
|
type: "text" | "icon";
|
|
6
|
-
|
|
6
|
+
active: string;
|
|
7
|
+
value?: boolean;
|
|
7
8
|
badge?: boolean;
|
|
8
9
|
containerStyles?: any;
|
|
9
10
|
onChange?: (value: string) => any;
|
|
@@ -30,5 +31,6 @@ export interface RedsTabBarEvent {
|
|
|
30
31
|
export declare const TabBarDefaultProps: {
|
|
31
32
|
list: DataType[];
|
|
32
33
|
type: string;
|
|
34
|
+
value: undefined;
|
|
33
35
|
badge: boolean;
|
|
34
36
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xhsreds/reds-rn-next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"author": "贾斌(呀哈) <jiabin@xiaohongshu.com>",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@floating-ui/react-native": "~0.10.6",
|
|
8
8
|
"dayjs": "^1.10.7",
|
|
9
|
-
"@xhsreds/reds-token-next": "0.1.
|
|
9
|
+
"@xhsreds/reds-token-next": "0.1.5"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
12
|
"@xhs/reder-icon-svg": "~1.0.1",
|
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
"react-native-svg": "*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"react-native": "0.72.5",
|
|
19
18
|
"react": "~18.2.0",
|
|
20
|
-
"react-native
|
|
19
|
+
"react-native": "0.72.5",
|
|
20
|
+
"react-native-svg": "~15.4.0",
|
|
21
|
+
"@xhs/spectrum": "1.2.4-feat-support-0.72-alpha.23"
|
|
21
22
|
},
|
|
22
23
|
"module": "./lib/esm/index.js",
|
|
23
24
|
"main": "./lib/cjs/index.js",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import BaseDemo from "!!raw-loader!../demo/index.tsx";
|
|
2
2
|
|
|
3
|
+
ActionSheets size属性继承自sheets组件 容器高度由sheets内部容器高度撑开
|
|
4
|
+
|
|
3
5
|
## 演示
|
|
4
6
|
|
|
5
7
|
### 基础用法
|
|
@@ -10,11 +12,11 @@ import BaseDemo from "!!raw-loader!../demo/index.tsx";
|
|
|
10
12
|
|
|
11
13
|
### Props
|
|
12
14
|
|
|
13
|
-
| 属性 | 描述
|
|
14
|
-
| ----------- |
|
|
15
|
-
| data | 列表数据
|
|
16
|
-
| description | 描述
|
|
17
|
-
| visible | 是否展示列表
|
|
15
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
16
|
+
| ----------- | -------------------- | ------------ | ------ |
|
|
17
|
+
| data | ActionSheets列表数据 | ActionItem[] | `[]` |
|
|
18
|
+
| description | 描述 | string | |
|
|
19
|
+
| visible | 是否展示列表 | boolean | false |
|
|
18
20
|
|
|
19
21
|
### Events
|
|
20
22
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { describe } from "vitest";
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import { redsBench } from "~root/utils/redsBench";
|
|
5
|
+
import { ActionSheet2 } from "@xhs/spectrum";
|
|
6
|
+
import { render, fireEvent } from "@testing-library/react-native";
|
|
7
|
+
import { Text } from "react-native";
|
|
8
|
+
|
|
9
|
+
describe("render", () => {
|
|
10
|
+
redsBench("base", async () => {
|
|
11
|
+
ActionSheet2.show({
|
|
12
|
+
options: [{ text: "操作按钮" }, { text: "操作按钮" }, { text: "操作按钮" }],
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { describe } from "vitest";
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import { redsBench } from "~root/utils/redsBench";
|
|
5
|
+
import { Avatar } from "@xhs/spectrum";
|
|
6
|
+
import { render, fireEvent } from "@testing-library/react-native";
|
|
7
|
+
import { Text } from "react-native";
|
|
8
|
+
|
|
9
|
+
describe("render", () => {
|
|
10
|
+
redsBench("base", async () => {
|
|
11
|
+
render(<Avatar type={"default"} size={48} style={{ marginHorizontal: 20 }} />);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { describe } from "vitest";
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import { redsBench } from "~root/utils/redsBench";
|
|
5
|
+
import { AvatarGroup } from "@xhs/spectrum";
|
|
6
|
+
import { render, fireEvent } from "@testing-library/react-native";
|
|
7
|
+
import { Text } from "react-native";
|
|
8
|
+
|
|
9
|
+
describe("render", () => {
|
|
10
|
+
const imgs = [
|
|
11
|
+
{
|
|
12
|
+
uri: "https://picasso-static.xiaohongshu.com/fe-platform/81bb94fcff424f3ca02d620e7460d5a8315b0158.png",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
uri: "https://picasso-static.xiaohongshu.com/fe-platform/81bb94fcff424f3ca02d620e7460d5a8315b0158.png",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
uri: "https://picasso-static.xiaohongshu.com/fe-platform/81bb94fcff424f3ca02d620e7460d5a8315b0158.png",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
uri: "https://picasso-static.xiaohongshu.com/fe-platform/81bb94fcff424f3ca02d620e7460d5a8315b0158.png",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
uri: "https://picasso-static.xiaohongshu.com/fe-platform/81bb94fcff424f3ca02d620e7460d5a8315b0158.png",
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
redsBench("base", async () => {
|
|
28
|
+
render(<AvatarGroup num={5} size={28} style={{ marginVertical: 8 }} src={imgs}></AvatarGroup>);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { describe } from "vitest";
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import { redsBench } from "~root/utils/redsBench";
|
|
5
|
+
import { Badge } from "@xhs/spectrum";
|
|
6
|
+
import { render, fireEvent } from "@testing-library/react-native";
|
|
7
|
+
import { Text } from "react-native";
|
|
8
|
+
|
|
9
|
+
describe("render", () => {
|
|
10
|
+
redsBench("base", async () => {
|
|
11
|
+
render(<Badge mt={-4} mr={-4} />);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { describe } from "vitest";
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import { redsBench } from "~root/utils/redsBench";
|
|
5
|
+
import { BottomBar } from "@xhs/spectrum";
|
|
6
|
+
import { render, fireEvent } from "@testing-library/react-native";
|
|
7
|
+
import { Text } from "react-native";
|
|
8
|
+
const handleClick = () => {
|
|
9
|
+
console.log("按钮点击");
|
|
10
|
+
};
|
|
11
|
+
describe("render", () => {
|
|
12
|
+
redsBench("base", async () => {
|
|
13
|
+
render(<BottomBar text="按钮" onPress={handleClick} />);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { describe } from "vitest";
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import { redsBench } from "~root/utils/redsBench";
|
|
5
|
+
import { Button } from "@xhs/spectrum";
|
|
6
|
+
import { render, fireEvent } from "@testing-library/react-native";
|
|
7
|
+
import { Text } from "react-native";
|
|
8
|
+
|
|
9
|
+
describe("render", () => {
|
|
10
|
+
redsBench("base", async () => {
|
|
11
|
+
render(<Button>主按钮</Button>);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -1,36 +1,20 @@
|
|
|
1
|
-
import { ConfigProviderProps } from "./interface";
|
|
1
|
+
import { ConfigProviderProps, RedsConfigProvider } from "./interface";
|
|
2
2
|
import { configCache } from "./hooks/ConfigCache/ConfigCache";
|
|
3
3
|
import { ConfigProviderContext, IConfigProviderContext } from "./hooks/ConfigContext/ConfigContext";
|
|
4
|
-
import React from "react";
|
|
4
|
+
import React, { ReactNode } from "react";
|
|
5
5
|
|
|
6
|
-
const ConfigProvider: React.FC<
|
|
7
|
-
const {
|
|
8
|
-
id = "root",
|
|
9
|
-
theme = {
|
|
10
|
-
colorMode: "light",
|
|
11
|
-
inherit: true,
|
|
12
|
-
},
|
|
13
|
-
parentId = "root",
|
|
14
|
-
children,
|
|
15
|
-
} = props;
|
|
6
|
+
const ConfigProvider: React.FC<RedsConfigProvider> = (props: RedsConfigProvider) => {
|
|
7
|
+
const { id = "root", token = {}, parentId = "root", colorMode = "light", children, inherit = true } = props;
|
|
16
8
|
|
|
17
9
|
const themeCache = {
|
|
18
|
-
colorMode:
|
|
10
|
+
colorMode: colorMode || "light",
|
|
19
11
|
token: {
|
|
20
|
-
lightColor: {
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
...theme.token?.darkColor,
|
|
25
|
-
},
|
|
26
|
-
alwaysColor: {
|
|
27
|
-
...theme.token?.alwaysColor,
|
|
28
|
-
},
|
|
29
|
-
components: {
|
|
30
|
-
...theme.token?.components,
|
|
31
|
-
},
|
|
12
|
+
lightColor: token?.lightColor ?? {},
|
|
13
|
+
darkColor: token?.darkColor ?? {},
|
|
14
|
+
alwaysColor: token?.alwaysColor ?? {},
|
|
15
|
+
components: token?.components ?? {},
|
|
32
16
|
},
|
|
33
|
-
inherit:
|
|
17
|
+
inherit: inherit,
|
|
34
18
|
};
|
|
35
19
|
|
|
36
20
|
configCache.addNewConfigCache({
|
|
@@ -40,10 +40,10 @@ export default () => {
|
|
|
40
40
|
// 主题定制
|
|
41
41
|
const [colorMode2, setColorMode2] = useState<ColorMode>("light");
|
|
42
42
|
const [infoLightColor, setInfoLightColor] = useState<string>("red");
|
|
43
|
-
const [infoDarkColor, setInfoDarkColor] = useState<string>("
|
|
43
|
+
const [infoDarkColor, setInfoDarkColor] = useState<string>("yellow");
|
|
44
44
|
const changeInfoToken = () => {
|
|
45
45
|
setInfoLightColor((preInfoLightColor) => (preInfoLightColor === "red" ? "blue" : "red"));
|
|
46
|
-
setInfoDarkColor((preInfoDarkColor) => (preInfoDarkColor === "
|
|
46
|
+
setInfoDarkColor((preInfoDarkColor) => (preInfoDarkColor === "yellow" ? "white" : "yellow"));
|
|
47
47
|
};
|
|
48
48
|
const changeColorMode2 = () => {
|
|
49
49
|
setColorMode2((preColorMode) => (preColorMode === "light" ? "dark" : "light"));
|
|
@@ -66,12 +66,7 @@ export default () => {
|
|
|
66
66
|
<TouchableOpacity onPress={changeColorMode}>
|
|
67
67
|
<Text>切换主题</Text>
|
|
68
68
|
</TouchableOpacity>
|
|
69
|
-
<ConfigProvider
|
|
70
|
-
id="1"
|
|
71
|
-
theme={{
|
|
72
|
-
colorMode: colorMode,
|
|
73
|
-
}}
|
|
74
|
-
>
|
|
69
|
+
<ConfigProvider id="1" colorMode={colorMode}>
|
|
75
70
|
<App />
|
|
76
71
|
</ConfigProvider>
|
|
77
72
|
<TouchableOpacity onPress={changeColorMode2}>
|
|
@@ -82,15 +77,13 @@ export default () => {
|
|
|
82
77
|
</TouchableOpacity>
|
|
83
78
|
<ConfigProvider
|
|
84
79
|
id="2"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
Info: infoDarkColor,
|
|
93
|
-
},
|
|
80
|
+
colorMode={colorMode2}
|
|
81
|
+
token={{
|
|
82
|
+
lightColor: {
|
|
83
|
+
Info: infoLightColor,
|
|
84
|
+
},
|
|
85
|
+
darkColor: {
|
|
86
|
+
Info: infoDarkColor,
|
|
94
87
|
},
|
|
95
88
|
}}
|
|
96
89
|
>
|
|
@@ -104,17 +97,15 @@ export default () => {
|
|
|
104
97
|
</TouchableOpacity>
|
|
105
98
|
<ConfigProvider
|
|
106
99
|
id="3"
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
Info: infoDarkColor3,
|
|
117
|
-
},
|
|
100
|
+
colorMode={colorMode3}
|
|
101
|
+
token={{
|
|
102
|
+
components: {
|
|
103
|
+
Button: {
|
|
104
|
+
lightColor: {
|
|
105
|
+
Info: infoLightColor3,
|
|
106
|
+
},
|
|
107
|
+
darkColor: {
|
|
108
|
+
Info: infoDarkColor3,
|
|
118
109
|
},
|
|
119
110
|
},
|
|
120
111
|
},
|
|
@@ -10,13 +10,13 @@ import BaseDemo from "!!raw-loader!../demo/base.tsx";
|
|
|
10
10
|
|
|
11
11
|
### Props
|
|
12
12
|
|
|
13
|
-
| 属性 | 描述 | 类型
|
|
14
|
-
| --------- | ------------------------------- |
|
|
15
|
-
| id | 主题 ID | string
|
|
16
|
-
| parentId | 父级主题 ID | string
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
13
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
14
|
+
| --------- | ------------------------------- | ----------- | ------ |
|
|
15
|
+
| id | 主题 ID | string | root |
|
|
16
|
+
| parentId | 父级主题 ID | string | root |
|
|
17
|
+
| colorMode | IThemeConfig colorMode 主题模式 | string | light |
|
|
18
|
+
| inherit | IThemeConfig inherit Token 继承 | boolean | true |
|
|
19
|
+
| token | IThemeConfig token Token 定制 | IThemeToken | |
|
|
20
|
+
| children | 主题包裹组件 | ReactNode | |
|
|
21
21
|
|
|
22
22
|
### Events
|
|
@@ -8,7 +8,7 @@ export type TypographyToken = keyof typeof typography;
|
|
|
8
8
|
|
|
9
9
|
export type ThemeColor = { [key in LightToken | DarkToken]: ValueOf<typeof lightColor | typeof darkColor> };
|
|
10
10
|
|
|
11
|
-
export type ColorMode = "light" | "dark";
|
|
11
|
+
export type ColorMode = "light" | "dark" | string;
|
|
12
12
|
export type Component =
|
|
13
13
|
| "Button"
|
|
14
14
|
| "Popover"
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
1
2
|
type ColorMode = "light" | "dark";
|
|
2
3
|
type Component = "Button" | "Popover" | "Text" | "Tag" | "Switch" | "Toast";
|
|
3
4
|
|
|
@@ -26,45 +27,36 @@ export interface ConfigProviderProps {
|
|
|
26
27
|
theme?: IThemeConfig;
|
|
27
28
|
parentId?: string;
|
|
28
29
|
}
|
|
30
|
+
export interface IThemeToken {
|
|
31
|
+
lightColor?: Record<string, string>;
|
|
32
|
+
darkColor?: Record<string, string>;
|
|
33
|
+
alwaysColor?: Record<string, string>;
|
|
34
|
+
components?: ComponentsToken;
|
|
35
|
+
}
|
|
29
36
|
export interface RedsConfigProvider {
|
|
30
37
|
id?: string;
|
|
31
38
|
parentId?: string;
|
|
32
|
-
theme?: IThemeConfig;
|
|
33
39
|
colorMode?: string;
|
|
34
40
|
inherit?: boolean;
|
|
35
|
-
token
|
|
41
|
+
token?: IThemeToken;
|
|
42
|
+
children?: ReactNode;
|
|
36
43
|
}
|
|
37
44
|
|
|
38
45
|
export interface RedsConfigProviderEvent {}
|
|
39
46
|
export const defaultProps: RedsConfigProvider = {
|
|
40
47
|
id: "root",
|
|
41
48
|
parentId: "root",
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
lightColor: {},
|
|
47
|
-
darkColor: {},
|
|
48
|
-
alwaysColor: {},
|
|
49
|
-
},
|
|
49
|
+
token: {
|
|
50
|
+
lightColor: {},
|
|
51
|
+
darkColor: {},
|
|
52
|
+
alwaysColor: {},
|
|
50
53
|
},
|
|
51
54
|
colorMode: "light",
|
|
52
55
|
inherit: true,
|
|
53
|
-
token: {},
|
|
54
56
|
};
|
|
55
57
|
export const ConfigProviderDefaultProps = {
|
|
56
58
|
id: "root",
|
|
57
59
|
parentId: "root",
|
|
58
|
-
theme: {
|
|
59
|
-
colorMode: "light",
|
|
60
|
-
inherit: true,
|
|
61
|
-
token: {
|
|
62
|
-
lightColor: {},
|
|
63
|
-
darkColor: {},
|
|
64
|
-
alwaysColor: {},
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
60
|
colorMode: "light",
|
|
68
61
|
inherit: true,
|
|
69
|
-
token: {},
|
|
70
62
|
};
|
|
@@ -73,11 +73,7 @@ export default () => {
|
|
|
73
73
|
<TouchableOpacity testID={"themeChangeButton"} onPress={changeColorMode}>
|
|
74
74
|
<Text>切换主题</Text>
|
|
75
75
|
</TouchableOpacity>
|
|
76
|
-
<ConfigProvider
|
|
77
|
-
theme={{
|
|
78
|
-
colorMode: colorMode,
|
|
79
|
-
}}
|
|
80
|
-
>
|
|
76
|
+
<ConfigProvider colorMode={colorMode}>
|
|
81
77
|
<App />
|
|
82
78
|
</ConfigProvider>
|
|
83
79
|
<TouchableOpacity testID={"themeChangeCustomButton"} onPress={changeColorMode2}>
|
|
@@ -87,15 +83,13 @@ export default () => {
|
|
|
87
83
|
<Text>主题定制</Text>
|
|
88
84
|
</TouchableOpacity>
|
|
89
85
|
<ConfigProvider
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
Info: infoDarkColor,
|
|
98
|
-
},
|
|
86
|
+
colorMode={colorMode2}
|
|
87
|
+
token={{
|
|
88
|
+
lightColor: {
|
|
89
|
+
Info: infoLightColor,
|
|
90
|
+
},
|
|
91
|
+
darkColor: {
|
|
92
|
+
Info: infoDarkColor,
|
|
99
93
|
},
|
|
100
94
|
}}
|
|
101
95
|
>
|
|
@@ -108,17 +102,15 @@ export default () => {
|
|
|
108
102
|
<Text>组件级主题切换</Text>
|
|
109
103
|
</TouchableOpacity>
|
|
110
104
|
<ConfigProvider
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
Info: infoDarkColor3,
|
|
121
|
-
},
|
|
105
|
+
colorMode={colorMode3}
|
|
106
|
+
token={{
|
|
107
|
+
components: {
|
|
108
|
+
Button: {
|
|
109
|
+
lightColor: {
|
|
110
|
+
Info: infoLightColor3,
|
|
111
|
+
},
|
|
112
|
+
darkColor: {
|
|
113
|
+
Info: infoDarkColor3,
|
|
122
114
|
},
|
|
123
115
|
},
|
|
124
116
|
},
|