This page has lots of good 'old HTML headings and content, wrapped in some
<spicy-sections>
custom elements. This decorator
element allows us to engage different named ux control affordances to the
sectioning content they wrap. A <spicy-sections>
can
present (and provide accessibility characteristics of) its sectioning
content as:
collapse
Each section is independently toggleable as
collapsed or expanded (image example).
exclusive-collapse
Like a single-select accordion or
'responsive tabs' (image example).
tab-bar
An exclusive collapse mode which projects headings
into a tab-bar (image example).
<spicy-sections>
allows us to supply information about
how to decide how it displays and what controls/affordances are provided
via MediaQueries (MediaAffordances
, here). The light DOM
doesn't change, everything is stylable, mainly through your elements
themselves. There are two affordance ::parts
. It is possible
to style the affordances employed differently as well.
Effectively, affordances can be thought of as selection managers (controllers that maintain state of the affordance). Managing selection of the affordance is similar to how checkboxes toggle independently (collapse) vs radio buttons are mutually exclusive choices (exclusive-collapse, tab-bar). Here, it is the selection managers that carry the state, and not the DOM elements. You'll note that if you bounce between them, their states exclusive and non-exclusive states can be maintained independently (You can see this in demo #2 which moves from radiobutton-like tabs to checkbox-like collapses)
Look at this page's content and then resize your window various ways to see how the affordances change...
collapse
.
tab-bar
.
Albert Einstein (/ˈaɪnstaɪn/ EYEN-styne;[4] German: [ˈalbɛʁt ˈʔaɪnʃtaɪn]; 14 March 1879 – 18 April 1955) was a German-born theoretical physicist,[5] widely acknowledged to be one of the greatest physicists of all time.
He is known for:
Nutritional Information Lentil Soup Servings Per Recipe: 6 Amount Per Serving Calories: 349 % Daily Value * Total Fat: 10g 15 % Saturated Fat: 1.0g Cholesterol: 0mg 0 % Sodium: 131mg 5 % Potassium: 970mg 27 % Total Carbohydrates: 48.2g 16 % Dietary Fiber: 22.2g 89 % Protein: 18.3g 37 % Sugars: 3g Vitamin A: 4230IU Vitamin C: 13mg Calcium: 98mg Iron: 6mg Thiamin: 0mg Niacin: 6mg Vitamin B6: 1mg Magnesium: 104mg Folate: 334mcg
* Percent Daily Values are based on a 2,000 calorie diet. Your daily values may be higher or lower depending on your calorie needs.
** Nutrient information is not available for all ingredients. Amount is based on available nutrient data. (-) Information is not currently available for this nutrient. If you are following a medically restrictive diet, please consult your doctor or registered dietitian before preparing this recipe for personal consumption. Powered by the ESHA Research Database © 2020, ESHA Research, Inc. All Rights Reserved
You can wrap the same element around a lone section and have it present summary/details like or as regular content too.
You can read about the ideas this is trying to flesh out in my blog post Design Affordance Controls. You can read more information about the region set, API, issues and so on through the home page of this glitch.