Skip to content

Commit 610ce4a

Browse files
committed
Refactor|Overmind: Refactor CodeFormatting/Prettier to useOvermind
1 parent f7a25a3 commit 610ce4a

File tree

3 files changed

+44
-34
lines changed

3 files changed

+44
-34
lines changed
Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React from 'react';
2-
import { inject, observer } from 'app/componentConnectors';
1+
import React, { FunctionComponent } from 'react';
2+
import { useOvermind } from 'app/overmind';
33

44
import {
55
SubContainer,
@@ -9,16 +9,28 @@ import {
99
Rule,
1010
} from '../../elements';
1111

12-
function PrettierComponent({ store, signals }) {
12+
const PrettierComponent: FunctionComponent = () => {
13+
const {
14+
state: {
15+
preferences: {
16+
settings: { prettierConfig },
17+
},
18+
},
19+
actions: {
20+
preferences: { settingChanged },
21+
},
22+
} = useOvermind();
23+
1324
const bindValue = name => ({
14-
value: store.preferences.settings.prettierConfig[name],
25+
value: prettierConfig[name],
1526
setValue: value =>
16-
signals.preferences.settingChanged({
27+
settingChanged({
1728
name: `prettierConfig.${name}`,
1829
value,
1930
}),
2031
});
2132

33+
const { fluid } = prettierConfig;
2234
return (
2335
<SubContainer>
2436
<PreferenceContainer>
@@ -45,15 +57,15 @@ function PrettierComponent({ store, signals }) {
4557
<Rule />
4658
<PaddedPreference
4759
style={{
48-
opacity: store.preferences.settings.prettierConfig.fluid ? 0.5 : 1,
60+
opacity: fluid ? 0.5 : 1,
4961
}}
5062
title="Print width"
5163
type="number"
5264
{...bindValue('printWidth')}
5365
/>
5466
<SubDescription
5567
style={{
56-
opacity: store.preferences.settings.prettierConfig.fluid ? 0.5 : 1,
68+
opacity: fluid ? 0.5 : 1,
5769
}}
5870
>
5971
Specify the line length that the printer will wrap on.
@@ -143,6 +155,6 @@ function PrettierComponent({ store, signals }) {
143155
</PreferenceContainer>
144156
</SubContainer>
145157
);
146-
}
158+
};
147159

148-
export const Prettier = inject('store', 'signals')(observer(PrettierComponent));
160+
export const Prettier = PrettierComponent;

packages/app/src/app/pages/common/Modals/PreferencesModal/CodeFormatting/index.js

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React, { FunctionComponent } from 'react';
2+
3+
import Question from 'react-icons/lib/go/question';
4+
5+
import { Prettier } from './Prettier';
6+
import { Title } from '../elements';
7+
8+
export const CodeFormatting: FunctionComponent = () => (
9+
<div>
10+
<Title>
11+
Prettier Settings{' '}
12+
<a
13+
href="https://prettier.io/docs/en/options.html"
14+
target="_blank"
15+
rel="noopener noreferrer"
16+
>
17+
<Question style={{ marginBottom: '3px' }} />
18+
</a>
19+
</Title>
20+
21+
<Prettier />
22+
</div>
23+
);

0 commit comments

Comments
 (0)