1- import { PreferenceText } from '@codesandbox/common/lib/components/Preference/PreferenceText ' ;
2- import themes from '@codesandbox/common/lib/themes' ;
1+ import React , { FunctionComponent } from 'react ' ;
2+
33import { useOvermind } from 'app/overmind' ;
4- import React from 'react' ;
54
65import {
7- PaddedPreference ,
8- PreferenceContainer ,
9- Rule ,
6+ Title ,
107 SubContainer ,
8+ PreferenceContainer ,
9+ PaddedPreference ,
1110 SubDescription ,
12- Title ,
11+ Rule ,
1312} from '../elements' ;
1413import VSCodePlaceholder from '../VSCodePlaceholder' ;
15- import { BigTitle } from './elements' ;
1614
17- export const Appearance : React . FC = ( ) => {
15+ import { EditorTheme } from './EditorTheme' ;
16+ import { PreferenceText } from './elements' ;
17+
18+ export const Appearance : FunctionComponent = ( ) => {
1819 const {
19- state : {
20- preferences : { settings } ,
21- } ,
2220 actions : {
2321 preferences : { settingChanged } ,
2422 } ,
23+ state : {
24+ preferences : { settings } ,
25+ } ,
2526 } = useOvermind ( ) ;
2627
27- const bindValue = ( name : string , setUndefined ?: boolean ) => ( {
28- value : setUndefined ? settings [ name ] || undefined : settings [ name ] ,
29- setValue : value =>
30- settingChanged ( {
31- name,
32- value,
33- } ) ,
28+ const bindValue = ( name : string ) => ( {
29+ setValue : value => settingChanged ( { name, value } ) ,
30+ value : settings [ name ] ,
3431 } ) ;
35-
3632 const fontOptions = [ 'Menlo' , 'Dank Mono' , 'Source Code Pro' ] ;
37- const themeOptions = themes . map ( t => t . name ) ;
3833
3934 return (
4035 < div >
@@ -48,14 +43,17 @@ export const Appearance: React.FC = () => {
4843 type = "number"
4944 { ...bindValue ( 'fontSize' ) }
5045 />
46+
5147 < Rule />
48+
5249 < PaddedPreference
53- title = "Font Family"
54- type = "dropdown"
5550 options = { [ 'Custom' ] . concat ( fontOptions ) }
5651 placeholder = "Source Code Pro"
52+ title = "Font Family"
53+ type = "dropdown"
5754 { ...bindValue ( 'fontFamily' ) }
5855 />
56+
5957 < SubDescription >
6058 We use{ ' ' }
6159 < a
@@ -67,20 +65,23 @@ export const Appearance: React.FC = () => {
6765 </ a > { ' ' }
6866 as default font, you can also use locally installed fonts
6967 </ SubDescription >
68+
7069 { ! fontOptions . includes ( settings . fontFamily ) && (
7170 < PreferenceText
72- style = { { marginTop : '1rem' } }
73- placeholder = "Enter your custom font"
7471 block
72+ placeholder = "Enter your custom font"
7573 { ...bindValue ( 'fontFamily' ) }
7674 />
7775 ) }
76+
7877 < Rule />
78+
7979 < PaddedPreference
8080 title = "Font Ligatures"
8181 type = "boolean"
8282 { ...bindValue ( 'enableLigatures' ) }
8383 />
84+
8485 < SubDescription >
8586 Whether we should enable{ ' ' }
8687 < a
@@ -92,93 +93,32 @@ export const Appearance: React.FC = () => {
9293 </ a >
9394 .
9495 </ SubDescription >
96+
9597 < Rule />
98+
9699 < PaddedPreference
97- title = "Line Height"
98- type = "number"
99100 placeholder = "1.15"
100101 step = "0.05"
102+ title = "Line Height"
103+ type = "number"
101104 { ...bindValue ( 'lineHeight' ) }
102105 />
106+
103107 < Rule />
108+
104109 < PaddedPreference
105110 title = "Zen Mode"
106111 type = "boolean"
107112 { ...bindValue ( 'zenMode' ) }
108113 />
114+
109115 < SubDescription >
110116 Hide all distracting elements, perfect for lessons and
111117 presentations.
112118 </ SubDescription >
113119 </ VSCodePlaceholder >
114120
115- { settings . experimentVSCode ? (
116- < div >
117- < BigTitle > Editor Theme</ BigTitle >
118- < SubDescription >
119- You can select your editor theme by selecting File { '->' } { ' ' }
120- Preferences { '->' } Color Theme in the menu bar.
121- </ SubDescription >
122- < Rule />
123-
124- < SubDescription style = { { marginBottom : '1rem' } } >
125- Custom VSCode Theme
126- </ SubDescription >
127-
128- < SubDescription style = { { marginBottom : '1rem' } } >
129- After changing this setting you
130- { "'" }
131- ll have to reload the browser and select { '"' }
132- Custom
133- { '"' } as your color theme.
134- </ SubDescription >
135-
136- < PreferenceText
137- isTextArea
138- style = { { fontFamily : 'Source Code Pro' , fontSize : '.8rem' } }
139- block
140- rows = { 7 }
141- placeholder = { `You can use your own theme from VSCode directly:
142- 1. Open VSCode
143- 2. Press (CMD or CTRL) + SHIFT + P
144- 3. Enter: '> Developer: Generate Color Scheme From Current Settings'
145- 4. Copy the contents and paste them here!` }
146- { ...bindValue ( 'manualCustomVSCodeTheme' , true ) }
147- />
148- </ div >
149- ) : (
150- < div >
151- < BigTitle > Editor Theme</ BigTitle >
152-
153- < PaddedPreference
154- title = "VSCode Theme"
155- type = "dropdown"
156- options = { themeOptions }
157- { ...bindValue ( 'editorTheme' ) }
158- />
159- < SubDescription >
160- This will be overwritten if you enter a custom theme.
161- </ SubDescription >
162- < Rule />
163-
164- < SubDescription style = { { marginBottom : '1rem' } } >
165- Custom VSCode Theme
166- </ SubDescription >
167-
168- < PreferenceText
169- isTextArea
170- style = { { fontFamily : 'Source Code Pro' , fontSize : '.8rem' } }
171- block
172- rows = { 7 }
173- placeholder = { `You can use your own theme from VSCode directly:
174- 1. Open VSCode
175- 2. Press (CMD or CTRL) + SHIFT + P
176- 3. Enter: '> Developer: Generate Color Scheme From Current Settings'
177- 4. Copy the contents and paste them here!` }
178- { ...bindValue ( 'customVSCodeTheme' , true ) }
179- />
180- </ div >
181- ) }
121+ < EditorTheme />
182122 </ PreferenceContainer >
183123 </ SubContainer >
184124 </ div >
0 commit comments