@frctls/seabed
v0.2.9
Published
Common build environment and shared React components for Fractal web applications
Downloads
22
Readme
Seabed
A sturdy base for web projects. Seabed is built on the philosophy that you should have full visibility and control over your development and build process, while keeping a set of base configurations and shared components between projects. You are encouraged to thouroughly read the generated configuration files.
This project was created as a common environment for Fractal web applications.
Requirements
Node >= 10.13
Yarn
Browser support
last 2 versions
> 1%
Based on
How it works
Add Seabed to your project with yarn add @fractal/seabed
.
yarn run seabed init
to initialize your project with Seabed's default configurations.
Any previously existing files will be compared, and their replacement confirmed.
What it generates
.browserslistrc // supported browsers
.eslintrc // ESLint rules
.gitattributes // GitHub support for proper JSX syntax highlighting in diffs
.gitignore // files ignored by git
.linguirc // LinguiJS configuration
.stylelintrc // stylelint rules
babel.config.js // Babel configuration
jest.config.js // Jest configuration
postcss.config.js // PostCSS configuration
production-configuration-server.js // Express server to test production builds
svgo.config.json // SVG Optimizer configuration
webpack.common.js // Webpack common configuration
webpack.development.js // Webpack development configuration (extends common)
webpack.production.js // Webpack production configuration (extends common)
src
├── assets
│ └── favicon.png // source image for favicon generation (transparent square PNG works best)
├── index.html // HTML template for React application to be rendered in
├── index.js // React application entry point
test
├── __mocks__
│ ├── fileMock.js // mock for file imports when running tests
│ └── styleMock.js // mock for stylesheet imports when running tests
└── test-helper.js // test helper with custom render function
Assumptions
You must create and maintain your own package.json
file. These are the recommended scripts for development, building, testing, and i18n management.
{
"scripts": {
"start": "webpack-dev-server --config webpack.development.js",
"lint": "eslint src test",
"stylelint": "stylelint src/styles",
"test": "yarn i18n-compile && TZ=UTC NODE_ENV=test jest test",
"test:es-check": "yarn i18n-compile && dotenv -e .env.test yarn build && es-check es5 build/*.js",
"build": "NODE_ENV=production webpack -p --config webpack.production.js",
"test-build": "yarn i18n-compile && yarn build && node production-configuration-server.js",
"i18n-add-locale": "lingui add-locale",
"i18n-extract": "lingui extract",
"i18n-compile": "lingui compile"
},
}
What it provides
- Webpack configurations for development and production environments, with support for
- React
- CSS and SCSS with vendor specific properties autoprefixing
- Markdown
- SVG with dynamic
stroke
andfill
values per import (with support for custom-svg-stroke
and-svg-fill
CSS properties) woff
andwoff2
fonts.po
language catalog files (using@lingui/loader
)- Automatic favicon generation, based on whatever image is present in
src/assets/favicon.png
- Content Security Policy configuration for production mode
- ES5 syntax checking before building
- Circle CI configuration based on linux alpine
- Babel 7, with support for
@babel/plugin-proposal-optional-chaining
@babel/proposal-class-properties
@babel/plugin-proposal-export-default-from
@babel/plugin-syntax-dynamic-import
babel-plugin-macros
babel-plugin-transform-imports
- Jest
- LinguiJS
Components
Usage of these components assumes that peerDependencies
are installed:
react
react-dom
prop-types
classnames
Provided components
common
Confirmation
(usesModal
internally)DropdownMenu
Modal
ExternalLink
fields (for redux-form
)
- []
Checkbox
- []
Input
- []
RadioGroup
- []
Textarea
CSS
Each of the available stylesheets is built with theming and customization in mind. We use CSS custom properties to achieve this. The available properties for each of the stylesheets are defined under :root
.
For maximum compatibility with mobile devices, a --mobile-viewport-height
is used on "fullscreen" mobile components, like Modal
. This properties defaults to 100vh
if not defined.
base.scss
import "@frctls/seabed/dist/base.scss"
This file must be included before all others, but after reset / normalize.
card.scss
import "@frctls/seabed/dist/card.scss";
modal.scss
import "@frctls/seabed/dist/modal.scss";
dropdown-menu.scss
import "@frctls/seabed/dist/dropdown-menu.scss";