Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b2935e6
Corrects CSS link in demo page
goodguyry Jun 26, 2019
95c8353
Add initial !tidy support
goodguyry Sep 21, 2019
f483172
Beefs up !tidy test runner
goodguyry Sep 21, 2019
6280568
Create and store an atRule for each breakpoint in the config
goodguyry Sep 21, 2019
89036ed
Incorporates tidy.atRules
goodguyry Sep 21, 2019
b24dbe3
Handle declarations with !tidy inside media query
goodguyry Sep 21, 2019
5115fbf
Ensures plugin ignores !tidy rule in max-width breakpoints
goodguyry Sep 21, 2019
3b1f93f
Adds support for escaping !tidy rule (required for Sass compiling)
goodguyry Sep 21, 2019
88364b9
Uses !tidy for docs declaration propagation
goodguyry Sep 21, 2019
f385ce2
Adds sourcemap test for the !tidy rule
goodguyry Sep 21, 2019
56e2cef
Comment cleanup
goodguyry Sep 21, 2019
07c66f2
Get root from declaration
goodguyry Sep 22, 2019
1242f3e
Reverts Tidy.atRules
goodguyry Sep 22, 2019
47849b0
Shares the same clean declaration between contexts
goodguyry Sep 22, 2019
f3cd25f
Code cleanup
goodguyry Sep 22, 2019
ed426f9
Rebuilds docs CSS
goodguyry Sep 22, 2019
8a5cccd
Updates documentation; organizes code a little bit
goodguyry Sep 22, 2019
aa9e11c
Adds initial !tidy documentation
goodguyry Sep 22, 2019
a5acf71
Cleans up README
goodguyry Sep 22, 2019
f41c410
Adds initial support for automating *-full function declarations
goodguyry Sep 24, 2019
390627a
Adds tests for getSiteMax helper
goodguyry Sep 25, 2019
c643443
Corrects issues with getSiteMax
goodguyry Sep 25, 2019
af0e4ab
Cleans up doc blocks
goodguyry Sep 25, 2019
b24e45e
Cleans up function caveat and !tidy example
goodguyry Sep 26, 2019
8b12afe
Updates breakpoints link
goodguyry Sep 27, 2019
53d68b5
Removes references to 'grid' for clarity
goodguyry Sep 27, 2019
c5094a5
Updates docs/ to use !tidy for tidy-offset functions
goodguyry Sep 27, 2019
9ffb260
Cleans up whitespace
goodguyry Sep 28, 2019
c4922ee
Removes outdated comment
goodguyry Sep 28, 2019
e590381
Cleans up variables
goodguyry Sep 28, 2019
dbde2eb
Merge pull request #52 from goodguyry/!tidy
goodguyry Sep 28, 2019
ef5606a
Adds a test for tidy-var() outputting a CSS Custom Property
goodguyry Sep 28, 2019
7cfeb39
Merge pull request #53 from goodguyry/fix/custom-properties
goodguyry Sep 28, 2019
d66dbe4
Strips whitespace from test runner compare
goodguyry Sep 28, 2019
b7cdfa7
Cleans up comment about JSON.stringify() in expect()
goodguyry Sep 28, 2019
e8694e4
Merge pull request #54 from goodguyry/test-cleanup
goodguyry Sep 28, 2019
696d3ba
`npm audit fix`
goodguyry Sep 28, 2019
45e6716
Updates devDependencies for clarity
goodguyry Sep 28, 2019
33bbd88
Merge pull request #55 from goodguyry/npm-audit
goodguyry Sep 28, 2019
8e368b5
Version bump (0.4.1-beta-1) and updated CHANGELOG
goodguyry Sep 28, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).

## 0.4.1

**Added**

- Support for automatically duplicating declarations that should propagate through breakpoints (#52)

**Fixed**

- Updates dependencies to fix known vulnerabilities (#55)

## 0.4.0

**Added**

- Support for configuring different grid specs across multiple breakpoints (#20)
- Support for configuring different column specs across multiple breakpoints (#20)
- Use the `tidy-var()` function to retrieve option values in declarations (#27, #32)
- Use the `debug` option to maintain the input declaration as a comment (#45, #48)

Expand All @@ -22,7 +32,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

**Removed**

- The `addGap` option for automatically adding the grid gap margin to column elements (#24)
- The `addGap` option for automatically adding the column gap margin to column elements (#24)
- Support for Node 6 (#41)

## 0.3.4
Expand Down
49 changes: 42 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ See [PostCSS] docs for examples for your environment.

* [Tidy Properties](#tidy-properties)
* [Tidy Functions](#tidy-functions)
* [!tidy Rule](#tidy-rule)
* [Options](#options)
* [Options Cascade](#options-cascade)
* [Using CSS Custom Properties in setting values](#using-css-custom-properties-in-setting-values)
Expand Down Expand Up @@ -131,7 +132,13 @@ Use `none` to bypass a required value. A single value applies to both `left` and

These functions are provided for incorporating the `tidy-` properties' output without using the properties themselves. These can be used on their own or nested inside a `calc()` function, and allow for more control over the declarations added by the plugin.

When using these functions, **the `siteMax`-based static value will not be output**. Use the `tidy-span-full()` and `tidy-offset-full()` functions to set the static `span` and `offset` widths, respectively.
**Unlike the above _properties_, these functions only output one value:**
* `tidy-[offset|span]()` outputs the fluid value
* `tidy-[offset|span]-full()` outputs the static value, based on the `siteMax` in the configuration.

Be sure to use the function most appropriate for your use-case. Typically, this means redeclaring the the `-full` version of the function in the breakpoint at which the site becomes static width.

**TIP:** For any function declarations that should stay the same across breakpoint configurations, or simply to redclare the `-full` version of a function, append the declaration with `!tidy` to signal to the plugin to handle duplicating the declaration.

### Span Function

Expand Down Expand Up @@ -190,12 +197,40 @@ When using these functions, **the `siteMax`-based static value will not be outpu
> }
> ```

## `!tidy` Rule

`!tidy` signifies that a declaration should cascade through configured
breakpoint changes.

> #### Example
>
> Assuming one '64rem' breakpoint change configured...
>
> ```css
>
> /* Input: */
> div {
> tidy-span: 3 !tidy;
> }
>
> /* Output: */
> div {
> tidy-span: 3;
> }
>
> @media (min-width: 64rem) {
> div {
> tidy-span: 3;
> }
> }
> ```

## Options

|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|[`columns`](#columns)|`{Number}`|`undefined`|The number of grid columns.|
|[`gap`](#gap)|`{String}`|`undefined`|The width of grid column gaps.|
|[`columns`](#columns)|`{Number}`|`undefined`|The number of columns.|
|[`gap`](#gap)|`{String}`|`undefined`|The width of column gaps.|
|[`siteMax`](#siteMax)|`{String}`|`undefined`|The max-width of the site.|
|[`edge`](#edge)|`{String}`|`undefined`|The value of the site's edge padding.|
|[`debug`](#debug)|`{Boolean}`|`false`|Add debug comments.|
Expand Down Expand Up @@ -272,10 +307,10 @@ div {

### `breakpoints`

Use the `breakpoints` object to define a grid configuration that will change based on screen size.
Use the `breakpoints` object to define a columns configuration that will change based on screen size.

1. Define the small-screen grid in the root object.
2. Define one or more `min-width` breakpoints at which the grid spec will change, and any configuration options that will change.
1. Define the small-screen columns configuration in the root object.
2. Define one or more `min-width` breakpoints at which the columns configuration will change, and any configuration options that will change.
4. The configuration settings cascade up from the root to the largest `breakpoint`.

```js
Expand All @@ -296,7 +331,7 @@ require('postcss-tidy-columns')({
});
```

See the [Scoped Settings](https://github.com/goodguyry/postcss-tidy-columns/wiki/Scoped-Settings) Wiki page for more.
See the [Gotchas](https://github.com/goodguyry/postcss-tidy-columns/wiki/Gotchas#configuration-breakpoints-caveats) Wiki page for more.

## Options Cascade

Expand Down
2 changes: 1 addition & 1 deletion docs/_layouts/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<div class="article-header__intro">
<h1>{{ page.title }}</h1>
<p>This page demonstrates incorporating Tidy Columns into your flexbox layout. Toggle a grid overlay with the button in the header, and view <a href="/css/main.css">the CSS file</a> for additional context.</p>
<p>This page demonstrates incorporating Tidy Columns into your flexbox layout. Toggle a grid overlay with the button in the header, and view <a href="css/main.css">the CSS file</a> for additional context.</p>
<p>On desktop, this title holder is absolutely-positioned, which means it's out of document flow, so the image caption can't naturally sit next to it. Use Tidy Columns to add a left offset to the caption to correct maintain alignment and spacing.</p>
</div>

Expand Down
26 changes: 12 additions & 14 deletions docs/_scss/article.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,20 @@

@media (min(md)) {
/**
* The header intro should span 6 columns on medium screens.
* The header intro should span 6 columns on medium screens AND large screens.
*
* tidy-span: 6;
* Because I am using a breakpoint configuration to set up two distinct
* Tidy Columns configurations, the declaration must be re-declared within
* the breakpoint to ensure the correct values are used in the calculation.
*
* Append !tidy to the declaration to automatically duplicate it inside the
* configuration's breakpoints.
*
* When compiling from Sass, you are required to escape the exclamation: \!tidy
*
* tidy-span: 6 !tidy;
*/
tidy-span: 6;
tidy-span: 6 \!tidy;
}

@media (min(lg)) {
Expand All @@ -93,16 +102,5 @@
padding-right: rem(64);
position: absolute;
right: 0;
/**
* Because I am using a breakpoint configuration to set up two distinct
* Tidy Columns configurations, the declaration must be re-declared within
* the breakpoint to ensure the correct values are used in the calculation.
*
* Check out the Tidy Columns Wiki for simple `keep-tidy` Sass mixin.
* @see https://github.com/goodguyry/postcss-tidy-columns/wiki
*
* tidy-span: 6;
*/
tidy-span: 6;
}
}
69 changes: 26 additions & 43 deletions docs/_scss/content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@
@include auto-margins;
/**
* The design calls for the content area to be 6 columns wide (out of 8) on
* small screens.
* small screens AND large screens.
*
* tidy-span: 6;
* Because I am using a breakpoint configuration to set up two distinct
* Tidy Columns configurations, the declaration must be re-declared within
* the breakpoint to ensure the correct values are used in the calculation.
*
* Append !tidy to the declaration to automatically duplicate it inside the
* configuration's breakpoints.
*
* When compiling from Sass, you are required to escape the exclamation: \!tidy
*
* tidy-span: 6 !tidy;
*/
tidy-span: 6;
tidy-span: 6 \!tidy;

@media (min(lg)) {
/**
Expand All @@ -21,20 +30,6 @@
* tidy-offset-left: 2;
*/
tidy-offset-left: 2;
/**
* The design calls for the content area to be 6 columns wide (out of 12) on
* larger screens.
*
* Because I am using a breakpoint configuration to set up two distinct
* Tidy Columns configurations, the declaration must be re-declared within
* the breakpoint to ensure the correct values are used in the calculation.
*
* Check out the Tidy Columns Wiki for simple `keep-tidy` Sass mixin.
* @see https://github.com/goodguyry/postcss-tidy-columns/wiki
*
* tidy-span: 6;
*/
tidy-span: 6;
}
}

Expand Down Expand Up @@ -132,27 +127,21 @@
* the edge of the site, then tack on the edge value to pull the figure to
* the edge of the site's max-width.
*
* margin-left: calc(tidy-offset(-1) - tidy-var(edge));
* When using tidy-* functions in non-width properties, the `-full` version
* of the function must be declared in a media query matching the site's
* max-width to ensure the static value is calculated based on the site's
* max-width rather than `vw` units. Appending the declaration with !tidy
* automates this..
*
* margin-left: calc(tidy-offset(-1) - tidy-var(edge)) !tidy;
*/
margin-left: calc(tidy-offset(-2) - tidy-var(edge));
margin-left: calc(tidy-offset(-2) - tidy-var(edge)) \!tidy;
max-width: tidy-var(siteMax);

.content__img {
margin-bottom: 0;
}
}

@media (min(full)) {
/**
* When using tidy-* functions in non-width properties, the `-full` version
* of the function must be declared in a media query matching the site's
* max-width to ensure the static value is calculated based on the site's
* max-width rather than `vw` units.
*
* margin-left: calc(tidy-offset-full(-2) - tidy-var(edge));
*/
margin-left: calc(tidy-offset-full(-2) - tidy-var(edge));
}
}

.content__figcaption--fullwidth {
Expand All @@ -173,23 +162,17 @@
* we must include the implied edge value in the offset so the distance is
* correct.
*
* right: calc(tidy-var(edge) + tidy-offset(1));
*/
right: calc(tidy-var(edge) + tidy-offset(1));
// Override the `tidy-span` property from the rule's root.
width: auto;
}

@media (min(full)) {
/**
* When using tidy-* functions in non-width properties, the `-full` version
* of the function must be declared in a media query matching the site's
* max-width to ensure the static value is calculated based on the site's
* max-width rather than `vw` units.
* max-width rather than `vw` units. Appending the declaration with !tidy
* automates this..
*
* right: calc(tidy-var(edge) + tidy-offset-full(1));
* right: calc(tidy-var(edge) + tidy-offset(1)) \!tidy;
*/
right: calc(tidy-var(edge) + tidy-offset-full(1));
right: calc(tidy-var(edge) + tidy-offset(1)) \!tidy;
// Override the `tidy-span` property from the rule's root.
width: auto;
}
}

Expand Down
54 changes: 23 additions & 31 deletions docs/_scss/site-footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,39 @@
font-size: rem(12);
margin-bottom: rem(10);
/**
* Quick and dirty full-width container.
* Quick and dirty, fully-responsive, full-width container.
*
* tidy-span: tidy-var(columns);
* Because I am using a breakpoint configuration to set up two distinct
* Tidy Columns configurations, the declaration must be re-declared within
* the breakpoint to ensure the correct values are used in the calculation.
*
* Append !tidy to the declaration to automatically duplicate it inside the
* configuration's breakpoints.
*
* When compiling from Sass, you are required to escape the exclamation: \!tidy
*
* tidy-span: tidy-var(columns) !tidy;
*/
tidy-span: tidy-var(columns);
tidy-span: tidy-var(columns) \!tidy;

@media(min(lg)) {
p {
/**
* The design calls for the footer content to be offset by 1.5 columns.
* It happens.
*
* This offset is for all screen sizes.
*
* Because I am using a breakpoint configuration to set up two distinct
* Tidy Columns configurations, the declaration must be re-declared within
* the breakpoint to ensure the correct values are used in the calculation.
*
* Check out the Tidy Columns Wiki for simple `keep-tidy` Sass mixin.
* @see https://github.com/goodguyry/postcss-tidy-columns/wiki
* Append !tidy to the declaration to automatically duplicate it inside the
* configuration's breakpoints.
*
* tidy-span: tidy-var(columns);
*/
tidy-span: tidy-var(columns);
}

p {
/**
* The design calls for the footer content to be offset by 1.5 columns.
* It happens.
* When compiling from Sass, you are required to escape the exclamation: \!tidy
*
* tidy-offset-left: 1.5;
* tidy-offset-left: 1.5 !tidy;
*/
tidy-offset-left: 1.5;

@media(min(lg)) {
/**
* Because I am using a breakpoint configuration to set up two distinct
* Tidy Columns configurations, the declaration must be re-declared within
* the breakpoint to ensure the correct values are used in the calculation.
*
* Check out the Tidy Columns Wiki for simple `keep-tidy` Sass mixin.
* @see https://github.com/goodguyry/postcss-tidy-columns/wiki
*
* tidy-offset-left: 1.5;
*/
tidy-offset-left: 1.5;
}
tidy-offset-left: 1.5 \!tidy;
}
}
Loading