Skip to content

Commit

Permalink
chore: Prepare Tailwind 2.0 - Part 2 (#82)
Browse files Browse the repository at this point in the history
* add tests

* rename default to DEFAULT
  • Loading branch information
RobinMalfait committed Oct 23, 2020
1 parent 1a51113 commit cbfeb47
Show file tree
Hide file tree
Showing 7 changed files with 3,955 additions and 48 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x]

steps:
- uses: actions/checkout@v2.3.3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1.4.4
with:
node-version: ${{ matrix.node-version }}
- name: Use cached node_modules
id: cache
uses: actions/cache@v2.1.1
with:
path: node_modules
key: nodeModules-${{ hashFiles('**/yarn.lock') }}-${{ matrix.node-version }}
restore-keys: |
nodeModules-
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm install
env:
CI: true
- run: npm run prepublishOnly
- run: npm test
env:
CI: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
node_modules
package-lock.json
/demo/out
coverage/
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"trailingComma": "es5"
},
"scripts": {
"test": "jest",
"dev": "next dev demo",
"build": "next build demo",
"export": "next export demo",
Expand All @@ -34,10 +35,13 @@
"cssnano": "^4.1.10",
"dedent": "^0.7.0",
"highlight.js": "^9.15.6",
"jest": "^26.6.1",
"next": "^9.4.4",
"postcss": "^7.0.17",
"react": "^16.8.6",
"prettier": "^2.1.2",
"react-dom": "^16.8.6",
"react": "^16.8.6",
"snapshot-diff": "^0.8.1",
"tailwindcss": "^2.0.0-alpha.1"
}
}
9 changes: 6 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const computed = {

function configToCss(config) {
return merge(
{},
...Object.keys(config)
.filter((key) => computed[key])
.map((key) => computed[key](config[key])),
Expand All @@ -26,18 +27,20 @@ module.exports = plugin.withOptions(
[
{
[`.${className}`]: merge(
...castArray(styles.default.css),
configToCss(config.default || {})
{},
...castArray(styles.DEFAULT.css),
configToCss(config.DEFAULT || {})
),
},
...modifiers.map((modifier) => ({
[`.${className}-${modifier}`]: merge(
{},
...castArray(styles[modifier].css),
configToCss(config[modifier] || {})
),
})),
...Object.keys(config)
.filter((key) => !['default', ...modifiers].includes(key))
.filter((key) => !['DEFAULT', ...modifiers].includes(key))
.map((modifier) => ({
[`.${className}-${modifier}`]: configToCss(config[modifier]),
})),
Expand Down

0 comments on commit cbfeb47

Please sign in to comment.