This template is setup to quickly allow an engineer to start a new Github web app repository containing the Layerframe best practices with NextJS.
- Configure the following in
package.json
"scripts": {
...
"deploy-staging": "gcloud app deploy app.staging.yaml --project MYSITE-staging",
"deploy-production": "gcloud app deploy app.yaml --project MYSITE",
...
}
- Setup any environment variables required inside of
app.yaml
,app.staging.yaml
andnext.config.js
. - Configure the
tailwind.config.js
to meet your needs.
- Run
yarn
to install node modules - Run
yarn run dev
to boot the NextJS app.
The app uses the built in
styled-jsx
tools along withtailwindcss
. When it comes to styling withstyled-jsx
it's important to understand how global styles work.
See https://tailwindcss.com/docs/using-with-preprocessors/ for more details about how this is implemented.
The components in this app depend heavily on framer-motion. See below for what each of these is used for.
This project uses gulp as a task runner to handle scaffolding components in the app. See the
gulpfile.js
,package.json
and thebin
folder for more.
Scaffolding makes it easy to build consistent components that contain Stories and tests for the application.
To build a component, run the following command.
yarn component Test
You'll see that the component is built based on the scaffold items found inside of bin/scaffolding/stateless-component
. Note: stateless-component
is connected via the file bin/scaffold-component.js
.
Gulp is being used for scaffolding only. Basically, when you run
yarn component MyNewComponent
it runs a gulp script. Seepackage.json
for more.
This project is full customizable to accept data from various external API services. See the
app.yaml
for where to add Google Cloud Platform environment variables for these services (You'll see a stub examplePRISMIC_API_URL
since this is a common one used.).
To add an endpoint you'll need to update the pages/api/constants
file with the endpoint url. You can then create a folder inside of pages/api
that the components can use e.g. pages/api/nav
. See the pages/api/nav
api endpoint as an example.
To deploy you can do the following:
- Run
gcloud deploy
orgcloud deploy-staging
This is the main configuration files for Google App Engine. See more at https://cloud.google.com/appengine/docs/standard/nodejs/config/appref
You'll notice in the
package.json
, there is a script like this"gcp-build": "next build"
. This is fired via thecloudbuild.yaml
andcloudbuild.staging.yaml
file in the root.
Note: In your staging cloudbuild instance, you'll need to set it to read from cloudbuild.staging.yaml. I think via trigger options.
Prismic is a headless CMS that we're using to handle localizations, images and scheduling content updates. Please familiarize yourself with the docs to understand how it works.
The repo url is https://YOUR_PROJECT.prismic.io and you can get access by asking for an invite or logging into an existing user.
This wordpress is implemented as a headless-CMS setup. Basically, we're only using it for API calls from the NextJS client-side application running on Google Cloud Platform.
The following tools have been installed on Wordpress to make life easier.
The following were cloned, zipped and manually installed via the Wordpress admin interface.
- GraphiQL IDE - IDE Plugin for WPGraphiQL
- WPGraphQL
- [TODO]
This project uses storybook for component review. You can get this started via the following commands.
- Run
yarn storybook
- Navigate to
http://localhost:6006/
(This should open automatically if compilation succeeds)
Storybook configuration is located in .storybook/config.js
.
This storybook has also already been preconfigured to load tachyons and other global CSS styles that are used within the <Head>
tag of the <Layout>
component. See https://github.com/jide/react-storybook/blob/master/docs/setting-up-for-css.md and https://storybook.js.org/docs/configurations/add-custom-head-tags/ for more information about this setup.
WARNING: If a new script of style tag is added to the Layout file, this will also need to be added to the
.storybook/preview-head.html
file.
There are quite a few Storybook add-ons available to meet your needs. These can be added via the .storybook/addons.js
file.