-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from bbc/adds-transcript-form
Adds transcript form
- Loading branch information
Showing
15 changed files
with
438 additions
and
30 deletions.
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import '@storybook/addon-knobs/register'; | ||
import '@storybook/addon-viewport/register'; | ||
import '@storybook/addon-actions/register'; | ||
import '@storybook/addon-links/register'; | ||
import '@storybook/addon-a11y/register'; | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,48 @@ | ||
import React, { useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Alert from 'react-bootstrap/Alert'; | ||
|
||
const CustomAlert = ({ ...props } ) => { | ||
|
||
const [ showAlert, toggleShowAlert ] = useState(props.show); | ||
|
||
const handleDismiss = () => { | ||
toggleShowAlert(false); | ||
}; | ||
|
||
const setAlertHeading = () => { | ||
return props.heading ? <Alert.Heading>{props.heading}</Alert.Heading> : null; | ||
}; | ||
|
||
const setAlert = () => { | ||
if (showAlert) { | ||
return ( | ||
<Alert | ||
variant={ props.variant } | ||
onClose={ handleDismiss } | ||
dismissible | ||
> | ||
{setAlertHeading()} | ||
{props.message} | ||
</Alert> | ||
); | ||
} else { | ||
return null; | ||
} | ||
}; | ||
|
||
return setAlert(); | ||
}; | ||
|
||
CustomAlert.propTypes = { | ||
show: PropTypes.bool.isRequired, | ||
heading: PropTypes.string, | ||
message: PropTypes.string, | ||
vatiant: PropTypes.string, | ||
}; | ||
|
||
CustomAlert.defaultProps = { | ||
show: true, | ||
}; | ||
|
||
export default CustomAlert; |
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,21 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import CustomAlert from '../index.js'; | ||
|
||
export const alertProps = { | ||
variant: 'danger', | ||
heading: 'Error could not contact the server', | ||
message: 'There was an error trying to create this transcript on the server', | ||
show: true | ||
}; | ||
|
||
storiesOf('Custom Alert', module) | ||
.add('Default', () => { | ||
return ( | ||
<section style={ { height: '90vh', overflow: 'scroll' } }> | ||
<CustomAlert | ||
{ ...alertProps } | ||
/> | ||
</section> | ||
); | ||
}); |
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
File renamed without changes.
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,18 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import StoryRouter from 'storybook-react-router'; | ||
import ItemForm from '../index.js'; | ||
import { modalActions, modalItems } from '../../FormModal/stories/index.stories.js'; | ||
|
||
storiesOf('Item Form', module) | ||
.addDecorator(StoryRouter()) | ||
.add('Edit Project', () => { | ||
return ( | ||
<section style={ { height: '90vh', overflow: 'scroll' } }> | ||
<ItemForm | ||
{ ...modalActions } | ||
{ ...modalItems[0] } | ||
/> | ||
</section> | ||
); | ||
}); |
Oops, something went wrong.