Skip to content

Commit

Permalink
Merge pull request #36 from pmndrs/feature/vanilla
Browse files Browse the repository at this point in the history
uikit vanilla
  • Loading branch information
bbohlender authored Apr 5, 2024
2 parents ff6732b + 1639741 commit b3b1d29
Show file tree
Hide file tree
Showing 153 changed files with 6,530 additions and 4,874 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
run: pnpm -F "./packages/**/*" build

- name: Copy README
run: cp ./README.md packages/uikit
run: cp ./README.md packages/react

- name: Gitversion
id: gitversion
Expand All @@ -61,19 +61,27 @@ jobs:
- name: Set publishing config
run: pnpm config set '//registry.npmjs.org/:_authToken' "${{ secrets.NPM_TOKEN }}"

- name: Deploy Uikit Package
- name: Deploy Uikit Vanilla Package
working-directory: ./packages/uikit
run: pnpm publish --access public --no-git-checks --tag ${{ steps.gitversion.outputs.preReleaseLabel == '' && 'latest' || steps.gitversion.outputs.preReleaseLabel }}

- name: Deploy Uikit-Lucide Package
working-directory: ./packages/icons/lucide
- name: Deploy Uikit-Lucide Vanilla Package
working-directory: ./packages/icons/lucide/vanilla
run: pnpm publish --access public --no-git-checks --tag ${{ steps.gitversion.outputs.preReleaseLabel == '' && 'latest' || steps.gitversion.outputs.preReleaseLabel }}

- name: Deploy Uikit React Package
working-directory: ./packages/react
run: pnpm publish --access public --no-git-checks --tag ${{ steps.gitversion.outputs.preReleaseLabel == '' && 'latest' || steps.gitversion.outputs.preReleaseLabel }}

- name: Deploy Uikit-Lucide React Package
working-directory: ./packages/icons/lucide/react
run: pnpm publish --access public --no-git-checks --tag ${{ steps.gitversion.outputs.preReleaseLabel == '' && 'latest' || steps.gitversion.outputs.preReleaseLabel }}

- name: Deploy Uikit-Default Package
- name: Deploy Uikit-Default React Package
working-directory: ./packages/kits/default
run: pnpm publish --access public --no-git-checks --tag ${{ steps.gitversion.outputs.preReleaseLabel == '' && 'latest' || steps.gitversion.outputs.preReleaseLabel }}

- name: Deploy Uikit-Apfel Package
- name: Deploy Uikit-Apfel React Package
working-directory: ./packages/kits/apfel
run: pnpm publish --access public --no-git-checks --tag ${{ steps.gitversion.outputs.preReleaseLabel == '' && 'latest' || steps.gitversion.outputs.preReleaseLabel }}

2 changes: 1 addition & 1 deletion examples/apfel/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default defineConfig({
resolve: {
alias: [
{ find: '@', replacement: path.resolve(__dirname, '../../packages/kits/apfel') },
{ find: '@react-three/uikit', replacement: path.resolve(__dirname, '../../packages/uikit/src/index.ts') },
{ find: '@react-three/uikit', replacement: path.resolve(__dirname, '../../packages/react/src/index.ts') },
],
},
build: {
Expand Down
4 changes: 2 additions & 2 deletions examples/auth/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Fullscreen,
DefaultProperties,
Text,
SvgIconFromText,
Icon,
setPreferredColorScheme,
canvasInputProps,
} from '@react-three/uikit'
Expand Down Expand Up @@ -75,7 +75,7 @@ function AuthenticationPage() {
>
<DefaultProperties color="white">
<Container flexDirection="row" alignItems="center">
<SvgIconFromText
<Icon
text={`<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
Expand Down
10 changes: 5 additions & 5 deletions examples/auth/src/components/user-auth-form.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Container, SvgIconFromText, Text } from '@react-three/uikit'
import { Container, Icon, Text } from '@react-three/uikit'
import {} from '@react-three/uikit-lucide'
import { Input } from '@/input'
import { Button } from '@/button'
import { colors } from '@/theme'
import { Input } from '@/input.js'
import { Button } from '@/button.js'
import { colors } from '@/theme.js'

export function UserAuthForm(props: React.ComponentPropsWithoutRef<typeof Container>) {
return (
Expand Down Expand Up @@ -33,7 +33,7 @@ export function UserAuthForm(props: React.ComponentPropsWithoutRef<typeof Contai
</Container>
</Container>
<Button variant="outline">
<SvgIconFromText
<Icon
marginRight={8}
width={16}
height={16}
Expand Down
2 changes: 1 addition & 1 deletion examples/auth/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default defineConfig({
resolve: {
alias: [
{ find: '@', replacement: path.resolve(__dirname, '../../packages/kits/default') },
{ find: '@react-three/uikit', replacement: path.resolve(__dirname, '../../packages/uikit/src/index.ts') },
{ find: '@react-three/uikit', replacement: path.resolve(__dirname, '../../packages/react/src/index.ts') },
],
},
build: {
Expand Down
2 changes: 1 addition & 1 deletion examples/card/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default defineConfig({
resolve: {
alias: [
{ find: '@', replacement: path.resolve(__dirname, '../../packages/kits/default') },
{ find: '@react-three/uikit', replacement: path.resolve(__dirname, '../../packages/uikit/src/index.ts') },
{ find: '@react-three/uikit', replacement: path.resolve(__dirname, '../../packages/react/src/index.ts') },
],
},
build: {
Expand Down
2 changes: 1 addition & 1 deletion examples/dashboard/src/components/UserNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function UserNav({ open, setOpen }: { open: boolean; setOpen: (open: bool
</Container>
<Switch />
</Container>
<Container>
<Container flexDirection="column">
{notifications.map((notification, index) => (
<Container
key={index}
Expand Down
2 changes: 1 addition & 1 deletion examples/dashboard/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default defineConfig({
resolve: {
alias: [
{ find: '@', replacement: path.resolve(__dirname, '../../packages/kits/default') },
{ find: '@react-three/uikit', replacement: path.resolve(__dirname, '../../packages/uikit/src/index.ts') },
{ find: '@react-three/uikit', replacement: path.resolve(__dirname, '../../packages/react/src/index.ts') },
],
},
build: {
Expand Down
2 changes: 1 addition & 1 deletion examples/default/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default defineConfig({
resolve: {
alias: [
{ find: '@', replacement: path.resolve(__dirname, '../../packages/kits/default') },
{ find: '@react-three/uikit', replacement: path.resolve(__dirname, '../../packages/uikit/src/index.ts') },
{ find: '@react-three/uikit', replacement: path.resolve(__dirname, '../../packages/react/src/index.ts') },
],
},
build: {
Expand Down
2 changes: 1 addition & 1 deletion examples/lucide/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default defineConfig({
resolve: {
alias: [
{ find: '@', replacement: path.resolve(__dirname, '../../packages/kits/default') },
{ find: '@react-three/uikit', replacement: path.resolve(__dirname, '../../packages/uikit/src/index.ts') },
{ find: '@react-three/uikit', replacement: path.resolve(__dirname, '../../packages/react/src/index.ts') },
],
},
build: {
Expand Down
4 changes: 2 additions & 2 deletions examples/market/src/components/menu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button } from '@/button.js'
import { Menubar, MenubarMenu, MenubarTrigger } from '@/menubar.js'
import { Container, SvgIconFromText, Text, getPreferredColorScheme, setPreferredColorScheme } from '@react-three/uikit'
import { Container, Icon, Text, getPreferredColorScheme, setPreferredColorScheme } from '@react-three/uikit'
import { useState } from 'react'
import { Moon, Sun, SunMoon } from '@react-three/uikit-lucide'

Expand All @@ -10,7 +10,7 @@ export function Menu() {
<Menubar borderRadius={0} paddingX={8} lg={{ paddingX: 16 }}>
<MenubarMenu>
<MenubarTrigger>
<SvgIconFromText
<Icon
text='<svg xmlns="http://www.w3.org/2000/svg" width="70" height="50" fill="none" viewBox="0 0 194 50"><path fill="black" d="M17.5 35h15v15h-15V35zm0-17.5h15v15h-15v-15zM0 17.5h15v15H0v-15z"></path><path fill="black" d="M35 0H17.5v15H35v17.5h15V0H35zM77.51 12.546V38h4.425V20.475h.236l7.035 17.45h3.306l7.035-17.413h.236V38h4.425V12.546h-5.643L91.01 30.99h-.299l-7.557-18.444h-5.642zm37.014 25.84c2.996 0 4.785-1.405 5.606-3.009h.149V38h4.325V25.223c0-5.046-4.114-6.563-7.756-6.563-4.014 0-7.097 1.79-8.091 5.27l4.201.597c.448-1.305 1.715-2.424 3.915-2.424 2.088 0 3.232 1.07 3.232 2.946v.075c0 1.292-1.355 1.354-4.723 1.715-3.704.398-7.246 1.504-7.246 5.804 0 3.754 2.746 5.742 6.388 5.742zm1.168-3.307c-1.876 0-3.219-.857-3.219-2.51 0-1.728 1.504-2.449 3.518-2.735 1.181-.161 3.542-.46 4.126-.932v2.25c0 2.125-1.715 3.927-4.425 3.927zM129.128 38h4.499V26.777c0-2.424 1.828-4.14 4.301-4.14.758 0 1.703.137 2.088.262v-4.14a10.817 10.817 0 00-1.616-.123c-2.187 0-4.014 1.243-4.71 3.455h-.199v-3.182h-4.363V38zm13.877 0h4.499v-6.413l1.641-1.753L154.987 38h5.381l-7.83-10.85 7.395-8.24h-5.257l-6.861 7.668h-.311V12.546h-4.499V38zm27.592.373c4.45 0 7.508-2.175 8.303-5.494l-4.201-.472c-.609 1.616-2.1 2.46-4.039 2.46-2.909 0-4.835-1.913-4.873-5.182h13.299v-1.38c0-6.699-4.027-9.645-8.725-9.645-5.468 0-9.036 4.015-9.036 9.906 0 5.991 3.518 9.807 9.272 9.807zm-4.797-11.72c.137-2.437 1.939-4.487 4.623-4.487 2.586 0 4.326 1.889 4.351 4.486H165.8zm26.626-7.744h-3.766v-4.574h-4.499v4.574h-2.71v3.48h2.71v10.615c-.025 3.592 2.585 5.356 5.966 5.257 1.28-.037 2.162-.286 2.647-.447l-.758-3.518a5.616 5.616 0 01-1.318.174c-1.131 0-2.038-.398-2.038-2.212v-9.869h3.766v-3.48z"></path></svg>'
svgWidth={194}
svgHeight={50}
Expand Down
2 changes: 1 addition & 1 deletion examples/market/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default defineConfig({
resolve: {
alias: [
{ find: '@', replacement: path.resolve(__dirname, '../../packages/kits/default') },
{ find: '@react-three/uikit', replacement: path.resolve(__dirname, '../../packages/uikit/src/index.ts') },
{ find: '@react-three/uikit', replacement: path.resolve(__dirname, '../../packages/react/src/index.ts') },
],
},
build: {
Expand Down
13 changes: 12 additions & 1 deletion examples/uikit/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export default function App() {
verticalAlign="bottom"
horizontalAlign="block"
cursor="pointer"
color="white"
>
{t}
more
Expand Down Expand Up @@ -134,10 +135,11 @@ export default function App() {
verticalAlign="center"
horizontalAlign="center"
padding={10}
color="white"
>
Hello World!
</Text>
<Text flexShrink={0} backgroundColor="black" padding={10}>
<Text color="white" flexShrink={0} backgroundColor="black" padding={10}>
Lorem voluptate aliqua est veniam pariatur enim reprehenderit nisi laboris. Tempor sit magna ea
occaecat velit veniam ipsum do deserunt adipisicing labore. Voluptate consectetur Lorem exercitation
laborum do nulla velit sit. Aliqua sit cupidatat excepteur fugiat. Labore proident ea in in ex ad aute
Expand Down Expand Up @@ -177,6 +179,15 @@ export default function App() {
fontSize={100}
color="red"
wordBreak="keep-all"
caretWidth={10}
caretBorderRadius={5}
caretBorder={3}
caretOpacity={0}
caretBorderColor="orange"
selectionOpacity={0}
selectionBorderRadius={5}
selectionBorder={3}
selectionBorderColor="orange"
focus={{ borderRadius: 20 }}
verticalAlign="center"
horizontalAlign="center"
Expand Down
8 changes: 6 additions & 2 deletions examples/uikit/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ export default defineConfig({
plugins: [react()],
resolve: {
alias: [
{ find: '@', replacement: path.resolve(__dirname, '../../packages/kits/default') },
{ find: '@react-three/uikit', replacement: path.resolve(__dirname, '../../packages/uikit/src/index.ts') },
{ find: '@react-three/uikit', replacement: path.resolve(__dirname, '../../packages/react/src/index.ts') },
{
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') },
],
},
optimizeDeps: {
Expand Down
13 changes: 13 additions & 0 deletions examples/vanilla/index.html
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>
77 changes: 77 additions & 0 deletions examples/vanilla/index.ts
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)
}
15 changes: 15 additions & 0 deletions examples/vanilla/package.json
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 added examples/vanilla/public/example.glb
Binary file not shown.
6 changes: 6 additions & 0 deletions examples/vanilla/public/example.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions examples/vanilla/vite.config.ts
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',
},
})
2 changes: 0 additions & 2 deletions packages/icons/lucide/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
icons/*
!.gitkeep
src/*
!.gitkeep
Loading

0 comments on commit b3b1d29

Please sign in to comment.