retil-interactions

Utilities to create unstyled interactive components

Usage no npm install needed!

<script type="module">
  import retilInteractions from 'https://cdn.skypack.dev/retil-interactions';
</script>

README

retil-interactions

  • this package should be completely free of styles or integrations for specific, style libraries, but does contain useStyles, which takes a style object of various forms possibly including named selectors, and replaces any named selectors with selectors from the context.

  • this package should contain usePopupTrigger, usePopup

  • things to test:

    • can we configure for usage with styled-components using a single global Provider? we'd probably need to configure a way of patching theme context, as well as the stuff to actually patch it with. we'd want a separate retil-interactions-styled-components package to handle this

      For our surfaces, we can probably use constant class names instead of using class names generated for empty styled components. e.g. an AnchorSurface could have a "retil-anchor-surface" classname, and we could just build our selectors based on that. No need for fancy styled components stuff.

      For , we can actually use a :first-child selector to pick out whatever control is the first child, which allows us to select anything.

  • why may want to then export reset styles for anchors, buttons, inputs, etc. along with UnstyledAnchor, UnstyledButton, UnstyledInput, etc. in a separate package.


  • surface and control primitives

    these render individual DOM elements, setting up context such that embedded styled components can target interaction states like hover, disabled, etc.

    • * can be difficult to style, you may want to use a div surface instead
    • <DivSurface activated onPress?>
      • you'll need to manually set aria roles, as I don't want to make assumptions
    • * must be rendered inside a form * actually sets the "disabled" attribute when disabled

    exported by retil-router

    • - will not change interaction state based on url

    • - sets up default "activated" state based on url

    • * sets up an interaction context for a control, putting into the context a ref that can be passed to the focusable part of the control to extract its interaction state. * renders a DelegateFocusProvider, delegating focus on any surfaces to the control
    • useControlRef() - returns the ref created by ControlInteractionProvider

    • <ControlDiv control decorators? />

      • "control" is an element that will be rendered as the first child of this component. e.g. ,