Skip to content

added clear button #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/components/FuncCard.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,30 @@

.modal-width {
width: 70%;
}

.small-btn {
height: 25px;
width: 25px;
position: absolute;
top: 183px;
left: 11px;
opacity: .3;
}

.small-btn i {
position: relative;
bottom: 7px;
font-size: 18px;
}

pre {
width: 100%;
margin-left: 2px;
}

.results-div {
display: flex;
width: 340px;
margin-left: -20px;
}
19 changes: 16 additions & 3 deletions src/components/FuncCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class FuncCard extends Component {
this.handleToggleCode = this.handleToggleCode.bind(this);
this.handleParamsChange = this.handleParamsChange.bind(this);
this.handleRunCode = this.handleRunCode.bind(this);
this.handleClearParams = this.handleClearParams.bind(this);
}

componentDidMount() {
Expand Down Expand Up @@ -54,6 +55,10 @@ class FuncCard extends Component {
this.setState(prevState => ({showCode: !prevState.showCode}));
}

handleClearParams() {
this.setState({params: [], result: "", error: ""})
}

render() {
const {
funcName,
Expand Down Expand Up @@ -91,9 +96,17 @@ class FuncCard extends Component {
onParamsChange={this.handleParamsChange}
onSubmit={this.handleParamSubmit}
/>

<Highlight lang="js" value={callCode} />

<div className="results-div">
<Button
floating
disabled={params.length === 0 && !result}
className='grey darken-3 small-btn'
waves='light'
icon='clear'
onClick={this.handleClearParams}
/>
<Highlight lang="js" value={callCode} />
</div>
<Button onClick={this.handleRunCode}>Run</Button>
<Modal
className="modal-width"
Expand Down
5 changes: 2 additions & 3 deletions src/containers/CardList.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ class CardList extends Component {
data={data}
handleDropdownChange={(e, value) => this.handleDropdownChange(value)}
/>
<Carousel>
{funcCards}
</Carousel>
<Carousel children={funcCards} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't change anything 😞 It doesn't matter how you set the children property, it will end up as props.children in Carousel component. The final result is the same.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't work even if I replace everything in App with example code from https://react-materialize.github.io/#/carousel.


</div>
);
}
Expand Down