Skip to content

Considerations for progressive enhancement #1622

@theetrain

Description

@theetrain

🚧 Status: Draft 🚧

The following items are needed in order to enable progressive enhancement capabilities for prerendered or server-rendered components:

General: documentation

Add a special section for progressive enhancement, and provide badges for every component that contains explicit support for it. We may also want a checklist system for all components; that way it's clear which components does or does not support certain functionality.

General: Form actions and href

See #1599

  • components with an inner button should provide a formAttributes prop that is of type { formAction: fn } | HTMLAttributes<form>

    Example:

    <FluidForm formAttributes={{ action: "?/addItem", formAction: enhance }} />

    Underlying component has:

     <script>
       export let formAttributes: HTMLAttributes<form>
       $: ({ formAction, ...formAttrs } = formAttributes)
     </script>
     <form {...formAttrs} use:formAction />
  • components with inner buttons that can change data or state may receive an href prop, allowing users to choose a new page or the same page with searchParams, impacting the displayed information

UIShell

WIP

  • use media queries for responsive styles

Accordion

WIP

Breakpoint

  • discourage use for progressive enhancement
  • Consider providing utility classes or components for responsive show/hide logic

<Button>

  • <Button> can leverage the native formaction attribute to set its individual formaction path
  • SvelteKit's use:enhance only applies to <form> elements (see demo for enhanced button formaction); so we would have to either wrap <Button> or advise users to provide their own <form> since <Button> is a primitive single-element component
  • ButtonSet can have its vertical or horizontal style set with CSS media queries

Modal

WIP

DataTable

WIP

Combobox

WIP

Dropdown

WIP

Tabs

WIP

Toggle

WIP

Tooltip, Tooltip Icon, Tooltip Definition

WIP

Theme

WIP

UIShell

  • Menu items currently toggle on click. It may be possible to leverage :has and :active in order to keep sub-menus open after clicking on them without JS. Otherwise, we'll consider these 'enhanced with JS' and provide href props to the top-most links, and encourage users to provide index pages for top-level links
### Related Tasks
- [ ] #310 
- [ ] https://github.com/carbon-design-system/carbon-components-svelte/issues/1006
- [ ] https://github.com/carbon-design-system/carbon-components-svelte/issues/1006

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions