Skip to content

Commit

Permalink
chore: add flipper spec (microsoft#2862)
Browse files Browse the repository at this point in the history
* chore: add flipper spec

* include direction which was forgotten as attr

* remove label prop in favor of using aria

* add detail to hidden from at behavior
  • Loading branch information
chrisdholt authored Apr 6, 2020
1 parent a821bb7 commit 6d18b44
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 0 deletions.
1 change: 1 addition & 0 deletions specs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Here you'll find specifications for custom elements and other library features.
- [Card](./card/card.md)
- [Checkbox](./checkbox.md)
- [Dialog](./dialog/dialog.md)
- [Flipper](./flipper/flipper.md)
- [Form associated custom elements]("./form-associated-custom-element.md")
- [Menu](./menu/menu.md)
- [Number field](./number-field.md)
Expand Down
101 changes: 101 additions & 0 deletions specs/flipper/flipper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Flipper

## Overview

The flipper component is most often used to page through blocks of content or collections of ui elements.

### Use Cases
- Tony is looking for a new refrigerator. He goes onto his computer and navigates the browser to a site that sells appliances. He sees a list of refrigerators but not the one he wants so he clicks an arrow button (flipper) to show more. He sees a new GE Cafe that interests him and clicks on it which directs him to a purchase page.

- Bobby is blind and is also looking for a new refrigerator. He goes onto his computer and navigates the browser to the same site that sells appliances. He tabs through a list of refrigerators until he finds the one that was recommended to him by a friend. Bobby is unaware of the flipper.

### Non-goals
- Other button implementations

### Prior Art/Examples
Limited prior art is available from major component libraries, however many brands and products leverage flippers on the front page of their sites. From a cursory search, the following prominently display either a carousel or scrolling region powered by "flippers":
- Hulu
- Netflix
- Amazon
- Microsoft

---


### API

Extends FAST Element

*Component Name*
- `fast-flipper`

*Attrs*
- `direction` - enum, previous or next. Defaults to next
- `hiddenFromAT` - The control is hidden from assistive technology. In the case that `aria-hidden` exists on the host, the control will default to that value and respond accordingly. If it doesn't exist, we'll internally default to hiding this from AT.
- `disabled` - the control is disabled. There are scenarios where a flipper would be visible and disabled

*Events*
- `click` - mimics the click event of traditional buttons

### Anatomy and Appearance

```
<template
role="button"
aria-hidden=${x => x.hiddenFromAT}
aria-disabled=${x => x.disabled}
tabindex=${x => x.hiddenFromAT ? -1 : 0}
>
${when(
x => x.direction === "next",
html`
<slot name="next" part="next"></slot>
`
)}
${when(
x => x.direction === "previous",
html`
<slot name="previous" part="previous"></slot>
`
)}
</template>
```


*Screenshots below are of the basic appearance of the component and are not exhaustive.*

| State | Image |
| ----- | ----- |
| previous | ![](./images/previous.png) |
| previous (hover) | ![](./images/previous-hover.png)
| next | ![](./images/next.png)
| next (hover) | ![](./images/next-hover.png)
| dark | ![](./images/previous-dark.png)
| dark (hover) | ![](./images/previous-dark-hover.png)

*Slot Names*
- next - often times a glyph, icon, or text to represent "next" interaction
- previous - often times a glyph, icon, or text to represent "previous" interaction

*Host Classes*
- disabled

*CSS Parts*
- next
- previous

---

## Implementation

### Accessibility

In a majority of use cases, flippers should be hidden from assistive technologies as it typically is a secondary method of navigation which can be confusing for users. Flippers are hidden from screen readers by default, but can be exposed by passing `false` to the `hiddenFromAT` prop. When exposing flippers to screen readers, it's important to pass an `aria-label` if the flipper content is purely presentational and not text. Correct and precise labeling of a component that is purely visual and has no textual context is needed to give proper context to assistive technologies.

### Globalization

Next and previous content should swap in LTR/RTL presentations.

### Test Plan

While testing is still TBD for our web components, I would expect this to align with the testing strategy and not require any additional test support.
Binary file added specs/flipper/images/next-hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added specs/flipper/images/next.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added specs/flipper/images/previous-dark-hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added specs/flipper/images/previous-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added specs/flipper/images/previous-hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added specs/flipper/images/previous.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6d18b44

Please sign in to comment.