Light weight CSS framework based on ITCSS, BEM and Scss.
npm install cactus-frameworkCactus is a very minimal but flexible CSS grid framework powered by Scss. Rather than defining a list of potential column widths, Cactus lets you define your own and automatically generates the classes for you.
npm install cactus-framework --saveThen integrate in to your build pipeline.
npm run testFor linting run:npm run lint
npm run build* Settings - Settings contains all of the configuration settings for Cactus. These should never be overwritten directly.
* Tools - Tools contains functions and mixins required for Cactus.
* Generic - Generic is used for any generic global styling, this should be avoided where possible.
* Elements - Elements contains styling for HTML elements such as .
* Objects - Objects contains class-based styling for non-cosmetic design patterns such as containers and layout.
* Debug - Debug is an optional set of styling which enables some debug styling to highlight incorrect grid usage.
`` scss`
.prefix-block {}
.prefix-block__element {}
.prefix-block--modifier {}
.prefix-block__element--modifier {}
For more information have a look at MindBEMding - Getting your head round BEM syntax by Harry Roberts, it's a great read!
which expects a map:` scss
$cactus-wrapper-config: (
sizes: (
default: 48em,
large: 56em,
small: 40em
)
);
`This will create the following classes:
` scss
.o-cactus__w
.o-cactus__w--large
.o-cactus__w--small
`$3
The Group element wraps Units and adds essential margins and offsets to create the layouts. All immediately nested elements should be cactus unit classes.` scss
.o-cactus__g // Default gutter width.
.o-cactus__g--gutter-small // Optional modifier for gutter width.
.o-cactus__g--gutter-none // Removes gutter.
.o-cactus__g--reverse // Reverse child unit elements.
`$3
The Unit defines the ratios of your columns as well as breakpoints where it will become effective.` scss
.o-cactus__u--1-2 // 1/2 width unit with no specified breakpoint
.o-cactus__u--l-13-19 // 13/19 width unit at the large breakpoint (for some insane layouts)
.o-cactus__u--m-1-8 // 1/8 width at the medium breakpoint
`$3
` html
This content will be 3/4 width on large screens and 1/2 on medium screens.
This content will be 3/4 width on large screens and 1/2 on medium screens.
`Cactus Grid Generator
There have been some major changes to how the settings for Cactus work. It will take me a while to re-write the documentation to account for this and add better tools for extending however for now here's a quick summary$3
The Cactus wrapper is an optional element which sets a maximum width constraint, by default this is centrally aligned in the page. You can define
$3
Here we can define each of the breakpoints we want to generate unit classes for and specify what those units should be:` scss
$cactus-unit-config: (
default: (
name: false,
breakpoint: false,
units: (1 1, 1 2, 1 4, 3 4)
),
medium: (
name: m,
breakpoint: 75em,
units: (1 1, 1 2, 1 3, 2 3)
)
);
`Here we have two breakpoints,
default and medium. Each comprises of:-
name - The name which will be used for the class, for example giving a name of 'm' will result in a generated class of .o-cactus__u--m-X. Setting to false means this is the global breakpoint with no media query attached.
- breakpoint - This is the width at which the breakpoint should apply and should be set in em's. A breakpoint of 50em would mean these classes only effect when the screen width is below 800px etc.
- units - Units expects an array of space separated fractions, so 1 2 is the same as 1/2 or 50%. This lets us tailor the exact unit widths we want to include.
$3
The classes and breakpoints we have defined will be exported in the following format:` scss
.o-cactus__u--1-4 // Quarter width
.o-cactus__u--3-4 // Three quarter width.o-cactus__u--m-1-3 // Quarter width at medium breakpoint
.o-cactus__u--m-2-3 // Three quarter width at medium breakpoint
.o-cactus__u--s-1 // Full width at small breakpoint
`Customising
To customise the default grid settings include your own overrides file and include before Cactus. You can include your own $cactus-unit-config or $cactus-gutter-config etc as your project requires. To see what options are available check settings/_grid.scss`.See the LICENSE file for license text and copywrite information.