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
[WIP] Add support for Bootstrap 4.2's Toasts feature (unfinished PR. feedback welcome) #1384
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c066f28
Toasts: unfinished commit working towards adding Toasts for ticket #1346
hcharley 3f21262
cruft: remove vscode settings
hcharley 89f1d2d
Merge branch 'master' into toasts
hcharley 2a29f42
Merge branch 'master' into toasts
hcharley d48c437
Merge branch 'master' into toasts
hcharley e9da8d5
Merge branch 'master' into toasts
hcharley af1bbe4
Merge branch 'master' into toasts
hcharley c3978dd
Merge branch 'master' into toasts
hcharley File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* eslint react/no-multi-comp: 0, react/prop-types: 0 */ | ||
import React from 'react'; | ||
import { PrismCode } from 'react-prism'; | ||
import PageTitle from '../UI/PageTitle'; | ||
import SectionTitle from '../UI/SectionTitle'; | ||
|
||
import ToastExample from '../examples/Toast'; | ||
const ToastExampleSource = require('!!raw-loader!../examples/Toast'); | ||
|
||
import ToastBodyExample from '../examples/ToastBody'; | ||
const ToastBodyExampleSource = require('!!raw-loader!../examples/ToastBody'); | ||
|
||
import ToastHeaderIconExample from '../examples/ToastHeaderIcon'; | ||
const ToastHeaderIconExampleSource = require('!!raw-loader!../examples/ToastHeaderIcon'); | ||
|
||
import ToastDismissExample from '../examples/ToastDismiss'; | ||
const ToastDismissExampleSource = require('!!raw-loader!../examples/ToastDismiss'); | ||
|
||
import AlertUncontrolledDismissExample from '../examples/AlertUncontrolledDismiss'; | ||
const AlertUncontrolledDismissExampleSource = require('!!raw-loader!../examples/AlertUncontrolledDismiss'); | ||
|
||
import {AlertFadelessExample, UncontrolledAlertFadelessExample} from '../examples/AlertFadeless'; | ||
const AlertFadelessExampleSource = require('!!raw-loader!../examples/AlertFadeless'); | ||
|
||
export default class ToastsPage extends React.Component { | ||
render() { | ||
return ( | ||
<div> | ||
<PageTitle title="Toasts" /> | ||
<div className="docs-example"> | ||
<ToastExample /> | ||
</div> | ||
<pre> | ||
<PrismCode className="language-jsx"> | ||
{ToastExampleSource} | ||
</PrismCode> | ||
</pre> | ||
|
||
<SectionTitle>Properties</SectionTitle> | ||
<pre> | ||
<PrismCode className="language-jsx"> | ||
{`Toast.propTypes = { | ||
className: PropTypes.string, | ||
closeClassName: PropTypes.string, | ||
color: PropTypes.string, // default: 'success' | ||
isOpen: PropTypes.bool, // default: true | ||
toggle: PropTypes.func, | ||
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]), | ||
// Controls the transition of the toast fading in and out | ||
// See [Fade](/components/fade/) for more details | ||
transition: PropTypes.shape(Fade.propTypes), | ||
}`} | ||
</PrismCode> | ||
</pre> | ||
|
||
<SectionTitle>Toast body</SectionTitle> | ||
<div className="docs-example"> | ||
<ToastBodyExample /> | ||
</div> | ||
<pre> | ||
<PrismCode className="language-jsx"> | ||
{ToastBodyExampleSource} | ||
</PrismCode> | ||
</pre> | ||
|
||
<SectionTitle>Header icons</SectionTitle> | ||
<div className="docs-example"> | ||
<ToastHeaderIconExample /> | ||
</div> | ||
<pre> | ||
<PrismCode className="language-jsx"> | ||
{ToastHeaderIconExampleSource} | ||
</PrismCode> | ||
</pre> | ||
|
||
<SectionTitle>Dismissing</SectionTitle> | ||
<div className="docs-example"> | ||
<ToastDismissExample buttonLabel="Show toast" /> | ||
</div> | ||
<pre> | ||
<PrismCode className="language-jsx"> | ||
{ToastDismissExampleSource} | ||
</PrismCode> | ||
</pre> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import React from 'react'; | ||
import { Toast, ToastBody, ToastHeader } from 'reactstrap'; | ||
|
||
const Example = (props) => { | ||
return ( | ||
<div> | ||
<div className="p-3 my-2 rounded"> | ||
<Toast> | ||
<ToastHeader> | ||
Reactstrap | ||
</ToastHeader> | ||
<ToastBody> | ||
This is a toast on a white background — check it out! | ||
</ToastBody> | ||
</Toast> | ||
</div> | ||
<div className="p-3 my-2 rounded bg-docs-transparent-grid"> | ||
<Toast> | ||
<ToastHeader> | ||
Reactstrap | ||
</ToastHeader> | ||
<ToastBody> | ||
This is a toast on a gridded background — check it out! | ||
</ToastBody> | ||
</Toast> | ||
</div> | ||
<div className="p-3 bg-primary my-2 rounded"> | ||
<Toast> | ||
<ToastHeader> | ||
Reactstrap | ||
</ToastHeader> | ||
<ToastBody> | ||
This is a toast on a primary background — check it out! | ||
</ToastBody> | ||
</Toast> | ||
</div> | ||
<div className="p-3 bg-secondary my-2 rounded"> | ||
<Toast> | ||
<ToastHeader> | ||
Reactstrap | ||
</ToastHeader> | ||
<ToastBody> | ||
This is a toast on a secondary background — check it out! | ||
</ToastBody> | ||
</Toast> | ||
</div> | ||
<div className="p-3 bg-success my-2 rounded"> | ||
<Toast> | ||
<ToastHeader> | ||
Reactstrap | ||
</ToastHeader> | ||
<ToastBody> | ||
This is a toast on a success background — check it out! | ||
</ToastBody> | ||
</Toast> | ||
</div> | ||
<div className="p-3 bg-danger my-2 rounded"> | ||
<Toast> | ||
<ToastHeader> | ||
Reactstrap | ||
</ToastHeader> | ||
<ToastBody> | ||
This is a toast on a danger background — check it out! | ||
</ToastBody> | ||
</Toast> | ||
</div> | ||
<div className="p-3 bg-warning my-2 rounded"> | ||
<Toast> | ||
<ToastHeader> | ||
Reactstrap | ||
</ToastHeader> | ||
<ToastBody> | ||
This is a toast on a warning background — check it out! | ||
</ToastBody> | ||
</Toast> | ||
</div> | ||
<div className="p-3 bg-info my-2 rounded"> | ||
<Toast> | ||
<ToastHeader> | ||
Reactstrap | ||
</ToastHeader> | ||
<ToastBody> | ||
This is a toast on an info background — check it out! | ||
</ToastBody> | ||
</Toast> | ||
</div> | ||
<div className="p-3 bg-dark my-2 rounded"> | ||
<Toast> | ||
<ToastHeader> | ||
Reactstrap | ||
</ToastHeader> | ||
<ToastBody> | ||
This is a toast on a dark background — check it out! | ||
</ToastBody> | ||
</Toast> | ||
</div> | ||
<div className="p-3 my-2 rounded" style={{ background: 'black' }}> | ||
<Toast> | ||
<ToastHeader> | ||
Reactstrap | ||
</ToastHeader> | ||
<ToastBody> | ||
This is a toast on a black background — check it out! | ||
</ToastBody> | ||
</Toast> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Example; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
import { Toast } from 'reactstrap'; | ||
|
||
const Example = (props) => { | ||
return ( | ||
<div> | ||
<Toast body> | ||
This is a toast with a body — check it out! | ||
</Toast> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Example; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* eslint react/no-multi-comp: 0, react/prop-types: 0 */ | ||
|
||
import React from 'react'; | ||
import { Button, Toast, ToastBody, ToastHeader } from 'reactstrap'; | ||
|
||
class ToastDismissExample extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
show: false | ||
}; | ||
|
||
this.toggle = this.toggle.bind(this); | ||
} | ||
|
||
toggle() { | ||
this.setState({ | ||
show: !this.state.show | ||
}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<Button color="danger" onClick={this.toggle}>{this.props.buttonLabel}</Button> | ||
<br /> | ||
<br /> | ||
<Toast isOpen={this.state.show}> | ||
<ToastHeader toggle={this.toggle}>Toast title</ToastHeader> | ||
<ToastBody> | ||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | ||
</ToastBody> | ||
</Toast> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default ToastDismissExample; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import React from 'react'; | ||
import { Toast, ToastBody, ToastHeader } from 'reactstrap'; | ||
|
||
const Example = (props) => { | ||
return ( | ||
<div> | ||
<Toast> | ||
<ToastHeader icon> | ||
Reactstrap | ||
</ToastHeader> | ||
<ToastBody> | ||
This is a toast with a primary icon — check it out! | ||
</ToastBody> | ||
</Toast> | ||
<Toast> | ||
<ToastHeader icon="secondary"> | ||
Reactstrap | ||
</ToastHeader> | ||
<ToastBody> | ||
This is a toast with a secondary icon — check it out! | ||
</ToastBody> | ||
</Toast> | ||
<Toast> | ||
<ToastHeader icon="success"> | ||
Reactstrap | ||
</ToastHeader> | ||
<ToastBody> | ||
This is a toast with a success icon — check it out! | ||
</ToastBody> | ||
</Toast> | ||
<Toast> | ||
<ToastHeader icon="danger"> | ||
Reactstrap | ||
</ToastHeader> | ||
<ToastBody> | ||
This is a toast with a danger icon — check it out! | ||
</ToastBody> | ||
</Toast> | ||
<Toast> | ||
<ToastHeader icon="warning"> | ||
Reactstrap | ||
</ToastHeader> | ||
<ToastBody> | ||
This is a toast with a warning icon — check it out! | ||
</ToastBody> | ||
</Toast> | ||
<Toast> | ||
<ToastHeader icon="info"> | ||
Reactstrap | ||
</ToastHeader> | ||
<ToastBody> | ||
This is a toast with an info icon — check it out! | ||
</ToastBody> | ||
</Toast> | ||
<Toast> | ||
<ToastHeader icon="light"> | ||
Reactstrap | ||
</ToastHeader> | ||
<ToastBody> | ||
This is a toast with a light icon — check it out! | ||
</ToastBody> | ||
</Toast> | ||
<Toast> | ||
<ToastHeader icon="dark"> | ||
Reactstrap | ||
</ToastHeader> | ||
<ToastBody> | ||
This is a toast with a dark icon — check it out! | ||
</ToastBody> | ||
</Toast> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Example; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to use prevState here.