All Projects → Siilwyn → Css Declaration Sorter

Siilwyn / Css Declaration Sorter

Licence: isc
Sort CSS declarations fast and automatically in a certain order.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Css Declaration Sorter

Front End
Operation Code's website
Stars: ✭ 301 (+60.11%)
Mutual labels:  hacktoberfest, postcss
Labean
HTTP/HTTPS port knocker for GNU/Linux written in Go
Stars: ✭ 188 (+0%)
Mutual labels:  hacktoberfest
Kogito Runtimes
Kogito Runtimes - Kogito is a cloud-native business automation technology for building cloud-ready business applications.
Stars: ✭ 188 (+0%)
Mutual labels:  hacktoberfest
Pyresample
Geospatial image resampling in Python
Stars: ✭ 188 (+0%)
Mutual labels:  hacktoberfest
V Chart Plugin
Easily bind a chart to the data stored in your Vue.js components.
Stars: ✭ 188 (+0%)
Mutual labels:  hacktoberfest
Cfwheels
An open source ColdFusion framework inspired by Ruby on Rails.
Stars: ✭ 188 (+0%)
Mutual labels:  hacktoberfest
Formatter Maven Plugin
Formatter Maven Plugin
Stars: ✭ 187 (-0.53%)
Mutual labels:  hacktoberfest
Community
Central repository for issues and recipes
Stars: ✭ 189 (+0.53%)
Mutual labels:  hacktoberfest
Programmers Community
This repository contains various solution of a problem in Ruby, C, C++, Python and Java.
Stars: ✭ 189 (+0.53%)
Mutual labels:  hacktoberfest
Petergate
Easy to use and read action and content based authorizations.
Stars: ✭ 188 (+0%)
Mutual labels:  hacktoberfest
Readability
Readability is Elixir library for extracting and curating articles.
Stars: ✭ 188 (+0%)
Mutual labels:  hacktoberfest
Nimlsp
Language Server Protocol implementation for Nim
Stars: ✭ 186 (-1.06%)
Mutual labels:  hacktoberfest
Androrat
A Simple android remote administration tool using sockets. It uses java on the client side and python on the server side
Stars: ✭ 187 (-0.53%)
Mutual labels:  hacktoberfest
Dailycodebase
2 month data structures and algorithmic scripting challenge starting from 20th December 2018 - Coding is Fun! 💯💯 Do it everyday!! Also, Do give us a ⭐ if you liked the repository
Stars: ✭ 186 (-1.06%)
Mutual labels:  hacktoberfest
Comit Rs
Reference implementation of COMIT, an open protocol facilitating trustless cross-blockchain applications.
Stars: ✭ 190 (+1.06%)
Mutual labels:  hacktoberfest
Orca
Orchestration engine
Stars: ✭ 187 (-0.53%)
Mutual labels:  hacktoberfest
Red Discordbot
A multi-function Discord bot
Stars: ✭ 2,855 (+1418.62%)
Mutual labels:  hacktoberfest
Consul
Development repository for the consul cookbook
Stars: ✭ 188 (+0%)
Mutual labels:  hacktoberfest
Laravel Datatables Html
Laravel DataTables HTML Builder Plugin
Stars: ✭ 188 (+0%)
Mutual labels:  hacktoberfest
Matterpoll
Create polls and surveys directly within Mattermost
Stars: ✭ 189 (+0.53%)
Mutual labels:  hacktoberfest
CSS declaration sorter logo

CSS Declaration Sorter

LGTM Grade npm

A Node.js module and PostCSS plugin to sort CSS, SCSS or Less declarations based on their property names. Ensuring styling is organized, more consistent and in order... The goal of this package is to sort the source code of a project in the build process or to decrease the distributed CSS gzipped size. Check out the Atom package for individual usage.

Niceness

  • Up-to-date CSS properties fetched from the MDN Compatibility Data project.
  • Choose your wanted order or provide your own.
  • Nested rules sorting support.
  • SCSS and Less support when combined with either postcss-scss or postcss-less.
  • Thought-out sorting orders out of the box, approved by their authors.

Alphabetical example

Input:

body {
    display: block;
    animation: none;
    color: #C55;
    border: 0;
}

Output:

body {
    animation: none;
    border: 0;
    color: #C55;
    display: block;
}

Built-in sorting orders

  • Alphabetical
    alphabetical
    Default, order in a simple alphabetical manner from a - z.

  • SMACSS
    smacss
    Order from most important, flow affecting properties, to least important properties.

    1. Box
    2. Border
    3. Background
    4. Text
    5. Other
  • Concentric CSS
    concentric-css
    Order properties applying outside the box model, moving inward to intrinsic changes.

    1. Positioning
    2. Visibility
    3. Box model
    4. Dimensions
    5. Text

Usage

Following the PostCSS plugin guidelines, this package depends on PostCSS as a peer dependency: npm install postcss css-declaration-sorter --save-dev

Note: To use with Node.js 10 install [email protected] and check out the matching version readme.

CLI

This module does not include its own CLI but works with the official PostCSS CLI. To use the examples below, the postcss-cli package is a required dependency.

Piping out result from file:
postcss input.css --use css-declaration-sorter | cat

Sorting multiple files by overwriting:
postcss *.css --use css-declaration-sorter --replace --no-map

Sorting all files in a directory with SCSS syntax using postcss-scss by overwriting:
postcss ./src/**/*.scss --syntax postcss-scss --use css-declaration-sorter --replace --no-map

Sorting all files in the directory with SCSS syntax and SMACSS order by overwriting, using package.json configuration:

"postcss": {
  "syntax": "postcss-scss",
  "map": false,
  "plugins": {
    "css-declaration-sorter": { "order": "smacss" }
  }
}

postcss ./src/**/*.scss --replace --config package.json

Vanilla JS

import postcss from 'postcss';
import cssDeclarationSorter from 'css-declaration-sorter';

postcss([cssDeclarationSorter({ order: 'smacss' })])
  .process('a { color: hyperblue; display: block; }', { from: undefined })
  .then(result => console.log(
    result.css === 'a { display: block; color: hyperblue; }'
  ));

View more usage examples in combination with other tools.


API

cssDeclarationSorter({ order, keepOverrides })

order

Type: string or function
Default: alphabetical
Options: alphabetical, smacss, concentric-css

Provide the name of one of the built-in sort orders or a comparison function that is passed to (Array.sort). This function receives two declaration names and is expected to return -1, 0 or 1 depending on the wanted order.

keepOverrides

Type: Boolean
Default: false

To prevent breaking legacy CSS where shorthand declarations override longhand declarations (also taking into account vendor prefixes) this option can enabled. For example animation-name: some; animation: greeting; will be kept in this order when keepOverrides is true.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].