@ -8,7 +8,9 @@ import Slider from './Slider'
import Toggle from './Toggle'
import Toggle from './Toggle'
import WindowPointer from './WindowPointer'
import WindowPointer from './WindowPointer'
import Collapse from './Collapse'
import Collapse from './Collapse'
import { COLORS } from '../lib/constants'
import { COLORS } from '../lib/constants'
import { formatCode } from '../lib/util'
class Settings extends React . Component {
class Settings extends React . Component {
constructor ( props ) {
constructor ( props ) {
@ -17,6 +19,7 @@ class Settings extends React.Component {
isVisible : false
isVisible : false
}
}
this . toggle = this . toggle . bind ( this )
this . toggle = this . toggle . bind ( this )
this . format = this . format . bind ( this )
}
}
toggle ( ) {
toggle ( ) {
@ -27,6 +30,15 @@ class Settings extends React.Component {
this . setState ( { isVisible : false } )
this . setState ( { isVisible : false } )
}
}
format ( ) {
try {
const newCode = formatCode ( this . props . code )
this . props . onChange ( 'code' , newCode )
} catch ( e ) {
// pass, create a toast here in the future.
}
}
render ( ) {
render ( ) {
return (
return (
< div className = "settings-container" >
< div className = "settings-container" >
@ -123,8 +135,10 @@ class Settings extends React.Component {
selected = { this . props . exportSize || '2x' }
selected = { this . props . exportSize || '2x' }
onChange = { this . props . onChange . bind ( null , 'exportSize' ) }
onChange = { this . props . onChange . bind ( null , 'exportSize' ) }
/ >
/ >
< Toggle label = "Prettify code" center = { true } enabled = { false } onChange = { this . format } / >
< Toggle
< Toggle
label = "Reset settings"
label = { < center className = "red" > Reset settings < / c e n t e r > }
center = { true }
enabled = { false }
enabled = { false }
onChange = { this . props . resetDefaultSettings }
onChange = { this . props . resetDefaultSettings }
/ >
/ >
@ -186,6 +200,10 @@ class Settings extends React.Component {
. settings - settings > : global ( . collapse ) {
. settings - settings > : global ( . collapse ) {
border - bottom : none ;
border - bottom : none ;
}
}
. red {
color : red ;
}
` }
` }
< / s t y l e >
< / s t y l e >
< / d i v >
< / d i v >