├── .gitbook └── assets │ ├── image (1).png │ ├── image (10).png │ ├── image (11).png │ ├── image (2).png │ ├── image (3).png │ ├── image (4).png │ ├── image (5).png │ ├── image (6).png │ ├── image (7).png │ ├── image (8).png │ ├── image (9).png │ └── image.png ├── README.md ├── SUMMARY.md ├── complex-components ├── accordions.md ├── datepickers.md └── tabs.md ├── faqs.md ├── form-components ├── checkboxes │ ├── README.md │ ├── anti-patterns-checkboxes.md │ └── styling-checkboxes.md ├── input │ ├── README.md │ ├── antipatterns-text-fields.md │ └── styling-input-fields.md ├── radio-buttons │ ├── README.md │ ├── antipatterns-radio-buttons.md │ └── styling-radio-buttons.md ├── select-element.md └── typeahead.md ├── general-considerations ├── considering-forms.md └── use-of-aria-live.md ├── global-components ├── buttons │ ├── README.md │ └── antipatterns-buttons.md └── images.md ├── messaging ├── alerts.md └── modals.md └── navigation ├── breadcrumbs.md ├── navbar ├── README.md └── antipatterns-navbars.md └── pagination ├── README.md └── styling-pagination.md /.gitbook/assets/image (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MelSumner/ember-component-patterns/c2306d556b58adf77b569f7680513caec0007a6d/.gitbook/assets/image (1).png -------------------------------------------------------------------------------- /.gitbook/assets/image (10).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MelSumner/ember-component-patterns/c2306d556b58adf77b569f7680513caec0007a6d/.gitbook/assets/image (10).png -------------------------------------------------------------------------------- /.gitbook/assets/image (11).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MelSumner/ember-component-patterns/c2306d556b58adf77b569f7680513caec0007a6d/.gitbook/assets/image (11).png -------------------------------------------------------------------------------- /.gitbook/assets/image (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MelSumner/ember-component-patterns/c2306d556b58adf77b569f7680513caec0007a6d/.gitbook/assets/image (2).png -------------------------------------------------------------------------------- /.gitbook/assets/image (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MelSumner/ember-component-patterns/c2306d556b58adf77b569f7680513caec0007a6d/.gitbook/assets/image (3).png -------------------------------------------------------------------------------- /.gitbook/assets/image (4).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MelSumner/ember-component-patterns/c2306d556b58adf77b569f7680513caec0007a6d/.gitbook/assets/image (4).png -------------------------------------------------------------------------------- /.gitbook/assets/image (5).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MelSumner/ember-component-patterns/c2306d556b58adf77b569f7680513caec0007a6d/.gitbook/assets/image (5).png -------------------------------------------------------------------------------- /.gitbook/assets/image (6).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MelSumner/ember-component-patterns/c2306d556b58adf77b569f7680513caec0007a6d/.gitbook/assets/image (6).png -------------------------------------------------------------------------------- /.gitbook/assets/image (7).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MelSumner/ember-component-patterns/c2306d556b58adf77b569f7680513caec0007a6d/.gitbook/assets/image (7).png -------------------------------------------------------------------------------- /.gitbook/assets/image (8).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MelSumner/ember-component-patterns/c2306d556b58adf77b569f7680513caec0007a6d/.gitbook/assets/image (8).png -------------------------------------------------------------------------------- /.gitbook/assets/image (9).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MelSumner/ember-component-patterns/c2306d556b58adf77b569f7680513caec0007a6d/.gitbook/assets/image (9).png -------------------------------------------------------------------------------- /.gitbook/assets/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MelSumner/ember-component-patterns/c2306d556b58adf77b569f7680513caec0007a6d/.gitbook/assets/image.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: >- 3 | This guide intends to be aligned with the idioms and syntax of the Octane 4 | edition of Ember. 5 | --- 6 | 7 | # Ember Component Patterns 8 | 9 | The goal of this guide is to cultivate a set of patterns that are practical and can reasonably be used by any Ember developer in their application. It is intended to be made publicly available with the [preview release of Ember Octane](https://emberjs.com/editions/octane/). 10 | 11 | The component patterns here will, at least initially, be without CSS styling. This is to help clearly delineate form and function. "First, make it useful; then make it beautiful" as the saying goes. When necessary to demonstrate the validity of the approach, however, a sub-section on styling may be added to the pattern if it helps to demonstrate what might otherwise be thought of as impossible. 12 | 13 | As this project matures, the [anti-patterns](https://en.wikipedia.org/wiki/Anti-pattern) will be explored by adding more prose and explains to demonstrate why other options were not chosen, providing both a well-lit path for success and a knowledge base for the shadows. 14 | 15 | What one can obtain from this collection of patterns depends on the reader; however a few potential types of readers, and possible goals, have been kept in mind. Some examples: 16 | 17 | ## For Developers 18 | 19 | * write more technically accurate code 20 | * worry a little bit less about writing code that is not accessible 21 | * have easy-to-reference base requirements for common component patterns 22 | * have confidence in the code you produce 23 | 24 | ## For Designers 25 | 26 | * understand what components really need to have from a functional perspective 27 | * ensure that designs will include the necessary functionality and accessibility 28 | * focus on design within clear technical constraints 29 | 30 | ## For BAs & TPMs 31 | 32 | * reference to help you more accurately know base requirements for the new feature\(s\) you want to add to your project 33 | * confidently plan out projects more accurately by reducing "unknown unknowns" 34 | 35 | {% hint style="info" %} 36 | Feedback is welcome! Visit the [GitHub repository for this project](https://github.com/MelSumner/ember-component-patterns) to raise an issue. 37 | {% endhint %} 38 | 39 | -------------------------------------------------------------------------------- /SUMMARY.md: -------------------------------------------------------------------------------- 1 | # Table of contents 2 | 3 | * [Ember Component Patterns](README.md) 4 | * [FAQs](faqs.md) 5 | 6 | ## General Considerations 7 | 8 | * [Considering Forms](general-considerations/considering-forms.md) 9 | * [Use of aria-live](general-considerations/use-of-aria-live.md) 10 | 11 | ## Global Components 12 | 13 | * [Buttons](global-components/buttons/README.md) 14 | * [Anti-patterns: Buttons](global-components/buttons/antipatterns-buttons.md) 15 | * [Images](global-components/images.md) 16 | 17 | ## Form Components 18 | 19 | * [Checkboxes](form-components/checkboxes/README.md) 20 | * [Anti-patterns: Checkboxes](form-components/checkboxes/anti-patterns-checkboxes.md) 21 | * [Styling: Checkboxes](form-components/checkboxes/styling-checkboxes.md) 22 | * [Text Fields](form-components/input/README.md) 23 | * [Anti-patterns: Text Fields](form-components/input/antipatterns-text-fields.md) 24 | * [Styling: Text Fields](form-components/input/styling-input-fields.md) 25 | * [Radio Buttons](form-components/radio-buttons/README.md) 26 | * [Anti-patterns: Radio Buttons](form-components/radio-buttons/antipatterns-radio-buttons.md) 27 | * [Styling: Radio Buttons](form-components/radio-buttons/styling-radio-buttons.md) 28 | * [Select Element](form-components/select-element.md) 29 | * [Typeahead/Combobox](form-components/typeahead.md) 30 | 31 | ## Navigation 32 | 33 | * [Navbar](navigation/navbar/README.md) 34 | * [Anti-patterns: Navbar](navigation/navbar/antipatterns-navbars.md) 35 | * [Breadcrumbs](navigation/breadcrumbs.md) 36 | * [Pagination](navigation/pagination/README.md) 37 | * [Styling: Pagination](navigation/pagination/styling-pagination.md) 38 | 39 | ## Messaging 40 | 41 | * [Modal](messaging/modals.md) 42 | * [Alerts](messaging/alerts.md) 43 | 44 | ## Complex Components 45 | 46 | * [Tabs](complex-components/tabs.md) 47 | * [Accordions](complex-components/accordions.md) 48 | * [Datepickers](complex-components/datepickers.md) 49 | 50 | -------------------------------------------------------------------------------- /complex-components/accordions.md: -------------------------------------------------------------------------------- 1 | # Accordions 2 | 3 | Coming Soon! 4 | 5 | -------------------------------------------------------------------------------- /complex-components/datepickers.md: -------------------------------------------------------------------------------- 1 | # Datepickers 2 | 3 | Coming Soon! 4 | 5 | -------------------------------------------------------------------------------- /complex-components/tabs.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Coming Soon! 3 | --- 4 | 5 | # Tabs 6 | 7 | -------------------------------------------------------------------------------- /faqs.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: >- 3 | As this project identifies FAQs, they will be posted here. If you have a 4 | question that is not answered here, please ask in the #topic-a11y channel in 5 | the Ember Community Discord chat. 6 | --- 7 | 8 | # FAQs 9 | 10 | ## Why don't you make this into an addon? 11 | 12 | This is not an addon because each app will have different needs and requirements. Instead, this guide is intended to demonstrate best practices so teams can build the components that are right for their project. Additionally, an addon requires maintenance, which is a non-negligible set of work on its own. 13 | 14 | ## Why isn't \(insert component name here\) in this guide? 15 | 16 | It's likely that your favorite component pattern isn't here yet because it hasn't been added yet. Or it's a carousel and those will never be here because they should never be used. 17 | 18 | ## You made a mistake! How do I tell you about it? 19 | 20 | Thanks for catching it! Please file an issue here: [https://github.com/MelSumner/ember-component-patterns/issues](https://github.com/MelSumner/ember-component-patterns/issues). 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /form-components/checkboxes/README.md: -------------------------------------------------------------------------------- 1 | # Checkboxes 2 | 3 | ## Introduction 4 | 5 | Checkboxes are a useful input element when it is desirable to allow users to select more than one option from a short list of options. Checkboxes can have three states: checked, not checked, and indeterminate. 6 | 7 | ### User Expectations 8 | 9 | Users expect the following to be true: 10 | 11 | * it should be possible to navigate via keyboard 12 | * animations should not be linked to functionality; if the user has disabled animations via system preferences, the checkbox should still be usable 13 | * there should be a clear indicator of focus 14 | * clicking on the label for the checkbox should also activate the checkbox itself \(this is done through properly [associating the label](../../general-considerations/considering-forms.md#labels) with the checkbox\) 15 | 16 | ## Part One: Considering Markup 17 | 18 | Sometimes, a single checkbox is desirable. In these cases, a checkbox input only requires an associated label for the input: 19 | 20 | ```markup 21 |
22 | 23 | 24 |
25 | ``` 26 | 27 | If the user should be able to select more than one option, a checkbox group should be used. To ensure that all of the checkboxes are associated with the single group, the `name` attribute value should be the same, and the checkbox group should be wrapped with the `
` element: 28 | 29 | ```markup 30 |
31 | What kind of jobs are you interested in (select all that apply)? 32 |
33 | 34 | 35 |
36 |
37 | 38 | 39 |
40 |
41 | 42 | 43 |
44 |
45 | 46 | 47 |
48 |
49 | ``` 50 | 51 | ### Keyboard Support 52 | 53 | | Key | Function | 54 | | :--- | :--- | 55 | 56 | 57 | 58 | 59 | 60 | 62 | 67 | 68 | 69 | 70 |
TAB 61 | 63 |
    64 |
  • Moves keyboard focus among the checkboxes
  • 65 |
66 |
71 | 72 | 73 | 74 | 75 | 77 | 90 | 91 | 92 | 93 |
SPACE 76 | 78 |
    79 |
  • Cycles the tri-state checkbox among unchecked, mixed, and checked states.
  • 80 |
  • When the tri-state checkbox is unchecked, all the controlled checkboxes 81 | are unchecked.
  • 82 |
  • When the tri-state checkbox is mixed, the controlled checkboxes return 83 | to the last combination of states they had when the tri-state checkbox 84 | was last mixed or to the default combination of states they had when the 85 | page loaded.
  • 86 |
  • When the tri-state checkbox is checked, all the controlled checkboxes 87 | are checked.
  • 88 |
89 |
94 | 95 | Ember has a checkbox input helper- [https://guides.emberjs.com/release/templates/input-helpers/\#toc\_checkboxes](https://guides.emberjs.com/release/templates/input-helpers/#toc_checkboxes) - but it should not be used in the place of common sense. Use this helper if it is sensible to do so. 96 | 97 | \(More explicit guidance and additional scenarios coming soon\) 98 | 99 | ## Part Three: Abstracting for reuse 100 | 101 | Coming soon! 102 | 103 | ## References 104 | 105 | * [https://www.w3.org/TR/wai-aria-practices-1.1/\#checkbox](https://www.w3.org/TR/wai-aria-practices-1.1/#checkbox) 106 | * [https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox) 107 | * [https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/checkbox\_role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/checkbox_role) 108 | * [https://codepen.io/jensimmons/pen/KKPzxJa](https://codepen.io/jensimmons/pen/KKPzxJa) 109 | 110 | {% hint style="info" %} 111 | Feedback is welcome! Visit the [GitHub repository for this project](https://github.com/MelSumner/ember-component-patterns) to raise an issue. 112 | {% endhint %} 113 | 114 | -------------------------------------------------------------------------------- /form-components/checkboxes/anti-patterns-checkboxes.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: >- 3 | Anti-patterns produce outcomes that are ineffective because they are not 4 | complete solutions, and as such are counterproductive. Developers are advised 5 | to be aware of anti-patterns and avoid their use. 6 | --- 7 | 8 | # Anti-patterns: Checkboxes 9 | 10 | ## Anti-pattern \#1: heading as checkbox group label 11 | 12 | The use of the header element with a wrapper div around a group of checkboxes may be a tempting approach at first sight. 13 | 14 | Consider this: 15 | 16 | ```markup 17 |
18 |

What are your preferred job titles?

19 |
20 | 21 | 22 |
23 |
24 | 25 | 26 |
27 |
28 | 29 | 30 |
31 |
32 | ``` 33 | 34 | At first glance, all might seem fine. However, as assistive technology such as a screen reader will not associate the title and the options correctly, this approach should be considered an anti-pattern and should be avoided. 35 | 36 | Instead, use the `
` with a `` to successfully contain and associate the checkbox group. It should be remembered that the default styling for these elements can be overridden and should not be considered a blocker for their use. 37 | 38 | -------------------------------------------------------------------------------- /form-components/checkboxes/styling-checkboxes.md: -------------------------------------------------------------------------------- 1 | # Styling: Checkboxes 2 | 3 | ## Preventing Text Selection 4 | 5 | Occasionally, when a checkbox is activated or deactivated, the input's label text appears selected. If this is bothersome, a little CSS can help: 6 | 7 | ```css 8 | label { 9 | user-select: none; 10 | } 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /form-components/input/README.md: -------------------------------------------------------------------------------- 1 | # Text Fields 2 | 3 | ## Introduction 4 | 5 | It seems as though most of the practical web is all about input fields. To create a form is simple, some might say; but to create it well requires a depth of knowledge about many different areas of this thing we call web design and development. 6 | 7 | ## Part One: Considering Markup 8 | 9 | {% hint style="danger" %} 10 | The examples in this section have been truncated to focus on accessibility. Simply copying and pasting these code samples will not produce a _complete_ result- some necessary attributes will have been left out. 11 | {% endhint %} 12 | 13 | ### Specification Considerations 14 | 15 | * An input field must have associated `