Skip to content

Commit

Permalink
Adds playback bar to story viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-signal committed May 6, 2022
1 parent 9817946 commit 85c8ff7
Show file tree
Hide file tree
Showing 17 changed files with 291 additions and 125 deletions.
16 changes: 16 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -7018,6 +7018,14 @@
}
}
},
"StoryViewer__pause": {
"message": "Pause",
"description": "Aria label for pausing a story"
},
"StoryViewer__play": {
"message": "Play",
"description": "Aria label for playing a story"
},
"StoryViewer__reply": {
"message": "Reply",
"description": "Button label to reply to a story"
Expand All @@ -7026,6 +7034,14 @@
"message": "Reply to Group",
"description": "Button label to reply to a group story"
},
"StoryViewer__mute": {
"message": "Mute",
"description": "Aria label for muting stories"
},
"StoryViewer__unmute": {
"message": "Unmute",
"description": "Aria label for unmuting stories"
},
"StoryViewsNRepliesModal__no-replies": {
"message": "No replies yet",
"description": "Placeholder text for when there are no replies"
Expand Down
1 change: 1 addition & 0 deletions images/icons/v2/pause_solid_20.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/icons/v2/play_solid_20.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/icons/v2/speaker-off-solid-20.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/icons/v2/speaker-on-solid-20.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
98 changes: 80 additions & 18 deletions stylesheets/components/StoryViewer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,6 @@
z-index: $z-index-above-above-base;
}

&__more {
@include button-reset;
height: 24px;
position: absolute;
right: 80px;
top: var(--title-bar-drag-area-height);
width: 24px;
z-index: $z-index-above-base;

@include color-svg('../images/icons/v2/more-horiz-24.svg', $color-white);

@include keyboard-mode {
&:focus {
background-color: $color-ultramarine;
}
}
}

&__container {
flex-grow: 1;
overflow: hidden;
Expand Down Expand Up @@ -89,6 +71,16 @@
@include font-body-2;
color: $color-white-alpha-60;
}

&__playback-bar {
display: flex;
justify-content: space-between;
}

&__playback-controls {
align-items: center;
display: flex;
}
}

&__caption {
Expand Down Expand Up @@ -154,6 +146,76 @@
}
}

&__more {
@include button-reset;
height: 24px;
width: 24px;

@include color-svg('../images/icons/v2/more-horiz-24.svg', $color-white);

@include keyboard-mode {
&:focus {
background-color: $color-black;
}
}
}

&__mute {
@include button-reset;
height: 20px;
margin: 0 24px;
width: 20px;
@include color-svg(
'../images/icons/v2/speaker-on-solid-20.svg',
$color-white
);
@include keyboard-mode {
&:focus {
background-color: $color-white-alpha-80;
}
}
}

&__pause {
@include button-reset;
height: 20px;
width: 20px;
@include color-svg('../images/icons/v2/pause_solid_20.svg', $color-white);
@include keyboard-mode {
&:focus {
background-color: $color-white-alpha-80;
}
}
}

&__play {
@include button-reset;
height: 20px;
width: 20px;
@include color-svg('../images/icons/v2/play_solid_20.svg', $color-white);
@include keyboard-mode {
&:focus {
background-color: $color-white-alpha-80;
}
}
}

&__unmute {
@include button-reset;
height: 20px;
margin: 0 18px;
width: 20px;
@include color-svg(
'../images/icons/v2/speaker-off-solid-20.svg',
$color-white
);
@include keyboard-mode {
&:focus {
background-color: $color-white-alpha-80;
}
}
}

&__progress {
display: flex;

Expand Down
88 changes: 47 additions & 41 deletions ts/components/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function ContextMenuPopper<T>({
onClose,
referenceElement,
title,
theme,
value,
}: ContextMenuPropsType<T>): JSX.Element | null {
const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(
Expand Down Expand Up @@ -84,49 +85,54 @@ export function ContextMenuPopper<T>({
}

return (
<div
className="ContextMenu__popper"
ref={setPopperElement}
style={styles.popper}
{...attributes.popper}
>
{title && <div className="ContextMenu__title">{title}</div>}
{menuOptions.map((option, index) => (
<button
aria-label={option.label}
className={classNames({
ContextMenu__option: true,
'ContextMenu__option--focused': focusedIndex === index,
})}
key={option.label}
type="button"
onClick={() => {
option.onClick(option.value);
onClose();
}}
>
<div className="ContextMenu__option--container">
{option.icon && (
<div
className={classNames('ContextMenu__option--icon', option.icon)}
/>
)}
<div>
<div className="ContextMenu__option--title">{option.label}</div>
{option.description && (
<div className="ContextMenu__option--description">
{option.description}
</div>
<div className={theme ? themeClassName(theme) : undefined}>
<div
className="ContextMenu__popper"
ref={setPopperElement}
style={styles.popper}
{...attributes.popper}
>
{title && <div className="ContextMenu__title">{title}</div>}
{menuOptions.map((option, index) => (
<button
aria-label={option.label}
className={classNames({
ContextMenu__option: true,
'ContextMenu__option--focused': focusedIndex === index,
})}
key={option.label}
type="button"
onClick={() => {
option.onClick(option.value);
onClose();
}}
>
<div className="ContextMenu__option--container">
{option.icon && (
<div
className={classNames(
'ContextMenu__option--icon',
option.icon
)}
/>
)}
<div>
<div className="ContextMenu__option--title">{option.label}</div>
{option.description && (
<div className="ContextMenu__option--description">
{option.description}
</div>
)}
</div>
</div>
</div>
{typeof value !== 'undefined' &&
typeof option.value !== 'undefined' &&
value === option.value ? (
<div className="ContextMenu__option--selected" />
) : null}
</button>
))}
{typeof value !== 'undefined' &&
typeof option.value !== 'undefined' &&
value === option.value ? (
<div className="ContextMenu__option--selected" />
) : null}
</button>
))}
</div>
</div>
);
}
Expand Down
3 changes: 3 additions & 0 deletions ts/components/StoryImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type PropsType = {
readonly attachment?: AttachmentType;
readonly children?: ReactNode;
readonly i18n: LocalizerType;
readonly isMuted?: boolean;
readonly isPaused?: boolean;
readonly isThumbnail?: boolean;
readonly label: string;
Expand All @@ -37,6 +38,7 @@ export const StoryImage = ({
attachment,
children,
i18n,
isMuted,
isPaused,
isThumbnail,
label,
Expand Down Expand Up @@ -106,6 +108,7 @@ export const StoryImage = ({
controls={false}
key={attachment.url}
loop={shouldLoop}
muted={isMuted}
ref={videoRef}
>
<source src={attachment.url} />
Expand Down
3 changes: 3 additions & 0 deletions ts/components/StoryViewer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function getDefaultProps(): PropsType {
conversationId: sender.id,
getPreferredBadge: () => undefined,
group: undefined,
hasAllStoriesMuted: false,
i18n,
loadStoryReplies: action('loadStoryReplies'),
markStoryRead: action('markStoryRead'),
Expand Down Expand Up @@ -51,6 +52,7 @@ function getDefaultProps(): PropsType {
timestamp: Date.now(),
},
],
toggleHasAllStoriesMuted: action('toggleHasAllStoriesMuted'),
};
}

Expand Down Expand Up @@ -153,6 +155,7 @@ story.add('Caption', () => (
story.add('Long Caption', () => (
<StoryViewer
{...getDefaultProps()}
hasAllStoriesMuted
stories={[
{
attachment: fakeAttachment({
Expand Down

0 comments on commit 85c8ff7

Please sign in to comment.