|
1 | | -import { PreferenceText } from '@codesandbox/common/lib/components/Preference/PreferenceText'; |
2 | | -import themes from '@codesandbox/common/lib/themes'; |
3 | | -import { useOvermind } from 'app/overmind'; |
4 | | -import React from 'react'; |
| 1 | +import React, { FunctionComponent } from 'react'; |
5 | 2 |
|
6 | | -import { |
7 | | - PaddedPreference, |
8 | | - PreferenceContainer, |
9 | | - Rule, |
10 | | - SubContainer, |
11 | | - SubDescription, |
12 | | - Title, |
13 | | -} from '../elements'; |
| 3 | +import { PreferenceContainer, SubContainer, Title } from '../elements'; |
14 | 4 | import VSCodePlaceholder from '../VSCodePlaceholder'; |
15 | | -import { BigTitle } from './elements'; |
16 | 5 |
|
17 | | -export const Appearance: React.FC = () => { |
18 | | - const { |
19 | | - state: { |
20 | | - preferences: { settings }, |
21 | | - }, |
22 | | - actions: { |
23 | | - preferences: { settingChanged }, |
24 | | - }, |
25 | | - } = useOvermind(); |
| 6 | +import { EditorTheme } from './EditorTheme'; |
26 | 7 |
|
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 | | - }), |
34 | | - }); |
| 8 | +export const Appearance: FunctionComponent = () => ( |
| 9 | + <div> |
| 10 | + <Title>Appearance</Title> |
35 | 11 |
|
36 | | - const fontOptions = ['Menlo', 'Dank Mono', 'Source Code Pro']; |
37 | | - const themeOptions = themes.map(t => t.name); |
| 12 | + <SubContainer> |
| 13 | + <PreferenceContainer> |
| 14 | + <VSCodePlaceholder /> |
38 | 15 |
|
39 | | - return ( |
40 | | - <div> |
41 | | - <Title>Appearance</Title> |
42 | | - |
43 | | - <SubContainer> |
44 | | - <PreferenceContainer> |
45 | | - <VSCodePlaceholder> |
46 | | - <PaddedPreference |
47 | | - title="Font Size" |
48 | | - type="number" |
49 | | - {...bindValue('fontSize')} |
50 | | - /> |
51 | | - <Rule /> |
52 | | - <PaddedPreference |
53 | | - title="Font Family" |
54 | | - type="dropdown" |
55 | | - options={['Custom'].concat(fontOptions)} |
56 | | - placeholder="Source Code Pro" |
57 | | - {...bindValue('fontFamily')} |
58 | | - /> |
59 | | - <SubDescription> |
60 | | - We use{' '} |
61 | | - <a |
62 | | - href="https://dank.sh/affiliate?n=cjgw9wi2q7sf20a86q0k176oj" |
63 | | - rel="noreferrer noopener" |
64 | | - target="_blank" |
65 | | - > |
66 | | - Dank Mono |
67 | | - </a>{' '} |
68 | | - as default font, you can also use locally installed fonts |
69 | | - </SubDescription> |
70 | | - {!fontOptions.includes(settings.fontFamily) && ( |
71 | | - <PreferenceText |
72 | | - style={{ marginTop: '1rem' }} |
73 | | - placeholder="Enter your custom font" |
74 | | - block |
75 | | - {...bindValue('fontFamily')} |
76 | | - /> |
77 | | - )} |
78 | | - <Rule /> |
79 | | - <PaddedPreference |
80 | | - title="Font Ligatures" |
81 | | - type="boolean" |
82 | | - {...bindValue('enableLigatures')} |
83 | | - /> |
84 | | - <SubDescription> |
85 | | - Whether we should enable{' '} |
86 | | - <a |
87 | | - href="https://en.wikipedia.org/wiki/Typographic_ligature" |
88 | | - target="_blank" |
89 | | - rel="noopener noreferrer" |
90 | | - > |
91 | | - font ligatures |
92 | | - </a> |
93 | | - . |
94 | | - </SubDescription> |
95 | | - <Rule /> |
96 | | - <PaddedPreference |
97 | | - title="Line Height" |
98 | | - type="number" |
99 | | - placeholder="1.15" |
100 | | - step="0.05" |
101 | | - {...bindValue('lineHeight')} |
102 | | - /> |
103 | | - <Rule /> |
104 | | - <PaddedPreference |
105 | | - title="Zen Mode" |
106 | | - type="boolean" |
107 | | - {...bindValue('zenMode')} |
108 | | - /> |
109 | | - <SubDescription> |
110 | | - Hide all distracting elements, perfect for lessons and |
111 | | - presentations. |
112 | | - </SubDescription> |
113 | | - </VSCodePlaceholder> |
114 | | - |
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 | | - )} |
182 | | - </PreferenceContainer> |
183 | | - </SubContainer> |
184 | | - </div> |
185 | | - ); |
186 | | -}; |
| 16 | + <EditorTheme /> |
| 17 | + </PreferenceContainer> |
| 18 | + </SubContainer> |
| 19 | + </div> |
| 20 | +); |
0 commit comments