Skip to content
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

Fix Story Duration Default #12645

Merged
merged 3 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions packages/story-editor/src/app/story/effects/useLoadStory.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ function loadStory(storyId, post, restore, clearHistory, globalConfig) {
: [],
},
globalStoryStyles: newGlobalStoryStyles,
autoAdvance: storyData?.autoAdvance
? storyData.autoAdvance
: globalConfig.globalAutoAdvance,
defaultPageDuration: storyData?.defaultPageDuration
? storyData?.defaultPageDuration
: globalConfig.globalPageDuration,
autoAdvance:
storyData?.autoAdvance === undefined
? globalConfig.globalAutoAdvance
: storyData?.autoAdvance,
defaultPageDuration:
storyData?.defaultPageDuration === undefined
? globalConfig.globalPageDuration
: storyData?.defaultPageDuration,
backgroundAudio: storyData?.backgroundAudio,
taxonomies,
terms,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,22 @@ import { __ } from '@googleforcreators/i18n';
* Internal dependencies
*/
import { useStory } from '../../../../app/story';
import { useConfig } from '../../../../app/config';
import GeneralPageAdvancementPanel from '../../shared/generalPageAdvancement';

function PageAdvancementPanel({ nameOverride }) {
const { globalPageDuration } = useConfig();
const { autoAdvance, defaultPageDuration, updateStory } = useStory(
({
state: {
story: { autoAdvance, defaultPageDuration },
},
actions: { updateStory },
}) => ({ autoAdvance, defaultPageDuration, updateStory })
}) => ({
autoAdvance,
defaultPageDuration: defaultPageDuration || globalPageDuration,
updateStory,
})
);

const onUpdate = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
useMemo,
useDebouncedCallback,
} from '@googleforcreators/react';
import { __ } from '@googleforcreators/i18n';
import { __, sprintf } from '@googleforcreators/i18n';
import { v4 as uuidv4 } from 'uuid';
import { trackEvent } from '@googleforcreators/tracking';
import {
Expand Down Expand Up @@ -164,20 +164,29 @@ function GeneralPageAdvancementPanel({
/>
</SwitchRow>
{autoAdvance && (
<Row>
<NumericInput
unit={` ${__('seconds', 'web-stories')}`}
suffix={__('Duration', 'web-stories')}
value={duration}
onChange={onDurationChange}
aria-label={__('Default page duration in seconds', 'web-stories')}
min={MIN_MAX.PAGE_DURATION.MIN}
max={MIN_MAX.PAGE_DURATION.MAX}
isFloat
disabled={customAdvancementDisabled}
containerStyleOverride={inputContainerStyleOverride}
/>
</Row>
<>
<Row>
<NumericInput
unit={` ${__('seconds', 'web-stories')}`}
suffix={__('Duration', 'web-stories')}
value={duration}
onChange={onDurationChange}
aria-label={__('Default page duration in seconds', 'web-stories')}
min={MIN_MAX.PAGE_DURATION.MIN}
max={MIN_MAX.PAGE_DURATION.MAX}
disabled={customAdvancementDisabled}
containerStyleOverride={inputContainerStyleOverride}
/>
</Row>
<Text size={THEME_CONSTANTS.TYPOGRAPHY.PRESET_SIZES.SMALL}>
{sprintf(
/* translators: 1: minimum duration. 2: maximum duration. */
__('Duration between %1$d and %2$d seconds.', 'web-stories'),
MIN_MAX.PAGE_DURATION.MIN,
MIN_MAX.PAGE_DURATION.MAX
swissspidy marked this conversation as resolved.
Show resolved Hide resolved
)}
</Text>
</>
)}
</SimplePanel>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* External dependencies
*/
import { useCallback, useEffect, useState } from '@googleforcreators/react';
import { __ } from '@googleforcreators/i18n';
import { __, sprintf } from '@googleforcreators/i18n';
import {
THEME_CONSTANTS,
NumericInput,
Expand All @@ -37,6 +37,7 @@ import {
MultilineForm,
SettingHeading,
SettingSubheading,
TextInputHelperText,
} from '../components';

const MIN_MAX = {
Expand All @@ -57,6 +58,12 @@ export const TEXT = {
SWITCH_LABEL: __('Page Advancement', 'web-stories'),
INPUT_LABEL: __('Default page duration in seconds', 'web-stories'),
INPUT_SUFFIX: __('Duration', 'web-stories'),
INPUT_HELPER: sprintf(
/* translators: 1: minimum duration. 2: maximum duration. */
__('Duration between %1$d and %2$d seconds.', 'web-stories'),
MIN_MAX.PAGE_DURATION.MIN,
MIN_MAX.PAGE_DURATION.MAX
),
};

const InputsWrapper = styled.div`
Expand Down Expand Up @@ -118,18 +125,24 @@ function PageAdvancementSettings({
/>
</InlineForm>
{_autoAdvance && (
<InlineForm>
<NumericInput
unit={` ${__('seconds', 'web-stories')}`}
suffix={TEXT.INPUT_SUFFIX}
value={defaultPageDuration}
onChange={onDurationChange}
aria-label={TEXT.INPUT_SUFFIX}
min={MIN_MAX.PAGE_DURATION.MIN}
max={MIN_MAX.PAGE_DURATION.MAX}
isFloat
/>
</InlineForm>
<>
<InlineForm>
<NumericInput
unit={` ${__('seconds', 'web-stories')}`}
suffix={TEXT.INPUT_SUFFIX}
value={defaultPageDuration}
onChange={onDurationChange}
aria-label={TEXT.INPUT_SUFFIX}
min={MIN_MAX.PAGE_DURATION.MIN}
max={MIN_MAX.PAGE_DURATION.MAX}
/>
</InlineForm>
<TextInputHelperText
size={THEME_CONSTANTS.TYPOGRAPHY.PRESET_SIZES.SMALL}
>
{TEXT.INPUT_HELPER}
</TextInputHelperText>
</>
)}
</InputsWrapper>
</MultilineForm>
Expand Down