forked from webiny/webiny-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce a new page rendering engine (webiny#2928)
- Loading branch information
Showing
446 changed files
with
24,725 additions
and
6,615 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import pageBuilder from "./pageBuilder"; | ||
import formBuilder from "./formBuilder"; | ||
|
||
export default () => [pageBuilder, formBuilder]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "theme", | ||
"version": "0.1.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@apollo/react-components": "^3.1.5", | ||
"@apollo/react-hooks": "^3.1.5", | ||
"@webiny/app-form-builder": "^5.33.5", | ||
"@webiny/app-page-builder": "^5.33.5", | ||
"@webiny/form": "^5.33.5", | ||
"@webiny/react-rich-text-renderer": "^5.33.5", | ||
"@webiny/react-router": "^5.33.5", | ||
"@webiny/validation": "^5.33.5", | ||
"classnames": "^2.2.6", | ||
"emotion": "^10.0.17", | ||
"graphql": "^15.7.2", | ||
"graphql-tag": "^2.12.6", | ||
"invariant": "^2.2.4", | ||
"lodash": "^4.4.2", | ||
"react": "17.0.2", | ||
"react-hamburger-menu": "^1.1.1", | ||
"react-helmet": "^6.1.0" | ||
}, | ||
"devDependencies": { | ||
"@types/invariant": "^2.2.35", | ||
"@types/lodash": "^4.14.178", | ||
"@types/react-hamburger-menu": "^0.0.4" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "../../tsconfig", | ||
"include": ["."], | ||
"compilerOptions": { | ||
"composite": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,23 @@ | ||
import pageBuilder from "./pageBuilder"; | ||
import formBuilder from "./formBuilder"; | ||
import StaticLayout from "./layouts/pages/Static"; | ||
import theme from "./theme"; | ||
|
||
export default () => [pageBuilder, formBuilder]; | ||
// TODO CLEAN! | ||
import { PbPageLayoutPlugin } from "@webiny/app-page-builder"; | ||
import { FbFormLayoutPlugin } from "@webiny/app-form-builder"; | ||
import { ThemePlugin } from "@webiny/app-website"; | ||
import DefaultFormLayout from "./layouts/forms/DefaultFormLayout"; | ||
|
||
export default () => [ | ||
new ThemePlugin(theme), | ||
new PbPageLayoutPlugin({ | ||
name: "static", | ||
title: "Static page", | ||
component: StaticLayout | ||
}), | ||
new FbFormLayoutPlugin({ | ||
name: "default", | ||
title: "Default layout", | ||
|
||
component: DefaultFormLayout | ||
}) | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import React, { useState } from "react"; | ||
import { Form } from "@webiny/form"; | ||
import { FormLayoutComponent } from "@webiny/app-form-builder/types"; | ||
import styled from "@emotion/styled"; | ||
import { Row } from "./DefaultFormLayout/Row"; | ||
import { Cell } from "./DefaultFormLayout/Cell"; | ||
import { Field } from "./DefaultFormLayout/Field"; | ||
import { SuccessMessage } from "./DefaultFormLayout/SuccessMessage"; | ||
import { SubmitButton } from "./DefaultFormLayout/SubmitButton"; | ||
import { TermsOfServiceSection } from "./DefaultFormLayout/TermsOfServiceSection"; | ||
import { ReCaptchaSection } from "./DefaultFormLayout/ReCaptchaSection"; | ||
|
||
import theme from "../../theme"; | ||
|
||
const Wrapper = styled.div` | ||
width: 100%; | ||
padding: 0 5px 5px 5px; | ||
box-sizing: border-box; | ||
background-color: ${theme.styles.colors.color5}; | ||
`; | ||
|
||
/** | ||
* This is the default form layout component, in which we render all the form fields. We also render terms of service | ||
* and reCAPTCHA (if enabled in form settings), and, at the very bottom, the submit button. | ||
* | ||
* Feel free to use this component as your starting point for your own form layouts. | ||
*/ | ||
const DefaultFormLayout: FormLayoutComponent = ({ | ||
getFields, | ||
getDefaultValues, | ||
submit, | ||
formData, | ||
ReCaptcha, | ||
TermsOfService | ||
}) => { | ||
// Is the form in loading (submitting) state? | ||
const [loading, setLoading] = useState(false); | ||
|
||
// Is the form successfully submitted? | ||
const [formSuccess, setFormSuccess] = useState(false); | ||
|
||
// All form fields - an array of rows where each row is an array that contain fields. | ||
const fields = getFields(); | ||
|
||
/** | ||
* Once the data is successfully submitted, we show a success message. | ||
*/ | ||
const submitForm = async (data: Record<string, any>): Promise<void> => { | ||
setLoading(true); | ||
const result = await submit(data); | ||
setLoading(false); | ||
if (result.error === null) { | ||
setFormSuccess(true); | ||
} | ||
}; | ||
|
||
if (formSuccess) { | ||
return <SuccessMessage formData={formData} />; | ||
} | ||
|
||
return ( | ||
/* "onSubmit" callback gets triggered once all of the fields are valid. */ | ||
/* We also pass the default values for all fields via the getDefaultValues callback. */ | ||
<Form onSubmit={submitForm} data={getDefaultValues()}> | ||
{({ submit }) => ( | ||
<Wrapper> | ||
{fields.map((row, rowIndex) => ( | ||
<Row key={rowIndex}> | ||
{row.map(field => ( | ||
<Cell key={field._id}> | ||
<Field field={field} /> | ||
</Cell> | ||
))} | ||
</Row> | ||
))} | ||
|
||
<TermsOfServiceSection component={TermsOfService} /> | ||
<ReCaptchaSection component={ReCaptcha} /> | ||
|
||
<SubmitButton onClick={submit} loading={loading}> | ||
{formData.settings.submitButtonLabel || "Submit"} | ||
</SubmitButton> | ||
</Wrapper> | ||
)} | ||
</Form> | ||
); | ||
}; | ||
|
||
export default DefaultFormLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import styled from "@emotion/styled"; | ||
import theme from "../../../theme"; | ||
|
||
export const Cell = styled.div` | ||
width: 100%; | ||
background-color: ${theme.styles.colors.color5}; | ||
padding: 15px; | ||
${theme.breakpoints.desktop} { | ||
&:first-child { | ||
padding-left: 0; | ||
} | ||
&:last-child { | ||
padding-right: 0; | ||
} | ||
} | ||
} | ||
`; |
Oops, something went wrong.