Skip to content

Commit

Permalink
feat: add routes & fabric canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
shiqimei committed Dec 27, 2022
1 parent 3c35759 commit 1257d55
Show file tree
Hide file tree
Showing 18 changed files with 2,463 additions and 6,006 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = {
quotes: ['error', 'single'],
semi: ['error', 'never'],
'react/no-unescaped-entities': ['off'],
'react/jsx-no-target-blank': ['off']
'react/jsx-no-target-blank': ['off'],
'@typescript-eslint/no-explicit-any': ['off']
}
}
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ [email protected] # Update client in development without reloading t

[email protected] # Define static page content in .html files
react-meteor-data # React higher-order component for reactively tracking Meteor data
nathantreid:css-modules
1 change: 1 addition & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ [email protected]
[email protected]
[email protected]
[email protected]
nathantreid:[email protected]
[email protected]
[email protected]
[email protected]
Expand Down
2 changes: 1 addition & 1 deletion client/main.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
body {
padding: 10px;
margin: 0;
font-family: sans-serif;
}
2 changes: 1 addition & 1 deletion client/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
</head>

<body>
<div id="react-target"></div>
<div id="root"></div>
</body>
8 changes: 5 additions & 3 deletions client/main.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from 'react'
import { Meteor } from 'meteor/meteor'
import { render } from 'react-dom'
import { App } from '/imports/ui/App'
import { createRoot } from 'react-dom/client'
import { router } from '../imports/pages/routes'
import { RouterProvider } from 'react-router-dom'

Meteor.startup(() => {
render(<App />, document.getElementById('react-target'))
const root = document.getElementById('root') as HTMLDivElement
createRoot(root).render(<RouterProvider router={router} />)
})
8 changes: 8 additions & 0 deletions imports/pages/board/Board.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.page {
width: 100vw;
height: 100vh;
.canvasContainer {
width: 100%;
height: 100%;
}
}
35 changes: 35 additions & 0 deletions imports/pages/board/Board.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React, { useEffect } from 'react'
import styles from './Board.module.scss'
import { fabric } from 'fabric'

export function Board() {
useEffect(() => {
const canvas = new fabric.Canvas('canvas-container', {
defaultCursor: 'default',
renderOnAddRemove: false,
imageSmoothingEnabled: false,
backgroundColor: '#F8F8F8',
skipOffscreen: true,
preserveObjectStacking: true,
selection: true,
fireRightClick: true
})
const resizeCanvasToFitWindow = () => {
canvas.setWidth(window.innerWidth)
canvas.setHeight(window.innerHeight)
}
resizeCanvasToFitWindow()
window.addEventListener('resize', resizeCanvasToFitWindow)
window.canvas = canvas

return () => {
window.removeEventListener('resize', resizeCanvasToFitWindow)
}
}, [])

return (
<div className={styles.page}>
<canvas id='canvas-container' className={styles.canvasContainer} height='100%' width='100%' />
</div>
)
}
1 change: 1 addition & 0 deletions imports/pages/board/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Board'
14 changes: 14 additions & 0 deletions imports/pages/routes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react'
import { createBrowserRouter } from 'react-router-dom'
import { Board } from './board'

export const router = createBrowserRouter([
{
path: '/',
element: <Board />
},
{
path: 'about',
element: <div>About</div>
}
])
11 changes: 0 additions & 11 deletions imports/ui/App.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions imports/ui/Hello.tsx

This file was deleted.

26 changes: 0 additions & 26 deletions imports/ui/Info.tsx

This file was deleted.

Loading

0 comments on commit 1257d55

Please sign in to comment.