Skip to content

Commit

Permalink
fix: remove @warp-ds/css dep to fix circular dependency (#149)
Browse files Browse the repository at this point in the history
Co-authored-by: AnnaRybkina <37986637+AnnaRybkina@users.noreply.github.com>
  • Loading branch information
BalbinaK and AnnaRybkina committed Aug 18, 2023
1 parent 51a7f4c commit e351c76
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 104 deletions.
5 changes: 0 additions & 5 deletions README.md
Expand Up @@ -14,11 +14,6 @@
- `boolean`
- If true forces resets to be excluded from preflights

### omitComponentClasses

- `boolean`
- if true forces component classes to be excluded from the process. Styling for the classes already used in component classes won't be generated.

### usePixels

- `boolean`
Expand Down
3 changes: 0 additions & 3 deletions dev.js
Expand Up @@ -20,9 +20,6 @@ const {
usePixels: {
type: 'boolean',
},
omitComponentClasses: {
type: 'boolean',
},
skipResets: {
type: 'boolean',
},
Expand Down
3 changes: 0 additions & 3 deletions package.json
Expand Up @@ -55,9 +55,6 @@
"vite": "^4.2.0",
"vitest": "^0.29.3"
},
"peerDependencies": {
"@warp-ds/css": "^1.0.0-alpha.37"
},
"eslintConfig": {
"extends": "@warp-ds"
},
Expand Down
91 changes: 3 additions & 88 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions src/plugin.js
@@ -1,4 +1,3 @@
import { classes } from '@warp-ds/css/component-classes/classes';
import { preflights } from '#preflights';
import { rules } from '#rules';
import { shortcuts } from '#shortcuts';
Expand All @@ -11,7 +10,6 @@ import { postprocess } from '#postprocess';
* @property {boolean} development // internal use only - force preflights(transform + resets) to be excluded and no external classes will be processed
* @property {boolean} skipResets // force resets to be excluded from preflights
* @property {boolean} externalizeClasses - if true forces external or 'core' classes to be excluded from the process.
* @property {boolean} omitComponentClasses - if true forces component classes to be excluded from the process.
* @property {Array} externalClasses - list of classes that will not be processed
* @property {boolean} usePixels - use pixel spacing instead of rem
*/
Expand All @@ -23,16 +21,15 @@ import { postprocess } from '#postprocess';
export function presetWarp(options = {}) {
checkEnvironment();
const externalizeClasses = options.externalizeClasses ?? !options.development; // 'true' by default
const safeExternalClasses = options.externalClasses || [];
const excludedClasses = options.omitComponentClasses ? [...classes, ...safeExternalClasses] : safeExternalClasses;
const externalClasses = options.externalClasses || [];
const theme = useTheme(options);
return {
name: '@warp-ds/uno',
theme,
rules,
variants,
preflights: options.development ? [] : preflights(options.skipResets),
postprocess: postprocess(externalizeClasses, excludedClasses),
postprocess: postprocess(externalizeClasses, externalClasses),
shortcuts,
};
}
Expand Down
23 changes: 23 additions & 0 deletions test/__snapshots__/external-classes.js.snap
@@ -0,0 +1,23 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`external classes > externalized class of mt-32 should be excluded from the css 1`] = `
"/* layer: default */
.mb-24{margin-bottom:2.4rem;}
.mt-16{margin-top:1.6rem;}"
`;

exports[`external classes > externalized class of mt-32 should be included if used with modifier 1`] = `
"/* layer: default */
.active\\\\:mt-32:active{margin-top:3.2rem;}
@media (min-width: 480px){
.sm\\\\:mt-32{margin-top:3.2rem;}
}
@media (min-width: 768px){
.md\\\\:mt-32{margin-top:3.2rem;}
}"
`;

exports[`external classes > externalized classes of mt-32 and mb-32 should be excluded from the css 1`] = `
"/* layer: default */
.mt-16{margin-top:1.6rem;}"
`;
22 changes: 22 additions & 0 deletions test/external-classes.js
@@ -0,0 +1,22 @@
import { setup } from './_helpers.js';
import { describe, expect, test } from 'vitest';

setup({ externalizeClasses: true, externalClasses: ["mt-32", "mb-32"] });

describe('external classes', () => {
test('externalized classes of mt-32 and mb-32 should be excluded from the css', async ({ uno }) => {
const classes = ['mt-16', 'mt-32', 'mb-32'];
const { css } = await uno.generate(classes);
expect(css).toMatchSnapshot();
});
test('externalized class of mt-32 should be excluded from the css', async ({ uno }) => {
const classes = ['mt-16', 'mt-32', 'mb-24'];
const { css } = await uno.generate(classes);
expect(css).toMatchSnapshot();
});
test('externalized class of mt-32 should be included if used with modifier', async ({ uno }) => {
const classes = ['sm:mt-32', 'md:mt-32', 'active:mt-32'];
const { css } = await uno.generate(classes);
expect(css).toMatchSnapshot();
});
});

0 comments on commit e351c76

Please sign in to comment.