Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
giulioz committed Apr 9, 2023
0 parents commit 8d2ba63
Show file tree
Hide file tree
Showing 26 changed files with 13,320 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
node_modules/
storybook-static/
71 changes: 71 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"env": {
"browser": true,
"shared-node-browser": true,
"es6": true,
"node": true
},
"extends": [
"prettier",
"plugin:prettier/recommended",
"plugin:react-hooks/recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"plugins": ["@typescript-eslint", "react", "prettier", "react-hooks", "import"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"ecmaVersion": 2018,
"jsx": true
},
"sourceType": "module"
},
"rules": {
"curly": ["error", "multi-line", "consistent"],
"no-console": "off",
"no-empty-pattern": "error",
"no-duplicate-imports": "error",
"prefer-const": "error",
"import/no-unresolved": ["error", { "commonjs": true, "amd": true }],
"import/export": "error",
"import/named": "off",
"import/no-named-as-default": "off",
"import/no-named-as-default-member": "off",
"import/namespace": "off",
"import/default": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"no-unused-vars": ["off"],
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error",
"react-hooks/exhaustive-deps": "off",
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }],
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off"
},
"settings": {
"react": {
"version": "detect"
},
"import/extensions": [".js", ".jsx", ".ts", ".tsx"],
"import/parsers": {
"@typescript-eslint/parser": [".js", ".jsx", ".ts", ".tsx"]
},
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx", ".json"],
"paths": ["src"]
}
}
},
"overrides": [
{
"files": ["src"],
"parserOptions": {
"project": ["./tsconfig.json", "./storybook/tsconfig.json"]
}
}
]
}
60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: release
on:
push:
branches:
- 'master'
- 'beta'
- 'alpha'
pull_request: {}
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout repo
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '14.x'
- name: Install deps
# this runs a build script so there is no dedicated build
run: yarn install
- name: Run storybook build script
run: yarn build-storybook
release:
needs: main
runs-on: ubuntu-latest
if: ${{ github.repository == 'buildwithflux/text-engine' && contains('refs/heads/master,refs/heads/beta,refs/heads/alpha',github.ref) && github.event_name == 'push' }}
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout repo
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '14.x'
- name: Install deps
# this runs a build script so there is no dedicated build
run: yarn install
- name: 🚀 Release
uses: cycjimmy/semantic-release-action@v2
with:
semantic_version: 17
extra_plugins: |
@semantic-release/git
branches: |
[
'master',
{name: 'beta', prerelease: true},
{name: 'alpha', prerelease: true}
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
node_modules/
coverage/
dist/
build/
types/
storybook-static/
Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
.DS_Store
.vscode
.docz/
package-lock.json
coverage/
.idea
yarn-error.log
.size-snapshot.json
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit $1
5 changes: 5 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install pretty-quick --staged
npm run eslint:ci --quiet
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.storybook
storybook-static
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
storybook-static/
*.typeface.json
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": false,
"trailingComma": "es5",
"singleQuote": true,
"tabWidth": 2,
"printWidth": 120,
"useTabs": false
}
29 changes: 29 additions & 0 deletions .storybook/Setup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as React from 'react'
import { Vector3 } from 'three'
import { Canvas, Props as CanvasProps } from '@react-three/fiber'

type Props = React.PropsWithChildren<
CanvasProps & {
cameraFov?: number
cameraPosition?: Vector3
lights?: boolean
}
>

export const Setup = ({
children,
cameraFov = 75,
cameraPosition = new Vector3(-5, 5, 5),
lights = true,
...restProps
}: Props) => (
<Canvas shadows camera={{ position: cameraPosition, fov: cameraFov }} {...restProps}>
{children}
{lights && (
<>
<ambientLight intensity={0.8} />
<pointLight intensity={1} position={[0, 6, 0]} />
</>
)}
</Canvas>
)
57 changes: 57 additions & 0 deletions .storybook/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
html,
body,
#root {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
overflow: hidden;
background-color: #121212;
}

#root {
overflow: auto;
}

.html-story-block {
color: white;
width: 120px;
position: relative;
margin-left: 100px;
}

.html-story-block.margin300 {
margin-left: 300px;
}

.html-story-block:before {
content: '';
display: block;
position: absolute;

top: 50%;
left: -60px;

width: 60px;
height: 1px;
background-color: white;
}

.html-story-label {
background-color: white;
color: black;
display: flex;
align-items: center;
justify-content: center;
padding: 8px;
}

.html-story-label-B {
font-size: 50px;
}
29 changes: 29 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { resolve } from 'path'

export default {
staticDirs: ['./public'],
stories: ['./stories/**/*.stories.{ts,tsx}'],
addons: [
'@storybook/addon-controls',
'@storybook/addon-knobs',
'@storybook/addon-actions',
'@storybook/addon-storysource',
],
typescript: {
check: true,
},
// https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-implicit-postcss-loader
features: {
postcss: false,
},
webpackFinal: (config) => {
config.module.rules.push({
test: /\.(glsl|vs|fs|vert|frag)$/,
exclude: /node_modules/,
use: ['raw-loader', 'glslify-loader'],
include: resolve(__dirname, '../'),
})

return config
},
}
8 changes: 8 additions & 0 deletions .storybook/manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { addons } from '@storybook/addons'
import theme from './theme'

addons.setConfig({
theme,
panelPosition: 'right',
showPanel: true,
})
14 changes: 14 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react'
import './index.css'

export const parameters = {
layout: 'fullscreen',
}

export const decorators = [
(Story) => (
<React.Suspense fallback={null}>
<Story />
</React.Suspense>
),
]
22 changes: 22 additions & 0 deletions .storybook/stories/Test.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as React from 'react'
import { withKnobs } from '@storybook/addon-knobs'
import { Vector3 } from 'three'

import { Setup } from '../Setup'

export default {
title: 'Test',
decorators: [withKnobs, (storyFn) => <Setup cameraPosition={new Vector3(2, 2, 2)}>{storyFn()}</Setup>],
}

function TestScene() {
return (
<mesh>
<boxBufferGeometry />
<meshBasicMaterial />
</mesh>
)
}

export const TestSt = () => <TestScene />
TestSt.storyName = 'Default'
6 changes: 6 additions & 0 deletions .storybook/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { create } from '@storybook/theming/create'

export default create({
base: 'light',
appBg: 'white',
})
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Flux

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# test-engine

## Acknowledgements

- drei for the library setup
Loading

0 comments on commit 8d2ba63

Please sign in to comment.