diff --git a/client/package.json b/client/package.json index 9f81a4fb9..829ffdd41 100644 --- a/client/package.json +++ b/client/package.json @@ -73,6 +73,7 @@ "eslint-plugin-only-ascii@^0.0.0": "patch:eslint-plugin-only-ascii@npm%3A0.0.0#./.yarn/patches/eslint-plugin-only-ascii-npm-0.0.0-29e3417685.patch" }, "dependencies": { + "@lottiefiles/react-lottie-player": "^3.5.3", "antd-mobile": "^5.28.0", "chalk": "4", "number-precision": "^1.6.0", diff --git a/client/packages/lowcoder/src/assets/icons/icon-lottie.svg b/client/packages/lowcoder/src/assets/icons/icon-lottie.svg new file mode 100644 index 000000000..90ca02dbd --- /dev/null +++ b/client/packages/lowcoder/src/assets/icons/icon-lottie.svg @@ -0,0 +1,132 @@ + diff --git a/client/packages/lowcoder/src/assets/icons/index.ts b/client/packages/lowcoder/src/assets/icons/index.ts index 409292ab7..df7c3d2bb 100644 --- a/client/packages/lowcoder/src/assets/icons/index.ts +++ b/client/packages/lowcoder/src/assets/icons/index.ts @@ -10,4 +10,6 @@ export { ReactComponent as DocIcon } from "./view-doc.svg"; export { ReactComponent as TutorialIcon } from "./tutorial.svg"; export { ReactComponent as ShortcutIcon } from "./icon-help-shortcut.svg"; +export { ReactComponent as LottieIcon } from "./icon-lottie.svg"; //Added By Aqib Mirza + export { GoogleLoginIcon, GithubLoginIcon, GeneralLoginIcon, EmailLoginIcon }; diff --git a/client/packages/lowcoder/src/comps/comps/jsonComp/jsonConstants.tsx b/client/packages/lowcoder/src/comps/comps/jsonComp/jsonConstants.tsx index 48c56d8ee..587c67840 100644 --- a/client/packages/lowcoder/src/comps/comps/jsonComp/jsonConstants.tsx +++ b/client/packages/lowcoder/src/comps/comps/jsonComp/jsonConstants.tsx @@ -26,3 +26,295 @@ export const theme = { base0E: "#b10dc9", base0F: "#85144b", }; + +export const defaultLottie = { + v: "5.8.1", + fr: 30, + ip: 0, + op: 43, + w: 1000, + h: 800, + nm: "Social_Media_82 1", + ddd: 0, + assets: [], + layers: [ + { + ddd: 0, + ind: 1, + ty: 4, + nm: "Shape 02", + td: 1, + sr: 1, + ks: { + o: { a: 0, k: 100, ix: 11 }, + r: { a: 0, k: 0, ix: 10 }, + p: { a: 0, k: [500, 396.73, 0], ix: 2, l: 2 }, + a: { a: 0, k: [0, 0, 0], ix: 1, l: 2 }, + s: { + a: 1, + k: [ + { + i: { x: [0.833, 0.833, 0.833], y: [0.833, 0.833, 0.833] }, + o: { x: [0.167, 0.167, 0.167], y: [0.167, 0.167, 0.167] }, + t: 0, + s: [0, 0, 100], + }, + { t: 3, s: [111.765, 111.765, 100] }, + ], + ix: 6, + l: 2, + }, + }, + ao: 0, + shapes: [ + { + ty: "sr", + sy: 1, + d: 1, + pt: { a: 0, k: 5, ix: 3 }, + p: { a: 0, k: [0, 0], ix: 4 }, + r: { a: 0, k: 0, ix: 5 }, + ir: { + a: 1, + k: [ + { + i: { x: [0.833], y: [0.833] }, + o: { x: [0.167], y: [0.167] }, + t: 3, + s: [37], + }, + { t: 6, s: [100] }, + ], + ix: 6, + }, + is: { a: 0, k: 0, ix: 8 }, + or: { a: 0, k: 212, ix: 7 }, + os: { a: 0, k: 0, ix: 9 }, + ix: 1, + nm: "Polystar Path 1", + mn: "ADBE Vector Shape - Star", + hd: false, + }, + { + ty: "fl", + c: { a: 0, k: [1, 0.082352941176, 0.622145469516, 1], ix: 4 }, + o: { a: 0, k: 100, ix: 5 }, + r: 1, + bm: 0, + nm: "Fill 1", + mn: "ADBE Vector Graphic - Fill", + hd: false, + }, + ], + ip: 0, + op: 43, + st: 0, + bm: 0, + }, + { + ddd: 0, + ind: 2, + ty: 4, + nm: "Reflection", + tt: 1, + sr: 1, + ks: { + o: { a: 0, k: 70, ix: 11 }, + r: { a: 0, k: 0, ix: 10 }, + p: { + a: 1, + k: [ + { + i: { x: 0.68, y: 1 }, + o: { x: 0.24, y: 0 }, + t: -3, + s: [500, 400, 0], + to: [271.667, 0, 0], + ti: [-271.667, 0, 0], + }, + { t: 38, s: [2130, 400, 0] }, + ], + ix: 2, + l: 2, + }, + a: { a: 0, k: [0, 0, 0], ix: 1, l: 2 }, + s: { a: 0, k: [100, 100, 100], ix: 6, l: 2 }, + }, + ao: 0, + shapes: [ + { + ty: "gr", + it: [ + { + ind: 0, + ty: "sh", + ix: 1, + ks: { + a: 0, + k: { + i: [ + [0, 0], + [0, 0], + ], + o: [ + [0, 0], + [0, 0], + ], + v: [ + [-318, -506], + [-1366, 542], + ], + c: false, + }, + ix: 2, + }, + nm: "Path 1", + mn: "ADBE Vector Shape - Group", + hd: false, + }, + { + ty: "st", + c: { + a: 0, + k: [0.960784313725, 0.864126227884, 0.632987347771, 1], + ix: 3, + }, + o: { a: 0, k: 100, ix: 4 }, + w: { a: 0, k: 161, ix: 5 }, + lc: 1, + lj: 1, + ml: 4, + bm: 0, + nm: "Stroke 1", + mn: "ADBE Vector Graphic - Stroke", + hd: false, + }, + { + ty: "fl", + c: { a: 0, k: [1, 0.082352941176, 0.946020687328, 1], ix: 4 }, + o: { a: 0, k: 100, ix: 5 }, + r: 1, + bm: 0, + nm: "Fill 1", + mn: "ADBE Vector Graphic - Fill", + hd: false, + }, + { + ty: "tr", + p: { a: 0, k: [0, 0], ix: 2 }, + a: { a: 0, k: [0, 0], ix: 1 }, + s: { a: 0, k: [100, 100], ix: 3 }, + r: { a: 0, k: 0, ix: 6 }, + o: { a: 0, k: 100, ix: 7 }, + sk: { a: 0, k: 0, ix: 4 }, + sa: { a: 0, k: 0, ix: 5 }, + nm: "Transform", + }, + ], + nm: "Shape 1", + np: 3, + cix: 2, + bm: 0, + ix: 1, + mn: "ADBE Vector Group", + hd: false, + }, + ], + ip: 0, + op: 43, + st: -4, + bm: 0, + }, + { + ddd: 0, + ind: 3, + ty: 4, + nm: "Shape 01", + sr: 1, + ks: { + o: { a: 0, k: 100, ix: 11 }, + r: { a: 0, k: 0, ix: 10 }, + p: { a: 0, k: [500, 396.73, 0], ix: 2, l: 2 }, + a: { a: 0, k: [0, 0, 0], ix: 1, l: 2 }, + s: { + a: 1, + k: [ + { + i: { x: [0.667, 0.667, 0.667], y: [1, 1, 1] }, + o: { x: [0.333, 0.333, 0.333], y: [0, 0, 0] }, + t: 0, + s: [0, 0, 100], + }, + { + i: { x: [0.667, 0.667, 0.667], y: [1, 1, 1] }, + o: { x: [0.333, 0.333, 0.333], y: [0, 0, 0] }, + t: 3, + s: [111.765, 111.765, 100], + }, + { + i: { x: [0.667, 0.667, 0.667], y: [1, 1, 1] }, + o: { x: [0.333, 0.333, 0.333], y: [0, 0, 0] }, + t: 6, + s: [111.765, 111.765, 100], + }, + { + i: { x: [0.667, 0.667, 0.667], y: [1, 1, 1] }, + o: { x: [0.333, 0.333, 0.333], y: [0, 0, 0] }, + t: 9, + s: [116, 116, 100], + }, + { t: 12, s: [111.765, 111.765, 100] }, + ], + ix: 6, + l: 2, + }, + }, + ao: 0, + shapes: [ + { + ty: "sr", + sy: 1, + d: 1, + pt: { a: 0, k: 5, ix: 3 }, + p: { a: 0, k: [0, 0], ix: 4 }, + r: { a: 0, k: 0, ix: 5 }, + ir: { + a: 1, + k: [ + { + i: { x: [0.833], y: [0.833] }, + o: { x: [0.167], y: [0.167] }, + t: 3, + s: [37], + }, + { t: 6, s: [100] }, + ], + ix: 6, + }, + is: { a: 0, k: 0, ix: 8 }, + or: { a: 0, k: 212, ix: 7 }, + os: { a: 0, k: 0, ix: 9 }, + ix: 1, + nm: "Polystar Path 1", + mn: "ADBE Vector Shape - Star", + hd: false, + }, + { + ty: "fl", + c: { a: 0, k: [1, 0.729411764706, 0.082352941176, 1], ix: 4 }, + o: { a: 0, k: 100, ix: 5 }, + r: 1, + bm: 0, + nm: "Fill 1", + mn: "ADBE Vector Graphic - Fill", + hd: false, + }, + ], + ip: 0, + op: 43, + st: 0, + bm: 0, + }, + ], + markers: [], +}; diff --git a/client/packages/lowcoder/src/comps/comps/jsonComp/jsonLottieComp.tsx b/client/packages/lowcoder/src/comps/comps/jsonComp/jsonLottieComp.tsx new file mode 100644 index 000000000..7e03d89ba --- /dev/null +++ b/client/packages/lowcoder/src/comps/comps/jsonComp/jsonLottieComp.tsx @@ -0,0 +1,151 @@ +import { Player } from "@lottiefiles/react-lottie-player"; +import { hiddenPropertyView } from "@lowcoder-ee/index.sdk"; +import { + ArrayOrJSONObjectControl, + NumberControl, +} from "comps/controls/codeControl"; +import { dropdownControl } from "comps/controls/dropdownControl"; +import { styleControl } from "comps/controls/styleControl"; +import { LottieStyle } from "comps/controls/styleControlConstants"; +import { trans } from "i18n"; +import { Section, sectionNames } from "lowcoder-design"; +import { useEffect, useState } from "react"; +import { UICompBuilder, withDefault } from "../../generators"; +import { + NameConfig, + NameConfigHidden, + withExposingConfigs, +} from "../../generators/withExposing"; +import { defaultLottie } from "./jsonConstants"; +/** + * JsonLottie Comp + */ +const animationStartOptions = [ + { + label: "Auto", + value: "auto", + }, + { + label: "On Hover", + value: "on hover", + }, +] as const; + +const loopOptions = [ + { + label: "Single play", + value: "single", + }, + { + label: "Endless loop", + value: "endless", + }, +] as const; + +const speedOptions = [ + { + label: "1x", + value: "1", + }, + { + label: "1.5x", + value: "1.5", + }, + { + label: "2x", + value: "2", + }, + { + label: "2.5x", + value: "2.5", + }, + { + label: "5x", + value: "5", + }, + { + label: "10x", + value: "10", + }, +] as const; + +let JsonLottieTmpComp = (function () { + const childrenMap = { + value: withDefault( + ArrayOrJSONObjectControl, + JSON.stringify(defaultLottie, null, 2) + ), + speed: dropdownControl(speedOptions, "1"), + width: withDefault(NumberControl, 100), + height: withDefault(NumberControl, 100), + backgroundColor: styleControl(LottieStyle), + animationStart: dropdownControl(animationStartOptions, "auto"), + loop: dropdownControl(loopOptions, "single"), + }; + + return new UICompBuilder(childrenMap, (props) => { + return ( +