Skip to content
This repository has been archived by the owner on Dec 27, 2021. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
GraxMonzo committed Jan 18, 2021
1 parent 7794ee2 commit 00beced
Show file tree
Hide file tree
Showing 10 changed files with 4,242 additions and 33 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
# editorconfig-tools is unable to ignore longs strings or urls
max_line_length = off

[CHANGELOG.md]
indent_size = false
44 changes: 44 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Tests

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

jobs:
build:
runs-on: ubuntu-latest

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

steps:
- name: Checkout code
uses: actions/checkout@v2.3.3

- name: Setup Node.js
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

- name: Execute tests
run: npm test
env:
CI: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_STORE
node_modules
package-lock.json
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

All notable changes to `@graxmonzo/tailwind-caret-color` will be documented in this file.

## 2.0.0 - 18-01-2021

- Initial release
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) GraxMonzo <bekzatsmov@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
33 changes: 26 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Caret Color - TailwindCSS Plugin

[![npm](https://img.shields.io/npm/v/@graxmonzo/tailwind-caret-color.svg?style=flat-square)](https://www.npmjs.com/package/@graxmonzo/tailwind-caret-color)
[![npm](https://img.shields.io/npm/dt/@graxmonzo/tailwind-caret-color.svg?style=flat-square)](https://www.npmjs.com/package/@graxmonzo/tailwind-caret-color)
[![npm](https://img.shields.io/npm/v/@graxmonzo/tailwind-caret-color.svg)](https://www.npmjs.com/package/@graxmonzo/tailwind-caret-color)
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/graxmonzo/tailwind-caret-color/Tests?label=tests)](https://github.com/graxmonzo/tailwind-caret-color/actions?query=workflow%3ATests+branch%3Amaster)
[![npm](https://img.shields.io/npm/dt/@graxmonzo/tailwind-caret-color.svg)](https://www.npmjs.com/package/@graxmonzo/tailwind-caret-color)

Fork of [`tailwind-caret-color`](https://github.com/Naoray/tailwind-caret-color) package. Tailwind 2.0.

This plugin generates classes for coloring carets using `caret-color: #;`.

Expand All @@ -22,14 +25,30 @@ yarn add @graxmonzo/tailwind-caret-color
Add it to the plugins array of your Tailwind config.

```js
plugins: [
// Other plugins
require('@graxmonzo/tailwind-caret-color')(),
],
// tailwind.config.js

{
variants: {
caretColor: ['dark', 'active'], // Default variants
},
plugins: [
require('@graxmonzo/tailwind-caret-color'),
],
}
```

For each color in `colors` config of tailwind a `caret-{color}` class is created, analog to `bg-` and `text-` classes.

## Testing

```bash
yarn test
```

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

## License

This project is licensed under the [MIT License](https://opensource.org/licenses/MIT).
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
45 changes: 26 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
const plugin = require("tailwindcss/plugin");

module.exports = function () {
return function ({ e, addUtilities, theme }) {
colors = theme('colors');
module.exports = plugin.withOptions(
({ className = "caret" } = {}) => {
return ({ e, addUtilities, theme, variants }) => {
const colors = theme("colors");

const caretColors = Object.keys(colors)
.reduce((acc, key) => {
if (typeof colors[key] === 'string') {
const caretColors = Object.keys(colors).reduce((acc, key) => {
if (typeof colors[key] === "string") {
return {
...acc,
[`.caret-${e(key)}`]: {
'caret-color': colors[key]
[`.${className}-${e(key)}`]: {
"caret-color": colors[key],
},
};
}

const variants = Object.keys(colors[key]);
const colorShades = Object.keys(colors[key]);

return {
...acc,
...variants.reduce((a, variant) => ({
...a,
[`.caret-${e(key)}-${variant}`]: {
'caret-color': colors[key][variant]
},
}), {}),
...colorShades.reduce(
(a, shade) => ({
...a,
[`.${className}-${e(key)}-${shade}`]: {
"caret-color": colors[key][shade],
},
}),
{}
),
};

}, {});

addUtilities(caretColors);
}
}
addUtilities(caretColors, variants("caretColor"));
};
},
() => ({
variants: { caretColor: ["dark", "active"] },
})
);
26 changes: 19 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
{
"name": "@graxmonzo/tailwind-caret-color",
"version": "1.0.5",
"version": "2.0.0",
"description": "Tailwind plugin to create caret color classes",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/GraxMonzo/tailwind-caret-color.git"
},
"author": "Krishan Koenig",
"contributors": [
"Bekzat Samatov"
],
"author": {
"name": "Beka",
"email": "bekzatsmov@gmail.com",
"url": "https://graxmonzo.com"
},
"license": "MIT",
"private": false,
"bugs": {
"url": "https://github.com/GraxMonzo/tailwind-caret-color/issues"
},
"homepage": "https://github.com/GraxMonzo/tailwind-caret-color#readme",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest"
},
"publishConfig": {
"registry": "https://npm.pkg.github.com/"
},
"devDependencies": {
"jest": "^26.6.3",
"jest-matcher-css": "^1.1.0",
"postcss": "^8.2.4",
"tailwindcss": "^2.0.2"
},
"dependencies": {
"lodash.merge": "^4.6.2"
}
}
Loading

0 comments on commit 00beced

Please sign in to comment.