1.0.2 • Published 3 years ago

@milo-css/utilities v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Milo CSS Utilities

An array of CSS Utility classes to be used in your Milo CSS-based framework.

Installation

npm i @milo-css/utilities

Utilities

Clearfix

@import "node_modules/@milo-css/utilities/clearfix";

ClassDescriptionNote
clearfixClear a floating elementRequires @milo-css/mixins/clearfix

Color

@import "node_modules/@milo-css/utilities/color";

Utility classes for background-color and color are created from the colours defined within a colors() map variable. Additional utility classes will be added by adding more key-value pairs to this map.

The variables below are provided by default but can be merged with or overridden in your framework:

$colors: () !default;
$colors: map-merge(
    (
        // Required base colours
        "white":                rgb(255, 255, 255),
        "black":                rgb(17, 17, 17),
        "primary":              rgb(10, 211, 255),
        "secondary":            rgb(235, 236, 238)
    ),
    $colors
);

The variables above will compile to generate the following classes:

ClassDescription
b-whiteSets the background color to white
b-blackSets the background color to black
b-primarySets the background color to primary
b-secondarySets the background color to secondary
c-whiteSets the text color to white
c-blackSets the text color to black
c-primarySets the text color to primary
c-secondarySets the text color to secondary

Display

@import "node_modules/@milo-css/utilities/display";

ClassDescription
d-blockDisplay as a block element
d-hiddenDisplay as a hidden element
d-flexDisplay as a fles element
d-gridDisplay as a grid element
d-inlineDisplay as a inline element
d-inline-blockDisplay as a inline block element
d-inline-flexDisplay as a inline flex element
d-tableDisplay as a table element
d-table-cellDisplay as a table cell element

Flex

@import "node_modules/@milo-css/utilities/flex";

Use all the below with d-flex on the container of the items to be flexed.

A good resource on flex can be found at css-tricks.com.

ClassDescription
Directions
flex-rowSets the direction to row
flex-columnSets the direction to column
flex-row-reverseSets the direction to row reverse
flex-column-reverseSets the direction to row column
Wrap
flex-nowrapSingle-line which may cause the container to overflow
flex-wrapMulti-lines, direction is defined by flex-direction
flex-wrap-reverseMulti-lines, opposite to direction defined by flex-direction
Justify Content - defines the alignment along the main axis
justify-content-startJustify child items on main axis to flex-start
justify-content-endJustify child items on main axis to flex-end
justify-content-centerJustify child items on main axis to center
justify-content-betweenJustify child items on main axis to space-between
justify-content-aroundJustify child items on main axis to space-around
justify-content-evenlyJustify child items on main axis to space-evenly
Align Items - defines the alignment along the cross axis on the current line
align-items-startAlign child items on cross axis to flex-start
align-items-endAlign child items on cross axis to flex-end
align-items-centerAlign child items on cross axis to center
align-items-baselineAlign child items on cross axis to baseline
align-items-stretchAlign child items on cross axis to stretch
Align Content - aligns lines within a flex container when there is extra space in the cross-axis
align-content-startAlign content on cross axis to flex-start
align-content-endAlign content on cross axis to flex-end
align-content-centerAlign content on cross axis to center
align-content-betweenAlign content on cross axis to space-between
align-content-aroundAlign content on cross axis to space-around
align-content-stretchAlign content on cross axis to stretch
Align Self - override default alignment (or the one specified by align-items) for individual flex items
align-self-startAlign item on cross axis to flex-start
align-self-endAlign item on cross axis to flex-end
align-self-centerAlign item on cross axis to center
align-self-baselineAlign item on cross axis to baseline
align-self-stretchAlign item on cross axis to stretch

Float

@import "node_modules/@milo-css/utilities/float";

ClassDescription
pull-leftFloat an element to the left
pull-rightFloat an element to the right

Grid

@import "node_modules/@milo-css/utilities/grid";

Use all the below with d-grid position all grid items wihin the parent container.

A good resource on flex can be found at css-tricks.com.

ClassDescription
Justify Items - defines the alignment of grid items along the inline (row) axis
grid-justify-items-startJustify grid items flush with the start edge of their cell
grid-justify-items-endJustify grid items flush with the end edge of their cell
grid-justify-items-centerJustify grid items with the center of their cell
grid-justify-items-stretchSet grid items to fill the whole width of their cell
Align Items - defines the alignment of grid items along the block (column) axis
grid-align-items-startAlign grid items flush with the start edge of their cell
grid-align-items-endAlign grid items flush with the end edge of their cell
grid-align-items-centerAlign grid items with the center of their cell
grid-align-items-stretchSet grid items to fill the whole height of their cell
Justify Content - defines the alignment of the grid along the inline (row) axis
grid-justify-content-startAligns the grid to be flush with the start edge of the grid container
grid-justify-content-endAligns the grid to be flush with the end edge of the grid container
grid-justify-content-centerAligns the grid in the center of the grid container
grid-justify-content-stretchResizes the grid items to allow the grid to fill the full width of the grid container
grid-justify-content-betweenPlaces an even amount of space between each grid item, with no space at the far ends
grid-justify-content-aroundPlaces an even amount of space between each grid item, with half-sized spaces on the far ends
grid-justify-content-evenlyPlaces an even amount of space between each grid item, including the far ends
Align Content - defines the alignment of the grid along the block (column) axis
grid-align-content-startAligns the grid to be flush with the start edge of the grid container
grid-align-content-endAligns the grid to be flush with the end edge of the grid container
grid-align-content-centerAligns the grid in the center of the grid container
grid-align-content-stretchResizes the grid items to allow the grid to fill the full height of the grid container
grid-align-content-betweenPlaces an even amount of space between each grid item, with no space at the far ends
grid-align-content-aroundPlaces an even amount of space between each grid item, with half-sized spaces on the far ends
grid-align-content-evenlyPlaces an even amount of space between each grid item, including the far ends

Image

@import "node_modules/@milo-css/utilities/image";

ClassDescriptionNote
img-fluidMake an image responsive and use the full width but no moreRequires @milo-css/mixins/img-fluid

List

@import "node_modules/@milo-css/utilities/list";

Utility classes to be applied to a <ul> or <ol> element. The variable below are provided by default but can be overridden in your framework:

$list-inline-elem-margin-x:     1rem !default;
ClassDescription
list-style-noneRemove bullets from a <ul> or <ol> element
list-style-resetRemove list style, padding and margin from a <ul> or <ol> element
list-inlineResets list style of a <ul> or <ol> element and displays its children inline

Overflow

@import "node_modules/@milo-css/utilities/overflow";

ClassDescription
noscrollSets overflow to hidden
scroll-xAllow scrolling horizontally when required

Position

@import "node_modules/@milo-css/utilities/position";

ClassDescription
relativeSets position to relative
absoluteSets position to absolute
fixedSets position to fixed
stickySets position to sticky

Sizing

@import "node_modules/@milo-css/utilities/sizing";

ClassDescription
full-heightSets the height to 100%
full-viewport-heightSets the height to 100% of the viewport height
full-widthSets the width to 100%
full-max-widthSets the max width to 100%

Spacing

@import "node_modules/@milo-css/utilities/spacing";

Produces semantic classes for all margin & padding properties based on a base value applied to keys defined within a spacers() map variable.

The variables below are provided by default but can be overridden in your framework:

$base-spacer:               1rem !default;
$base-spacer-y:             $base-spacer !default;
$base-spacer-x:             $base-spacer !default;

$spacers: (
    // Size     // Lengths
    "0":        (x: 0, y: 0),
    "h":        (x: ($base-spacer-x * .5), y: ($base-spacer-y * .5)),
    "1":        (x: $base-spacer-x, y: $base-spacer-y),
    "1h":       (x: ($base-spacer-x * 1.5), y: ($base-spacer-y * 1.5)),
    "2":        (x: ($base-spacer-x * 2), y: ($base-spacer-y * 2)),
    "2h":       (x: ($base-spacer-x * 2.5), y: ($base-spacer-y * 2.5)),
    "3":        (x: ($base-spacer-x * 3), y: ($base-spacer-y * 3)),
    "4":        (x: ($base-spacer-x * 4), y: ($base-spacer-y * 4)),
    "5":        (x: ($base-spacer-x * 5), y: ($base-spacer-y * 5)),
    "6":        (x: ($base-spacer-x * 6), y: ($base-spacer-y * 6)),
    "7":        (x: ($base-spacer-x * 7), y: ($base-spacer-y * 7)),
    "8":        (x: ($base-spacer-x * 8), y: ($base-spacer-y * 8)),
    "9":        (x: ($base-spacer-x * 9), y: ($base-spacer-y * 9)),
    "10":       (x: ($base-spacer-x * 10), y: ($base-spacer-y * 10)),
) !default;

The variables above will compile to generate the following classes for each variable outlined in the spacers() map where XX is the key, eg. mt-1h:

ClassDescription
Margin
m-XXSets margin on all sides
mt-XXSets margin-top
mr-XXSets margin-right
mb-XXSets margin-bottom
ml-XXSets margin-left
mx-XXSets a margin on the x (horizontal) axis
my-XXSets a margin on the y (vertical) axis
Padding
p-XXSets padding on all sides
pt-XXSets padding-top
pr-XXSets padding-right
pb-XXSets padding-bottom
pl-XXSets padding-left
px-XXSets a padding on the x (horizontal) axis
py-XXSets a padding on the y (vertical) axis

The following classes are also included:

ClassDescriptionNote
Margin
margin-zeroSets margin on all side to zero
m-autoSets margin on all side to auto
mt-autoSets margin-top to auto
mr-autoSets margin-right to auto
mb-autoSets margin-bottom to auto
ml-autoSets margin-left to auto
Padding
padding-zeroSets padding on all side to zero
Push
push-autoSets margin on the x (horizontal) axis to autoRequires @milo-css/mixins/push-auto

Text

@import "node_modules/@milo-css/utilities/text";

Utility classes to be applied to text-based elements. The variables below are provided by default but can be overridden in your framework:

$strong-font-weight:        700 !default;
$lead-font-weight:          600 !default;
$small-font-size:           80% !default;
$muted-opacity:             .6 !default;
ClassDescription
Text Align
-leftSets text alignment to left
-rightSets text alignment to right
-centerSets text alignment to center
-justifySets text alignment to justify
Other
strongSets font weight to strong
leadSets font weight to value of $lead-font-weight
mutedSets the opacity to muted
nowrapStops the text from wrapping
smallSets font size to small
uppercaseMakes the text uppercase

Visibility

@import "node_modules/@milo-css/utilities/visibility";

Utility classes for background-color and color are created from the colours defined within a colors() map variable. Additional utility classes will be added by adding more key-value pairs to this map.

Produces semantic classes for hiding element based on values defined within a viewport-breakpoints() map variable.

The variables below are provided by default but can be overridden in your framework:

$viewport-breakpoints: (
    xs: 0,
    sm: 576px,
    md: 768px,
    lg: 992px,
    xl: 1200px
) !default;

The variables above will compile to generate the following classes:

ClassDescriptionNote
hidden-xsHide this element on the xs breakpoint onlyRequires media-breakpoint-only() mixin thats part of @milo-css/grid module
hidden-smHide this element on the sm breakpoint onlyRequires media-breakpoint-only() mixin thats part of @milo-css/grid module
hidden-mdHide this element on the md breakpoint onlyRequires media-breakpoint-only() mixin thats part of @milo-css/grid module
hidden-lgHide this element on the lg breakpoint onlyRequires media-breakpoint-only() mixin thats part of @milo-css/grid module
hidden-xlHide this element on the xl breakpoint onlyRequires media-breakpoint-only() mixin thats part of @milo-css/grid module
hidden-xs-downHide this element on the xs breakpoint and lowerRequires media-breakpoint-down() mixin thats part of @milo-css/grid module
hidden-sm-downHide this element on the sm breakpoint and lowerRequires media-breakpoint-down() mixin thats part of @milo-css/grid module
hidden-md-downHide this element on the md breakpoint and lowerRequires media-breakpoint-down() mixin thats part of @milo-css/grid module
hidden-lg-downHide this element on the lg breakpoint and lowerRequires media-breakpoint-down() mixin thats part of @milo-css/grid module
hidden-xl-downHide this element on the xl breakpoint and lowerRequires media-breakpoint-down() mixin thats part of @milo-css/grid module
hidden-xs-upHide this element on the xs breakpoint and higherRequires media-breakpoint-up() mixin thats part of @milo-css/grid module
hidden-sm-upHide this element on the sm breakpoint and higherRequires media-breakpoint-up() mixin thats part of @milo-css/grid module
hidden-md-upHide this element on the md breakpoint and higherRequires media-breakpoint-up() mixin thats part of @milo-css/grid module
hidden-lg-upHide this element on the lg breakpoint and higherRequires media-breakpoint-up() mixin thats part of @milo-css/grid module
hidden-xl-upHide this element on the xl breakpoint and higherRequires media-breakpoint-up() mixin thats part of @milo-css/grid module