11import React , { FunctionComponent } from 'react' ;
2+
23import { useOvermind } from 'app/overmind' ;
34
45import {
@@ -9,107 +10,112 @@ import {
910 Rule ,
1011} from '../../elements' ;
1112
12- const PrettierComponent : FunctionComponent = ( ) => {
13+ export const Prettier : FunctionComponent = ( ) => {
1314 const {
15+ actions : {
16+ preferences : { settingChanged } ,
17+ } ,
1418 state : {
1519 preferences : {
1620 settings : { prettierConfig } ,
1721 } ,
1822 } ,
19- actions : {
20- preferences : { settingChanged } ,
21- } ,
2223 } = useOvermind ( ) ;
2324
24- const bindValue = name => ( {
25- value : prettierConfig [ name ] ,
25+ const bindValue = ( name : string ) => ( {
2626 setValue : value =>
27- settingChanged ( {
28- name : `prettierConfig.${ name } ` ,
29- value,
30- } ) ,
27+ settingChanged ( { name : `prettierConfig.${ name } ` , value } ) ,
28+ value : prettierConfig [ name ] ,
3129 } ) ;
3230
33- const { fluid } = prettierConfig ;
3431 return (
3532 < SubContainer >
3633 < PreferenceContainer >
3734 < SubDescription >
3835 This configuration can be overridden by a{ ' ' }
3936 < a
4037 href = "https://prettier.io/docs/en/configuration.html"
41- target = "_blank"
4238 rel = "noopener noreferrer"
39+ target = "_blank"
4340 >
4441 .prettierrc
4542 </ a > { ' ' }
4643 JSON file at the root of the sandbox.
4744 </ SubDescription >
45+
4846 < Rule />
47+
4948 < PaddedPreference
5049 title = "Fluid print width"
5150 type = "boolean"
5251 { ...bindValue ( 'fluid' ) }
5352 />
53+
5454 < SubDescription >
5555 Wrap the code based on the editor width.
5656 </ SubDescription >
57+
5758 < Rule />
59+
5860 < PaddedPreference
59- style = { {
60- opacity : fluid ? 0.5 : 1 ,
61- } }
61+ style = { { opacity : prettierConfig . fluid ? 0.5 : 1 } }
6262 title = "Print width"
6363 type = "number"
6464 { ...bindValue ( 'printWidth' ) }
6565 />
66- < SubDescription
67- style = { {
68- opacity : fluid ? 0.5 : 1 ,
69- } }
70- >
66+
67+ < SubDescription style = { { opacity : prettierConfig . fluid ? 0.5 : 1 } } >
7168 Specify the line length that the printer will wrap on.
7269 </ SubDescription >
70+
7371 < Rule />
7472
7573 < PaddedPreference
7674 title = "Tab width"
7775 type = "number"
7876 { ...bindValue ( 'tabWidth' ) }
7977 />
78+
8079 < SubDescription >
8180 Specify the number of spaces per indentation-level.
8281 </ SubDescription >
82+
8383 < Rule />
8484
8585 < PaddedPreference
8686 title = "Use tabs"
8787 type = "boolean"
8888 { ...bindValue ( 'useTabs' ) }
8989 />
90+
9091 < SubDescription >
9192 Indent lines with tabs instead of spaces.
9293 </ SubDescription >
94+
9395 < Rule />
9496
9597 < PaddedPreference
9698 title = "Semicolons"
9799 type = "boolean"
98100 { ...bindValue ( 'semi' ) }
99101 />
102+
100103 < SubDescription >
101104 Print semicolons at the ends of statements.
102105 </ SubDescription >
106+
103107 < Rule />
104108
105109 < PaddedPreference
106110 title = "Use single quotes"
107111 type = "boolean"
108112 { ...bindValue ( 'singleQuote' ) }
109113 />
114+
110115 < SubDescription >
111116 Use { "'" } single{ "'" } quotes instead of { '"' } double{ '"' } quotes.
112117 </ SubDescription >
118+
113119 < Rule />
114120
115121 < PaddedPreference
@@ -118,43 +124,49 @@ const PrettierComponent: FunctionComponent = () => {
118124 options = { [ 'none' , 'es5' , 'all' ] }
119125 { ...bindValue ( 'trailingComma' ) }
120126 />
127+
121128 < SubDescription >
122129 Print trailing commas wherever possible.
123130 </ SubDescription >
131+
124132 < Rule />
125133
126134 < PaddedPreference
127135 title = "Bracket spacing"
128136 type = "boolean"
129137 { ...bindValue ( 'bracketSpacing' ) }
130138 />
139+
131140 < SubDescription >
132141 Print spaces between brackets in object literals.
133142 </ SubDescription >
143+
134144 < Rule />
135145
136146 < PaddedPreference
137147 title = "JSX Brackets"
138148 type = "boolean"
139149 { ...bindValue ( 'jsxBracketSameLine' ) }
140150 />
151+
141152 < SubDescription >
142153 Put the `{ '>' } ` of a multi-line JSX element at the end of the last
143154 line instead of being alone on the next line.
144155 </ SubDescription >
156+
145157 < Rule />
158+
146159 < PaddedPreference
160+ options = { [ 'avoid' , 'always' ] }
147161 title = "Arrow Function Parentheses"
148162 type = "dropdown"
149- options = { [ 'avoid' , 'always' ] }
150163 { ...bindValue ( 'arrowParens' ) }
151164 />
165+
152166 < SubDescription >
153167 Include parentheses around a sole arrow function parameter.
154168 </ SubDescription >
155169 </ PreferenceContainer >
156170 </ SubContainer >
157171 ) ;
158172} ;
159-
160- export const Prettier = PrettierComponent ;
0 commit comments