Skip to content

Commit 29d4bcd

Browse files
authored
Merge pull request #59 from variadicjs/clear-button
added clear button
2 parents 3dd18b8 + 8f49b0e commit 29d4bcd

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed

src/components/FuncCard.css

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,30 @@
2323

2424
.modal-width {
2525
width: 70%;
26+
}
27+
28+
.small-btn {
29+
height: 25px;
30+
width: 25px;
31+
position: absolute;
32+
top: 183px;
33+
left: 11px;
34+
opacity: .3;
35+
}
36+
37+
.small-btn i {
38+
position: relative;
39+
bottom: 7px;
40+
font-size: 18px;
41+
}
42+
43+
pre {
44+
width: 100%;
45+
margin-left: 2px;
46+
}
47+
48+
.results-div {
49+
display: flex;
50+
width: 340px;
51+
margin-left: -20px;
2652
}

src/components/FuncCard.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class FuncCard extends Component {
2121
this.handleToggleCode = this.handleToggleCode.bind(this);
2222
this.handleParamsChange = this.handleParamsChange.bind(this);
2323
this.handleRunCode = this.handleRunCode.bind(this);
24+
this.handleClearParams = this.handleClearParams.bind(this);
2425
}
2526

2627
componentDidMount() {
@@ -54,6 +55,10 @@ class FuncCard extends Component {
5455
this.setState(prevState => ({showCode: !prevState.showCode}));
5556
}
5657

58+
handleClearParams() {
59+
this.setState({params: [], result: "", error: ""})
60+
}
61+
5762
render() {
5863
const {
5964
funcName,
@@ -91,9 +96,17 @@ class FuncCard extends Component {
9196
onParamsChange={this.handleParamsChange}
9297
onSubmit={this.handleParamSubmit}
9398
/>
94-
95-
<Highlight lang="js" value={callCode} />
96-
99+
<div className="results-div">
100+
<Button
101+
floating
102+
disabled={params.length === 0 && !result}
103+
className='grey darken-3 small-btn'
104+
waves='light'
105+
icon='clear'
106+
onClick={this.handleClearParams}
107+
/>
108+
<Highlight lang="js" value={callCode} />
109+
</div>
97110
<Button onClick={this.handleRunCode}>Run</Button>
98111
<Modal
99112
className="modal-width"

src/containers/CardList.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ class CardList extends Component {
5656
data={data}
5757
handleDropdownChange={(e, value) => this.handleDropdownChange(value)}
5858
/>
59-
<Carousel>
60-
{funcCards}
61-
</Carousel>
59+
<Carousel children={funcCards} />
60+
6261
</div>
6362
);
6463
}

0 commit comments

Comments
 (0)