-
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from pmndrs/feature/vanilla
uikit vanilla
- Loading branch information
Showing
153 changed files
with
6,530 additions
and
4,874 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body style="margin: 0; overscroll-behavior: none; overflow: hidden;"> | ||
<script type="module" src="./index.ts"></script> | ||
<canvas style="width: 100dvw; height: 100dvh;" id="root"></canvas> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { AmbientLight, PerspectiveCamera, Scene, WebGLRenderer } from 'three' | ||
import { reversePainterSortStable, Container, Root, Image, Text, Svg, Content } from '@pmndrs/uikit' | ||
import { Delete } from '@pmndrs/uikit-lucide' | ||
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js' | ||
import { GLTFLoader } from 'three/examples/jsm/Addons.js' | ||
|
||
// init | ||
|
||
const camera = new PerspectiveCamera(70, 1, 0.01, 100) | ||
camera.position.z = 10 | ||
|
||
const scene = new Scene() | ||
scene.add(new AmbientLight(undefined, 2)) | ||
|
||
const canvas = document.getElementById('root') as HTMLCanvasElement | ||
const controls = new OrbitControls(camera, canvas) | ||
|
||
const renderer = new WebGLRenderer({ antialias: true, canvas }) | ||
|
||
//UI | ||
const root = new Root(camera, renderer, undefined, { | ||
flexDirection: 'row', | ||
gap: 10, | ||
padding: 10, | ||
sizeX: 15, | ||
sizeY: 5, | ||
alignItems: 'center', | ||
backgroundColor: 'red', | ||
}) | ||
scene.add(root) | ||
const c = new Content(root, { height: 100, backgroundColor: 'black' }) | ||
const loader = new GLTFLoader() | ||
loader.load('example.glb', (gltf) => c.setContent(gltf.scene)) | ||
new Delete(root, { width: 100 }) | ||
new Svg(root, 'example.svg', { height: '20%' }) | ||
new Text(root, 'Hello World', { fontSize: 40 }) | ||
new Container(root, { alignSelf: 'stretch', flexGrow: 1, backgroundColor: 'blue' }) | ||
const x = new Container(root, { | ||
padding: 30, | ||
flexGrow: 1, | ||
hover: { backgroundColor: 'yellow' }, | ||
backgroundColor: 'green', | ||
}) | ||
x.dispatchEvent({ type: 'pointerOver', target: x, nativeEvent: { pointerId: 1 } } as any) | ||
new Image(x, 'https://picsum.photos/300/300', { | ||
borderRadius: 1000, | ||
height: '100%', | ||
flexBasis: 0, | ||
flexGrow: 1, | ||
}) | ||
|
||
renderer.setAnimationLoop(animation) | ||
renderer.localClippingEnabled = true | ||
renderer.setTransparentSort(reversePainterSortStable) | ||
|
||
function updateSize() { | ||
renderer.setSize(window.innerWidth, window.innerHeight) | ||
renderer.setPixelRatio(window.devicePixelRatio) | ||
camera.aspect = window.innerWidth / window.innerHeight | ||
camera.updateProjectionMatrix() | ||
} | ||
|
||
updateSize() | ||
window.addEventListener('resize', updateSize) | ||
|
||
// animation | ||
|
||
let prev: number | undefined | ||
function animation(time: number) { | ||
const delta = prev == null ? 0 : time - prev | ||
prev = time | ||
|
||
root.update(delta) | ||
controls.update(delta) | ||
|
||
renderer.render(scene, camera) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"type": "module", | ||
"dependencies": { | ||
"@pmndrs/uikit": "workspace:^", | ||
"@pmndrs/uikit-lucide": "workspace:^", | ||
"react-dom": "^18.2.0", | ||
"three": "^0.161.0" | ||
}, | ||
"scripts": { | ||
"dev": "vite --host" | ||
}, | ||
"devDependencies": { | ||
"@types/three": "^0.161.0" | ||
} | ||
} |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { defineConfig } from 'vite' | ||
import path from 'path' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
resolve: { | ||
alias: [ | ||
{ find: '@', replacement: path.resolve(__dirname, '../../packages/kits/default') }, | ||
{ | ||
find: '@pmndrs/uikit/internals', | ||
replacement: path.resolve(__dirname, '../../packages/uikit/src/internals.ts'), | ||
}, | ||
{ find: '@pmndrs/uikit', replacement: path.resolve(__dirname, '../../packages/uikit/src/index.ts') }, | ||
], | ||
}, | ||
base: '/uikit/examples/vanilla/', | ||
optimizeDeps: { | ||
include: ['@pmndrs/uikit-lucide', '@pmndrs/uikit'], | ||
esbuildOptions: { | ||
target: 'esnext', | ||
}, | ||
}, | ||
build: { | ||
target: 'esnext', | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
icons/* | ||
!.gitkeep | ||
src/* | ||
!.gitkeep |
Oops, something went wrong.