Code Monkey home page Code Monkey logo

a11y-elements's People

Contributors

westbrook avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

a11y-elements's Issues

Acquiring data...

It's easy to hide away everything that goes into an element and only ship something like the followign over the wire:

<my-element></my-element>
<script>
document.querySelector('my-element').data = data;
</script>

This can be particularly useful in the context of a child element, as it means that in-app implementations get to take less into account, there are just passing a data object, after all.

However, the data = data context will fail in non-JS contexts, presents difficulty in the context of rendering on the server, and will likely require a fairly complex configuration object, and/or a high number of attributes and properties to ensure that reusability is as high as it can/needs to be. To that end, I think it is important to explore APIs that draw on slotted content as much as possible to populate the final shadow DOM output. In some cases that may be fairly easy to manage, one final piece of content === one slot certainly keeps things simple. However, when you need a variable amount of content/slots, things can get hairy quickly and if you want to wrap that slotted content in more complex DOM, things are even less direct.

I'd love to establish a pattern that allowed web components to act more directly like we see with select elements:

<select value="something">
    <option value="nothing">Nothing</option>
    <option value="somthing>Something</option>
</select>

When you insect that select element, much of its internal API is a surfacing of the option elements internal to it as data. It's like SSR when it was still just rendering on the server, as opposed to the complex and varied topic it's morphed into as of late.

I spent a good part of a day chatting with Erik Isaksen about this concept earlier this week in the context of a tabs pattern, and together we worked towards an idea that looks like this: https://stackblitz.com/edit/lit-element-7q3rfk?file=tab-viewer.js Mix slots and Mutation observer to manage a dynamic template of projection points for your light DOM content... and it's coming together fairly nicely, if I do say so myself. It would seem that with some more abstraction that this could serve as a basis for data acquisition from the DOM across a number of accessible patterns.

In so far as the only element in question so far is the a11y-accordion, I'm going to put together a more specific issue to outline how I think we could leverage this pattern in that context, soon. In the interim, I'd love to hear any thoughts that this might bring to anyone's mind.

Thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.