Skip to content

Commit

Permalink
Add Contextual VideoCard and VideoThumbnail components (Shopify#2725)
Browse files Browse the repository at this point in the history
* Initial commit of adding the two components

* Rewrote tests to follow Polaris test style

* requested changes for easier diff viewing/copying

* Renamed VideoCard to MediaCard

* Edited documentation

* Renamed media card variables

* First doc edits from content session 1

* [MediaCard] Finished README; require children

* [VideoThumbnail] finalized doc

* add missing prop descriptions

* fix into doc commit

* [VideoThumbnail] Call onBeforeStartPlaying onFocus for keyboard supportted video preloading

* [VideoThumbnail] Account for all combos of hours, mins, and secs

* [VideoThumbnail] Fix test coverage

* fix change log

* lint 😑

* [MediaCard] remove Popover.preventAutofocus

* little fixes

Co-authored-by: Chloe Rice <chloe.rice@shopify.com>
  • Loading branch information
2 people authored and athornburg committed Apr 15, 2020
1 parent 6dce31e commit 0b85374
Show file tree
Hide file tree
Showing 18 changed files with 1,297 additions and 33 deletions.
4 changes: 3 additions & 1 deletion .storybook/polaris-readme-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ import {
Link,
List,
Loading,
MediaCard,
Modal,
Navigation,
OptionList,
Expand Down Expand Up @@ -189,7 +190,8 @@ import {
TrapFocus,
Truncate,
UnstyledLink,
VisuallyHidden
VisuallyHidden,
VideoThumbnail
} from '@shopify/polaris';
import {
PlusMinor,
Expand Down
7 changes: 7 additions & 0 deletions UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

### Breaking changes

### New components

- Added [`MediaCard`](https://polaris.shopify.com/components/structure/video-card) and [`VideoThumbnail`](https://polaris.shopify.com/components/images-and-icons/video-thumbnail) ([#2725](https://github.com/Shopify/polaris-react/pull/2725))
- Added [`VideoThumbnail`](https://polaris.shopify.com/components/images-and-icons/video-thumbnail) ([#2725](https://github.com/Shopify/polaris-react/pull/2725))

### Enhancements

- Added utilities for parsing video duration (https://polaris.shopify.com/components/images-and-icons/video-thumbnail) ([#2725](https://github.com/Shopify/polaris-react/pull/2725))

### Bug fixes

### Documentation
Expand Down
83 changes: 51 additions & 32 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
"label": "Avatar",
"labelWithInitials": "Avatar with initials {initials}"
},

"Autocomplete": {
"spinnerAccessibilityLabel": "Loading"
},

"Badge": {
"PROGRESS_LABELS": {
"incomplete": "Incomplete",
Expand All @@ -23,12 +21,10 @@
"new": "New"
}
},

"Button": {
"spinnerAccessibilityLabel": "Loading",
"connectedDisclosureAccessibilityLabel": "Related actions"
},

"Common": {
"checkbox": "checkbox",
"undo": "Undo",
Expand All @@ -39,19 +35,16 @@
"submit": "Submit",
"more": "More"
},

"ContextualSaveBar": {
"save": "Save",
"discard": "Discard"
},

"DataTable": {
"sortAccessibilityLabel": "sort {direction} by",
"navAccessibilityLabel": "Scroll table {direction} one column",
"totalsRowHeading": "Totals",
"totalRowHeading": "Total"
},

"DatePicker": {
"previousMonth": "Show previous month, {previousMonthName} {showPreviousYear}",
"nextMonth": "Show next month, {nextMonth} {nextYear}",
Expand Down Expand Up @@ -80,20 +73,17 @@
"sunday": "Su"
}
},

"DiscardConfirmationModal": {
"title": "Discard all unsaved changes",
"message": "If you discard changes, you’ll delete any edits you made since you last saved.",
"primaryAction": "Discard changes",
"secondaryAction": "Continue editing"
},

"DropZone": {
"overlayTextFile": "Drop file to upload",
"overlayTextImage": "Drop image to upload",
"errorOverlayTextFile": "File type is not valid",
"errorOverlayTextImage": "Image type is not valid",

"FileUpload": {
"actionTitleFile": "Add file",
"actionTitleImage": "Add image",
Expand All @@ -102,28 +92,23 @@
"label": "Upload file"
}
},

"EmptySearchResult": {
"altText": "Empty search results"
},

"Frame": {
"skipToContent": "Skip to content",
"Navigation": {
"closeMobileNavigationLabel": "Close navigation"
}
},

"Icon": {
"backdropWarning": "The {color} icon doesn’t accept backdrops. The icon colors that have backdrops are: {colorsWithBackDrops}"
},

"ActionMenu": {
"RollupActions": {
"rollupButton": "Actions"
}
},

"Filters": {
"moreFilters": "More filters",
"moreFiltersWithCount": "More filters ({count})",
Expand All @@ -135,23 +120,19 @@
"clear": "Clear",
"clearLabel": "Clear {filterName}"
},

"Modal": {
"iFrameTitle": "body markup",
"modalWarning": "These required properties are missing from Modal: {missingProps}"
},

"Pagination": {
"previous": "Previous",
"next": "Next",
"pagination": "Pagination"
},

"ProgressBar": {
"negativeWarningMessage": "Values passed to the progress prop shouldn’t be negative. Resetting {progress} to 0.",
"exceedWarningMessage": "Values passed to the progress prop shouldn’t exceed 100. Setting {progress} to 100."
},

"ResourceList": {
"sortingLabel": "Sort by",
"defaultItemSingular": "item",
Expand All @@ -171,34 +152,28 @@
"a11yCheckboxSelectAllMultiple": "Select all {itemsLength} {resourceNamePlural}",
"ariaLiveSingular": "{itemsLength} item",
"ariaLivePlural": "{itemsLength} items",

"Item": {
"actionsDropdownLabel": "Actions for {accessibilityLabel}",
"actionsDropdown": "Actions dropdown",
"viewItem": "View details for {itemName}"
},

"BulkActions": {
"actionsActivatorLabel": "Actions",
"moreActionsActivatorLabel": "More actions",
"warningMessage": "To provide a better user experience. There should only be a maximum of {maxPromotedActions} promoted actions."
},

"FilterCreator": {
"filterButtonLabel": "Filter",
"selectFilterKeyPlaceholder": "Select a filter\u2026",
"addFilterButtonLabel": "Add filter",
"showAllWhere": "Show all {resourceNamePlural} where:"
},

"FilterControl": {
"textFieldLabel": "Search {resourceNamePlural}"
},

"FilterValueSelector": {
"selectFilterValuePlaceholder": "Select a filter\u2026"
},

"DateSelector": {
"dateFilterLabel": "Select a value",
"dateValueLabel": "Date",
Expand Down Expand Up @@ -230,35 +205,79 @@
}
}
},

"SkeletonPage": {
"loadingLabel": "Page loading"
},

"Spinner": {
"warningMessage": "The color {color} is not meant to be used on {size} spinners. The colors available on large spinners are: {colors}"
},

"Tabs": {
"toggleTabsLabel": "More tabs"
},

"Tag": {
"ariaLabel": "Remove {children}"
},

"TextField": {
"characterCount": "{count} characters",
"characterCountWithMaxLength": "{count} of {limit} characters used"
},

"TopBar": {
"toggleMenuLabel": "Toggle menu",

"SearchField": {
"clearButtonLabel": "Clear",
"search": "Search"
}
},
"MediaCard": {
"popoverButton": "Actions"
},
"VideoThumbnail": {
"playButtonA11yLabel": {
"default": "Play video",
"defaultWithDuration": "Play video of length {duration}",
"duration": {
"hours": {
"other": {
"only": "{hourCount} hours",
"andMinutes": "{hourCount} hours and {minuteCount} minutes",
"andMinute": "{hourCount} hours and {minuteCount} minute",
"minutesAndSeconds": "{hourCount} hours, {minuteCount} minutes, and {secondCount} seconds",
"minutesAndSecond": "{hourCount} hours, {minuteCount} minutes, and {secondCount} second",
"minuteAndSeconds": "{hourCount} hours, {minuteCount} minute, and {secondCount} seconds",
"minuteAndSecond": "{hourCount} hours, {minuteCount} minute, and {secondCount} second",
"andSeconds": "{hourCount} hours and {secondCount} seconds",
"andSecond": "{hourCount} hours and {secondCount} second"
},
"one": {
"only": "{hourCount} hour",
"andMinutes": "{hourCount} hour and {minuteCount} minutes",
"andMinute": "{hourCount} hour and {minuteCount} minute",
"minutesAndSeconds": "{hourCount} hour, {minuteCount} minutes, and {secondCount} seconds",
"minutesAndSecond": "{hourCount} hour, {minuteCount} minutes, and {secondCount} second",
"minuteAndSeconds": "{hourCount} hour, {minuteCount} minute, and {secondCount} seconds",
"minuteAndSecond": "{hourCount} hour, {minuteCount} minute, and {secondCount} second",
"andSeconds": "{hourCount} hour and {secondCount} seconds",
"andSecond": "{hourCount} hour and {secondCount} second"
}
},
"minutes": {
"other": {
"only": "{minuteCount} minutes",
"andSeconds": "{minuteCount} minutes and {secondCount} seconds",
"andSecond": "{minuteCount} minutes and {secondCount} second"
},
"one": {
"only": "{minuteCount} minute",
"andSeconds": "{minuteCount} minute and {secondCount} seconds",
"andSecond": "{minuteCount} minute and {secondCount} second"
}
},
"seconds": {
"other": "{secondCount} seconds",
"one": "{secondCount} second"
}
}
}
}
}
}
63 changes: 63 additions & 0 deletions src/components/MediaCard/MediaCard.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@import '../../styles/common';

$portrait-breakpoint: 804px;

.MediaCard {
height: 100%;
width: 100%;
display: flex;
flex-flow: row wrap;

&.portrait {
flex-flow: column nowrap;
}

@include breakpoint-before($portrait-breakpoint, inclusive) {
flex-flow: column nowrap;
}
}

.MediaContainer {
&:not(.portrait) {
flex-basis: 40%;
}
}

.InfoContainer {
position: relative;

&:not(.portrait) {
flex-basis: 60%;
}
}

.Popover {
position: absolute;
z-index: z-index(overlay);
top: spacing();
right: spacing();
}

.Heading {
margin-right: spacing(extra-loose);
}

.PrimaryAction {
margin-right: spacing(tight);
}

.SecondaryAction {
margin-left: -spacing(tight);
}

.ActionContainer {
padding-top: spacing(tight);

&.portrait {
padding-top: spacing(extra-loose);
}

@include breakpoint-before($portrait-breakpoint, inclusive) {
padding-top: spacing(extra-loose);
}
}
Loading

0 comments on commit 0b85374

Please sign in to comment.