Skip to content

Commit

Permalink
Small Chores (splinetool#4)
Browse files Browse the repository at this point in the history
* chore: Add prettierrc

* Get rid of unnecessary files

* Fix types

* Remove example/src folder

* Update main path
  • Loading branch information
marcofugaro authored Nov 26, 2021
1 parent 7001ae4 commit 8fbc6b0
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
package.json
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
5 changes: 3 additions & 2 deletions example/src/App.tsx → example/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useRef, useState, useEffect } from 'react';
import { Spline, SplineRef } from '@splinetool/react-spline';
import { SPEObject, SplineEvent } from '@splinetool/runtime';
import { Spline, SplineRef } from '..';
// TODO import these from react-spline
import type { SPEObject, SplineEvent } from '@splinetool/runtime';
import anime from 'animejs';

function App() {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script type="module" src="/main.tsx"></script>
</body>
</html>
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"files": [
"dist"
],
"types": "./dist/index",
"types": "./dist/Spline.d.ts",
"main": "./dist/react-spline.umd.js",
"module": "./dist/react-spline.es.js",
"exports": {
Expand Down
4 changes: 0 additions & 4 deletions src/Spline.css

This file was deleted.

12 changes: 9 additions & 3 deletions src/Spline.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Application } from '@splinetool/runtime';
import './Spline.css';

import {
useEffect,
Expand Down Expand Up @@ -218,8 +217,15 @@ export const Spline = forwardRef<SplineRef, SplineProps>(

return (
<div
className={responsive ? 'spline-responsive' : ''}
style={{ display: `${isLoading ? 'none' : 'flex'}`, ...style }}
style={{
display: `${isLoading ? 'none' : 'flex'}`,
// TODO this is not working, pass this option to Application.ts instead
...(responsive && {
width: '100% !important',
height: '100% !important',
}),
...style,
}}
>
<canvas ref={canvasRef} id={id} />
</div>
Expand Down
1 change: 0 additions & 1 deletion src/index.ts

This file was deleted.

10 changes: 3 additions & 7 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineConfig({
root: 'example',
build: {
lib: {
entry: path.resolve(__dirname, './src/index.ts'),
entry: path.resolve(__dirname, './src/Spline.tsx'),
name: 'react-spline',
fileName: (format) => `react-spline.${format}.js`,
},
Expand All @@ -17,18 +17,14 @@ export default defineConfig({
// into your library
external: ['react', 'react-dom', '@splinetool/runtime'],
output: {
// Override dist folder because root is in the example/ folder
dir: 'dist',
// Provide global variables to use in the UMD build
// for externalized deps
globals: {
react: 'React',
'@splinetool/runtime': 'SPRuntime',
},
dir: 'dist',
assetFileNames: (assetInfo) => {
if (assetInfo.name == 'style.css')
return 'Spline.css';
return assetInfo.name;
},
},
},
},
Expand Down

0 comments on commit 8fbc6b0

Please sign in to comment.