@walltowall/gatsby-theme-slice-studio
Gatsby theme that provides interactive client documentation for Wall-to-Wall
Gatsby websites.
Install
yarn add @walltowall/gatsby-theme-ww-slice-studio
How to use
Configure Gatsby
Setup the consuming project's gatsby-config as shown below:
plugins: [
{
resolve: '@walltowall/gatsby-theme-ww-slice-studio',
options: {
root: __dirname,
siteTitle: 'Site Title',
schemas,
layouts: [
'about',
'design',
'home',
'project',
'services',
'recognition',
'team',
],
sliceZones: {
page: {
description:
'Each page document in Prismic represents a unique and visitable page on your website.',
zones: {
body:
"Body slices comprise the majority of the content on it's respective page.",
},
},
},
},
},
]
Configure Netlify & Authentication
Once your gatsby-config has been set-up, you'll need to configure a
netlify.toml in your project root to serve the appropriate lambda functions
for authentication. Below is the absolute minimum you'll need to configure
lambda functionality.
[build]
functions = "node_modules/@walltowall/gatsby-theme-ww-slice-studio/src/lambda"
After setting up your .toml file, ensure to add the appropriate environment
variables to your Netlify site's dashboard. See .env for the values to enter.
Writing documentation
Layouts
As shown in the example gatsby-config, every defined layout will need to have
a corresponding .js file in your project's /studio/layouts that follow the
following structure:
export const LAYOUT_NAME = {
name: 'Name',
customType: 'page',
description: 'Sample description',
example: [
['PageBodyHorizontalNavigation', 0],
['PageBodyFeaturedProjects', 0],
['PageBodyMixedSizedProjects', 0],
],
zones: [
{
render: () => <PageBodyHeader nextSharesBg={[true]} />,
},
{
name: 'Navigation',
preset: 'Horizontal Navigation',
reasoning:
'Provides quick access to different project types for visitors.',
render: () => (
<PageBodyHorizontalNavigation
title="design"
rootHref="/"
nextSharesBg={[true]}
>
<PageBodyHorizontalNavigation.Item href="/">
Hospitality + Leisure
</PageBodyHorizontalNavigation.Item>
<PageBodyHorizontalNavigation.Item href="/">
Interior Design
</PageBodyHorizontalNavigation.Item>
<PageBodyHorizontalNavigation.Item href="/">
Office + Healthcare
</PageBodyHorizontalNavigation.Item>
<PageBodyHorizontalNavigation.Item href="/">
Residential
</PageBodyHorizontalNavigation.Item>
<PageBodyHorizontalNavigation.Item href="/">
Retail + Restaurants
</PageBodyHorizontalNavigation.Item>
</PageBodyHorizontalNavigation>
),
},
{
name: 'Project Grid',
slices: ['PageBodyFeaturedProjects', 'PageBodyBrandedCallout'],
recommendedSlices: [
'PageBodyFeaturedProjects',
'PageBodyMixedSizedProjects',
'PageBodySmallProjects',
'PageBodyBrandedCallout',
],
reasoning:
'Varied usage of the recommended slices helps give the layout a dynamic flow. The callout helps to provide a break in the list of projects.',
render: () => (
<>
<PageBodyFeaturedProjects nextSharesBg={[true]}>
<PageBodyFeaturedProjects.Project
variant="large"
imageURL="https://pvadev.cdn.prismic.io/pvadev/541704ba04a3f58caa4a37dd325d793d351dbd1d_0-flower-avenue.jpg"
imageAlt="Example."
location="Honolulu, Hawaii"
categoryUID="residential"
name="Flower Avenue"
href={true}
/>
</PageBodyFeaturedProjects>
<PageBodyBrandedCallout
variant="dark"
textHTML="<h1>Our team of architects and interior designers is both collaborative and visionary.</h1>"
buttonHref={true}
buttonText="Our approach"
nextSharesBg={[true]}
/>
<PageBodyFooter />
</>
),
},
],
}
Once you have written all of your required layouts, create
/studio/layouts/index.js in your project and export all of your layouts as
named exports:
export { project } from './project'
export { otherLayout } from './otherLayout'
Slices
To write documentation for individual slices, create a docs object property on
the slice component directly.
See below for an example:
export const PageBodyText = props => {
}
PageBodyText.docs = {
name: 'Text',
examples: [
{
name: 'With Heading',
render: () => <PageBodyText />,
},
],
}
General Documentation
To write additional general documentation, you can create additional markdown
files in the /src/docs directory of this theme.
Each markdown file should have generally follow the following frontmatter:
---
parent: General
title: Images
path: general/images
summary: >-
Short summary of article
---
List of Required Files
Due to the nature of aliased imports with webpack, below is a comprehensive list
of required files that your project needs for this theme to function correctly:
src/index.css: Your fonts and base styles to inject into each Studio Frame.
src/slices/index.js: Export slicesMap as PageBody from
src/slices/PageBody: so our theme has alias access to it.
/netlify.toml: Must be configured to point to the theme's lambda folder. Ex:
node_modules/@walltowall/gatsby-theme-ww-slice-studio/src/lambda
studio/layouts: Must contain your layouts and the appropriate index.js