-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christopher Vachon
committed
Oct 7, 2022
1 parent
8d777f9
commit 88dafc3
Showing
22 changed files
with
4,674 additions
and
1 deletion.
There are no files selected for viewing
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,2 @@ | ||
lib | ||
node_modules |
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,36 @@ | ||
module.exports = module.exports = { | ||
env: { | ||
browser: true, | ||
node: true, | ||
jest: true | ||
}, | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
ecmaVersion: 2020 | ||
}, | ||
plugins: ["@typescript-eslint", "jest-extended", "jest", "prettier"], | ||
extends: ["prettier"], | ||
rules: { | ||
"jest/no-disabled-tests": "warn", | ||
"jest/no-focused-tests": "error", | ||
"jest/no-identical-title": "error", | ||
"jest/prefer-to-have-length": "warn", | ||
"jest/valid-expect": "error", | ||
"linebreak-style": ["error", "unix"], | ||
"no-console": [ | ||
"error", | ||
{ | ||
allow: ["info", "error", "debug"] | ||
} | ||
], | ||
"prettier/prettier": "error", | ||
quotes: [ | ||
"error", | ||
"double", | ||
{ | ||
allowTemplateLiterals: true | ||
} | ||
], | ||
semi: ["error", "always"] | ||
} | ||
}; |
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,3 @@ | ||
# These are supported funding model platforms | ||
|
||
github: [codevachon] |
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,54 @@ | ||
name: Build and Deploy Docs | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
# Allow one concurrent deployment | ||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
# Build job | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: pnpm/[email protected] | ||
name: Install pnpm | ||
with: | ||
version: latest | ||
|
||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: "18.x" | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Build Docs | ||
run: pnpm run build:docs | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v1 | ||
with: | ||
path: ./docs | ||
|
||
# Deployment job | ||
deploy: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v1 |
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,31 @@ | ||
name: Build and Deploy GitHub Package | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: pnpm/[email protected] | ||
name: Install pnpm | ||
with: | ||
version: latest | ||
|
||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: "18.x" | ||
registry-url: "https://npm.pkg.github.com" | ||
scope: "@codevachon" | ||
|
||
- run: pnpm install | ||
- run: pnpm run build | ||
- run: npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.CODEVACHON_GITHUB_TOKEN }} |
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,27 @@ | ||
name: Build and Deploy NPM Package | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: pnpm/[email protected] | ||
name: Install pnpm | ||
with: | ||
version: latest | ||
|
||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: "18.x" | ||
registry-url: "https://registry.npmjs.org" | ||
|
||
- run: pnpm install | ||
- run: pnpm run build | ||
- run: npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
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,31 @@ | ||
name: CI Tests | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [12.x, 14.x, 16.x, 18.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: pnpm/[email protected] | ||
name: Install pnpm | ||
with: | ||
version: latest | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- run: pnpm install | ||
- run: pnpm run test |
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 |
---|---|---|
|
@@ -102,3 +102,7 @@ dist | |
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Built Files | ||
lib | ||
docs |
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,2 @@ | ||
lib | ||
node_modules |
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,9 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.formatOnPaste": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.tabSize": 4, | ||
"editor.insertSpaces": true, | ||
"eslint.packageManager": "pnpm", | ||
"vs-browser.url": "http://localhost:3000" | ||
} |
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 +1,173 @@ | ||
# classnames | ||
# @codevachon/classnames | ||
|
||
A Library Used for managing ClassNames in Javascript | ||
|
||
## Usage | ||
|
||
```tsx | ||
import { ClassNames } from "@codevachon/classnames"; | ||
|
||
export default function Homepage() { | ||
return ( | ||
<div | ||
className={new ClassNames([ | ||
"bg-slate-900 text-white", | ||
"flex justify-center items-center", | ||
"h-screen w-full" | ||
]).list()} | ||
> | ||
<h1 className={new ClassNames(["text-6xl"]).list()}>Hello World</h1> | ||
</div> | ||
); | ||
} | ||
``` | ||
|
||
## API | ||
|
||
### .add() | ||
|
||
Adds a class to the instance | ||
|
||
```js | ||
import { ClassNames } from "@44north/classnames"; | ||
|
||
const list = new ClassNames("a", "b", "c").list(); | ||
// list => "a b c" | ||
``` | ||
|
||
```js | ||
const list = new ClassNames().add("a", "b", "c").list(); | ||
// list => "a b c" | ||
``` | ||
|
||
```js | ||
const list = new ClassNames().add(["a", "b", "c"]).list(); | ||
// list => "a b c" | ||
``` | ||
|
||
```js | ||
const list = new ClassNames().add("a b c").list(); | ||
// list => "a b c" | ||
``` | ||
|
||
```js | ||
const list = new ClassNames().add(["a b c"]).list(); | ||
// list => "a b c" | ||
``` | ||
|
||
```js | ||
const list = new ClassNames("a").add(new ClassNames(["b", "c"])).list(); | ||
// list => "a b c" | ||
``` | ||
|
||
### .remove() | ||
|
||
removes a class from the instance | ||
|
||
```js | ||
const list = new ClassNames().add(["a", "b", "c"]).remove("a").list(); | ||
// list => "b c" | ||
``` | ||
|
||
```js | ||
const list = new ClassNames().add(["a", "b", "c"]).remove(["a", "c"]).list(); | ||
// list => "b" | ||
``` | ||
|
||
```js | ||
const list = new ClassNames().add(["a", "b", "c"]).remove("a", "c").list(); | ||
// list => "b" | ||
``` | ||
|
||
```js | ||
const list = new ClassNames().add(["mt-3", "mb-4", "pt-8"]).remove(new RegExp("t-")).list(); | ||
// list => "mb-4" | ||
``` | ||
|
||
### .list() / .toString() | ||
|
||
returns this instance as a class formated string. | ||
|
||
```js | ||
const list = new ClassNames().add(["a", "b", "c"]).list(); | ||
// list => "b c" | ||
``` | ||
|
||
```jsx | ||
<h1 classNames={new ClassNames("text-xl").list()}>Hello World!</h1> | ||
``` | ||
|
||
### .find() | ||
|
||
allows you to search the instance for a particular class | ||
|
||
```js | ||
const list = new ClassNames().add(["a", "b", "c"]).find("b"); | ||
// list => ["b"] | ||
``` | ||
|
||
```js | ||
const list = new ClassNames().add(["mt-3", "mb-4", "pt-8"]).find(new RegExp("b")); | ||
// list => "mb-4" | ||
``` | ||
|
||
### .isEmpty() | ||
|
||
returns if the instance has any classes | ||
|
||
```js | ||
const value = new ClassNames(["a", "b", "c"]).isEmpty(); | ||
// value => false | ||
``` | ||
|
||
### .has() | ||
|
||
returns if the instance has the provided value | ||
|
||
```js | ||
const value = new ClassNames(["a", "b", "c"]).has("b"); | ||
// value => true | ||
``` | ||
|
||
```js | ||
const value = new ClassNames(["mt-3", "mb-4", "pt-8"]).has(new RegExp("z-")); | ||
// value => false | ||
``` | ||
|
||
### .isClassNames() | ||
|
||
returns if the provided value is an instance of ClassName | ||
|
||
```js | ||
const value = new ClassNames().isClassName(["a"]); | ||
// value => false | ||
``` | ||
|
||
### .length | ||
|
||
returns the number of classes added to the instance | ||
|
||
```js | ||
const value = new ClassNames(["a", "b", "c"]).length; | ||
// value => 3 | ||
``` | ||
|
||
## Conditionals | ||
|
||
You can pass an object as part of add with the classname as a key and value as a boolean. | ||
|
||
```js | ||
const values = { | ||
a: true, | ||
b: false, | ||
c: a !== b | ||
}; | ||
|
||
const list = new ClassNames(values).list(); | ||
// list => "a c" | ||
``` | ||
|
||
## Static Methods | ||
|
||
- .add() - Alias of `new ClassNames().add()` | ||
- .isClassNames() - Alias of `new ClassNames().isClassNames()` |
Oops, something went wrong.