Add local setting for pop-in player position

master
Thibaut Girka 4 years ago
parent ea5298ab9b
commit 49ee69f75f
  1. 17
      app/javascript/flavours/glitch/features/local_settings/page/index.js
  2. 7
      app/javascript/flavours/glitch/features/picture_in_picture/index.js
  3. 1
      app/javascript/flavours/glitch/reducers/local_settings.js
  4. 5
      app/javascript/flavours/glitch/styles/components/status.scss

@ -28,6 +28,8 @@ const messages = defineMessages({
rewrite_mentions_no: { id: 'settings.rewrite_mentions_no', defaultMessage: 'Do not rewrite mentions' }, rewrite_mentions_no: { id: 'settings.rewrite_mentions_no', defaultMessage: 'Do not rewrite mentions' },
rewrite_mentions_acct: { id: 'settings.rewrite_mentions_acct', defaultMessage: 'Rewrite with username and domain (when the account is remote)' }, rewrite_mentions_acct: { id: 'settings.rewrite_mentions_acct', defaultMessage: 'Rewrite with username and domain (when the account is remote)' },
rewrite_mentions_username: { id: 'settings.rewrite_mentions_username', defaultMessage: 'Rewrite with username' }, rewrite_mentions_username: { id: 'settings.rewrite_mentions_username', defaultMessage: 'Rewrite with username' },
pop_in_left: { id: 'settings.pop_in_left', defaultMessage: 'Left' },
pop_in_right: { id: 'settings.pop_in_right', defaultMessage: 'Right' },
}); });
export default @injectIntl export default @injectIntl
@ -384,7 +386,7 @@ class LocalSettingsPage extends React.PureComponent {
</section> </section>
</div> </div>
), ),
({ onChange, settings }) => ( ({ intl, onChange, settings }) => (
<div className='glitch local-settings__page media'> <div className='glitch local-settings__page media'>
<h1><FormattedMessage id='settings.media' defaultMessage='Media' /></h1> <h1><FormattedMessage id='settings.media' defaultMessage='Media' /></h1>
<LocalSettingsPageItem <LocalSettingsPageItem
@ -428,6 +430,19 @@ class LocalSettingsPage extends React.PureComponent {
> >
<FormattedMessage id='settings.pop_in_player' defaultMessage='Enable pop-in player' /> <FormattedMessage id='settings.pop_in_player' defaultMessage='Enable pop-in player' />
</LocalSettingsPageItem> </LocalSettingsPageItem>
<LocalSettingsPageItem
settings={settings}
item={['media', 'pop_in_position']}
id='mastodon-settings--pop-in-position'
options={[
{ value: 'left', message: intl.formatMessage(messages.pop_in_left) },
{ value: 'right', message: intl.formatMessage(messages.pop_in_right) },
]}
onChange={onChange}
dependsOn={[['media', 'pop_in_player']]}
>
<FormattedMessage id='settings.pop_in_position' defaultMessage='Pop-in player position:' />
</LocalSettingsPageItem>
</div> </div>
), ),
]; ];

@ -6,9 +6,11 @@ import Audio from 'flavours/glitch/features/audio';
import { removePictureInPicture } from 'flavours/glitch/actions/picture_in_picture'; import { removePictureInPicture } from 'flavours/glitch/actions/picture_in_picture';
import Header from './components/header'; import Header from './components/header';
import Footer from './components/footer'; import Footer from './components/footer';
import classNames from 'classnames';
const mapStateToProps = state => ({ const mapStateToProps = state => ({
...state.get('picture_in_picture'), ...state.get('picture_in_picture'),
left: state.getIn(['local_settings', 'media', 'pop_in_position']) === 'left',
}); });
export default @connect(mapStateToProps) export default @connect(mapStateToProps)
@ -27,6 +29,7 @@ class PictureInPicture extends React.Component {
foregroundColor: PropTypes.string, foregroundColor: PropTypes.string,
accentColor: PropTypes.string, accentColor: PropTypes.string,
dispatch: PropTypes.func.isRequired, dispatch: PropTypes.func.isRequired,
left: PropTypes.bool,
}; };
handleClose = () => { handleClose = () => {
@ -35,7 +38,7 @@ class PictureInPicture extends React.Component {
} }
render () { render () {
const { type, src, currentTime, accountId, statusId } = this.props; const { type, src, currentTime, accountId, statusId, left } = this.props;
if (!currentTime) { if (!currentTime) {
return null; return null;
@ -72,7 +75,7 @@ class PictureInPicture extends React.Component {
} }
return ( return (
<div className='picture-in-picture'> <div className={classNames('picture-in-picture', { left })}>
<Header accountId={accountId} statusId={statusId} onClose={this.handleClose} /> <Header accountId={accountId} statusId={statusId} onClose={this.handleClose} />
{player} {player}

@ -50,6 +50,7 @@ const initialState = ImmutableMap({
fullwidth : true, fullwidth : true,
reveal_behind_cw : false, reveal_behind_cw : false,
pop_in_player : true, pop_in_player : true,
pop_in_position : 'right',
}), }),
notifications : ImmutableMap({ notifications : ImmutableMap({
favicon_badge : false, favicon_badge : false,

@ -1066,6 +1066,11 @@ a.status-card.compact:hover {
right: 20px; right: 20px;
width: 300px; width: 300px;
&.left {
right: unset;
left: 20px;
}
&__footer { &__footer {
border-radius: 0 0 4px 4px; border-radius: 0 0 4px 4px;
background: lighten($ui-base-color, 4%); background: lighten($ui-base-color, 4%);

Loading…
Cancel
Save