Skip to main content

Gatsby

Build static sites with Ravenbright CSS & Gatsby. Check out the full demo on Ravenbright CSS Github repo.

View demo
tip

Make sure that you already have installed Node.js & npm CLI. read about this on npm official docs

Install Gatsby​

Step 1: create Gatsby project​

Create your project folder & run this command bellow to follow Gatsby built-in installation process on your CLI

npm init gatsby

Step 2: run the Gatsby project​

After it's finished, access the project folder & type npm run dev to start the server

cd project
npm run develop

Step 3: understand Gatsby files & directory structure​

├── src/
│ ├── components/
│ │ │── Header.js
│ │ └── Layout.js
│ └── pages/
│ │ └── index.js
│ └── styles/
│ └── global.css
└── package.json

Global CSS​

Step 1: download or install Ravenbright CSS​

Quickly download Ravenbright source code & copy the CSS into your project folder.

Download source code

or run this command below:

npm install ravenbrightcss --save

Step 2: create the CSS folder​

Put Ravenbright CSS file into src/styles directory

Import the Ravenbright CSS​

Open Layout.js file which located components/. Then, import Ravenbright CSS with the following content::

components/Layout.js
import React from "react";
import "../styles/dist/Ravenbright.min.css";

export default function Layout({ children }) {
return (
<>
<main>{children}</main>
</>
);
}

Step 3: start using Ravenbright CSS utility classes, components or CSS variables​

Open index.js located in pages/. Then write the following content:

pages/index.js
import * as React from "react";
import Layout from "../components/Layout";
function IndexPage() {
return (
<Layout>
<section className="p-t-14 p-b-14 dark-bg-black">
<h1> Big headline</h1>
<p>
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
officia deserunt mollit anim id est laborum.
</p>
<button className="bg-green-600 radius-md p-x-5 p-x-3">
Get started
</button>
</section>
</Layout>
);
}

export default IndexPage;

🎉 It's a wrap! You can check the new hero section built with Ravenbright CSS in http:localhost://3000 👈 to see the updates.

Component-based CSS​

Step 1: create new Button.module.css​

Put Ravenbright CSS variables or utility classes inside Button.module.css in components/ folder.

components/Button.module.css
.btn {
--rbrh-green-700: #007c32;
--rbrh-spacing-4: 0.75rem;
--rbrh-spacing-5: 1rem;
--rbrh-radius-md: 0.75rem;
--rbrh-radius-sm: 0.5rem;
--rbrh-radius-xs: 0.25rem;
--rbrh-shadow-lg: 0rem 0.875rem 1.5rem -0.5rem rgba(0, 0, 0, 0.25);
cursor: pointer;
border: 0;
background: var(--rbrh-green-700);
color: white;
border-radius: var(--rbrh-radius-sm);
box-shadow: var(--rbrh-shadow-lg);
padding: var(--rbrh-spacing-4) var(--rbrh-spacing-5);
text-decoration: none;
margin: var(--rbrh-spacing-4) 0;
}
.w-fit {
width: fit-content;
}
.w-100 {
width: 100%;
}

Step 2: create a new Button.js component​

Create a new Button.js component in components/.

components/Button.js
import React from "react";
import styles from "./Button.module.css";

const Button = () => {
return (
<Button
type="Button"
// Note how the "error" class is accessed as a property on the imported
// `styles` object.
className={styles.btn}
>
Get started with Ravenbright CSS
</Button>
);
};
export default Button;

Step 3: import Button on index.js​

Open index.js which located in pages/ then import the Button components & it's done 🥳.

pages/index.js
import * as React from "react";
import Layout from "../components/Layout";
import Button from "../components/Button.js";
function IndexPage() {
return (
<Layout>
<section className="p-t-14 p-b-14 dark-bg-black">
<h1> Big headline</h1>
<p>
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
officia deserunt mollit anim id est laborum.
</p>
<Button />
</section>
</Layout>
);
}
export default IndexPage;

Check the new button built with Ravenbright in http:localhost://3000 👈 to see the updates.