-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pseudo element support and rename pseudo classes plugin to pseudo
- Loading branch information
1 parent
3269ff5
commit f7a7e91
Showing
7 changed files
with
47 additions
and
14 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
...ges/stylishly-pseudo-classes/package.json → packages/stylishly-pseudo/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
{ | ||
"name": "stylishly-pseudo-classes", | ||
"name": "stylishly-pseudo", | ||
"version": "0.8.0", | ||
"description": "", | ||
"main": "lib/pseudoClasses.js", | ||
"main": "lib/pseudo.js", | ||
"author": "Nathan Marks <info@nathanmarks.io> (http://nathanmarks.io)", | ||
"license": "MIT", | ||
"repository": "https://github.com/nathanmarks/stylishly", | ||
"peerDependencies": { | ||
"stylishly": "^0.8.0" | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...ishly-pseudo-classes/src/pseudoClasses.js → packages/stylishly-pseudo/src/pseudo.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* eslint-env mocha */ | ||
import { assert } from 'chai'; | ||
import { createStyleSheet, getClassNames } from 'packages/stylishly/src/styleSheet'; | ||
import { createPluginRegistry } from 'packages/stylishly/src/pluginRegistry'; | ||
import nested from 'packages/stylishly-nested/src/nested'; | ||
import pseudo from 'packages/stylishly-pseudo/src/pseudo'; | ||
|
||
describe('pseudo elements', () => { | ||
it('should create a rule with a pseudo element and expose the className', () => { | ||
const pluginRegistry = createPluginRegistry(); | ||
pluginRegistry.registerPlugins(nested(), pseudo()); | ||
|
||
const styleSheet = createStyleSheet('Foo', () => { | ||
return { | ||
'container::after': { | ||
color: 'red', | ||
}, | ||
}; | ||
}); | ||
|
||
const rules = styleSheet.resolveStyles({}, pluginRegistry); | ||
|
||
assert.strictEqual(rules.length, 1, 'has 1 rule'); | ||
assert.strictEqual(rules[0].type, 'style'); | ||
assert.strictEqual(rules[0].selectorText, '.foo__container::after'); | ||
assert.strictEqual(rules[0].declaration.color, 'red'); | ||
|
||
const classes = getClassNames(rules); | ||
|
||
assert.strictEqual(Object.keys(classes).length, 1, 'should return 1 class name'); | ||
assert.strictEqual(classes.container, 'foo__container', 'should have the container className'); | ||
}); | ||
}); |