Skip to content

PostCSS plugin to add helper utils for your CSS

License

Notifications You must be signed in to change notification settings

isuke/postcss-ghost-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

postcss-ghost-utils Test and Lint "npm" "git-consistent friendly"

"node v14" "node v16" "node v18"

postcss-ghost-utils is a PostCSS plugin.

This plugin can give you useful css syntax. It is NOT include old css technique (ex. clearfix).

Usage

Install

$ npm install -D postcss postcss-ghost-utils
# or
$ yarn add -D postcss postcss-ghost-utils

.postcss.config.js

module.exports = {
  plugins: [
    require('postcss-ghost-utils')
  ]
}

Rule List

font-size-line-height

Input Output
.one {
  @ghost font-size-line-height(16px, 2px);
}
.one {
  font-size: 16px;
  line-height: calc(16px + 2px * 2);
}

new-line

Input Output
.one {
  @ghost new-line;
}
.one {
  white-space: pre-wrap;
  word-wrap: break-word;
}

truncate

Input Output
.one {
  @ghost truncate;
}

.two {
  @ghost truncate('-');
}
.one {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.two {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: '-';
}

margin-left-right

Input Output
.one {
  @ghost margin-left-right(16px);
}
.one {
  margin-left: 16px;
  margin-right: 16px;
}

margin-top-bottom

Input Output
.one {
  @ghost margin-top-bottom(16px);
}
.one {
  margin-top: 16px;
  margin-bottom: 16px;
}

padding-left-right

Input Output
.one {
  @ghost padding-left-right(16px);
}
.one {
  padding-left: 16px;
  padding-right: 16px;
}

padding-top-bottom

Input Output
.one {
  @ghost padding-top-bottom(16px);
}
.one {
  padding-top: 16px;
  padding-bottom: 16px;
}

border-left-right

Input Output
.one {
  @ghost border-left-right(2px solid black);
}
.one {
  border-left: 2px solid black;
  border-right: 2px solid black;
}

border-top-bottom

Input Output
.one {
  @ghost border-top-bottom(2px solid black);
}
.one {
  border-top: 2px solid black;
  border-bottom: 2px solid black;
}

border-top-radius

Input Output
.one {
  @ghost border-top-radius(4px);
}

.two {
  @ghost border-top-radius(4px 2px);
}
.one {
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
}

.two {
  border-top-left-radius: 4px 2px;
  border-top-right-radius: 4px 2px;
}

border-bottom-radius

Input Output
.one {
  @ghost border-bottom-radius(4px);
}

.two {
  @ghost border-bottom-radius(4px 2px);
}
.one {
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
}

.two {
  border-bottom-left-radius: 4px 2px;
  border-bottom-right-radius: 4px 2px;
}

border-left-radius

Input Output
.one {
  @ghost border-left-radius(4px);
}

.two {
  @ghost border-left-radius(4px 2px);
}
.one {
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

.two {
  border-top-left-radius: 4px 2px;
  border-bottom-left-radius: 4px 2px;
}

border-right-radius

Input Output
.one {
  @ghost border-right-radius(4px);
}

.two {
  @ghost border-right-radius(4px 2px);
}
.one {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

.two {
  border-top-right-radius: 4px 2px;
  border-bottom-right-radius: 4px 2px;
}

size

Input Output
.one {
  @ghost size(160px);
}

.two {
  @ghost size(160px, 240px);
}
.one {
  width: 160px;
  height: 160px;
}

.two {
  width: 160px;
  height: 240px;
}

circle

Input Output
.one {
  @ghost circle(200px);
  background-color: #ff0000;
  border: 10px solid #ffffff;
}
.one {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background-color: #ff0000;
  border: 10px solid #ffffff;
}

transition

Input Output
.one {
  @ghost transition(100ms, ease-in, color);
}

.two {
  @ghost transition(100ms, ease-in, color, background-color, border-color);
}
.one {
  transition: 100ms ease-in color;
}

.two {
  transition: 100ms ease-in color, 100ms ease-in background-color, 100ms ease-in border-color;
}

Experimental Rule List

The following rules may not work with not pure css ex) LESS, SASS.

all-buttons

Input Output
@ghost all-buttons {
  background-color: transparent;
  border: none;
  cursor: pointer;
  outline: 0;
}

@ghost all-buttons(hover) {
  transform: translateY(-2px);
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
}

@ghost all-buttons(active) {
  transform: none;
  box-shadow: none;
}

@ghost all-buttons(focus) {
  transform: translateY(-2px);
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
}
button, [type='button'], [type='reset'], [type='submit'] {
  background-color: transparent;
  border: none;
  cursor: pointer;
  outline: 0;
}

button:hover, [type='button']:hover, [type='reset']:hover, [type='submit']:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
}

button:active, [type='button']:active, [type='reset']:active, [type='submit']:active {
  transform: none;
  box-shadow: none;
}

button:focus, [type='button']:focus, [type='reset']:focus, [type='submit']:focus {
  transform: translateY(-2px);
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
}

About

PostCSS plugin to add helper utils for your CSS

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published