Bläddra i källkod

Restores selected indicator, removes hook for isSelected on shape

main
Steve Ruiz 4 år sedan
förälder
incheckning
9877c2ff97
3 ändrade filer med 14 tillägg och 15 borttagningar
  1. 1
    2
      components/canvas/canvas.tsx
  2. 4
    6
      components/canvas/shape.tsx
  3. 9
    7
      state/sessions/brush-session.ts

+ 1
- 2
components/canvas/canvas.tsx Visa fil

@@ -56,14 +56,13 @@ export default function Canvas() {
56 56
       onPointerMove={handlePointerMove}
57 57
       onPointerUp={handlePointerUp}
58 58
       onTouchStart={handleTouchStart}
59
-      // onTouchMove={handleTouchMove}
60 59
     >
61 60
       <Defs />
62 61
       {isReady && (
63 62
         <g ref={rGroup}>
64 63
           <BoundsBg />
65 64
           <Page />
66
-          {/* <Selected /> */}
65
+          <Selected />
67 66
           <Bounds />
68 67
           <Handles />
69 68
           <Brush />

+ 4
- 6
components/canvas/shape.tsx Visa fil

@@ -8,8 +8,6 @@ import useShapeEvents from 'hooks/useShapeEvents'
8 8
 import { getShapeStyle } from 'lib/shape-styles'
9 9
 
10 10
 function Shape({ id, isSelecting }: { id: string; isSelecting: boolean }) {
11
-  const isSelected = useSelector((s) => s.values.selectedIds.has(id))
12
-
13 11
   const shape = useSelector(({ data }) => getPage(data).shapes[id])
14 12
 
15 13
   const rGroup = useRef<SVGGElement>(null)
@@ -32,7 +30,7 @@ function Shape({ id, isSelecting }: { id: string; isSelecting: boolean }) {
32 30
   const style = getShapeStyle(shape.style)
33 31
 
34 32
   return (
35
-    <StyledGroup ref={rGroup} isSelected={isSelected} transform={transform}>
33
+    <StyledGroup ref={rGroup} transform={transform}>
36 34
       {isSelecting && (
37 35
         <HoverIndicator
38 36
           as="use"
@@ -86,6 +84,9 @@ const StyledGroup = styled('g', {
86 84
   [`& ${HoverIndicator}`]: {
87 85
     opacity: '0',
88 86
   },
87
+  [`&:hover ${HoverIndicator}`]: {
88
+    opacity: '0.16',
89
+  },
89 90
   variants: {
90 91
     isSelected: {
91 92
       true: {
@@ -103,9 +104,6 @@ const StyledGroup = styled('g', {
103 104
         [`& ${HoverIndicator}`]: {
104 105
           opacity: '0',
105 106
         },
106
-        [`&:hover ${HoverIndicator}`]: {
107
-          opacity: '0.16',
108
-        },
109 107
       },
110 108
     },
111 109
   },

+ 9
- 7
state/sessions/brush-session.ts Visa fil

@@ -1,9 +1,9 @@
1
-import { current } from "immer"
2
-import { Bounds, Data } from "types"
3
-import BaseSession from "./base-session"
4
-import { getShapeUtils } from "lib/shape-utils"
5
-import { getBoundsFromPoints, getShapes } from "utils/utils"
6
-import * as vec from "utils/vec"
1
+import { current } from 'immer'
2
+import { Bounds, Data } from 'types'
3
+import BaseSession from './base-session'
4
+import { getShapeUtils } from 'lib/shape-utils'
5
+import { getBoundsFromPoints, getShapes } from 'utils/utils'
6
+import * as vec from 'utils/vec'
7 7
 
8 8
 export default class BrushSession extends BaseSession {
9 9
   origin: number[]
@@ -25,7 +25,9 @@ export default class BrushSession extends BaseSession {
25 25
     for (let id in snapshot.shapeHitTests) {
26 26
       const test = snapshot.shapeHitTests[id]
27 27
       if (test(brushBounds)) {
28
-        data.selectedIds.add(id)
28
+        if (!data.selectedIds.has(id)) {
29
+          data.selectedIds.add(id)
30
+        }
29 31
       } else if (data.selectedIds.has(id)) {
30 32
         data.selectedIds.delete(id)
31 33
       }

Laddar…
Avbryt
Spara