feat: Pass components to blocks in server, setup Icon.

This commit is contained in:
Sam Tolmay 2021-11-22 16:50:52 +02:00
parent 739704496d
commit 7db2640974
No known key found for this signature in database
GPG Key ID: D004126FCD1A6DF0
11 changed files with 86 additions and 6 deletions

25
.pnp.cjs generated
View File

@ -5747,7 +5747,8 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["next-auth", "virtual:003bebd8b7a948d12b44e2c11a621884feb1891eea3645171e827971487f79396db9f7422bc411ccf3f90877e94ec86f5c3da70b96efb5daddb2ee3b35eae5c6#npm:4.0.0-beta.6"],
["next-with-less", "virtual:003bebd8b7a948d12b44e2c11a621884feb1891eea3645171e827971487f79396db9f7422bc411ccf3f90877e94ec86f5c3da70b96efb5daddb2ee3b35eae5c6#npm:2.0.2"],
["react", "npm:18.0.0-alpha-327d5c484-20211106"],
["react-dom", "virtual:04055f037dce009b6d437327a3df2c0a05f0436e14e2b705672dd0d1e0a3dfd29d8d62e0db8cb7e152c4b95e36ad3ccd6a68c9e962121dec9e597b25e0481519#npm:18.0.0-alpha-327d5c484-20211106"]
["react-dom", "virtual:04055f037dce009b6d437327a3df2c0a05f0436e14e2b705672dd0d1e0a3dfd29d8d62e0db8cb7e152c4b95e36ad3ccd6a68c9e962121dec9e597b25e0481519#npm:18.0.0-alpha-327d5c484-20211106"],
["react-icons", "virtual:003bebd8b7a948d12b44e2c11a621884feb1891eea3645171e827971487f79396db9f7422bc411ccf3f90877e94ec86f5c3da70b96efb5daddb2ee3b35eae5c6#npm:4.3.1"]
],
"linkType": "SOFT",
}]
@ -22628,6 +22629,28 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
"linkType": "HARD",
}]
]],
["react-icons", [
["npm:4.3.1", {
"packageLocation": "./.yarn/cache/react-icons-npm-4.3.1-46cb955834-2cc608acdd.zip/node_modules/react-icons/",
"packageDependencies": [
["react-icons", "npm:4.3.1"]
],
"linkType": "SOFT",
}],
["virtual:003bebd8b7a948d12b44e2c11a621884feb1891eea3645171e827971487f79396db9f7422bc411ccf3f90877e94ec86f5c3da70b96efb5daddb2ee3b35eae5c6#npm:4.3.1", {
"packageLocation": "./.yarn/__virtual__/react-icons-virtual-0dd268c70d/0/cache/react-icons-npm-4.3.1-46cb955834-2cc608acdd.zip/node_modules/react-icons/",
"packageDependencies": [
["react-icons", "virtual:003bebd8b7a948d12b44e2c11a621884feb1891eea3645171e827971487f79396db9f7422bc411ccf3f90877e94ec86f5c3da70b96efb5daddb2ee3b35eae5c6#npm:4.3.1"],
["@types/react", null],
["react", "npm:18.0.0-alpha-327d5c484-20211106"]
],
"packagePeers": [
"@types/react",
"react"
],
"linkType": "HARD",
}]
]],
["react-is", [
["npm:16.13.1", {
"packageLocation": "./.yarn/cache/react-is-npm-16.13.1-a9b9382b4f-f7a19ac349.zip/node_modules/react-is/",

Binary file not shown.

View File

@ -18,6 +18,7 @@ export { default as Anchor } from './blocks/Anchor/Anchor.js';
export { default as Box } from './blocks/Box/Box.js';
export { default as DangerousHtml } from './blocks/DangerousHtml/DangerousHtml.js';
export { default as Html } from './blocks/Html/Html.js';
export { default as Icon } from './blocks/Icon/Icon.js';
export { default as Img } from './blocks/Img/Img.js';
export { default as List } from './blocks/List/List.js';
export { default as Span } from './blocks/Span/Span.js';

View File

@ -47,7 +47,8 @@
"next": "12.0.3",
"next-auth": "4.0.0-beta.6",
"react": "18.0.0-alpha-327d5c484-20211106",
"react-dom": "18.0.0-alpha-327d5c484-20211106"
"react-dom": "18.0.0-alpha-327d5c484-20211106",
"react-icons": "4.3.1"
},
"devDependencies": {
"@next/eslint-plugin-next": "12.0.2",

View File

@ -65,8 +65,9 @@ const CategorySwitch = ({ block, Blocks, context, lowdefy }) => {
triggerEvent: block.triggerEvent,
})}
// TODO: React throws a basePath warning
basePath={lowdefy.basePath}
basePath={lowdefy._internal.basePath}
blockId={block.blockId}
components={lowdefy._internal.components}
events={block.eval.events}
homePageId={lowdefy.homePageId}
key={block.blockId}
@ -97,8 +98,9 @@ const CategorySwitch = ({ block, Blocks, context, lowdefy }) => {
registerMethod: block.registerMethod,
triggerEvent: block.triggerEvent,
})}
basePath={lowdefy.basePath}
basePath={lowdefy._internal.basePath}
blockId={block.blockId}
components={lowdefy._internal.components}
events={block.eval.events}
homePageId={lowdefy.homePageId}
key={block.blockId}

View File

@ -65,8 +65,9 @@ const Container = ({ block, Blocks, Component, context, lowdefy }) => {
registerMethod: block.registerMethod,
triggerEvent: block.triggerEvent,
})}
basePath={lowdefy.basePath}
basePath={lowdefy._internal.basePath}
blockId={block.blockId}
components={lowdefy._internal.components}
content={content}
events={block.eval.events}
homePageId={lowdefy.homePageId}

View File

@ -72,8 +72,9 @@ const List = ({ block, Blocks, Component, context, lowdefy }) => {
triggerEvent: block.triggerEvent,
unshiftItem: block.unshiftItem,
})}
basePath={lowdefy.basePath}
basePath={lowdefy._internal.basePath}
blockId={block.blockId}
components={lowdefy._internal.components}
events={block.eval.events}
homePageId={lowdefy.homePageId}
key={block.blockId}

View File

@ -15,7 +15,11 @@
*/
import Link from 'next/link';
import { createIcon } from '@lowdefy/block-utils';
import icons from '../plugins/icons.js';
export default {
Link,
Icon: createIcon(icons),
};

View File

@ -19,9 +19,11 @@
import { Anchor } from '@lowdefy/blocks-basic/blocks.js';
import { Box } from '@lowdefy/blocks-basic/blocks.js';
import { Html } from '@lowdefy/blocks-basic/blocks.js';
import { Icon } from '@lowdefy/blocks-basic/blocks.js';
export default {
Anchor,
Box,
Html,
Icon,
};

View File

@ -0,0 +1,35 @@
/*
Copyright 2020-2021 Lowdefy, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/* eslint-disable import/no-duplicates */
import { AiOutlineFire } from 'react-icons/ai';
import { AiOutlineRocket } from 'react-icons/ai';
import { AiOutlineLoading3Quarters } from 'react-icons/ai';
import { AiOutlineExclamationCircle } from 'react-icons/ai';
import { AiOutlineExperiment } from 'react-icons/ai';
import { FcLandscape } from 'react-icons/fc';
import { MdIcecream } from 'react-icons/md';
export default {
AiOutlineLoading3Quarters,
AiOutlineExclamationCircle,
AiOutlineFire,
AiOutlineRocket,
AiOutlineExperiment,
FcLandscape,
MdIcecream,
};

View File

@ -3959,6 +3959,7 @@ __metadata:
next-with-less: 2.0.2
react: 18.0.0-alpha-327d5c484-20211106
react-dom: 18.0.0-alpha-327d5c484-20211106
react-icons: 4.3.1
languageName: unknown
linkType: soft
@ -17764,6 +17765,15 @@ __metadata:
languageName: node
linkType: hard
"react-icons@npm:4.3.1":
version: 4.3.1
resolution: "react-icons@npm:4.3.1"
peerDependencies:
react: "*"
checksum: 2cc608acdd3e906aa3aaee290b8398220639677c949382d86e554020e5dab6a9f1ed7484418aa5272cb5c5c018e1fc9a323d433d901697a76530029f9ecb1263
languageName: node
linkType: hard
"react-is@npm:17.0.2, react-is@npm:^17.0.1":
version: 17.0.2
resolution: "react-is@npm:17.0.2"