The PatternFly React demo app serves as a demo for building your production app with Patternfly, PatternFly React, Redux, and React Router.
Running demo: https://patternfly-react-demo-app.firebaseapp.com/#/
This project was bootstrapped with Create React App.
The most recent version of the create-react-app guide can be found here for further customizations to this boilerplate.
Note If you do not have yarn installed run: npm install -g yarn
Run the following commands:
yarn install
yarn build
yarn start
This project has the following structure:
.
├── /build/ # Compiled build output
│ ├── /static/ # Compressed static assets (css,js,img)
│ ├── /index.html # Compressed index.html
├── /node_modules/ # 3rd-party libraries and utilities
├── /public/ # Static files such as favicon.ico etc.
│ ├── /index.html # Customizable index.html
│ ├── favicon.ico # Application icon to be displayed in bookmarks
├── /src/ # Core application source
│ ├── /components/ # Shared React UI components
│ ├── /fonts/ # Fonts to be included in Webpack bundle
│ ├── /img/ # Images to be included in Webpack bundle
│ ├── /pages/ # Reusable page templates used in various routes
│ ├── /App.scss # Application SCSS
│ ├── /App.test.js # Application tests written in Jest
│ ├── /App.js # Application UI Component
│ ├── /index.js # Main React container entry
│ ├── /logo.svg # Application logo
│ ├── /registerServiceWorker # sw-precache-webpack-plugin
│ ├── /routes.js # React Router application routes
│── package.json # The list of project dependencies and NPM scripts
│── yarn.lock # Yarn package lock file
PatternFly Sass was added via the Create React App Preprocessor Guide. All Patternfly build assets are copied to src
so that they may be included in the default
create-react-app build. The App.scss
file will include all PatternFly Sass along with PatternFly React Sass extensions. Once Sass compiles, the resulting CSS can be found in src/App.css
.
Note Only static assets which are import
'ed into your application will be included in your resulting build output. I.e. import './App.css';
will ensure App.css
is included.
In the project directory, you can run:
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
Launches the test runner in the interactive watch mode.
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
Note: this is a one-way operation. Once you eject
, you can’t go back!
If you aren’t satisfied with the build tool and configuration choices, you can eject
at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject
will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use eject
. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
If you are using Visual Studio Code as your code editor of choice, there is a package extension that will allow you to format your JavaScript/TypeScript/CSS using Prettier.
You can install the prettier extension by searching for Prettier - Code formatter
Visual Studio Code Market Place: Prettier - Code formatter
Upon installation you can begin using prettier through the command palette:
1. CMD + Shift + P -> Format Document
OR
1. Select the text you want to Prettify
2. CMD + Shift + P -> Format Selection
Note If you don't like the defaults, you can rebind editor.action.formatDocument
and editor.action.formatSelection
in the keyboard shortcuts menu of vscode.**
More information on prettier for vscode can be found here: https://github.com/prettier/prettier-vscode
We have some other demos of PatternFly React in the following branches. These provide some other examples of how to use PatternFly React in your application.
- Redux Saga - using Redux Saga and adding a login page in the PatternFly React Demo app boilerplate
- Typescript - using Typescript with the PatternFly React Demo app boilerplate
- Flow JS - using Flow JS with the PatternFly React Demo app boilerplate
There are a few things that can be done to resolve any questions or problems you might have.
- Search our GitHub issues
- Join our patternfly-react channel on Slack
- Join our mailing-list following the instructions on patternfly.org