@ray-js/ray-ipc-half-horizontal-drag 0.0.1-beta-1

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/README.md ADDED
@@ -0,0 +1,32 @@
1
+ English | [简体中文](./README-zh_CN.md)
2
+
3
+ # @ray-js/ray-ipc-half-horizontal-drag
4
+
5
+ [![latest](https://img.shields.io/npm/v/@ray-js/ray-ipc-half-horizontal-drag/latest.svg)](https://www.npmjs.com/package/@ray-js/ray-ipc-half-horizontal-drag) [![download](https://img.shields.io/npm/dt/@ray-js/ray-ipc-half-horizontal-drag.svg)](https://www.npmjs.com/package/@ray-js/ray-ipc-half-horizontal-drag)
6
+
7
+ > 水平方向可拖动,显示出下一个组件的小部分内容
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ $ npm install @ray-js/ray-ipc-half-horizontal-drag
13
+ # or
14
+ $ yarn add @ray-js/ray-ipc-half-horizontal-drag
15
+ ```
16
+
17
+ ## Develop
18
+
19
+ ```sh
20
+ # install deps
21
+ yarn
22
+
23
+ # watch compile demo
24
+ yarn start:tuya
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ```tsx
30
+ import Foo from '@ray-js/ray-ipc-half-horizontal-drag';
31
+ export default () => <Foo />;
32
+ ```
@@ -0,0 +1,14 @@
1
+ export const tuya = {
2
+ backgroundColor: '#f2f4f6',
3
+ navigationBarTitleText: 'Ray 跨端组件'
4
+ };
5
+ export const wechat = {
6
+ backgroundColor: '#f2f4f6',
7
+ navigationBarTitleText: 'Ray 跨端组件'
8
+ };
9
+ export const native = {
10
+ backgroundColor: 'transparent',
11
+ isBleOfflineOverlay: false,
12
+ useSafeAreaView: true,
13
+ navigationBarTitleText: 'Ray 跨端组件'
14
+ };
package/lib/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { IProps } from './props';
3
+ declare const HalfHorizontalDrag: React.FC<IProps>;
4
+ export default HalfHorizontalDrag;
package/lib/index.js ADDED
@@ -0,0 +1,73 @@
1
+ import "core-js/modules/esnext.iterator.map.js";
2
+ import React from 'react';
3
+ import { View, ScrollView, Image } from '@ray-js/ray';
4
+ import styles from './index.module.less';
5
+ const HalfHorizontalDrag = props => {
6
+ const {
7
+ className,
8
+ classNameBox,
9
+ style,
10
+ datas,
11
+ onBgClick,
12
+ onRightClick
13
+ } = props;
14
+ const onCurRightImage = (e, data) => {
15
+ onRightClick && onRightClick(data);
16
+ };
17
+ const onCurBgClick = (e, data) => {
18
+ onBgClick && onBgClick(data);
19
+ };
20
+ const datasRender = num => {
21
+ let classBox;
22
+ if (num === 1) {
23
+ classBox = styles.container_box_2;
24
+ } else {
25
+ classBox = styles.container_box_3;
26
+ }
27
+ return /*#__PURE__*/React.createElement(React.Fragment, null, datas.map(data => {
28
+ return /*#__PURE__*/React.createElement(View, {
29
+ className: `${styles.container_box} ${classBox} ${classNameBox}`,
30
+ key: data.name
31
+ }, /*#__PURE__*/React.createElement(View, {
32
+ className: styles.container_box_content
33
+ }, /*#__PURE__*/React.createElement(Image, {
34
+ className: styles.container_box_content_bg,
35
+ mode: "widthFix",
36
+ src: data.bgImage
37
+ }), /*#__PURE__*/React.createElement(View, {
38
+ style: {
39
+ flex: 1,
40
+ overflow: 'hidden'
41
+ },
42
+ onClick: e => onCurBgClick(e, data)
43
+ }, /*#__PURE__*/React.createElement(View, {
44
+ className: `${styles.container_box_content_name}`
45
+ }, data.name), /*#__PURE__*/React.createElement(View, {
46
+ className: `${styles.container_box_content_subName}`
47
+ }, data.subName)), /*#__PURE__*/React.createElement(Image, {
48
+ className: styles.container_box_content_icon,
49
+ mode: "widthFix",
50
+ src: data.rightIcon,
51
+ onClick: e => onCurRightImage(e, data)
52
+ })));
53
+ }));
54
+ };
55
+ return /*#__PURE__*/React.createElement(React.Fragment, null, (() => {
56
+ if (datas.length === 2 || datas.length === 1) {
57
+ return /*#__PURE__*/React.createElement(View, {
58
+ className: `half_horizontal_drag ${styles.container} ${className}`,
59
+ style: style
60
+ }, datasRender(1));
61
+ }
62
+ if (datas.length > 2) {
63
+ return /*#__PURE__*/React.createElement(ScrollView, {
64
+ className: `half_horizontal_drag ${styles.container} ${className}`,
65
+ style: style,
66
+ scrollX: true
67
+ }, datasRender(2));
68
+ }
69
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
70
+ })());
71
+ };
72
+ HalfHorizontalDrag.displayName = 'HalfHorizontalDrag';
73
+ export default HalfHorizontalDrag;
@@ -0,0 +1,86 @@
1
+ @class-prefix: ~'half_horizontal_drag';
2
+
3
+ .@{class-prefix} {
4
+ color: #000;
5
+ font-size: 48rpx;
6
+ font-weight: bold;
7
+ }
8
+
9
+ .container {
10
+ display: flex;
11
+ flex-direction: row;
12
+ white-space: nowrap;
13
+ height: 200rpx;
14
+ margin: 48rpx 0;
15
+ }
16
+
17
+ .container_box_2 {
18
+ flex: 1;
19
+ }
20
+
21
+ .container_box_3 {
22
+ width: 314rpx;
23
+ }
24
+
25
+ .container_box {
26
+ height: 100%;
27
+ overflow: hidden;
28
+ display: inline-block;
29
+ margin-left: 16rpx;
30
+ border-radius: 32rpx;
31
+
32
+ &:last-child {
33
+ margin-right: 32rpx;
34
+ }
35
+
36
+ &_content {
37
+ display: flex;
38
+ flex-direction: row;
39
+ height: 100%;
40
+ padding: 18rpx 0 18rpx 24rpx;
41
+ justify-content: space-between;
42
+ align-items: center;
43
+ position: relative;
44
+
45
+ &_bg {
46
+ position: absolute;
47
+ left: 0;
48
+ top: 0;
49
+ width: 100%;
50
+ height: 100%;
51
+ z-index: -1;
52
+ }
53
+
54
+ &_name {
55
+ font-size: 28rpx;
56
+ color: #fff;
57
+ overflow: hidden;
58
+ text-overflow: ellipsis;
59
+ }
60
+
61
+ &_subName {
62
+ font-size: 24rpx;
63
+ color: rgba(255, 255, 255, 0.7);
64
+ overflow: hidden;
65
+ text-overflow: ellipsis;
66
+ }
67
+
68
+ &_icon {
69
+ margin: 0 8rpx;
70
+ width: 44rpx;
71
+ height: 44rpx;
72
+ margin-right: 10rpx;
73
+ }
74
+ }
75
+ }
76
+
77
+ .right_icon_bg {
78
+ width: 40rpx;
79
+ height: 40rpx;
80
+ border-radius: 40rpx;
81
+ background: #fff;
82
+ margin-right: 10rpx;
83
+ display: flex;
84
+ align-items: center;
85
+ justify-content: center;
86
+ }
package/lib/props.d.ts ADDED
@@ -0,0 +1,55 @@
1
+ /// <reference types="react" />
2
+ export interface IProps {
3
+ /**
4
+ * @description.zh 数据
5
+ * @description.en datas
6
+ */
7
+ datas: IPropDatas[];
8
+ /**
9
+ * @description.zh 类名
10
+ * @description.en class name
11
+ */
12
+ className?: string;
13
+ /**
14
+ * @description.zh 盒子类名
15
+ * @description.en class name box
16
+ */
17
+ classNameBox?: string;
18
+ /**
19
+ * @description.zh 样式
20
+ * @description.en Style
21
+ */
22
+ style?: React.CSSProperties;
23
+ /**
24
+ * @description.zh 点击事件
25
+ * @description.en bg image
26
+ */
27
+ onBgClick?: (data: IPropDatas) => void;
28
+ /**
29
+ * @description.zh 点击事件
30
+ * @description.en bg image
31
+ */
32
+ onRightClick?: (data: IPropDatas) => void;
33
+ }
34
+ export interface IPropDatas {
35
+ /**
36
+ * @description.zh 名称
37
+ * @description.en name
38
+ */
39
+ name: string;
40
+ /**
41
+ * @description.zh 子名称
42
+ * @description.en sub name
43
+ */
44
+ subName?: string;
45
+ /**
46
+ * @description.zh 右侧图标
47
+ * @description.en right icon
48
+ */
49
+ rightIcon?: string;
50
+ /**
51
+ * @description.zh 背景图
52
+ * @description.en bg image
53
+ */
54
+ bgImage?: string;
55
+ }
package/lib/props.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@ray-js/ray-ipc-half-horizontal-drag",
3
+ "version": "0.0.1-beta-1",
4
+ "description": "水平方向可拖动,显示出下一个组件的小部分内容",
5
+ "main": "lib/index",
6
+ "files": [
7
+ "lib"
8
+ ],
9
+ "license": "MIT",
10
+ "types": "lib/index.d.ts",
11
+ "maintainers": [
12
+ "tuya_npm",
13
+ {
14
+ "name": "tuyafe",
15
+ "email": "tuyafe@tuya.com"
16
+ }
17
+ ],
18
+ "scripts": {
19
+ "lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
20
+ "build": "ray build --type=component",
21
+ "watch": "ray start --type=component --output ./example/src/lib",
22
+ "build:tuya": "ray build -t tuya ./example",
23
+ "build:wechat": "ray build ./example --target=wechat",
24
+ "build:web": "ray build ./example --target=web",
25
+ "build:native": "ray build ./example --target=native",
26
+ "start:native": "ray start ./example -t native --verbose",
27
+ "start:tuya": "ray start -t tuya ./example",
28
+ "start:wechat": "ray start ./example -t wechat --verbose",
29
+ "start:web": "ray start ./example -t web",
30
+ "prepublishOnly": "yarn build",
31
+ "release-it": "standard-version"
32
+ },
33
+ "peerDependencies": {
34
+ "@ray-js/ray": "^1.4.9"
35
+ },
36
+ "dependencies": {
37
+ "clsx": "^1.2.1"
38
+ },
39
+ "devDependencies": {
40
+ "@commitlint/cli": "^7.2.1",
41
+ "@commitlint/config-conventional": "^9.0.1",
42
+ "@ray-js/cli": "^1.4.9",
43
+ "@ray-js/ray": "^1.4.9",
44
+ "core-js": "^3.19.1",
45
+ "eslint-config-tuya-panel": "^0.4.2",
46
+ "husky": "^1.2.0",
47
+ "lint-staged": "^10.2.11",
48
+ "standard-version": "9.3.2",
49
+ "@ray-js/panel-sdk": "^1.13.0-storage.7"
50
+ },
51
+ "resolutions": {
52
+ "@ray-js/builder-mp": "1.4.15"
53
+ },
54
+ "husky": {
55
+ "hooks": {
56
+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS --config commitlint.config.js",
57
+ "pre-commit": "lint-staged"
58
+ }
59
+ },
60
+ "lint-staged": {
61
+ "*.{ts,tsx,js,jsx}": [
62
+ "eslint --fix",
63
+ "git add"
64
+ ],
65
+ "*.{json,md,yml,yaml}": [
66
+ "prettier --write",
67
+ "git add"
68
+ ]
69
+ }
70
+ }