Skip to content

Commit

Permalink
feat(showcase-title): add title slide in showcase mode (#314)
Browse files Browse the repository at this point in the history
* feat(showcase-title): add title slide in showcase mode

* feat(showcase-title): add exact to presenter route
  • Loading branch information
KatvonRivia committed Mar 26, 2020
1 parent 88d7767 commit 431778f
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 13 deletions.
26 changes: 16 additions & 10 deletions src/scripts/components/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import StoriesSelector from '../stories-selector/stories-selector';
import PresentationSelector from '../presentation-selector/presentation-selector';
import ShowcaseSelector from '../showcase-selector/showcase-selector';
import Globes from '../globes/globes';
import StoryTitle from '../story-title/story-title';

import translations from '../../i18n';

Expand All @@ -40,14 +41,19 @@ const TranslatedApp: FunctionComponent = () => {
return (
<Router>
<IntlProvider locale={language} messages={translations[language]}>
<Route
path={[
'/stories/:storyId/:slideIndex',
'/present/:storyId/:slideIndex',
'/showcase/:storyIds/:storyIndex/:slideIndex'
]}>
<Story />
</Route>
<Switch>
<Route path={['/showcase/:storyIds/:storyIndex/title']}>
<StoryTitle />
</Route>
<Route
path={[
'/stories/:storyId/:slideIndex',
'/present/:storyId/:slideIndex',
'/showcase/:storyIds/:storyIndex/:slideIndex'
]}>
<Story />
</Route>
</Switch>
<Route
path={['/present/:storyId', '/stories/:storyId']}
render={props => <Redirect to={`${props.match.url}/0`} />}></Route>
Expand All @@ -66,10 +72,10 @@ const TranslatedApp: FunctionComponent = () => {
<Route path="/stories" exact>
<StoriesSelector />
</Route>
<Route path="/present">
<Route path="/present" exact>
<PresentationSelector />
</Route>
<Route path={['/showcase/:storyIds', '/showcase']}>
<Route path={['/showcase/:storyIds', '/showcase']} exact>
<ShowcaseSelector />
</Route>
</Switch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const ShowcaseSelector: FunctionComponent = () => {
<Button
className={styles.button}
label={'play'}
link={`/showcase/${selectedIds.join('&')}/0/0`}
link={`/showcase/${selectedIds.join('&')}/0/title`}
icon={PlayIcon}
/>
</div>
Expand Down
21 changes: 21 additions & 0 deletions src/scripts/components/story-title/story-title.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@require '../../../variables.styl'

.storyTitle
display: flex
flex-direction: column
justify-content: center
align-items: center
height: 60%
font-family: NotesEsa

.title
color: $main
font-weight: bold
font-size: emCalc(36px)

.description
margin: 0
color: $textDefault
font-weight: normal
font-size: emCalc(36px)
font-family: Arial, Helvetica, sans-serif
27 changes: 27 additions & 0 deletions src/scripts/components/story-title/story-title.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React, {FunctionComponent} from 'react';
import {useHistory} from 'react-router-dom';

import {useStoryParams} from '../../hooks/use-story-params';
import {useInterval} from '../../hooks/use-interval';

import styles from './story-title.styl';

const StoryTitle: FunctionComponent = () => {
const {storyIds, storyIndex, storyListItem} = useStoryParams();
const history = useHistory();
const showcaseStoryIds = storyIds.join('&');
const nextLink = `/showcase/${showcaseStoryIds}/${storyIndex}/0`;

useInterval(() => {
history.replace(nextLink);
}, 3000);

return (
<div className={styles.storyTitle}>
<h1 className={styles.title}>{storyListItem?.title}</h1>
<h2 className={styles.description}>{storyListItem?.description}</h2>
</div>
);
};

export default StoryTitle;
5 changes: 3 additions & 2 deletions src/scripts/hooks/use-story-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ export const useStoryNavigation = () => {
autoPlayLink = `/showcase/${showcaseStoryIds}/${storyIndex}/${nextSlideIndex}`;
// when no slides are left, go to first slide of next story
} else if (nextStoryIndex < storyIds.length) {
autoPlayLink = `/showcase/${showcaseStoryIds}/${nextStoryIndex}/0`;
autoPlayLink = `/showcase/${showcaseStoryIds}/${nextStoryIndex}/title`;
// after the last story, return to the beginning
} else {
autoPlayLink = `/showcase/${showcaseStoryIds}/0/0`;
autoPlayLink = `/showcase/${showcaseStoryIds}/0/title`;
}
}

return {autoPlayLink, nextSlideLink, previousSlideLink};
};

0 comments on commit 431778f

Please sign in to comment.