Skip to content

Commit cb483e1

Browse files
authored
feat: introduce a new page rendering engine (#2928)
1 parent ced07d0 commit cb483e1

File tree

446 files changed

+24725
-6615
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

446 files changed

+24725
-6615
lines changed

apps/admin/src/App.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// $webiny-theme-typography-font-family: "Source Sans Pro";
1414

1515
// Import theme styles
16-
@import "~theme/styles.scss";
16+
@import "~theme/global.scss";
1717

1818
// Import main styles
1919
@import "~@webiny/app-serverless-cms/styles.scss";

apps/admin/src/components/PageElementsProvider.tsx

Lines changed: 0 additions & 60 deletions
This file was deleted.

apps/admin/src/components/theme.ts

Lines changed: 0 additions & 52 deletions
This file was deleted.

apps/admin/src/plugins/pageBuilder.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,15 @@ import pageBuilderConfig from "@webiny/app-page-builder/editor/plugins/pageBuild
77
/* Welcome screen widget for Page Builder */
88
import welcomeScreenWidget from "@webiny/app-page-builder/admin/plugins/welcomeScreenWidget";
99

10+
import editorPlugins from "./pageBuilder/editorPlugins";
11+
import renderPlugins from "./pageBuilder/renderPlugins";
12+
1013
export default [
1114
pageBuilderConfig({
1215
maxEventActionsNesting: 10
1316
}),
1417
pageBuilderPlugins(),
1518
welcomeScreenWidget,
16-
/**
17-
* This plugin is responsible for lazy-loading plugin presets for page builder editor and list views.
18-
* Since Editor is quite heavy, we don't want to include it in the main app bundle.
19-
* The tricky part here is that we want developers to be able to customize which plugins are being loaded, so
20-
* we need this plugin to allow plugin customization while still using code splitting.
21-
*/
22-
{
23-
type: "pb-plugins-loader",
24-
async loadEditorPlugins() {
25-
return (await import("./pageBuilder/editorPlugins")).default;
26-
},
27-
async loadRenderPlugins() {
28-
return (await import("./pageBuilder/renderPlugins")).default;
29-
}
30-
}
19+
editorPlugins,
20+
renderPlugins
3121
];

apps/theme-legacy/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import pageBuilder from "./pageBuilder";
2+
import formBuilder from "./formBuilder";
3+
4+
export default () => [pageBuilder, formBuilder];

apps/theme-legacy/package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "theme",
3+
"version": "0.1.0",
4+
"main": "index.js",
5+
"license": "MIT",
6+
"dependencies": {
7+
"@apollo/react-components": "^3.1.5",
8+
"@apollo/react-hooks": "^3.1.5",
9+
"@webiny/app-form-builder": "^5.33.5",
10+
"@webiny/app-page-builder": "^5.33.5",
11+
"@webiny/form": "^5.33.5",
12+
"@webiny/react-rich-text-renderer": "^5.33.5",
13+
"@webiny/react-router": "^5.33.5",
14+
"@webiny/validation": "^5.33.5",
15+
"classnames": "^2.2.6",
16+
"emotion": "^10.0.17",
17+
"graphql": "^15.7.2",
18+
"graphql-tag": "^2.12.6",
19+
"invariant": "^2.2.4",
20+
"lodash": "^4.4.2",
21+
"react": "17.0.2",
22+
"react-hamburger-menu": "^1.1.1",
23+
"react-helmet": "^6.1.0"
24+
},
25+
"devDependencies": {
26+
"@types/invariant": "^2.2.35",
27+
"@types/lodash": "^4.14.178",
28+
"@types/react-hamburger-menu": "^0.0.4"
29+
}
30+
}
File renamed without changes.

apps/theme-legacy/tsconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../../tsconfig",
3+
"include": ["."],
4+
"compilerOptions": {
5+
"composite": false
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
@import "@webiny/react-rich-text-renderer/styles.scss";
2+
@import url("https://fonts.googleapis.com/css?family=IBM+Plex+Sans:400,500,700|Lato:400,700");
3+
14
/* http://meyerweb.com/eric/tools/css/reset/
25
v2.0 | 20110126
36
License: none (public domain)
@@ -9,32 +12,42 @@ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockq
912
border: 0;
1013
font-size: 100%;
1114
font: inherit;
12-
vertical-align: baseline; }
15+
vertical-align: baseline;
16+
}
1317

1418
/* HTML5 display-role reset for older browsers */
1519

1620
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
17-
display: block; }
21+
display: block;
22+
}
1823

1924
body {
20-
line-height: 1; }
25+
line-height: 1;
26+
}
2127

2228
ol, ul {
23-
list-style: none; }
29+
list-style: none;
30+
}
2431

2532
blockquote, q {
26-
quotes: none; }
33+
quotes: none;
34+
}
2735

2836
blockquote {
2937
&:before, &:after {
3038
content: '';
31-
content: none; } }
39+
content: none;
40+
}
41+
}
3242

3343
q {
3444
&:before, &:after {
3545
content: '';
36-
content: none; } }
46+
content: none;
47+
}
48+
}
3749

3850
table {
3951
border-collapse: collapse;
40-
border-spacing: 0; }
52+
border-spacing: 0;
53+
}

apps/theme/index.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
1-
import pageBuilder from "./pageBuilder";
2-
import formBuilder from "./formBuilder";
1+
import StaticLayout from "./layouts/pages/Static";
2+
import theme from "./theme";
33

4-
export default () => [pageBuilder, formBuilder];
4+
// TODO CLEAN!
5+
import { PbPageLayoutPlugin } from "@webiny/app-page-builder";
6+
import { FbFormLayoutPlugin } from "@webiny/app-form-builder";
7+
import { ThemePlugin } from "@webiny/app-website";
8+
import DefaultFormLayout from "./layouts/forms/DefaultFormLayout";
9+
10+
export default () => [
11+
new ThemePlugin(theme),
12+
new PbPageLayoutPlugin({
13+
name: "static",
14+
title: "Static page",
15+
component: StaticLayout
16+
}),
17+
new FbFormLayoutPlugin({
18+
name: "default",
19+
title: "Default layout",
20+
21+
component: DefaultFormLayout
22+
})
23+
];
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import React, { useState } from "react";
2+
import { Form } from "@webiny/form";
3+
import { FormLayoutComponent } from "@webiny/app-form-builder/types";
4+
import styled from "@emotion/styled";
5+
import { Row } from "./DefaultFormLayout/Row";
6+
import { Cell } from "./DefaultFormLayout/Cell";
7+
import { Field } from "./DefaultFormLayout/Field";
8+
import { SuccessMessage } from "./DefaultFormLayout/SuccessMessage";
9+
import { SubmitButton } from "./DefaultFormLayout/SubmitButton";
10+
import { TermsOfServiceSection } from "./DefaultFormLayout/TermsOfServiceSection";
11+
import { ReCaptchaSection } from "./DefaultFormLayout/ReCaptchaSection";
12+
13+
import theme from "../../theme";
14+
15+
const Wrapper = styled.div`
16+
width: 100%;
17+
padding: 0 5px 5px 5px;
18+
box-sizing: border-box;
19+
background-color: ${theme.styles.colors.color5};
20+
`;
21+
22+
/**
23+
* This is the default form layout component, in which we render all the form fields. We also render terms of service
24+
* and reCAPTCHA (if enabled in form settings), and, at the very bottom, the submit button.
25+
*
26+
* Feel free to use this component as your starting point for your own form layouts.
27+
*/
28+
const DefaultFormLayout: FormLayoutComponent = ({
29+
getFields,
30+
getDefaultValues,
31+
submit,
32+
formData,
33+
ReCaptcha,
34+
TermsOfService
35+
}) => {
36+
// Is the form in loading (submitting) state?
37+
const [loading, setLoading] = useState(false);
38+
39+
// Is the form successfully submitted?
40+
const [formSuccess, setFormSuccess] = useState(false);
41+
42+
// All form fields - an array of rows where each row is an array that contain fields.
43+
const fields = getFields();
44+
45+
/**
46+
* Once the data is successfully submitted, we show a success message.
47+
*/
48+
const submitForm = async (data: Record<string, any>): Promise<void> => {
49+
setLoading(true);
50+
const result = await submit(data);
51+
setLoading(false);
52+
if (result.error === null) {
53+
setFormSuccess(true);
54+
}
55+
};
56+
57+
if (formSuccess) {
58+
return <SuccessMessage formData={formData} />;
59+
}
60+
61+
return (
62+
/* "onSubmit" callback gets triggered once all of the fields are valid. */
63+
/* We also pass the default values for all fields via the getDefaultValues callback. */
64+
<Form onSubmit={submitForm} data={getDefaultValues()}>
65+
{({ submit }) => (
66+
<Wrapper>
67+
{fields.map((row, rowIndex) => (
68+
<Row key={rowIndex}>
69+
{row.map(field => (
70+
<Cell key={field._id}>
71+
<Field field={field} />
72+
</Cell>
73+
))}
74+
</Row>
75+
))}
76+
77+
<TermsOfServiceSection component={TermsOfService} />
78+
<ReCaptchaSection component={ReCaptcha} />
79+
80+
<SubmitButton onClick={submit} loading={loading}>
81+
{formData.settings.submitButtonLabel || "Submit"}
82+
</SubmitButton>
83+
</Wrapper>
84+
)}
85+
</Form>
86+
);
87+
};
88+
89+
export default DefaultFormLayout;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import styled from "@emotion/styled";
2+
import theme from "../../../theme";
3+
4+
export const Cell = styled.div`
5+
width: 100%;
6+
background-color: ${theme.styles.colors.color5};
7+
padding: 15px;
8+
9+
${theme.breakpoints.desktop} {
10+
&:first-child {
11+
padding-left: 0;
12+
}
13+
14+
&:last-child {
15+
padding-right: 0;
16+
}
17+
}
18+
}
19+
`;

0 commit comments

Comments
 (0)