Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests & Publish coverage report & Add typedoc #1

Merged
merged 5 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, 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: [14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ node_modules
dist
dist-ssr
*.local
/coverage

# Lib
/lib
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ function App() {
}
```

One limitation due to React internals is to never place a glitched element as the direct child of a conditional rendering block. E.g. please **never** do this:
One limitation, when having the `createContainers` option set to true (which is the default), to not place the glitched element as the direct child of a component or a conditional rendering block. E.g. this will **not** work:
```jsx
<>
{/* Do NOT do this */}
{/* Will not work */}
{condition &&
<span ref={glitch.ref}>🌎</span>
}
Expand All @@ -56,6 +56,7 @@ One limitation due to React internals is to never place a glitched element as th
Instead, wrap the glitched element with a container:
```jsx
<>
{/* Will work */}
{condition &&
<div>
<span ref={glitch.ref}>🌎</span>
Expand All @@ -77,15 +78,16 @@ function App() {
}
```

The `options` props accepts any value defined in [the original PowerGlitch library](https://github.com/7PH/powerglitch).
The `options` props accept any value defined in [the original PowerGlitch library](https://github.com/7PH/powerglitch).

Take a look at the [playground](https://7ph.github.io/powerglitch/#/playground) to visually find out the best glitch options for your element.

## Glitch controls

The `useGlitch` hook returns an object containing:
- `ref`: A function ref which you should use on the element you want to glitch, as shown in previous sections.
- `startGlitch/stopGlitch`: Glitch control functions to start and stop the glitch animation.
- `startGlitch`: Glitch control functions to start the glitch animation.
- `stopGlitch`: Glitch control functions to stop the glitch animation.
- `setOptions`: A function to change the glitch options. This will update the glitched element with the new options.

Here is an example:
Expand Down
6 changes: 6 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
presets: [
['@babel/preset-env', {targets: {node: 'current'}}],
'@babel/preset-typescript',
],
};
1 change: 1 addition & 0 deletions docs/api-docs/.nojekyll
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
113 changes: 113 additions & 0 deletions docs/api-docs/assets/highlight.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
:root {
--light-hl-0: #000000;
--dark-hl-0: #D4D4D4;
--light-hl-1: #008000;
--dark-hl-1: #6A9955;
--light-hl-2: #AF00DB;
--dark-hl-2: #C586C0;
--light-hl-3: #001080;
--dark-hl-3: #9CDCFE;
--light-hl-4: #A31515;
--dark-hl-4: #CE9178;
--light-hl-5: #0000FF;
--dark-hl-5: #569CD6;
--light-hl-6: #795E26;
--dark-hl-6: #DCDCAA;
--light-hl-7: #0070C1;
--dark-hl-7: #4FC1FF;
--light-hl-8: #800000;
--dark-hl-8: #808080;
--light-hl-9: #800000;
--dark-hl-9: #569CD6;
--light-hl-10: #FF0000;
--dark-hl-10: #9CDCFE;
--light-hl-11: #000000FF;
--dark-hl-11: #D4D4D4;
--light-hl-12: #267F99;
--dark-hl-12: #4EC9B0;
--light-code-background: #FFFFFF;
--dark-code-background: #1E1E1E;
}

@media (prefers-color-scheme: light) { :root {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--hl-10: var(--light-hl-10);
--hl-11: var(--light-hl-11);
--hl-12: var(--light-hl-12);
--code-background: var(--light-code-background);
} }

@media (prefers-color-scheme: dark) { :root {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--hl-10: var(--dark-hl-10);
--hl-11: var(--dark-hl-11);
--hl-12: var(--dark-hl-12);
--code-background: var(--dark-code-background);
} }

:root[data-theme='light'] {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--hl-10: var(--light-hl-10);
--hl-11: var(--light-hl-11);
--hl-12: var(--light-hl-12);
--code-background: var(--light-code-background);
}

:root[data-theme='dark'] {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--hl-10: var(--dark-hl-10);
--hl-11: var(--dark-hl-11);
--hl-12: var(--dark-hl-12);
--code-background: var(--dark-code-background);
}

.hl-0 { color: var(--hl-0); }
.hl-1 { color: var(--hl-1); }
.hl-2 { color: var(--hl-2); }
.hl-3 { color: var(--hl-3); }
.hl-4 { color: var(--hl-4); }
.hl-5 { color: var(--hl-5); }
.hl-6 { color: var(--hl-6); }
.hl-7 { color: var(--hl-7); }
.hl-8 { color: var(--hl-8); }
.hl-9 { color: var(--hl-9); }
.hl-10 { color: var(--hl-10); }
.hl-11 { color: var(--hl-11); }
.hl-12 { color: var(--hl-12); }
pre, code { background: var(--code-background); }
54 changes: 54 additions & 0 deletions docs/api-docs/assets/main.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/api-docs/assets/search.js

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

Loading