You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement remaining W3C HTML global attributes (#257)
This commit implements 25 W3C global HTML attributes as ViewModifiers,
completing the full suite of remaining global attributes from the HTML
specification. Each modifier balances W3C idioms with SwiftUI
conventions to provide a familiar experience for SwiftUI developers.
New modifiers added:
- accesskey(_:) - Keyboard shortcuts for element activation
- autocapitalize(_:) - Text capitalization control with enum
- autofocus(_:) - Page load focus control
- contenteditable(_:) - Content editability with enum/bool support
- direction(_:) - Text directionality (ltr, rtl, auto)
- draggable(_:) - Drag and drop support
- enterKeyHint(_:) - Virtual keyboard enter key hints
- hidden(_:) - Element visibility with state support
- inert(_:) - Non-interactive element marking
- inputMode(_:) - Virtual keyboard type hints
- customElement(_:) - Custom element support (is attribute)
- Microdata support (itemscope, itemtype, itemid, itemprop, itemref)
- nonce(_:) - Content Security Policy nonce
- popover(_:) - Popover element support with state
- slot(_:) - Shadow DOM slot assignment
- spellcheck(_:) - Spell checking control
- inlineStyle(_:) - Inline CSS (style attribute)
- tabIndex(_:) / focusable() - Focus and keyboard navigation
- tooltip(_:) - Advisory information (title attribute)
- translatable(_:) - Translation control
- writingSuggestions(_:) - Browser writing suggestions
Updated AttributeModifier.GlobalAttribute enum with all new cases.
Updated documentation in SlipstreamForWebDevelopers.md with a new
"Global attributes" section mapping W3C attributes to Slipstream
modifiers.
Implementation follows established patterns using AttributeModifier and
ConditionalAttributeModifier for consistent behavior across the
codebase.
Part of #27
---------
Co-authored-by: Claude <noreply@anthropic.com>
Modeling after [the W3C specification](https://html.spec.whatwg.org/multipage/dom.html#global-attributes),
278
+
provided below is an organized table of W3C global HTML attributes and their equivalent Slipstream view modifiers.
279
+
280
+
### Global attributes
281
+
282
+
W3C attribute | Slipstream modifier | Notes
283
+
:-------------|:-------------------|:------
284
+
[`accesskey`](https://html.spec.whatwg.org/multipage/interaction.html#the-accesskey-attribute) | ``keyboardShortcut(_:)`` | Specifies a keyboard shortcut to activate or focus the element
285
+
[`autocapitalize`](https://html.spec.whatwg.org/multipage/interaction.html#attr-autocapitalize) | ``autocapitalize(_:)`` | Controls whether and how text input is automatically capitalized
286
+
[`autofocus`](https://html.spec.whatwg.org/multipage/interaction.html#attr-fe-autofocus) | ``autofocus(_:)`` | Indicates that the element should be focused on page load
287
+
`class` | ``className(_:)`` | Adds classes to the element. Use TailwindCSS modifiers for styling
288
+
[`contenteditable`](https://html.spec.whatwg.org/multipage/interaction.html#attr-contenteditable) | ``contenteditable(_:)`` | Indicates whether the element's content is editable
289
+
[`data-*`](https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes) | ``data(_:)`` | Sets custom data attributes on the view
290
+
[`dir`](https://html.spec.whatwg.org/multipage/dom.html#attr-dir) | ``direction(_:)`` | Specifies the element's text directionality
291
+
[`draggable`](https://html.spec.whatwg.org/multipage/dnd.html#attr-draggable) | ``draggable(_:)`` | Indicates whether the element can be dragged
292
+
[`enterkeyhint`](https://html.spec.whatwg.org/multipage/interaction.html#attr-enterkeyhint) | ``submitLabel(_:)`` | Hints at the action label for the enter key on virtual keyboards
293
+
[`hidden`](https://html.spec.whatwg.org/multipage/interaction.html#attr-hidden) | ``hidden(_:)`` | Sets the HTML hidden attribute (different from TailwindCSS hidden())
294
+
`id` | ``id(_:)`` | Sets the element's unique identifier
295
+
[`inert`](https://html.spec.whatwg.org/multipage/interaction.html#the-inert-attribute) | ``allowsHitTesting(_:)`` | Controls whether the element can receive user interaction (inverted logic)
296
+
[`inputmode`](https://html.spec.whatwg.org/multipage/interaction.html#attr-inputmode) | ``keyboardType(_:)`` | Sets the keyboard type for text input
297
+
[`is`](https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is) | ``customElement(_:)`` | Specifies the name of a custom element
298
+
[`itemid`](https://html.spec.whatwg.org/multipage/microdata.html#attr-itemid) | ``itemID(_:)`` | The globally unique identifier of a microdata item
299
+
[`itemprop`](https://html.spec.whatwg.org/multipage/microdata.html#names:-the-itemprop-attribute) | ``itemProp(_:)`` | Used to add properties to a microdata item
300
+
[`itemref`](https://html.spec.whatwg.org/multipage/microdata.html#attr-itemref) | ``itemRef(_:)`` | Associates non-descendant properties with a microdata item
301
+
[`itemscope`](https://html.spec.whatwg.org/multipage/microdata.html#attr-itemscope) | ``itemScope(_:)`` | Creates a new microdata item
302
+
[`itemtype`](https://html.spec.whatwg.org/multipage/microdata.html#attr-itemtype) | ``itemType(_:)`` | Specifies the vocabulary URL for a microdata item
303
+
[`lang`](https://html.spec.whatwg.org/multipage/dom.html#attr-lang) | ``language(_:)`` | Sets the primary language for the view's contents
304
+
[`nonce`](https://html.spec.whatwg.org/multipage/urls-and-fetching.html#attr-nonce) | ``nonce(_:)`` | A cryptographic nonce used by Content Security Policy
305
+
[`popover`](https://html.spec.whatwg.org/multipage/popover.html#attr-popover) | ``popover(_:)`` | Indicates that the element is a popover element
306
+
`slot` | ``slot(_:)`` | Assigns a slot in a shadow DOM shadow tree
307
+
[`spellcheck`](https://html.spec.whatwg.org/multipage/interaction.html#attr-spellcheck) | ``spellcheck(_:)`` | Specifies whether the element may be checked for spelling errors
308
+
[`style`](https://html.spec.whatwg.org/multipage/dom.html#attr-style) | ``inlineStyle(_:)`` | Contains CSS styling declarations. Prefer TailwindCSS modifiers when possible
309
+
[`tabindex`](https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex) | ``tabIndex(_:)`` or ``focusable()`` | Controls focus and keyboard navigation
310
+
[`title`](https://html.spec.whatwg.org/multipage/dom.html#attr-title) | ``tooltip(_:)`` | Advisory information, typically shown as a tooltip
311
+
[`translate`](https://html.spec.whatwg.org/multipage/dom.html#attr-translate) | ``translatable(_:)`` | Specifies whether content should be translated
312
+
[`writingsuggestions`](https://html.spec.whatwg.org/multipage/interaction.html#attr-writingsuggestions) | ``writingSuggestions(_:)`` | Controls whether browser-provided writing suggestions should be offered
0 commit comments