![](https://raw.githubusercontent.com/isuke/postcss-ghost-utils/images/title-plain.png)
!["node v18"](https://camo.githubusercontent.com/417a94e6c324d07f317b4a17a66944c23ae0cdd01b8fd8d1bc77f3acf068563a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6e6f64652d7631382d3032366530302e737667)
postcss-ghost-utils is a PostCSS plugin.
This plugin can give you useful css syntax.
It is NOT include old css technique (ex. clearfix).
$ 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')
]
}
Input | Output |
.one {
@ghost font-size-line-height(16px, 2px);
}
|
.one {
font-size: 16px;
line-height: calc(16px + 2px * 2);
}
|
Input | Output |
.one {
@ghost new-line;
}
|
.one {
white-space: pre-wrap;
word-wrap: break-word;
}
|
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: '-';
}
|
Input | Output |
.one {
@ghost margin-left-right(16px);
}
|
.one {
margin-left: 16px;
margin-right: 16px;
}
|
Input | Output |
.one {
@ghost margin-top-bottom(16px);
}
|
.one {
margin-top: 16px;
margin-bottom: 16px;
}
|
Input | Output |
.one {
@ghost padding-left-right(16px);
}
|
.one {
padding-left: 16px;
padding-right: 16px;
}
|
Input | Output |
.one {
@ghost padding-top-bottom(16px);
}
|
.one {
padding-top: 16px;
padding-bottom: 16px;
}
|
Input | Output |
.one {
@ghost border-left-right(2px solid black);
}
|
.one {
border-left: 2px solid black;
border-right: 2px solid black;
}
|
Input | Output |
.one {
@ghost border-top-bottom(2px solid black);
}
|
.one {
border-top: 2px solid black;
border-bottom: 2px solid black;
}
|
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;
}
|
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;
}
|
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;
}
|
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;
}
|
Input | Output |
.one {
@ghost size(160px);
}
.two {
@ghost size(160px, 240px);
}
|
.one {
width: 160px;
height: 160px;
}
.two {
width: 160px;
height: 240px;
}
|
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;
}
|
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;
}
|
The following rules may not work with not pure css ex) LESS, SASS.
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);
}
|