Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-hyperjump committed Jun 20, 2024
0 parents commit c02a000
Show file tree
Hide file tree
Showing 14 changed files with 8,670 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Code Quality

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm install

- name: Run lint
run: npm run lint

- name: Run unit test
run: npm run test:coverage

- name: Upload coverage
uses: codecov/codecov-action@v4

build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm install

- name: Build package
run: npm run build
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release

on:
release:
types: [published]

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "18.x"
registry-url: https://registry.npmjs.org

- name: Install dependencies
run: npm install

- name: Build package
run: npm run build

- name: Release package
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
coverage
dist
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Contributing

Thanks for considering contributing to this open-source project! We welcome and appreciate any contributions, whether they are bug reports, feature requests, or code changes.

## How to Contribute

1. Fork the repository
2. Create a new branch for your contribution (e.g. `feat/new_feature` or `fix/bug_fix`)
3. Make your changes
4. Commit your changes and push to your fork
5. Create a pull request (PR) against the `main` branch of the main repository
6. Wait for your PR to be reviewed and merged

### Issue Tracking

We use GitHub issues to track bugs and feature requests. If you find a bug or have a feature request, please search the existing issues to see if it has already been reported. If not, please open a new issue.

### Pull Request Guidelines

- Make sure your code is well-documented and follows our existing code style
- Include test cases for any new functionality
- Make sure your code passes all existing tests and linting checks
- Reference any relevant issues in your PR description
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Kevin Hermawan

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.
73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# @hyperjumptech/react-next-pathname

![Minified size](https://img.shields.io/bundlephobia/min/@hyperjumptech/react-next-pathname) ![Test coverage](https://img.shields.io/codecov/c/github/hyperjumptech/react-next-pathname) ![Monthly download](https://img.shields.io/npm/dm/@hyperjumptech/react-next-pathname)

`@hyperjumptech/react-next-pathname` tracks the next pathname immediately when a link is clicked, without waiting for the new page to load. At Hyperjump, we use this to instantly update the sidebar or navigation, making the application feel smooth and fast.

## Installation

To install `@hyperjumptech/react-next-pathname`, run the following command:

**NPM**

```
npm install @hyperjumptech/react-next-pathname
```

**Yarn**

```
yarn add @hyperjumptech/react-next-pathname
```

**pnpm**

```
pnpm add @hyperjumptech/react-next-pathname
```

## Usage

First, wrap your application with the NextPathnameProvider to provide the context to all components:

```tsx
import React from "react";
import { NextPathnameProvider } from "@hyperjumptech/react-next-pathname";

function App({ children }) {
return <NextPathnameProvider>{children}</NextPathnameProvider>;
}

export default App;
```

Then, use the useNextPathname hook to access the next pathname in your components:

```tsx
import { useEffect } from "react";
import { useNextPathname } from "@hyperjumptech/react-next-pathname";

function MyComponent() {
const { nextPathname } = useNextPathname();

useEffect(() => {
if (nextPathname) {
console.log("Next pathname:", nextPathname);
// Perform any side effects or conditional navigation logic here
}
}, [nextPathname]);

return (
<div>
<p>Next pathname: {nextPathname}</p>
<a href="/another-page">Go to another page</a>
</div>
);
}

export default MyComponent;
```

## License

[MIT License](/LICENSE)
18 changes: 18 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.1/schema.json",
"organizeImports": {
"enabled": true
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"ignore": ["dist", "coverage"]
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"ignore": ["dist", "coverage"]
}
}
Loading

0 comments on commit c02a000

Please sign in to comment.