From 6b631d0af0d8464ba365975c799951e5eddd73e5 Mon Sep 17 00:00:00 2001 From: Cole Peters Date: Wed, 20 Mar 2024 14:21:27 -0500 Subject: [PATCH 1/3] Add opt out in config for reset --- dist/enhance.css | 5 +++++ reset.mjs | 7 ++++--- test/reset.test.js | 12 ++++++++++++ theme.mjs | 24 ++++++++++++------------ 4 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 test/reset.test.js diff --git a/dist/enhance.css b/dist/enhance.css index a519df7..935a556 100644 --- a/dist/enhance.css +++ b/dist/enhance.css @@ -126,6 +126,11 @@ svg, video { display: block; max-width: 100%; +} +img, +picture, +svg, +video { block-size: auto; } button, diff --git a/reset.mjs b/reset.mjs index 19e88b2..88a4f97 100644 --- a/reset.mjs +++ b/reset.mjs @@ -1,5 +1,6 @@ -export default function reset (query) { - return /*css*/` +export default function reset({ config }) { + const { reset = true } = config + return reset ? /*css*/` /*** Reset ***/ *, *::before, @@ -94,5 +95,5 @@ dialog { scroll-behavior: auto !important; } } -` +` : '' } diff --git a/test/reset.test.js b/test/reset.test.js new file mode 100644 index 0000000..df6e3d7 --- /dev/null +++ b/test/reset.test.js @@ -0,0 +1,12 @@ +import test from 'tape' + +import reset from '../reset.mjs' + +const config = { + reset: false +} + +test('reset', t => { + t.equal(reset({ config }), '', 'should return an empty string when `config.reset` is `false`') + t.end() +}) diff --git a/theme.mjs b/theme.mjs index 971f697..5e387a1 100644 --- a/theme.mjs +++ b/theme.mjs @@ -13,17 +13,17 @@ import spaceScaleProperties from './space-scale-properties.mjs' export default function theme(config) { return /*css*/` -${themeColor({config})} -${properties({config})} -${typeScaleProperties({config})} -${spaceScaleProperties({config})} -${reset()} -${typeface({config})} -${smoothing({config})} -${background({config})} -${border({config})} -${color({config})} -${fill({config})} -${stroke({config})} +${themeColor({ config })} +${properties({ config })} +${typeScaleProperties({ config })} +${spaceScaleProperties({ config })} +${reset({ config })} +${typeface({ config })} +${smoothing()} +${background({ config })} +${border({ config })} +${color({ config })} +${fill({ config })} +${stroke({ config })} ` } From d7c199f4d680c3bb6dca961e8f959571e6ed853f Mon Sep 17 00:00:00 2001 From: Cole Peters Date: Wed, 20 Mar 2024 14:23:37 -0500 Subject: [PATCH 2/3] Document reset --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 1ca0fb1..6382e9b 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,16 @@ Theme scales are intended to give you enough colors for all use cases including ### `radii` `radii` is an array of border radii. The defaults are 2, 8, 16, and 9999 ( for use with pill buttons ) +### `reset` + +Enhance Styles includes a CSS reset by default. To opt out of this reset being included in the stylesheet emitted by Enhance Styles, add the following to your configuration: + +```json +{ + "reset": false +} +``` + ## Standalone usage To use Enhance Styles in other applications or frameworks, clone the repository: From 6f57727b4b37406aa353bacc46f98b5fb6701171 Mon Sep 17 00:00:00 2001 From: Cole Peters Date: Wed, 20 Mar 2024 14:32:36 -0500 Subject: [PATCH 3/3] Add additional reset test --- reset.mjs | 2 +- test/reset.test.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/reset.mjs b/reset.mjs index 88a4f97..04ba623 100644 --- a/reset.mjs +++ b/reset.mjs @@ -1,4 +1,4 @@ -export default function reset({ config }) { +export default function reset({ config = {} } = {}) { const { reset = true } = config return reset ? /*css*/` /*** Reset ***/ diff --git a/test/reset.test.js b/test/reset.test.js index df6e3d7..85c224a 100644 --- a/test/reset.test.js +++ b/test/reset.test.js @@ -2,11 +2,12 @@ import test from 'tape' import reset from '../reset.mjs' -const config = { +const optOut = { reset: false } test('reset', t => { - t.equal(reset({ config }), '', 'should return an empty string when `config.reset` is `false`') + t.notEqual(reset(), '', 'should emit reset styles by default') + t.equal(reset({ config: optOut }), '', 'should return an empty string when `config.reset` is `false`') t.end() })