@@ -72,15 +72,18 @@ ToolbarButton.propTypes = {
72
72
* Callback to toggle visibility of highlights in the document.
73
73
* @prop {() => any } toggleSidebar -
74
74
* Callback to toggle the visibility of the sidebar.
75
- * @prop {() => any } toggleDoodleability -
76
- * Callback to toggle visibility of highlights in the document.
75
+ * @prop {(object ) => any } setDoodleOptions
76
+ * Callback to set the options of the doodle canvas
77
77
* @prop {import("preact").Ref<HTMLButtonElement> } [toggleSidebarRef] -
78
78
* Ref that gets set to the toolbar button for toggling the sidebar.
79
79
* This is exposed to enable the drag-to-resize functionality of this
80
80
* button.
81
81
* @prop {boolean } [useMinimalControls] -
82
82
* If true, all controls are hidden except for the "Close sidebar" button
83
83
* when the sidebar is open.
84
+ * @prop {boolean } [drawingToolbarActivated]
85
+ *
86
+ * @prop {() => any } drawingToolbarToggle
84
87
*/
85
88
86
89
/**
@@ -97,54 +100,102 @@ export default function Toolbar({
97
100
showHighlights,
98
101
toggleHighlights,
99
102
toggleSidebar,
100
- toggleDoodleability ,
103
+ setDoodleOptions ,
101
104
toggleSidebarRef,
102
105
useMinimalControls = false ,
106
+ drawingToolbarActivated,
107
+ drawingToolbarToggle,
103
108
} ) {
104
- return (
105
- < div >
106
- { useMinimalControls && isSidebarOpen && (
107
- < ToolbarButton
108
- className = "annotator-toolbar__sidebar-close"
109
- label = "Close annotation sidebar"
110
- icon = "cancel"
111
- onClick = { closeSidebar }
112
- />
113
- ) }
114
- { ! useMinimalControls && (
115
- < ToolbarButton
116
- className = "annotator-toolbar__sidebar-toggle"
117
- buttonRef = { toggleSidebarRef }
118
- label = "Annotation sidebar"
119
- icon = { isSidebarOpen ? 'caret-right' : 'caret-left' }
120
- expanded = { isSidebarOpen }
121
- onClick = { toggleSidebar }
122
- />
123
- ) }
124
- { ! useMinimalControls && (
125
- < div className = "annotator-toolbar-buttonbar" >
109
+ if ( ! drawingToolbarActivated ) {
110
+ return (
111
+ < div >
112
+ { useMinimalControls && isSidebarOpen && (
126
113
< ToolbarButton
127
- label = "Show highlights "
128
- icon = { showHighlights ? 'show' : 'hide' }
129
- selected = { showHighlights }
130
- onClick = { toggleHighlights }
114
+ className = "annotator-toolbar__sidebar-close "
115
+ label = "Close annotation sidebar"
116
+ icon = "cancel"
117
+ onClick = { closeSidebar }
131
118
/>
119
+ ) }
120
+ { ! useMinimalControls && (
132
121
< ToolbarButton
133
- label = {
134
- newAnnotationType === 'note' ? 'New page note' : 'New annotation'
135
- }
136
- icon = { newAnnotationType === 'note' ? 'note' : 'annotate' }
137
- onClick = { createAnnotation }
122
+ className = "annotator-toolbar__sidebar-toggle"
123
+ buttonRef = { toggleSidebarRef }
124
+ label = "Annotation sidebar"
125
+ icon = { isSidebarOpen ? 'caret-right' : 'caret-left' }
126
+ expanded = { isSidebarOpen }
127
+ onClick = { toggleSidebar }
138
128
/>
129
+ ) }
130
+ { ! useMinimalControls && (
131
+ < div className = "annotator-toolbar-buttonbar" >
132
+ < ToolbarButton
133
+ label = "Show highlights"
134
+ icon = { showHighlights ? 'show' : 'hide' }
135
+ selected = { showHighlights }
136
+ onClick = { toggleHighlights }
137
+ />
138
+ < ToolbarButton
139
+ label = {
140
+ newAnnotationType === 'note'
141
+ ? 'New page note'
142
+ : 'New annotation'
143
+ }
144
+ icon = { newAnnotationType === 'note' ? 'note' : 'annotate' }
145
+ onClick = { createAnnotation }
146
+ />
147
+ < ToolbarButton
148
+ label = "New Doodle"
149
+ icon = "doodle"
150
+ onClick = { drawingToolbarToggle }
151
+ />
152
+ </ div >
153
+ ) }
154
+ </ div >
155
+ ) ;
156
+ } else {
157
+ return (
158
+ < div >
159
+ { useMinimalControls && isSidebarOpen && (
139
160
< ToolbarButton
140
- label = { 'New Doodle' }
141
- icon = { 'doodle' }
142
- onClick = { toggleDoodleability }
161
+ className = "annotator-toolbar__sidebar-close"
162
+ label = "Close annotation sidebar"
163
+ icon = "cancel"
164
+ onClick = { closeSidebar }
143
165
/>
144
- </ div >
145
- ) }
146
- </ div >
147
- ) ;
166
+ ) }
167
+ { ! useMinimalControls && (
168
+ < ToolbarButton
169
+ className = "annotator-toolbar__sidebar-toggle"
170
+ buttonRef = { toggleSidebarRef }
171
+ label = "Annotation sidebar"
172
+ icon = { isSidebarOpen ? 'caret-right' : 'caret-left' }
173
+ expanded = { isSidebarOpen }
174
+ onClick = { toggleSidebar }
175
+ />
176
+ ) }
177
+ { ! useMinimalControls && (
178
+ < div className = "annotator-toolbar-buttonbar" >
179
+ < ToolbarButton
180
+ label = "Stop doodle"
181
+ icon = "close"
182
+ onClick = { drawingToolbarToggle }
183
+ />
184
+ < ToolbarButton
185
+ label = "Pen"
186
+ icon = "pen"
187
+ onClick = { ( ) => setDoodleOptions ( { tool : 'pen' , size : 7 } ) }
188
+ />
189
+ < ToolbarButton
190
+ label = "Eraser"
191
+ icon = "erase"
192
+ onClick = { ( ) => setDoodleOptions ( { tool : 'eraser' , size : 25 } ) }
193
+ />
194
+ </ div >
195
+ ) }
196
+ </ div >
197
+ ) ;
198
+ }
148
199
}
149
200
150
201
Toolbar . propTypes = {
@@ -158,4 +209,7 @@ Toolbar.propTypes = {
158
209
toggleDoodleability : propTypes . func . isRequired ,
159
210
toggleSidebarRef : propTypes . any ,
160
211
useMinimalControls : propTypes . bool ,
212
+ drawingToolbarActivated : propTypes . bool ,
213
+ drawingToolbarToggle : propTypes . func . isRequired ,
214
+ setDoodleOptions : propTypes . func . isRequired ,
161
215
} ;
0 commit comments