Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support React.js #34

Merged
merged 45 commits into from
Dec 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
4faad41
updated load template to return the files base pathname
nikolas-con Dec 7, 2021
fafa014
fixed the path when is the root path and updated the handle event to …
nikolas-con Dec 7, 2021
74816c2
implemented support multiple-pages in production
nikolas-con Dec 7, 2021
b167d1c
added sample react project for development
LiveDuo Dec 9, 2021
6678d24
fixed type error
LiveDuo Dec 9, 2021
b84d3ad
added local react server
LiveDuo Dec 9, 2021
b0063f4
added react scripts and notes to fix
LiveDuo Dec 9, 2021
60e2e6b
fixed react server non get requests
LiveDuo Dec 9, 2021
06d02e8
fixed dynamic check for react / next
LiveDuo Dec 9, 2021
07d075b
moved part of react server from lib to react project
LiveDuo Dec 9, 2021
d9f9418
moved component code to library
LiveDuo Dec 9, 2021
cbc8b0b
added dynamic selection of builder, allowed custom port for standalon…
LiveDuo Dec 10, 2021
c8e8cef
fixed upload file for standalone builder
LiveDuo Dec 10, 2021
3bd79ad
linked destack to bin file, moved dev script from react project to lib
LiveDuo Dec 13, 2021
f17b9c7
removed unused destack ts, implemented prod build for development (wip)
LiveDuo Dec 13, 2021
446ca82
fixed autoreload issue, implemented destack bin build for react
LiveDuo Dec 13, 2021
095fe9d
added publish and export scripts
LiveDuo Dec 13, 2021
3322076
added npm publish alpha and beta scripts
LiveDuo Dec 13, 2021
f29a43f
fixed react build and start in lib and added react build in pre publi…
LiveDuo Dec 14, 2021
2c87a7a
fixed react server script after imported as npm package
LiveDuo Dec 14, 2021
297357d
fixed typescript issues with react component
LiveDuo Dec 14, 2021
8e98602
fixed react flash reload issue with tailwind css
LiveDuo Dec 14, 2021
83a5eb9
changed react start local server port to 3000
LiveDuo Dec 14, 2021
505f069
improved test consistency
LiveDuo Dec 14, 2021
c659ff9
fixed test combatibility with node 12
LiveDuo Dec 14, 2021
c035bd7
fixed rollup formidable warnings
LiveDuo Dec 15, 2021
69fee55
fixed react server refresh in development
LiveDuo Dec 15, 2021
201586a
moved public path variable inline
LiveDuo Dec 15, 2021
989e0eb
added conditional tmate session
LiveDuo Dec 16, 2021
1fee5fc
added workflow_dispatch event
LiveDuo Dec 16, 2021
a012879
added react notes to readme
LiveDuo Dec 16, 2021
bc9b06f
completed readme updates for react
LiveDuo Dec 16, 2021
56ca8ea
fixed typos in readme
LiveDuo Dec 16, 2021
318f766
Merge branch 'main' into feature/react-support
LiveDuo Dec 16, 2021
06e87a7
fixed typo in react instructions
LiveDuo Dec 16, 2021
f2cecc1
Merge branch 'feature/react-support' into feature/multiple-pages
LiveDuo Dec 17, 2021
05b2712
fixed issue from merge and compatibility with react
nikolas-con Dec 17, 2021
90198a6
fixed react production detection
LiveDuo Dec 17, 2021
41bceb8
undo production detection fix
LiveDuo Dec 17, 2021
8ca7e0c
fixed production detection
LiveDuo Dec 17, 2021
d51310a
fixed production
nikolas-con Dec 17, 2021
3645c86
resolve PR changes
nikolas-con Dec 18, 2021
e171d71
fixed multiple-pages react production
nikolas-con Dec 19, 2021
aaf2b19
Merge branch 'feature/react-support' into feature/multiple-pages
nikolas-con Dec 19, 2021
79516f2
Merge pull request #32 from nikolas-con/feature/multiple-pages
LiveDuo Dec 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 68 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Destack 🔌 Own your stack. Embrace your design.

Build landing pages visually right in your Next.js project. Deploy them zero further configuration!
Build landing pages visually right in your React or Next.js projects. Deploy them zero further configuration!

Editor preview: [Destack Online Builder](https://destack-page.vercel.app/)

Expand All @@ -12,7 +12,7 @@ Example in production: [prettyfunnels.com](https://www.prettyfunnels.com/landing

# What's Destack?

It's a tool to build landing pages within your [Next.js](https://nextjs.org/) project. It's powered by [Grapes.js](https://grapesjs.com/) and includes the complete set of blocks from [Tailblocks.cc](https://tailblocks.cc/). Supports asset uploading, form submission and a variaty of Tailwind colors.
It's a tool to build landing pages within your [React](https://reactjs.org/) or [Next.js](https://nextjs.org/) projects. It's powered by [Grapes.js](https://grapesjs.com/) and includes the complete set of blocks from [Tailblocks.cc](https://tailblocks.cc/). Supports asset uploading, form submission and a variaty of Tailwind colors.

*Destack is a tool to help you stop worrying about the marketing pages and focus on your project.*

Expand All @@ -36,19 +36,19 @@ Stores the images uploaded in the editor in your repository & displays them when

#### 👩🏻‍💻 Easy Setup & Deployment

Works existing & new [Next.js](https://nextjs.org/) projects. Requires minimal setup and no extra configuration to deploy your landing pages to production.
Works existing & new [React](https://reactjs.org/) and [Next.js](https://nextjs.org/) projects. Requires minimal setup and no extra configuration to deploy your landing pages to production.

# Getting Started

### With a new project:
### With a new Next.js project:

- Fork the [destack-starter](https://github.com/LiveDuo/destack-starter) project

- OR deploy a project to Vercel: [<img src="https://github.com/LiveDuo/destack/raw/main/assets/vercel_big.png" width="92">](https://vercel.com/new/git/external?repository-url=https://github.com/LiveDuo/destack-starter&project-name=destack-starter&repository-name=destack-starter)

- OR preview it online with Gitpod: [<img src="https://github.com/LiveDuo/destack/raw/main/assets/gitpod_big.png" width="92">](https://gitpod.io/#https://github.com/LiveDuo/destack-starter)

### With an existing project:
### With an existing Next.js project:

##### 1. Install Destack on your Next.js project

Expand Down Expand Up @@ -92,6 +92,58 @@ export default function Page(props) {
```
</details>

### With a new React.js project:

- Fork the [destack-react-starter](https://github.com/LiveDuo/destack-react-starter) project

- OR deploy a project to Vercel: [<img src="https://github.com/LiveDuo/destack/raw/main/assets/vercel_big.png" width="92">](https://vercel.com/new/git/external?repository-url=https://github.com/LiveDuo/destack-react-starter&project-name=destack-react-starter&repository-name=destack-react-starter)

- OR preview it online with Gitpod: [<img src="https://github.com/LiveDuo/destack/raw/main/assets/gitpod_big.png" width="92">](https://gitpod.io/#https://github.com/LiveDuo/destack-react-starter)

### With an existing React.js project:

##### 1. Install Destack on your React.js project

```sh
npm i destack
```

##### 2. Setup the builder endpoint

In `package.json`:
- Replace the "start" script with `destack -d \"react-scripts start\"`
- Then, replace the "build" script with `destack -b \"react-scripts build\"`

##### 3. Then create a new page

In any React.js component you want to setup Destack:
```js
import 'grapesjs/dist/css/grapes.min.css'
export { ContentProviderReact as default } from 'destack'

```

<details>
<summary>How to use along other components</summary>
<br>

```js
import 'grapesjs/dist/css/grapes.min.css'

import { ContentProviderReact } from 'destack'

const App = () => {
return (
<div style={{ height: '100%' }}>
<span>Hello world</span>
<ContentProviderReact />
</div>
)
}
export default App
```
</details>

# How it works

🛠 Destack is composed of two main components, the first is a React component that shows the editor or the generated page and the second is a Next.js API route that saves your progress to your repository.
Expand All @@ -102,28 +154,34 @@ export default function Page(props) {

🚀 When is time to go in `production` (ie. do `npm run build` or deploy to Vercel) the React component reads `NODE_ENV` again and statically generates the HTML version of the page you build in the editor from the `default.json` file Destack created for you earlier.

> Note: The above description is for Next.js. In React.js, the `destack -b` script creates an API route similar to the one described above that handles template changes and file uploads in development. In production the `destack -d` script copies `default.json` to the `public` folder and builds a static version of the page.

# How to's & guides

### Adding an HTML form

- Drop a block that contains a form
- Click on the form & head to components settings
- Add form URL & check `async` if don't want a redirection
- To handle a `async` forms you can create an API route (eg. [api/submit.js](https://github.com/LiveDuo/destack/blob/main/dev/nextjs-project/pages/api/submit.js))
- To handle a `async` forms you can create an API route
- Next.js: Create a file in [api/submit.js](https://github.com/LiveDuo/destack/blob/main/dev/nextjs-project/pages/api/submit.js)
- React.js: You will need a seperate Node.js server listening on `/api/submit`

### Uploading images

- Drop a block that contains an image or use image block
- Click on an image to open the upload modal
- Select the image you want to update and click on it to add it to the page
- Notes: Images are uploaded to `public/uploaded` with their original filenames
- Note: Images are uploaded to `public/uploaded` with their original filenames

### Show editor in production

- Install Destack to a new or existing project
- Set `showEditorInProd={true}` in the `ContentProvider` component
- The result should be similar to [Destack Online Builder](https://destack-page.vercel.app/)

Note: this is only available for Next.js.

<details>
<summary>Code snippet</summary>
<br>
Expand All @@ -147,9 +205,9 @@ export default function Page(props) {
See [CONTRIBUTING.md](CONTRIBUTING.md)
<br>

# How is this possible?
# How this project came to existence

This project was none's bright idea. It was not something that was planned and design in depth in advance. Instead it was evolved out of the need and enjoyment of using some amazing tools and prototype quickly. These projects heavily improved my developer life and a few of my friends'.
This project was nothing that was planned and design in depth in advance. Instead it was evolved out of the need and enjoyment of using some amazing tools and prototype quickly. These projects heavily improved my developer life and a few of my friends'.

> Next.js 🅧 ➕ Tailwind CSS 🍃 ➕ Grapes.js 🍇 = 💣💣

Expand All @@ -163,6 +221,5 @@ Please go and show these projects some love (⭐️). Don't forget to check out
Made with [contributors-img](https://contrib.rocks).

# Upcoming Tasks
- [ ] Intoduce Destack templates
- [ ] Custom tailwind.config.js file
- [ ] Tests for local editor & editor in prod
- [ ] Move builder API route to next.config.js
1 change: 1 addition & 0 deletions dev/react-project/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP_PREFLIGHT_CHECK=true
23 changes: 23 additions & 0 deletions dev/react-project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
7 changes: 7 additions & 0 deletions dev/react-project/data/default.json

Large diffs are not rendered by default.

Loading