Coder Social home page Coder Social logo

enzo-mourany / css-property-sorter Goto Github PK

View Code? Open in Web Editor NEW
12.0 3.0 1.0 408 KB

VSCode extension that allows to sort css properties in a logical and consistent order

Home Page: https://marketplace.visualstudio.com/items?itemName=EnzoMourany.css-property-sorter

License: MIT License

TypeScript 100.00%
css css-properties vscode vscode-extension sass scss extension linter prettier typescript

css-property-sorter's Introduction

Icon

CSS Property Sorter

release vscode downloads rating

About The Extension

This extension allows you to sort the CSS properties of each selector in a CSS or SCSS file. It makes the code more readable and facilitates maintenance.

There is an ordering standard for css properties that is not well respected. This extension allows you to automatically order all these properties.

Built With

  • TypeScript
  • VSCodeAPI

Compatibility

  • CSS
  • SCSS

Installation

  1. Open the extensions panel in VSCode
  2. Search for CSS Property Sorter
  3. Click Install

Usage

  1. Open a CSS or SCSS file
  2. Click on the CSS Sort button in the status bar

Status Bar Button

or tap Ctrl+Shift+P and type CSS Sort

Command Palette

  1. Click on run in the notification that appears

Notification Run Button

  1. The properties are now sorted !

Selector Before Sort

Selector After Sort

Configuration

The extension uses the following sorting standard :

  • flexbox properties
  • grid properties
  • positionning properties
  • visibility properties
  • cliping properties
  • box properties
  • animation properties
  • background properties
  • border properties
  • typography properties

Roadmap

Done

  • Sort the properties of the selectors in the order in which they appear in the file
  • Support for SCSS files
  • Save indentation of the properties
  • Support at-rules (media queries, keyframes, etc.)
  • Support @include and @media query
  • Display cssSortButton only if the file is a css or scss file

Planned

  • Add a configuration panel to allow the user to choose the order of the properties (JSON file)
  • Sort selectors in the order (CSS file)
  • Save comments before properties
  • Support LESS files
  • Support SASS files
  • Better shortcut for the command
  • Alert the user if he writes a property incorrectly or if he puts information (or mesure unity) that does not match inside the property
  • Remove malformed CSS comments that interfere with the rest of the code

See the open issues for a full list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Install the dependencies npm i or pnpm i
  3. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  4. Commit your Changes (git commit -m 'Add some AmazingFeature')
  5. Push to the Branch (git push origin feature/AmazingFeature)
  6. Open a Pull Request

License

MIT License

Contact

Enzo Mourany

Project Link

Show your support

Give a โญ๏ธ if this project helped you!

css-property-sorter's People

Contributors

enzo-mourany avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

lhari

css-property-sorter's Issues

[Bug] Media queries and intendation break

Indentation and nesting for rules inside media queries are messed up when sorting properties.

Before After
before after

Actually, indentation higher than 1 levels breaks anywhere, for that matter.

Don't sort @keyframes properties

Sort.ts don't have to sort @Keyframes properties, like on this example :

Before :

section
{
        min-height: 100vh;
	justify-content: center;
	align-items: center;
	display: flex;
	background: #1c1c25;
}

@keyframes identifier
{
	0%
	{
		transform: translateX(-100%);
	}
	100%
	{
		transform: translateX(0);
	}
}

After

section
{
	display: flex;
	justify-content: center;
	align-items: center;
        min-height: 100vh;
	background: #1c1c25;
}

@keyframes identifier
{
	0%
	{
		transform: translateX(-100%);
	}
	100%
	{
		transform: translateX(0);
	}
}

The keyframes part must remain as it is after sort.

[Feature Request] Support for CSS-in-JS like styled components

I'd like to see this workflow if possible

  1. Highlight/select css-in-js object properties such as those used in Emotion and Styled Components.
  2. Type ctrl+p and select format selection with CSS Property Sorter.

Screenshot example of selected properties from CSS-in-JS object:
Screenshot 2023-06-08 at 10 08 43 AM

Idea to add

Sometimes, we miss to put the semicolon, it can be great if the extension patch the error when we sort the css, cause there's no error if there's no semicolon at the line before the closing bracket. I hade to repair that for 5 lines, so not a big problem, but will be a good feature. Great work ๐Ÿ‘๐Ÿป๐Ÿ‘๐Ÿป

Not working on my machine

It's not working on my vs code setup, either run it with command command palette, or via status bar, i'm still trying to figure out why but here some error if it's help.
Capture

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.