-
Notifications
You must be signed in to change notification settings - Fork 33
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 #322 from CaptainFact/feat/shift-statements-per-pr…
…ovider Timecodes shifting is now specific to video provider
- Loading branch information
Showing
21 changed files
with
357 additions
and
158 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
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,10 @@ | ||
import styled from 'styled-components' | ||
import { fontSize, space } from 'styled-system' | ||
|
||
const StyledLabel = styled.label` | ||
${fontSize} | ||
${space} | ||
` | ||
|
||
/** @component */ | ||
export default StyledLabel |
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
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,44 @@ | ||
import styled from 'styled-components' | ||
import { fontSize, space, themeGet } from 'styled-system' | ||
|
||
export const StyledH1 = styled.h1` | ||
font-size: ${themeGet('fontSizes.0')}; | ||
margin-bottom: ${themeGet('space.4')}; | ||
${fontSize} | ||
${space} | ||
` | ||
|
||
export const StyledH2 = styled.h2` | ||
font-size: ${themeGet('fontSizes.1')}; | ||
margin-bottom: ${themeGet('space.4')}; | ||
${fontSize} | ||
${space} | ||
` | ||
|
||
export const StyledH3 = styled.h3` | ||
font-size: ${themeGet('fontSizes.2')}; | ||
margin-bottom: ${themeGet('space.3')}; | ||
${fontSize} | ||
${space} | ||
` | ||
|
||
export const StyledH4 = styled.h4` | ||
font-size: ${themeGet('fontSizes.3')}; | ||
margin-bottom: ${themeGet('space.2')}; | ||
${fontSize} | ||
${space} | ||
` | ||
|
||
export const StyledH5 = styled.h5` | ||
font-size: ${themeGet('fontSizes.4')}; | ||
margin-bottom: ${themeGet('space.2')}; | ||
${fontSize} | ||
${space} | ||
` | ||
|
||
export const StyledH6 = styled.h6` | ||
font-size: ${themeGet('fontSizes.5')}; | ||
margin-bottom: ${themeGet('space.1')}; | ||
${fontSize} | ||
${space} | ||
` |
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,58 +1,84 @@ | ||
import React from 'react' | ||
import { connect } from 'react-redux' | ||
import { withNamespaces } from 'react-i18next' | ||
import { Field, reduxForm } from 'redux-form' | ||
import { Formik } from 'formik' | ||
import { Flex } from '@rebass/grid' | ||
|
||
import { Edit } from 'styled-icons/fa-regular/Edit' | ||
|
||
import { shiftStatements } from '../../state/video_debate/effects' | ||
import Modal from '../Modal/Modal' | ||
import { popModal } from '../../state/modals/reducer' | ||
import { Icon } from '../Utils/Icon' | ||
import { flashErrorMsg, flashSuccessMsg } from '../../state/flashes/reducer' | ||
import FieldWithButton from '../FormUtils/FieldWithButton' | ||
import { shiftStatements } from '../../state/video_debate/statements/effects' | ||
import StyledLabel from '../FormUtils/StyledLabel' | ||
import { StyledH3 } from '../StyledUtils/Title' | ||
|
||
const TimeShiftForm = reduxForm({ | ||
form: 'shiftStatements', | ||
initialValues: { offset: 0 } | ||
})( | ||
withNamespaces('main')(({ handleSubmit, t }) => ( | ||
<form onSubmit={handleSubmit}> | ||
<Field | ||
component={FieldWithButton} | ||
name="offset" | ||
type="number" | ||
placeholder="+0s" | ||
buttonLabel={t('actions.apply')} | ||
validate={offset => !offset} | ||
/> | ||
</form> | ||
)) | ||
) | ||
class EditVideoModal extends React.PureComponent { | ||
renderTitle() { | ||
return ( | ||
<span> | ||
<Edit size="1em" /> {this.props.t('video.edit')} | ||
</span> | ||
) | ||
} | ||
|
||
@connect( | ||
null, | ||
{ popModal, flashErrorMsg, flashSuccessMsg, shiftStatements } | ||
) | ||
@withNamespaces('videoDebate') | ||
export default class EditVideoModal extends React.PureComponent { | ||
render() { | ||
const { t, popModal, video } = this.props | ||
|
||
return ( | ||
<Modal | ||
handleCloseClick={this.props.popModal} | ||
title={ | ||
<span> | ||
<Icon name="pencil" /> {this.props.t('video.edit')} | ||
</span> | ||
} | ||
> | ||
<h4 className="title is-4">{this.props.t('video.shiftStatements')}</h4> | ||
<TimeShiftForm onSubmit={this.shiftSubmit} /> | ||
<Modal handleCloseClick={popModal} title={this.renderTitle()}> | ||
<Flex flexDirection="column"> | ||
<StyledH3>{t('video.shiftStatements')}</StyledH3> | ||
<Formik | ||
initialValues={{ youtube_offset: video.youtube_offset }} | ||
onSubmit={async (values, { setSubmitting }) => { | ||
setSubmitting(true) | ||
const reply = await this.props.shiftStatements(values) | ||
setSubmitting(false) | ||
this.props.popModal() | ||
return reply | ||
}} | ||
> | ||
{({ handleSubmit, isSubmitting, values, handleChange }) => ( | ||
<form onSubmit={handleSubmit}> | ||
<Flex> | ||
<StyledLabel fontSize={3} mr={3}> | ||
Youtube | ||
</StyledLabel> | ||
<FieldWithButton | ||
type="number" | ||
input={{ | ||
name: 'youtube_offset', | ||
max: '10000000', | ||
value: values.youtube_offset, | ||
onChange: handleChange | ||
}} | ||
meta={{ submitting: isSubmitting }} | ||
placeholder="+0s" | ||
buttonLabel={t('main:actions.apply')} | ||
buttonClickHandler={handleSubmit} | ||
/> | ||
</Flex> | ||
</form> | ||
)} | ||
</Formik> | ||
</Flex> | ||
</Modal> | ||
) | ||
} | ||
} | ||
|
||
shiftSubmit = ({ offset }) => { | ||
if (offset) { | ||
return this.props.shiftStatements(offset).then(() => this.props.popModal()) | ||
} | ||
} | ||
const mapDispatchToProps = { | ||
popModal, | ||
flashErrorMsg, | ||
flashSuccessMsg, | ||
shiftStatements | ||
} | ||
|
||
export default withNamespaces(['videoDebate', 'main'])( | ||
connect( | ||
state => ({ video: state.VideoDebate.video.data }), | ||
mapDispatchToProps | ||
)(EditVideoModal) | ||
) |
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
Oops, something went wrong.