$ cnpm install @mapbox/assembly
A CSS framework that makes the hard parts of building anything on the web easy. We define the hard parts as: managing class specificity, designing cross-browser form components that work well with each other, creating a harmonious typographic scale, maintaining a baseline grid, and keeping responsive designs simple.
For usage guidelines and documentation, check out https://labs.mapbox.com/assembly/.
Assembly targets modern versions of Chrome, Firefox, Safari, and Edge on desktop; Safari on iOS; and Chrome on Android.
See https://labs.mapbox.com/assembly/ for usage guidelines.
See our Migration guides to understand what changes you might need to make when upgrading Assembly in your project.
Assembly exposes a JS module for creating custom builds. Why might you want to create a custom build?
Returns a Promise that resolves when all assets have been written to outdir.
const Assembly = require('assembly');
Assembly.buildUserAssets('path/to/my/outdir', myOptions)
.then(() => /* something */)
.catch((err) => /* handle error */);
Options, all of which are optional:
files: An array of file paths to stylesheets you would like to append to assembly.css. These will be processed through Assembly's PostCSS pipeline.
variables: An object whose properties will override and add to src/variables.json. Use this option to change or add variables.
These variables are accessible in any stylesheets you append via the CSS custom properties syntax, e.g. var(--property-name).
mediaQueries: An object whose properties will override and add to src/mediaQueries.json. Use this option to change or add media queries.
These media queries are accessible in any stylesheets you append via the CSS custom media query syntax, e.g. @media --media-query-name.
colorVariants: An object or array specifying the color variants you would like added to assembly.css. This is documented in detail below.
icons: An array of icons names to include in Assembly. Names correspond to file names in src/svgs/. Use this option to decrease the size of assembly.js by only including the icons you need.
browsersList: A Browserslist array to be used by Autoprefixer. Default:
[
'last 4 Chrome versions',
'last 4 Firefox versions',
'last 4 Safari versions',
'last 2 Edge versions',
'last 2 iOS versions',
'last 2 Android versions',
'not IE 11',
'not dead'
]
quiet: Suppress logs.
colorVariants optionIf the colorVariants value is an array, it must be an array of color names corresponding to variables. All components will have color variants generated for all colors in the array.
The following configuration specifies an array of default colors. All components will have these (and only these) color variants.
["red", "green-light"]
If the colorVariants value is an object, each property value must be an array of color names corresponding to variables. The property names designate which component each color array applies to:
default: These colors apply to all components that are not otherwise specified.buttonFill: *-dark colors will not be used.buttonStroke: *-dark colors will not be used.inputTextarea: *-dark colors will not be used.selectFill: *-dark colors will not be used.selectStroke: *-dark colors will not be used.checkbox: *-dark colors will not be used.radio: *-dark colors will not be used.switch: *-dark colors will not be used.toggle: *-dark colors will not be used.range: *-dark colors will not be used.colorbackgroundlink: *-dark colors will not be used.borderhoverShadow: Only lighten* and darken* colors will be used.hoverBackgroundhoverColorhoverBorderThe following configuration specifies colors for individual components. In this configuration, every component not specified will have the default color variants; specified components will have their specified color variants; and switch and range components will have no color variants (only the default will be available).
{
"default": ["lighten50", "lighten25", "gray"],
"buttonFill": ["green", "purple"],
"selectFill": ["green"],
"background": ["orange", "yellow", "pink"],
"link": ["orange"],
"hoverShadow": ["lighten50"],
"switch": [],
"range": []
}
Assembly strives for flat, single rule declarations and avoids overrides whenever possible. Declarations are marked as !important for classes whose names directly correspond with what they do — e.g. bg-blue, px12. This way they cannot be overridden and so are guaranteed to actually do what they say they do.
.pt6 for padding-top: 6px instead an abstract scale like .pt-small or .pt-1.xl, l, m, s, sm.Media query class variants (e.g. block-mm as a variant of block) are automatically generated and added to the CSS build with scripts/build-media-variants.js. If you want to generate media variants for a new class, or change which classes get media variants, you'll need to modify the lists in that file.
npm ci # Installs your `node_modules`
npm start # Builds everything, starts a dev server, rebuilds & reloads on changes
npm run build:js # Build SVGs and other JS
For other scripts, look in package.json.
Development is done in the publisher-staging branch, but releases are made from the publisher-production branch. Here's how you cut a release:
publisher-staging:
CHANGELOG.package.json and package-lock.json.Prepare 0.8.0.publisher-production branch. Conduct the following steps from publisher-production.publisher-production:
git tag -a 0.8.0 -m "".git push --tags.Copyright 2013 - present © cnpmjs.org | Home |