Skip to content

Commit

Permalink
Merge pull request #1 from posaune0423/feat/use-deno
Browse files Browse the repository at this point in the history
feat: use deno for sample
  • Loading branch information
posaune0423 authored Dec 10, 2024
2 parents 371c54a + 7800136 commit 7a7e921
Show file tree
Hide file tree
Showing 23 changed files with 628 additions and 3,011 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ Try [Demo](https://use-haptic.vercel.app) here !!!!! 👈🏻

```bash
npm install use-haptic
yarn add use-haptic
pnpm add use-haptic
bun add use-haptic
```

## Quick start
Expand Down Expand Up @@ -61,11 +58,11 @@ VITE v5.4.6 ready in 102 ms
## Usage

```tsx
import { useHaptic } from "use-haptic";
import { useHaptic } from 'use-haptic'

function VibrationButton() {
const { vibe } = useHaptic();
return <button onClick={vibe}>Vibe</button>;
const { vibe } = useHaptic()
return <button onClick={vibe}>Vibe</button>
}
```

Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "use-haptic",
"version": "1.0.1",
"version": "1.0.2",
"description": "Hooks for Haptic Feedback for mobile web",
"scripts": {
"lint": "biome check .",
Expand Down
1 change: 1 addition & 0 deletions sample/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ lerna-debug.log*
node_modules
dist
dist-ssr
.vite
*.local

# Editor directories and files
Expand Down
3 changes: 3 additions & 0 deletions sample/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["denoland.vscode-deno"]
}
51 changes: 10 additions & 41 deletions sample/README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,19 @@
# React + TypeScript + Vite
# Vite + Deno + React + TypeScript

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
## Running

Currently, two official plugins are available:
You need to have Deno v2.0.0 or later installed to run this repo.

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
Start a dev server:

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
export default tseslint.config({
languageOptions: {
// other options...
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
},
})
```
$ deno task dev
```

- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
- Optionally add `...tseslint.configs.stylisticTypeChecked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:
## Deploy

```js
// eslint.config.js
import react from 'eslint-plugin-react'
Build production assets:

export default tseslint.config({
// Set the react version
settings: { react: { version: '18.3' } },
plugins: {
// Add the react plugin
react,
},
rules: {
// other rules...
// Enable its recommended rules
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
},
})
```
$ deno task build
```
25 changes: 25 additions & 0 deletions sample/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"tasks": {
"dev": "deno run -A --node-modules-dir npm:vite",
"build": "deno run -A --node-modules-dir npm:vite build",
"preview": "deno run -A --node-modules-dir npm:vite preview",
"serve": "deno run --allow-net --allow-read jsr:@std/http@1/file-server dist/"
},
"compilerOptions": {
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"jsx": "react-jsx",
"jsxImportSource": "react",
"jsxImportSourceTypes": "@types/react"
},
"nodeModulesDir": "auto",
"imports": {
"@deno/vite-plugin": "npm:@deno/vite-plugin@^1.0.0",
"@types/react": "npm:@types/react@^18.3.12",
"@types/react-dom": "npm:@types/react-dom@^18.3.1",
"@vitejs/plugin-react-swc": "npm:@vitejs/plugin-react-swc@^3.7.1",
"react": "npm:react@^18.3.1",
"react-dom": "npm:react-dom@^18.3.1",
"use-haptic": "npm:use-haptic@^1.0.1",
"vite": "npm:vite@^6.0.1"
}
}
Loading

0 comments on commit 7a7e921

Please sign in to comment.