Skip to content

Commit bf05e38

Browse files
committed
Moved indentation buttons to separate component: Indentations
1 parent 1090379 commit bf05e38

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

src/Formatter/Formatter.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22

33
import Tabs from './Tabs';
4+
import Indentations from './Indentations';
45

56

67

@@ -10,26 +11,19 @@ export default function Formatter ({
1011

1112
let [showOutput, setShowOutput] = React.useState(false);
1213

13-
let indentationItems = settings.indentations.map((v, i) => {
14-
return (
15-
<div className="bg-white text-black text-sm cursor-pointer font-bold px-2 py-1 mr-1 duration-300 hover:bg-slate-700 hover:text-white">
16-
{v.name}
17-
</div>
18-
);
19-
});
20-
2114
let tabsProps = {
2215
showOutput, setShowOutput
2316
};
17+
let indentationsProps = {
18+
settings
19+
};
2420

2521
return (
2622
<div className="Formatter px-4 py-16 bg-slate-300">
2723
<div className="max-w-4xl mx-auto shadow">
2824
<div className="bg-slate-200 flex">
2925
<Tabs {...tabsProps} />
30-
<div className="flex px-4 py-4">
31-
{indentationItems}
32-
</div>
26+
<Indentations {...indentationsProps} />
3327
</div>
3428
<div className="bg-slate-100 px-4 py-4">
3529
<textarea name="" id="" cols="30" rows="10" className="w-full border-2 border-slate-500"></textarea>

src/Formatter/Indentations.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
3+
4+
export default function Indentations ({
5+
settings
6+
}) {
7+
let indentationItems = settings.indentations.map((v, i) => {
8+
return (
9+
<div className="bg-white text-black text-sm cursor-pointer font-bold px-2 py-1 mr-1 duration-300 hover:bg-slate-700 hover:text-white">
10+
{v.name}
11+
</div>
12+
);
13+
});
14+
15+
return (
16+
<div className="flex px-4 py-4">
17+
{indentationItems}
18+
</div>
19+
);
20+
}

0 commit comments

Comments
 (0)