Skip to content

Commit 1e66286

Browse files
committed
first commit
0 parents  commit 1e66286

24 files changed

+4867
-0
lines changed

.github/workflows/ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
Linting:
11+
name: Linting
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Project
15+
uses: actions/checkout@v3
16+
- name: Use Node.js v18
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: 18
20+
check-latest: true
21+
cache: yarn
22+
registry-url: https://registry.npmjs.org/
23+
- name: Install Dependencies
24+
run: yarn --frozen-lockfile
25+
- name: Run ESLint
26+
run: yarn lint --fix=true
27+
28+
Building:
29+
name: Compile source code
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout Project
33+
uses: actions/checkout@v3
34+
- name: Use Node.js v18
35+
uses: actions/setup-node@v3
36+
with:
37+
node-version: 16
38+
cache: yarn
39+
registry-url: https://registry.npmjs.org/
40+
- name: Install Dependencies
41+
run: yarn --frozen-lockfile
42+
- name: Typecheck And Build Code
43+
run: yarn typecheck && yarn build

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
# Optional eslint cache
3+
.eslintcache
4+
5+
6+
# Output of 'npm pack'
7+
*.tgz
8+
9+
# dotenv environment variables file
10+
.env
11+
12+
# next.js build output
13+
.next
14+
15+
*node_modules
16+
.idea
17+
.DS_Store
18+
dist
19+
20+
21+
# yarn v2
22+
.yarn/cache
23+
.yarn/unplugged
24+
.yarn/build-state.yml
25+
.yarn/install-state.gz
26+
.pnp.*

CHANGELOG.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Changelogs
2+
3+
## v0.0.16
4+
5+
- Use `React.memo` for better performance
6+
- Allow passing custom css tag in props
7+
8+
## v0.0.15
9+
10+
- Properly handle `routeChangeError` event
11+
12+
## v0.0.14
13+
14+
### Added
15+
16+
- Added nonce support
17+
- Added autocomplete for advanced options
18+
19+
## v0.0.13
20+
21+
### Fixed
22+
23+
- Fixed react version issue
24+
25+
## v0.0.12
26+
27+
### Updated
28+
29+
- Updated README.md's 'How to use' section to be more clear and consise. Also added further context to Default Config.
30+
- Updated Next.js version to v12
31+
32+
## v0.0.11
33+
34+
### Added
35+
36+
- Added next.js version 11.0.0 in package.json `peerDependancies`.
37+
- Added color highlight to the code in the README.md file.
38+
- Added type of showOnShallow of NextNProgress class in `index.d.ts`.
39+
40+
### Updated
41+
42+
- Upgraded the `next` version to 11.0.0 in `devDependencies`.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Ndungutse Charles
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Next.js Progressbar
2+
3+
A simple Next.js progressbar component using [NProgress](http://ricostacruz.com/nprogress/).
4+
5+
> [I've created this Blog to help you create your own progressbar](https://gosink.in/next-js-make-your-own-progress-bar-indicator-component-easily/)
6+
7+
**Demo**: [https://demo-nextjs-progressbar.vercel.app](https://demo-nextjs-progressbar.vercel.app/)
8+
9+
## How to install?
10+
11+
```bash
12+
npm i nextjs-progressbar
13+
```
14+
15+
## How to use?
16+
17+
After installing the package, import `NextNProgress` in your `pages/_app.js` file:
18+
19+
```js
20+
import NextNProgress from 'nextjs-progressbar';
21+
```
22+
23+
And for rendering add `<NextNProgress />` to your `return()` in `MyApp()`:
24+
25+
```js
26+
import NextNProgress from 'nextjs-progressbar';
27+
28+
export default function MyApp({ Component, pageProps }) {
29+
return (
30+
<>
31+
<NextNProgress />
32+
<Component {...pageProps} />;
33+
</>
34+
);
35+
}
36+
```
37+
38+
### Default Config
39+
40+
If no props are passed to `<NextNProgress />`, below is the default configuration applied.
41+
42+
```jsx
43+
<NextNProgress color="#29D" startPosition={0.3} stopDelayMs={200} height={3} showOnShallow={true} />
44+
```
45+
46+
- `color`: to change the default color of progressbar. You can also use `rgb(,,)` or `rgba(,,,)`.
47+
- `startPosition`: to set the default starting position : `0.3 = 30%`.
48+
- `stopDelayMs`: time for delay to stop progressbar in `ms`.
49+
- `height`: height of progressbar in `px`.
50+
- `showOnShallow`: You can choose whether you want the progressbar to be displayed if you're using shallow routing. It takes a boolean. Learn more about shallow routing [in Next.js docs](https://nextjs.org/docs/routing/shallow-routing).
51+
52+
### Advanced Config
53+
54+
#### Adding nonce
55+
56+
We use internal css in this package. If you are using csp, you can add nonce to the `<style>` tag by providing `nonce` prop to `<NextNProgress />` component.
57+
58+
```jsx
59+
<NextNProgress nonce="my-nonce" />
60+
```
61+
62+
#### Custom CSS
63+
64+
You can use `transformCSS` prop to pass custom css.
65+
**Note:** You must return a `JSX.Element` from the function.
66+
67+
```jsx
68+
<NextNProgress
69+
transformCSS={(css) => {
70+
// css is the default css string. You can modify it and return it or return your own css.
71+
return <style>{css}</style>;
72+
}}
73+
/>
74+
```
75+
76+
#### Other Configs
77+
78+
You can use [other configurations](https://github.com/rstacruz/nprogress#configuration) which NProgress provides by adding a JSON in `options` props.
79+
80+
```jsx
81+
<NextNProgress options={{ easing: 'ease', speed: 500 }} />
82+
```

example/.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "next/core-web-vitals"
3+
}

example/.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env*.local
29+
30+
# vercel
31+
.vercel
32+
33+
# typescript
34+
*.tsbuildinfo
35+
next-env.d.ts

example/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
```
14+
15+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
16+
17+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
18+
19+
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
20+
21+
## Learn More
22+
23+
To learn more about Next.js, take a look at the following resources:
24+
25+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
26+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
27+
28+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
29+
30+
## Deploy on Vercel
31+
32+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
33+
34+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

example/next.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** @type {import('next').NextConfig} */
2+
const nextConfig = {}
3+
4+
module.exports = nextConfig

example/package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "example",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"start": "next start",
9+
"lint": "next lint"
10+
},
11+
"dependencies": {
12+
"@types/node": "20.3.2",
13+
"@types/react": "18.2.14",
14+
"@types/react-dom": "18.2.6",
15+
"eslint": "8.43.0",
16+
"eslint-config-next": "13.4.7",
17+
"next": "13.4.7",
18+
"next13-progressbar": "../",
19+
"react": "18.2.0",
20+
"react-dom": "18.2.0",
21+
"typescript": "5.1.5"
22+
}
23+
}

0 commit comments

Comments
 (0)