0.2.0 • Published 1 year ago

postcss-space-between v0.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

postcss-space-between

github.actions.changeset.badge codecov.badge MIT npm.badge

Changelog

Postcss plugin to add postcss plugin to add vertical / horizontal spacing between direct children

Input

.horizontal-list {
  @space-x 40px;
}
.vertical-list {
  --vertical-spacing: 40px;
  @space-y var(--vertical-spacing);
}
.global-variant {
  /* for usage in css module or web framework that uses :global (such as svelte) */
  @gspace-x 40px;
  @gspace-y 40px;
}

Output

.horizontal-list * > * {
  margin-left: 40px;
}
.vertical-list * > * {
  margin-top: 40px;
}
:global(.global-variant * > *) {
  margin-left: 40px;
  margin-top: 40px;
}

Installation

npm install --save-dev postcss postcss-space-between

Add to your postcss config

module.exports = {
  plugins: [
+   require('postcss-space-between'),
  ],
};

Supported At Rules

At RuleDescription
@space-xAdd horizontal spacing between direct children
@gspace-xAdd horizontal spacing between direct children with :global
@space-yAdd vertical spacing between direct children
@gspace-yAdd vertical spacing between direct children with :global

Test Cases & Examples

The following table lists test cases covered by this plugin, please refer to tests for details and to test input css as examples

Test CaseDescriptionInputOutput
in media queries@media min-width: 768px { .list { @space-x 40px; } }inputoutput
with combined selector.list-1, .list2 { @space-y: 40px; }inputoutput
with postcss-nestingsection { & .list { @space-x 40px; } }inputoutput
with postcss-nestedsection { .list { @space-x 40px; } }inputoutput
0.2.0

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago