Skip to content

Commit c9148b8

Browse files
committed
feat: initial commit
0 parents  commit c9148b8

13 files changed

+4238
-0
lines changed

.editorconfig

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
root = true
2+
3+
[*]
4+
ij_html_space_inside_empty_tag = true
5+
max_line_length = 140
6+
end_of_line = lf
7+
insert_final_newline = true
8+
charset = utf-8
9+
indent_style = space
10+
indent_size = 2
11+
trim_trailing_whitespace = true
12+
13+
# quote style
14+
ij_javascript_force_quote_style = true
15+
ij_typescript_force_quote_style = true
16+
ij_javascript_use_double_quotes = false
17+
ij_typescript_use_double_quotes = false
18+
19+
# bracket spacing
20+
ij_javascript_spaces_within_object_literal_braces = true
21+
ij_typescript_spaces_within_object_literal_braces = true
22+
ij_javascript_spaces_within_object_type_braces = true
23+
ij_typescript_spaces_within_object_type_braces = true
24+
25+
# imports
26+
ij_javascript_spaces_within_imports = true
27+
ij_typescript_spaces_within_imports = true
28+
ij_javascript_import_merge_members = true
29+
ij_typescript_import_merge_members = true
30+
ij_javascript_import_sort_members = true
31+
ij_typescript_import_sort_members = true

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Use Node.js LTS
14+
uses: actions/setup-node@v4
15+
with:
16+
node-version: 'lts/*'
17+
cache: npm
18+
19+
- name: Install modules
20+
run: npm install
21+
22+
- name: Type check
23+
run: npm run type-check
24+
25+
- name: Lint
26+
run: npm run lint:check
27+
28+
- name: Format
29+
run: npm run format:check
30+
31+
# - name: Run tests
32+
# run: npm test

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
# production
12+
/build
13+
/dist
14+
15+
# misc
16+
.DS_Store
17+
.env.local
18+
.env.development.local
19+
.env.test.local
20+
.env.production.local
21+
22+
npm-debug.log*
23+
yarn-debug.log*
24+
yarn-error.log*
25+
26+
/.vscode
27+
/.idea

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright © 2025 Jure Rotar
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: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# react-pointer-lock
2+
3+
A lightweight and type-safe React hook for the Pointer Lock API.
4+
5+
## Installation
6+
7+
```shell
8+
npm install react-pointer-lock
9+
```
10+
11+
## Usage
12+
13+
```ts
14+
import { useRef } from 'react';
15+
import { usePointerLock } from 'react-pointer-lock-form';
16+
17+
const MapViewer = () => {
18+
const mapRef = useRef<HTMLDivElement>(null);
19+
const { lock, unlock } = usePointerLock(mapRef);
20+
21+
const position = useRef({ x: 0, y: 0 });
22+
23+
const handleMouseMove = (e: MouseEvent) => {
24+
if(!mapRef.current) {
25+
return;
26+
}
27+
position.current.x += e.movementX;
28+
position.current.y += e.movementY;
29+
mapRef.current.scrollTo(position.current.x, position.current.y);
30+
};
31+
32+
return (
33+
<div
34+
ref={mapRef}
35+
onMouseDown={lock}
36+
onMouseUp={unlock}
37+
onMouseMove={handleMouseMove}
38+
>
39+
...
40+
</div>
41+
);
42+
};
43+
```

biome.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3+
"formatter": {
4+
"useEditorconfig": true,
5+
"formatWithErrors": true,
6+
"attributePosition": "multiline",
7+
"ignore": ["dist"]
8+
},
9+
"linter": {
10+
"rules": {
11+
"a11y": {},
12+
"recommended": true,
13+
"suspicious": {
14+
"noConsole": "error"
15+
},
16+
"correctness": {
17+
"noUnusedVariables": "error",
18+
"noUnusedImports": "error"
19+
},
20+
"style": {
21+
"noNonNullAssertion": "off"
22+
}
23+
},
24+
"ignore": ["dist"]
25+
},
26+
"javascript": {
27+
"formatter": {
28+
"jsxQuoteStyle": "double",
29+
"quoteProperties": "asNeeded",
30+
"semicolons": "always",
31+
"arrowParentheses": "always",
32+
"bracketSpacing": true,
33+
"bracketSameLine": false,
34+
"quoteStyle": "single",
35+
"attributePosition": "multiline",
36+
"trailingCommas": "all"
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)