Browse Source

Improves default data

main
Steve Ruiz 4 years ago
parent
commit
733acfaf3a
5 changed files with 115 additions and 96 deletions
  1. 1
    0
      components/editor.tsx
  2. 1
    1
      lib/shape-utils/dot.tsx
  3. 6
    1
      lib/shape-utils/polyline.tsx
  4. 106
    93
      state/data.ts
  5. 1
    1
      state/state.ts

+ 1
- 0
components/editor.tsx View File

@@ -7,6 +7,7 @@ import CodePanel from "./code-panel/code-panel"
7 7
 import ControlsPanel from "./controls-panel/controls-panel"
8 8
 import styled from "styles"
9 9
 import StylePanel from "./style-panel/style-panel"
10
+import { useSelector } from "state"
10 11
 
11 12
 export default function Editor() {
12 13
   useKeyboardEvents()

+ 1
- 1
lib/shape-utils/dot.tsx View File

@@ -29,7 +29,7 @@ const dot = registerShapeUtils<DotShape>({
29 29
   },
30 30
 
31 31
   render({ id }) {
32
-    return <DotCircle id={id} cx={0} cy={0} r={4} />
32
+    return <DotCircle id={id} cx={0} cy={0} r={3} />
33 33
   },
34 34
 
35 35
   applyStyles(shape, style) {

+ 6
- 1
lib/shape-utils/polyline.tsx View File

@@ -9,6 +9,7 @@ import {
9 9
   boundsContainPolygon,
10 10
 } from "utils/bounds"
11 11
 import { getBoundsFromPoints, translateBounds } from "utils/utils"
12
+import { colors } from "state/data"
12 13
 
13 14
 const polyline = registerShapeUtils<PolylineShape>({
14 15
   boundsCache: new WeakMap([]),
@@ -24,7 +25,11 @@ const polyline = registerShapeUtils<PolylineShape>({
24 25
       point: [0, 0],
25 26
       points: [[0, 0]],
26 27
       rotation: 0,
27
-      style: {},
28
+      style: {
29
+        strokeWidth: 2,
30
+        strokeLinecap: "round",
31
+        strokeLinejoin: "round",
32
+      },
28 33
       ...props,
29 34
     }
30 35
   },

+ 106
- 93
state/data.ts View File

@@ -1,6 +1,27 @@
1 1
 import { Data, ShapeType } from "types"
2 2
 import shapeUtils from "lib/shape-utils"
3 3
 
4
+export const colors = {
5
+  transparent: "transparent",
6
+  white: "rgba(248, 249, 250, 1.000)",
7
+  lightGray: "rgba(224, 226, 230, 1.000)",
8
+  gray: "rgba(172, 181, 189, 1.000)",
9
+  darkGray: "rgba(52, 58, 64, 1.000)",
10
+  black: "rgba(0,0,0, 1.000)",
11
+  lime: "rgba(115, 184, 23, 1.000)",
12
+  green: "rgba(54, 178, 77, 1.000)",
13
+  teal: "rgba(9, 167, 120, 1.000)",
14
+  cyan: "rgba(14, 152, 173, 1.000)",
15
+  blue: "rgba(28, 126, 214, 1.000)",
16
+  indigo: "rgba(66, 99, 235, 1.000)",
17
+  violet: "rgba(112, 72, 232, 1.000)",
18
+  grape: "rgba(174, 62, 200, 1.000)",
19
+  pink: "rgba(214, 51, 108, 1.000)",
20
+  red: "rgba(240, 63, 63, 1.000)",
21
+  orange: "rgba(247, 103, 6, 1.000)",
22
+  yellow: "rgba(245, 159, 0, 1.000)",
23
+}
24
+
4 25
 export const defaultDocument: Data["document"] = {
5 26
   pages: {
6 27
     page0: {
@@ -9,94 +30,107 @@ export const defaultDocument: Data["document"] = {
9 30
       name: "Page 0",
10 31
       childIndex: 0,
11 32
       shapes: {
12
-        rayShape: shapeUtils[ShapeType.Ray].create({
13
-          id: "rayShape",
14
-          name: "Ray",
33
+        shape3: shapeUtils[ShapeType.Dot].create({
34
+          id: "shape3",
35
+          name: "Shape 3",
15 36
           childIndex: 3,
16
-          point: [300, 300],
17
-          direction: [0.5, 0.5],
37
+          point: [400, 500],
38
+          style: {
39
+            stroke: colors.black,
40
+            fill: colors.lightGray,
41
+            strokeWidth: 1,
42
+          },
18 43
         }),
19
-        // shape3: shapeUtils[ShapeType.Dot].create({
20
-        //   id: "shape3",
21
-        //   name: "Shape 3",
22
-        //   childIndex: 3,
23
-        //   point: [400, 500],
24
-        //   style: {
25
-        //     fill: "#AAA",
26
-        //     stroke: "#c6cacb",
27
-        //     strokeWidth: 1,
28
-        //   },
29
-        // }),
30 44
         shape0: shapeUtils[ShapeType.Circle].create({
31 45
           id: "shape0",
32 46
           name: "Shape 0",
33 47
           childIndex: 1,
34 48
           point: [100, 600],
35 49
           radius: 50,
50
+          style: {
51
+            stroke: colors.black,
52
+            fill: colors.lightGray,
53
+            strokeWidth: 1,
54
+          },
36 55
         }),
37 56
         shape5: shapeUtils[ShapeType.Ellipse].create({
38 57
           id: "shape5",
39 58
           name: "Shape 5",
40 59
           childIndex: 5,
41
-          point: [400, 600],
60
+          point: [200, 200],
61
+          radiusX: 50,
62
+          radiusY: 100,
63
+          style: {
64
+            stroke: colors.black,
65
+            fill: colors.lightGray,
66
+            strokeWidth: 1,
67
+          },
68
+        }),
69
+        shape7: shapeUtils[ShapeType.Ellipse].create({
70
+          id: "shape7",
71
+          name: "Shape 7",
72
+          childIndex: 7,
73
+          point: [100, 100],
42 74
           radiusX: 50,
43 75
           radiusY: 30,
76
+          style: {
77
+            stroke: colors.black,
78
+            fill: colors.lightGray,
79
+            strokeWidth: 1,
80
+          },
81
+        }),
82
+        shape6: shapeUtils[ShapeType.Line].create({
83
+          id: "shape6",
84
+          name: "Shape 6",
85
+          childIndex: 1,
86
+          point: [400, 400],
87
+          direction: [0.2, 0.2],
88
+          style: {
89
+            stroke: colors.black,
90
+            fill: colors.lightGray,
91
+            strokeWidth: 1,
92
+          },
93
+        }),
94
+        rayShape: shapeUtils[ShapeType.Ray].create({
95
+          id: "rayShape",
96
+          name: "Ray",
97
+          childIndex: 3,
98
+          point: [300, 100],
99
+          direction: [0.5, 0.5],
100
+          style: {
101
+            stroke: colors.black,
102
+            fill: colors.lightGray,
103
+            strokeWidth: 1,
104
+          },
105
+        }),
106
+        shape2: shapeUtils[ShapeType.Polyline].create({
107
+          id: "shape2",
108
+          name: "Shape 2",
109
+          childIndex: 2,
110
+          point: [200, 600],
111
+          points: [
112
+            [0, 0],
113
+            [75, 200],
114
+            [100, 50],
115
+          ],
116
+          style: {
117
+            stroke: colors.black,
118
+            fill: colors.transparent,
119
+            strokeWidth: 1,
120
+          },
121
+        }),
122
+        shape1: shapeUtils[ShapeType.Rectangle].create({
123
+          id: "shape1",
124
+          name: "Shape 1",
125
+          childIndex: 1,
126
+          point: [400, 600],
127
+          size: [200, 200],
128
+          style: {
129
+            stroke: colors.black,
130
+            fill: colors.lightGray,
131
+            strokeWidth: 1,
132
+          },
44 133
         }),
45
-        // shape7: shapeUtils[ShapeType.Ellipse].create({
46
-        //   id: "shape7",
47
-        //   name: "Shape 7",
48
-        //   childIndex: 7,
49
-        //   point: [100, 100],
50
-        //   radiusX: 50,
51
-        //   radiusY: 30,
52
-        //   style: {
53
-        //     fill: "#AAA",
54
-        //     stroke: "#c6cacb",
55
-        //     strokeWidth: 1,
56
-        //   },
57
-        // }),
58
-        // shape2: shapeUtils[ShapeType.Polyline].create({
59
-        //   id: "shape2",
60
-        //   name: "Shape 2",
61
-        //   childIndex: 2,
62
-        //   point: [200, 600],
63
-        //   points: [
64
-        //     [0, 0],
65
-        //     [75, 200],
66
-        //     [100, 50],
67
-        //   ],
68
-        //   style: {
69
-        //     fill: "none",
70
-        //     stroke: "#c6cacb",
71
-        //     strokeWidth: 2,
72
-        //     strokeLinecap: "round",
73
-        //     strokeLinejoin: "round",
74
-        //   },
75
-        // }),
76
-        // shape1: shapeUtils[ShapeType.Rectangle].create({
77
-        //   id: "shape1",
78
-        //   name: "Shape 1",
79
-        //   childIndex: 1,
80
-        //   point: [400, 600],
81
-        //   size: [200, 200],
82
-        //   style: {
83
-        //     fill: "#AAA",
84
-        //     stroke: "#c6cacb",
85
-        //     strokeWidth: 1,
86
-        //   },
87
-        // }),
88
-        // shape6: shapeUtils[ShapeType.Line].create({
89
-        //   id: "shape6",
90
-        //   name: "Shape 6",
91
-        //   childIndex: 1,
92
-        //   point: [400, 400],
93
-        //   direction: [0.2, 0.2],
94
-        //   style: {
95
-        //     fill: "#AAA",
96
-        //     stroke: "#c6cacb",
97
-        //     strokeWidth: 1,
98
-        //   },
99
-        // }),
100 134
       },
101 135
     },
102 136
   },
@@ -137,24 +171,3 @@ new Polyline({
137 171
     },
138 172
   },
139 173
 }
140
-
141
-export const colors = {
142
-  transparent: "transparent",
143
-  white: "rgba(248, 249, 250, 1.000)",
144
-  lightGray: "rgba(224, 226, 230, 1.000)",
145
-  gray: "rgba(172, 181, 189, 1.000)",
146
-  darkGray: "rgba(52, 58, 64, 1.000)",
147
-  black: "rgba(0,0,0, 1.000)",
148
-  lime: "rgba(115, 184, 23, 1.000)",
149
-  green: "rgba(54, 178, 77, 1.000)",
150
-  teal: "rgba(9, 167, 120, 1.000)",
151
-  cyan: "rgba(14, 152, 173, 1.000)",
152
-  blue: "rgba(28, 126, 214, 1.000)",
153
-  indigo: "rgba(66, 99, 235, 1.000)",
154
-  violet: "rgba(112, 72, 232, 1.000)",
155
-  grape: "rgba(174, 62, 200, 1.000)",
156
-  pink: "rgba(214, 51, 108, 1.000)",
157
-  red: "rgba(240, 63, 63, 1.000)",
158
-  orange: "rgba(247, 103, 6, 1.000)",
159
-  yellow: "rgba(245, 159, 0, 1.000)",
160
-}

+ 1
- 1
state/state.ts View File

@@ -94,7 +94,7 @@ const state = createState({
94 94
     loading: {
95 95
       on: {
96 96
         MOUNTED: {
97
-          do: "restoreSavedData",
97
+          do: ["restoreSavedData", "zoomCameraToFit"],
98 98
           to: "ready",
99 99
         },
100 100
       },

Loading…
Cancel
Save