Skip to content

Commit

Permalink
chore(react): add dev playground
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Apr 20, 2023
1 parent d18ab8a commit 5c11bd3
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
],
"scripts": {
"build": "unbuild",
"dev": "pnpm -C playground run dev",
"dev:build": "pnpm -C playground run build",
"test:types": "tsc --noEmit"
},
"peerDependencies": {
Expand All @@ -52,6 +54,8 @@
"devDependencies": {
"@types/node": "^18.15.12",
"@types/react": "^18.0.37",
"@types/react-dom": "^18.0.11",
"@vitejs/plugin-react": "^4.0.0-beta.1",
"fast-blurhash": "^1.1.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
19 changes: 19 additions & 0 deletions packages/react/playground/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { LazyImage } from '../src'

function App() {
return (
<>
<div>
<LazyImage
blurhash="LKO2:N%2Tw=w]~RBVZRi};RPxuwH"
data-srcset="image-320w.jpg 320w, image-640w.jpg 640w"
auto-sizes
width="640"
height="640"
/>
</div>
</>
)
}

export default App
12 changes: 12 additions & 0 deletions packages/react/playground/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@unlazy/react</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/main.tsx"></script>
</body>
</html>
9 changes: 9 additions & 0 deletions packages/react/playground/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
9 changes: 9 additions & 0 deletions packages/react/playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
}
}
1 change: 1 addition & 0 deletions packages/react/playground/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
6 changes: 6 additions & 0 deletions packages/react/playground/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

export default defineConfig({
plugins: [react()],
})
5 changes: 3 additions & 2 deletions packages/react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
/* Limit global types to those in the current package */
"typeRoots": ["./node_modules/@types"]
"typeRoots": ["./node_modules/@types"],
"jsx": "react-jsx"
},
"include": ["src"],
"include": ["src", "playground"],
"exclude": ["**/dist"]
}
53 changes: 53 additions & 0 deletions pnpm-lock.yaml

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

0 comments on commit 5c11bd3

Please sign in to comment.