Skip to content

Commit

Permalink
Make sound disclaimer texts configurable
Browse files Browse the repository at this point in the history
REDMINE-20897
  • Loading branch information
tf committed Jan 22, 2025
1 parent f8c02da commit 25bd216
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import styles from './SoundDisclaimer.module.css';
import MutedIcon from './muted.svg';
import UnmutedIcon from './unmuted.svg';

export function SoundDisclaimer() {
export function SoundDisclaimer({configuration}) {
const {isEditable, isSelected} = useContentElementEditorState();
const {t} = useI18n();
const muted = useMediaMuted();
Expand All @@ -18,11 +18,17 @@ export function SoundDisclaimer() {
<button className={classNames(styles.unmute, {[styles.active]: muted})}
onClick={() => media.mute(false)}>
<MutedIcon />
<p dangerouslySetInnerHTML={{__html: t('pageflow_scrolled.public.sound_disclaimer.help_muted')}} />
<p>
{configuration.mutedText ||
t('pageflow_scrolled.public.sound_disclaimer.help_muted')}
</p>
</button>
<div className={classNames(styles.unmuted, {[styles.active]: !muted})}>
<UnmutedIcon />
<p dangerouslySetInnerHTML={{__html: t('pageflow_scrolled.public.sound_disclaimer.help_unmuted')}} />
<p>
{configuration.unmutedText ||
t('pageflow_scrolled.public.sound_disclaimer.help_unmuted')}
</p>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import {editor, NoOptionsHintView} from 'pageflow-scrolled/editor';
import I18n from 'i18n-js';

import {editor} from 'pageflow-scrolled/editor';
import {TextInputView} from 'pageflow/ui';

import pictogram from './pictogram.svg';

Expand All @@ -7,9 +10,19 @@ editor.contentElementTypes.register('soundDisclaimer', {
category: 'media',
supportedPositions: ['inline'],

configurationEditor() {
configurationEditor({entry}) {
this.tab('general', function() {
this.view(NoOptionsHintView);
this.input('mutedText', TextInputView, {
placeholder: I18n.t('pageflow_scrolled.public.sound_disclaimer.help_muted', {
locale: entry.metadata.get('locale')
})
});

this.input('unmutedText', TextInputView, {
placeholder: I18n.t('pageflow_scrolled.public.sound_disclaimer.help_unmuted', {
locale: entry.metadata.get('locale')
})
});
});
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,14 @@ import {storiesOfContentElement} from 'pageflow-scrolled/spec/support/stories';

storiesOfContentElement(module, {
typeName: 'soundDisclaimer',
baseConfiguration: {}
baseConfiguration: {},
variants: [
{
name: 'With custom texts',
configuration: {
mutedText: 'Unmute now for the best experience.',
unmutedText: 'Unmuted! Have fun!',
}
}
]
});

0 comments on commit 25bd216

Please sign in to comment.