-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[VideoThumbmail] Improve VideoThumbnail play button #7319
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@shopify/polaris': patch | ||
| --- | ||
|
|
||
| Update the `VideoThumbnail` play button user experience |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,16 +11,11 @@ $progress-bar-height: 6px; | |
| background-repeat: no-repeat; | ||
| width: 100%; | ||
| height: 100%; | ||
| } | ||
|
|
||
| &.WithPlayer { | ||
| position: absolute; | ||
| z-index: 1; | ||
| top: 0; | ||
| left: 0; | ||
| width: 100%; | ||
| height: 100%; | ||
| padding-bottom: auto; | ||
| } | ||
| .ThumbnailContainer { | ||
| position: relative; | ||
| height: 100%; | ||
| } | ||
|
|
||
| .PlayButton { | ||
|
|
@@ -33,50 +28,42 @@ $progress-bar-height: 6px; | |
| padding: 0; | ||
| border: none; | ||
| background: transparent; | ||
| opacity: 0.8; | ||
| transition: opacity var(--p-duration-200) var(--p-ease-in); | ||
| cursor: pointer; | ||
|
|
||
| &:hover, | ||
| &:focus { | ||
| opacity: 1; | ||
| } | ||
|
|
||
| &:focus { | ||
| outline: none; | ||
| box-shadow: inset 2px 0 0 var(--p-focused); | ||
| background-image: linear-gradient( | ||
| var(--pc-play-button-focused-state-overlay), | ||
| var(--pc-play-button-focused-state-overlay) | ||
| ); | ||
|
|
||
| .Timestamp { | ||
| background-color: rgba(0, 0, 0, 0.8); | ||
| } | ||
| } | ||
|
|
||
| &:hover .Timestamp { | ||
sophschneider marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| background-color: rgba(0, 0, 0, 0.8); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are these custom colours ok? design had black with this opacity and no token was suitable
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are okay for now. We can find/fix them up later. |
||
| } | ||
| } | ||
|
|
||
| .PlayIcon { | ||
| position: absolute; | ||
| top: 50%; | ||
| left: 50%; | ||
| width: $start-button-size; | ||
| height: $start-button-size; | ||
| margin-top: -$start-button-size * 0.5; | ||
| margin-left: -$start-button-size * 0.5; | ||
| fill: var(--p-icon-on-interactive); | ||
| } | ||
|
|
||
| .Timestamp { | ||
| position: absolute; | ||
| bottom: 0; | ||
| padding: 0 var(--p-space-1); | ||
| margin-bottom: var(--p-space-2); | ||
| margin-left: var(--p-space-2); | ||
| padding: var(--p-space-1) var(--p-space-2) var(--p-space-1) var(--p-space-1); | ||
| margin-bottom: var(--p-space-4); | ||
| margin-left: var(--p-space-4); | ||
| border-radius: var(--p-border-radius-1); | ||
| color: var(--p-text); | ||
| background-color: var(--p-surface); | ||
| opacity: 0.8; | ||
| color: var(--p-text-on-interactive); | ||
| background-color: rgba(0, 0, 0, 0.6); | ||
| text-align: center; | ||
| } | ||
|
|
||
| .withProgress { | ||
| margin-bottom: var(--p-space-3); | ||
| transition: background-color var(--p-duration-200) var(--p-ease-in); | ||
| } | ||
|
|
||
| .Progress { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,17 @@ | ||
| import React from 'react'; | ||
| import {PlayMinor} from '@shopify/polaris-icons'; | ||
|
|
||
| import {useI18n} from '../../utilities/i18n'; | ||
| import {classNames} from '../../utilities/css'; | ||
| import { | ||
| secondsToTimeComponents, | ||
| secondsToTimestamp, | ||
| secondsToDurationTranslationKey, | ||
| } from '../../utilities/duration'; | ||
| import {useMediaQuery} from '../../utilities/media-query'; | ||
| import {Icon} from '../Icon'; | ||
| import {Stack} from '../Stack'; | ||
| import {Text} from '../Text'; | ||
|
|
||
| import {PlayIcon} from './illustrations'; | ||
| import styles from './VideoThumbnail.scss'; | ||
|
|
||
| export interface VideoThumbnailProps { | ||
|
|
@@ -49,6 +52,7 @@ export function VideoThumbnail({ | |
| onBeforeStartPlaying, | ||
| }: VideoThumbnailProps) { | ||
| const i18n = useI18n(); | ||
| const {isNavigationCollapsed} = useMediaQuery(); | ||
| let buttonLabel; | ||
|
|
||
| if (accessibilityLabel) { | ||
|
|
@@ -73,13 +77,19 @@ export function VideoThumbnail({ | |
| } | ||
|
|
||
| const timeStampMarkup = videoLength ? ( | ||
| <p | ||
| className={classNames( | ||
| styles.Timestamp, | ||
| showVideoProgress && styles.withProgress, | ||
| )} | ||
| > | ||
| {secondsToTimestamp(videoLength)} | ||
| <p className={styles.Timestamp}> | ||
| <Stack alignment="center" spacing="extraTight"> | ||
| <span className={styles.PlayIcon}> | ||
| <Icon source={PlayMinor} /> | ||
| </span> | ||
| <Text | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yesssssss. Spread the word @mrcthms 🚀 |
||
| variant={isNavigationCollapsed ? 'bodyLg' : 'bodyMd'} | ||
| as="p" | ||
| fontWeight="semibold" | ||
| > | ||
| {secondsToTimestamp(videoLength)} | ||
| </Text> | ||
| </Stack> | ||
| </p> | ||
| ) : null; | ||
|
|
||
|
|
@@ -109,10 +119,11 @@ export function VideoThumbnail({ | |
| } | ||
|
|
||
| return ( | ||
| <div | ||
| className={styles.Thumbnail} | ||
| style={{backgroundImage: `url(${thumbnailUrl})`}} | ||
| > | ||
| <div className={styles.ThumbnailContainer}> | ||
| <div | ||
| className={styles.Thumbnail} | ||
| style={{backgroundImage: `url(${thumbnailUrl})`}} | ||
| /> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| <button | ||
| type="button" | ||
| className={styles.PlayButton} | ||
|
|
@@ -122,9 +133,8 @@ export function VideoThumbnail({ | |
| onFocus={onBeforeStartPlaying} | ||
| onTouchStart={onBeforeStartPlaying} | ||
| > | ||
| <img className={styles.PlayIcon} src={PlayIcon} alt="" /> | ||
| {timeStampMarkup} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving this inside since it changes opacity on hover and the button is the whole thumbnail |
||
| </button> | ||
| {timeStampMarkup} | ||
| {progressMarkup} | ||
| </div> | ||
| ); | ||
|
|
||
This file was deleted.
This file was deleted.


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't used
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish there was a tool to find unused scss class names. Could be impactful across multiple repos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was actually looking into something like that this morning :D Definitely possible and would be so useful