@@ -36,9 +36,6 @@ import download from "downloadjs";
3636// misc utilities
3737import { getShapeId } from "../../utils/misc" ;
3838
39- // Radios
40- import { Radios } from ".." ;
41-
4239// Component
4340const ExportShape = ( { show, setShow, shape } ) => {
4441 console . log ( { shape } ) ;
@@ -85,6 +82,13 @@ const ExportShape = ({ show, setShow, shape }) => {
8582 console . log ( { exportData} ) ;
8683 } ;
8784
85+ const setExportType = value => {
86+ setExportData ( {
87+ ...exportData ,
88+ 'type' : value
89+ } ) ;
90+ }
91+
8892 // Export method
8993 const doExport = ( id , name ) => {
9094 console . log ( `Save as ${ exportData . type } ` ) ;
@@ -146,7 +150,7 @@ const ExportShape = ({ show, setShow, shape }) => {
146150 < Row >
147151 < Col >
148152 < Form >
149- < Form . Group className = "mb-3" controlId = "export-name" >
153+ < Form . Group className = "mb-3" id = "export-name" >
150154 < Form . Label > Name</ Form . Label >
151155 < Form . Control type = "text" name = "name" value = { exportData . name } onChange = { handleChange } />
152156 </ Form . Group >
@@ -162,8 +166,8 @@ const ExportShape = ({ show, setShow, shape }) => {
162166 />
163167 </ Form . Group >
164168 < Row >
165- < Form . Group as = { Col } controlId = "export-width" >
166- < Form . Label > Set a width(in px)</ Form . Label >
169+ < Form . Group as = { Col } id = "export-width" >
170+ < Form . Label > Set a width({ exportData . width } px)</ Form . Label >
167171 < Form . Control
168172 type = "range"
169173 min = "100"
@@ -173,8 +177,8 @@ const ExportShape = ({ show, setShow, shape }) => {
173177 name = "width"
174178 onChange = { handleChange } />
175179 </ Form . Group >
176- < Form . Group as = { Col } controlId = "export-height" >
177- < Form . Label > Set a height(in px)</ Form . Label >
180+ < Form . Group as = { Col } id = "export-height" >
181+ < Form . Label > Set a height({ exportData . height } px)</ Form . Label >
178182 < Form . Control
179183 type = "range"
180184 min = "100"
@@ -186,78 +190,24 @@ const ExportShape = ({ show, setShow, shape }) => {
186190 </ Form . Group >
187191 </ Row >
188192
189- { /* <div>
190- <label htmlFor="export-name">Name</label>
191- <input
192- type="text"
193- name="name"
194- id="export-name"
195- value={exportData.name}
196- onChange={handleChange} />
197- </div> */ }
198-
199- { /* <div>
200- <label htmlFor="export-color">Color</label>
201- <input
202- type="color"
203- name="backgroundColor"
204- id="export-color"
205- value={exportData.backgroundColor}
206- onChange={handleChange} />
207- </div> */ }
208-
209- { /* <div>
210- <label htmlFor="export-width">Set a width(in px)</label>
211- <input
212- type="range"
213- min="100"
214- max="700"
215- value={exportData.width}
216- id="export-width"
217- name="width"
218- onChange={handleChange} />
219-
220- <label htmlFor="export-height">Set a height(in px)</label>
221- <input
222- type="range"
223- min="100"
224- max="700"
225- value={exportData.height}
226- id="export-height"
227- name="height"
228- onChange={handleChange} />
229- </div> */ }
230-
231193 < div >
232- < Form . Group >
233- < Form . Label > File Format</ Form . Label >
234- < div >
235- < ToggleButtonGroup type = "radio" name = "options" defaultValue = { 1 } variant = "outline-dark" size = "sm" defaultValue = { 'png' } >
236- < ToggleButton id = "tbg-radio-1" value = { 'png' } variant = "outline-dark" >
237- PNG
238- </ ToggleButton >
239- < ToggleButton id = "tbg-radio-2" value = { 'jpeg' } variant = "outline-dark" >
240- JPEG
241- </ ToggleButton >
242- < ToggleButton id = "tbg-radio-3" value = { 'svg' } variant = "outline-dark" >
243- SVG
244- </ ToggleButton >
245- </ ToggleButtonGroup >
246- </ div >
247- </ Form . Group >
248- < Radios
249- groupName = "type"
250- heading = "Export as:"
251- options = { [
252- { value : "png" , displayValue : "PNG" } ,
253- { value : "jpeg" , displayValue : "JPEG" } ,
254- { value : "svg" , displayValue : "SVG" } ,
255- ] }
256- selectedOption = { exportData . type }
257- onValueChange = { handleChange }
258- />
259- </ div >
260-
194+ < Form . Group >
195+ < Form . Label > Export As</ Form . Label >
196+ < div >
197+ < ToggleButtonGroup type = "radio" name = "options" defaultValue = { 1 } variant = "outline-dark" size = "sm" defaultValue = { exportData . type } >
198+ < ToggleButton id = "tbg-radio-1" value = { 'png' } variant = "outline-dark" onClick = { ( ) => setExportType ( 'png' ) } >
199+ PNG
200+ </ ToggleButton >
201+ < ToggleButton id = "tbg-radio-2" value = { 'jpeg' } variant = "outline-dark" onClick = { ( ) => setExportType ( 'jpeg' ) } >
202+ JPEG
203+ </ ToggleButton >
204+ < ToggleButton id = "tbg-radio-3" value = { 'svg' } variant = "outline-dark" onClick = { ( ) => setExportType ( 'svg' ) } >
205+ SVG
206+ </ ToggleButton >
207+ </ ToggleButtonGroup >
208+ </ div >
209+ </ Form . Group >
210+ </ div >
261211 </ Form >
262212 </ Col >
263213 < Col >
@@ -277,7 +227,7 @@ const ExportShape = ({ show, setShow, shape }) => {
277227 </ Modal . Body >
278228
279229 < Modal . Footer >
280- < Button variant = "outline-info" >
230+ < Button variant = "outline-info" onClick = { ( ) => setShow ( false ) } >
281231 Cancel
282232 </ Button >
283233 < Button variant = "secondary"
0 commit comments