crispi-css-utilities v1.0.1
| Project | Version | Demo | Author | Repository | License |
|---|---|---|---|---|---|
| crispi-css-utilities | 1.0.0 | css-utilities.crispi.app | Christophe Gasquez | Git Hub | ISC |
Crispi CSS Utilities
Crispi Css Utilities is a style micro framework that can be used in both SCSS and CSS.
It provides classes respecting a naming formalism that can be easily deduced.
You can customize the entire library to adapt it to your needs and your designs.
Installation
Node package (recommended)
Add the Node package to your project:
$ npm i crispi-css-utilities --saveYou can now use the library in your project in CSS mode or SCSS mode and customize it to your liking.
HTTP Deliver (not recommended)
Add the style sheet links that suit you (light, medium or complete) on your <head> tag.
<!-- {{ version }} must be replace by the version name( light, medium or complete). -->
<link href="https://css-utilities.crispi.app/css/{{ version }}.styles.css" rel="stylesheet">Choice of versions
Crispi Css Utilities provides you with three versions of its style sheets: light, medium and complete:
- The
lightversion contains a limited number of properties. These are the most common properties. It is a version quite suitable for small projects wanting to be fast and light. - The
mediumversion contains a large part of the properties available in CSS and makes it possible to meet the majority of needs. This is the recommended version for the majority of projects. - The
completeversion provides the exhaustive list of CSS properties available. Some of them are uncommon. It is also the heaviest version. This version is only recommended for projects requiring uncommon CSS rules, or for testing or learning purposes.
Overall operation
Crispi CSS Utilities is a micro framework providing developers with a set of classes
responding to a simple formalism:
The name of the property in kebab case (example: text-align),
followed by the expected value in kebab case (example: center), separated by a double dash --.
Example: To center the text of a paragraph, you can therefore write:
<p class="text-align--center">My centered paragraph</p>
If the list of properties corresponds strictly to that defined by the CSS standards, the list of values is enriched.
Indeed, in addition to the fixed values linked to the property, 'non-fixed' values can be specified.
Example: The
word-spacingproperty can take as a fixed value, one of the following values:auto,initail,inherit. However, it can be associated with a non-fixed value, such as a length in pixelspxor ephemeral unitem.<p class="word-spacing--length-10px">My centered paragraph</p>
All non-fixed values are added as custom properties and can therefore be modified at any time
using the pseudo-selector :root.
They respect the standard nomenclature: double dash followed by the name of the value (example: --primary).
We have broken down non-fixed values into five categories:
- Colors broken down into three sub-lists: main, status, shade;
- Fonts;
- Integers broken down into two sub-lists: decimals, integers;
- Sizes broken down into seven sub-lists: ephemeral units, pixels, borders, containers, font-sizes, gaps, percents;
- Times.
Colors variables
Three color lists can be used: main colors, status colors and shade colors.
Main colors
The main colors are:
lightwith default value#efefef,darkwith default value#242424,primarywith default value#157e82,secondarywith default value#154a82,tertiarywith default value#15824f,
Status colors
The status colors are:
infowith default value#2875c6,successwith default value#3bbf4f,warningwith default value#faa701,dangerwith default value#861010,defaultwith default value#666666,
Shade colors
The shade colors are:
shade-100with default valuelighten($dark, 90%),shade-200with default valuelighten($dark, 80%),shade-300with default valuelighten($dark, 70%),shade-400with default valuelighten($dark, 60%),shade-500with default valuelighten($dark, 50%),shade-600with default valuelighten($dark, 40%),shade-700with default valuelighten($dark, 30%),shade-800with default valuelighten($dark, 20%),shade-900with default valuelighten($dark, 10%),
Font variables
The list of fonts is:
f-primarywith default valuehevetica,f-secondarywith default valueverdana,f-tertiarywith default valuearial,
Integer variables
Two integer lists can be used: decimals and integers.
Decimals
The list of decimals is:
dec-1with default value.1,dec-2with default value.2,dec-3with default value.3,dec-4with default value.4,dec-5with default value.5,dec-6with default value.6,dec-7with default value.7,dec-8with default value.8,dec-9with default value.9,
Integers
The list of integers is:
int-1with default value1,int-2with default value2,int-3with default value3,int-4with default value4,int-5with default value5,int-6with default value6,int-7with default value7,int-8with default value8,int-9with default value9,int-10with default value10,
Size variables
Six size lists can be used: ephemeral units (em), pixels (px), borders, containers, font-sizes, gaps and percents.
Ephemeral units
The list of ephemeral units is:
length-05emwith default value.5em,length-075emwith default value.75em,length-1emwith default value1em,length-2emwith default value2em,length-3emwith default value3em,
Pixels
The list of pixels is:
length-0with default value0,length-1pxwith default value1px,length-2pxwith default value2px,length-3pxwith default value3px,length-5pxwith default value5px,length-10pxwith default value10px,length-20pxwith default value20px,length-30pxwith default value30px,length-50pxwith default value50px,length-75pxwith default value75px,length-100pxwith default value100px,length-150pxwith default value150px,length-200pxwith default value200px,length-300pxwith default value300px,length-400pxwith default value400px,length-500pxwith default value500px,
Borders
border-size-xswith default value.1rem,border-size-smwith default value.2rem,border-size-mdwith default value.4rem,border-size-lgwith default value.7rem,border-size-xlwith default value1rem,border-sizewith default value$border-size-md,
Containers
The list of containers is:
container-xswith default value375px,container-smwith default value650px,container-mdwith default value820px,container-lgwith default value1180px,container-xlwith default value1400px,containerwith default value$container-md,container-fullwith default value100%,
Font sizes
The list of sizes is:
font-size-xswith default value.5rem,font-size-smwith default value.75rem,font-size-mdwith default value1rem,font-size-lgwith default value2rem,font-size-xlwith default value3rem,font-sizewith default value$font-size-md,
Gaps
The list of gaps is:
gap-xswith default value.5rem,gap-smwith default value1rem,gap-mdwith default value1.5rem,gap-lgwith default value2rem,gap-xlwith default value3rem,gapwith default value$gap-md,
Percents
The list of percents is:
percent-0with default value0%,percent-10with default value10%,percent-20with default value20%,percent-30with default value30%,percent-40with default value40%,percent-50with default value50%,percent-60with default value60%,percent-70with default value70%,percent-80with default value80%,percent-90with default value90%,percent-100with default value100%,
Time variables
The list of times is:
duration-01with default value.1s,duration-05with default value.5s,duration-1with default value1s,duration-2with default value2s,
Use in CSS mode
We recommend using SCSS mode. But if you don't want to compile your style sheets, and only use CSS technology, you can still use and customize Crispi CSS Utilities.
CSS importation
You can either use the CSS stylesheets stored on our servers (not recommended), or add our CSS stylesheets to your project via npm, or by downloading them from our github repository.
Example: Import directly from Crispi servers
<!-- {{ version }} must be replace by the version name( light, medium or complete). --> <link href="https://css-utilities.crispi.app/css/{{ version }}.styles.css" rel="stylesheet"> <link href="{{your-project-name}}/css/your-project-styles.css" rel="stylesheet">Import from your project:
<link href="{{your-project-name}}/css/crispi-css-utilities.css" rel="stylesheet"> <link href="{{your-project-name}}/css/your-project-styles.css" rel="stylesheet">
CSS customizations
By importing your stylesheet after Crispi CSS Utilities, you will be able to modify all customs properties
using the :root pseudo selector.
If you import our style sheet after ours, only custom property modifications with a stronger selector
will be taken into account (example: body:root { /*Your custom propertie modifications*/ }).
Example: To modify the colors associated with the main color, you can:
:root { --ligth: #25002b; --dark: #f6dcfa; --primary: #a800c4; --secondary: #9bc400; --tertiary: #0081c4; }
With this simple declaration, all the classes of Crispi CSS Utilities will be in the colors of your project!
In addition to colors, you can modify the non-fixed fonts,
integers, sizes and times values
to tune your design as precisely as possible.
Use in SCSS mode
We recommend that you integrate Crispi CSS Utilities into your project in SCSS mode. Thus, you can modify the variables before creating the custom properties, but also use the functions and mixins of the library to enrich and factorize your own code. The most experienced users can also create their own versions of Crispi CSS Utilities by generating only the classes that interest them, associated with the desired names and values (show: SCSS customization).
SCSS importations
You can import Crispi CSS Utilities directly into your SCSS stylesheet. Thus, you can both modify the variables used by the libraries, but also use the functions and mixins that it makes available to you.
Import the library (with @import), choosing the desired version: light, medium or complete.
Functions, mixins and customization are available in all versions.
Example: To add the complete version to your stylesheet
@import 'node_modules/css-utilities/scss/complete.styles.scss';
The library is built into your project and compiled by your scss interpreter. So you can both use it in your style sheet, but also in the html page that imports your compiled CSS file.
SCSS customizations
You can customize your styles in the same way as with the CSS mode, using the custom property. See the part: CSS customization.
You can also customize your styles thanks to the scss variables.
Crispi CSS Utilities SCSS variables are all set to !default,
so you can override them with your own values.
For them to be taken into account during compilation,
define them before importing the Crispi CSS Utilities styles.
Example: To change the primary color, do...
$primary: yellow; @import 'node_modules/ncss-utilities/scss/medium.styles.scss';
Because all non-fixed values inherit from an SCSS variable marked as !default,
you can easily deduce all of these variables and their custom properties.
Example: For non-fixed value
container-xs// You can deduct that associated scss variable: $container-xs: 375px !default; // You can deduct that associated custom property :root { --container-xs: $container-xs; } // The list of variables associated with container values will also contain // a container-xs property associated with the custom property --container-xs $container-list: ( 'container-xs': var(--container-xs) )
So, by overriding the original $container-xs variable,
you are also overriding the associated custom property as well as its reference in the parent list.
Finally, you can use the functions and mixins of Crispi CSS utilities to add your own CSS classes to your final stylesheet.
Example: To create your abbreviated background color classes:
@import 'node_modules/css-utilities/scss/tools'; @include classesGenerator(('bkc': background-color), fromListToMap(red, blue));After compiling:
.bkc--red { background-color: red; } .bkc--blue { background-color: blue; }
Library structure
/crispi-css-utilities
|-- /src
| |-- /css
| | |-- complete.styles.css
| | |-- light.styles.css
| | |-- medium.styles.css
| | |-- styles.css
| |
| |-- /scss
| | |-- /constants
| | | |-- _index.scss
| | | |-- _property-key-pairs.scss
| | | |-- _property-value-pairs.scss
| | |
| | |-- /factories
| | | |-- _css.complete.scss
| | | |-- _css.light.scss
| | | |-- _css.medium.scss
| | |
| | |-- /tools
| | | |-- _functions.scss
| | | |-- _index.scss
| | | |-- _mixins.scss
| | |
| | |-- /variables
| | | |-- _colors.scss
| | | |-- _fonts.scss
| | | |-- _index.scss
| | | |-- _integers.scss
| | | |-- _sizes.scss
| | | |-- _times.scss
| | |
| | |-- complete.styles.scss
| | |-- light.styles.scss
| | |-- medium.styles.scss
| | |-- styles.scss
| |
| |-- index.html
|
|-- package.json
|-- package-lock.json
|-- README.md