-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(showcase): play one story after another, loop through selection
- Loading branch information
1 parent
12830cf
commit ff9a43c
Showing
7 changed files
with
81 additions
and
25 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 |
---|---|---|
@@ -1,32 +1,29 @@ | ||
import {Slide} from '../types/story'; | ||
import {StoryMode} from '../types/story-mode'; | ||
|
||
interface Params { | ||
pathname: string; | ||
pageNumber: number; | ||
slides?: Slide[]; | ||
} | ||
|
||
export const getStoryNavigation = ({pathname, pageNumber, slides}: Params) => { | ||
if (!slides) { | ||
return null; | ||
} | ||
|
||
const nextPageNumber = pageNumber + 1; | ||
const previousPageNumber = pageNumber - 1; | ||
const showNextButton = nextPageNumber < slides.length; | ||
const showPreviousButton = previousPageNumber >= 0; | ||
export const getStoryNavigation = ( | ||
pathname: string, | ||
mode: StoryMode, | ||
currentStory: number, | ||
storyIds?: string | ||
) => { | ||
if (mode === StoryMode.Showcase) { | ||
if (!storyIds) { | ||
return null; | ||
} | ||
const stories = storyIds.split('&'); | ||
const nextStoryNumber = currentStory + 1; | ||
const showNextStory = currentStory < stories.length; | ||
const nextStoryPath = `/showcase/${storyIds}/${nextStoryNumber}/0`; | ||
const initialPath = `/showcase/${storyIds}/0/0`; | ||
|
||
const pathParts = pathname.split('/'); | ||
pathParts.pop(); | ||
const nextPath = pathParts.concat(nextPageNumber.toString()).join('/'); | ||
const previousPath = pathParts | ||
.concat(previousPageNumber.toString()) | ||
.join('/'); | ||
|
||
return { | ||
previousLink: previousPath, | ||
showPrevious: showPreviousButton, | ||
nextLink: nextPath, | ||
showNext: showNextButton | ||
}; | ||
return {nextStoryPath, showNextStory, initialPath}; | ||
} | ||
return null; | ||
}; |
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,36 @@ | ||
import {Slide} from '../types/story'; | ||
|
||
interface Params { | ||
pathname: string; | ||
pageNumber: number; | ||
slides?: Slide[]; | ||
} | ||
|
||
export const getStorySlideNavigation = ({ | ||
pathname, | ||
pageNumber, | ||
slides | ||
}: Params) => { | ||
if (!slides) { | ||
return null; | ||
} | ||
|
||
const nextPageNumber = pageNumber + 1; | ||
const previousPageNumber = pageNumber - 1; | ||
const showNextButton = nextPageNumber < slides.length; | ||
const showPreviousButton = previousPageNumber >= 0; | ||
|
||
const pathParts = pathname.split('/'); | ||
pathParts.pop(); | ||
const nextPath = pathParts.concat(nextPageNumber.toString()).join('/'); | ||
const previousPath = pathParts | ||
.concat(previousPageNumber.toString()) | ||
.join('/'); | ||
|
||
return { | ||
previousLink: previousPath, | ||
showPrevious: showPreviousButton, | ||
nextLink: nextPath, | ||
showNext: showNextButton | ||
}; | ||
}; |
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