Skip to content

Commit 39445ba

Browse files
committed
feat(features): document more concepts and motivations
1 parent ffaa6bd commit 39445ba

9 files changed

Lines changed: 255 additions & 491 deletions

File tree

package-lock.json

Lines changed: 0 additions & 81 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/prose/features/00-motivations/accessibility.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,22 @@ publish: true
44
order: 0
55
---
66

7-
Baleada Features implements comprehensive, reusable, flexible features for **accessibility**, one of the core motivations behind the package.
7+
Baleada Features implements comprehensive **accessibility**.
88

9-
Some accessibility features—like ARIA role & attribute management, keyboard interactions, and focus management—are always required.
10-
Baleada Features takes care of all of those things for you!
9+
This includes accessibility features that are always required (like ARIA role & attribute management, keyboard interactions, and focus management) as well as optional, situational, and dynamic features.
1110

12-
For example, use your mouse, keyboard, touch, and screen reader to play with this custom multiselectable listbox, and note:
11+
For example, use your mouse, keyboard, touch, and screen reader to play with this custom multiselectable listbox, and note these features, required by WAI-ARIA guidelines:
1312
- It announces itself properly to assistive tech, including selection state and disabled state
1413
- It supports Excel-inspired pointer and keyboard interactions
1514
- It automatically manages focus on the listbox options
1615

1716
<ExampleListboxAccessible class="mt-6 mx-auto w-full with-max-w" variant="default" />
1817

19-
Other accessibility features are optional or situational.
20-
21-
For example, after you add the required accessible label to a listbox, you might want to add an optional description, announced to assistive tech. Baleada Features makes it easy to do so.
18+
And note how this listbox, which has the required label, also has a fully optional description that gets announced to assistive tech. Baleada Features makes this easy to do.
2219

2320
<ExampleListboxAccessible class="mt-6 mx-auto w-full with-max-w" variant="described" />
2421

25-
Other accessibility features are required, but configurable.
22+
Other accessibility features are situational and [configurable](/docs/features/motivations/configurability).
2623

2724
For example, in the listboxes above:
2825
- We use a vertical orientation
@@ -65,9 +62,7 @@ And on top of that, Baleada Features adds these features to UI elements where yo
6562

6663
<ExampleListboxAccessible class="mt-6 mx-auto w-full with-max-w" variant="dynamic" />
6764

68-
The web platform is amazing, but when it comes to accessibility, it's still missing so many UI components, and so much configurability.
69-
70-
Baleada Features aims to close that gap.
65+
When it comes to accessibility, the web platform is amazing, but it's still missing so many UI components, and so much configurability. Baleada Features aims to close that gap.
7166

7267
::: type="success"
7368
Accessibility is great UX!

src/prose/features/00-motivations/composability.md

Lines changed: 16 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -4,135 +4,31 @@ publish: true
44
order: 1
55
---
66

7-
Baleada Features is designed around **composability**—the ability to build complex features by combining simpler, reusable pieces.
7+
Baleada Features is designed for **composability**—the ability to build complex UIs by combining smaller reusable pieces.
88

9-
The package organizes features into layers that build on each other:
9+
You can use an [interface](/docs/features/interfaces-overview) or a [combo](/docs/features/combo-overview) to wire up essential UI logic and [accessibility](/docs/features/motivations/accessibility) features, then add [extensions](/docs/features/extensions-overview) to bring additional functionality. You can even drop down to [affordances](/docs/features/affordances-overview) for lower level tasks like binding props or adding custom event listeners to an existing element.
1010

11-
1. **Affordances** — Low-level tools for binding attributes, handling events, and showing/hiding elements
12-
2. **Extensions** — Reusable behaviors like `usePopup`, `useFocus`, `usePress`, and `useHover`
13-
3. **Interfaces** — Complete accessible UI patterns like `useListbox`, `useButton`, and `useTextbox`
14-
4. **Combos** — Full components that combine interfaces and extensions, like `useCombobox`, `useSelect`, and `useMenu`
15-
16-
Each layer composes features from the layers below it, and you can use any layer directly depending on your needs.
17-
18-
19-
:::
20-
## Extensions compose into interfaces
2111
:::
22-
23-
Extensions add focused, reusable behaviors to elements. For example, `usePress` handles all the complexity of pointer and keyboard press interactions:
24-
25-
::: canCopy
2612
```ts
27-
import { usePress } from '@baleada/vue-features'
28-
29-
const press = usePress(element)
30-
31-
// React to press events
32-
watch(press.firstDescriptor, () => {
33-
console.log('Pressed!')
34-
})
35-
```
36-
:::
37-
38-
Interfaces like `useButton` compose extensions internally. A button needs press detection, ability state, and proper ARIA bindings—`useButton` composes all of these together:
39-
40-
::: canCopy
41-
```ts
42-
import { useButton } from '@baleada/vue-features'
43-
44-
const button = useButton()
45-
// Internally composes usePress, useAbility, bind(), and more
46-
```
47-
:::
48-
49-
50-
:::
51-
## Interfaces compose into combos
52-
:::
53-
54-
When you need a complete component, like a combobox with a textbox, button, and popup listbox, you can use a combo. Combos compose multiple interfaces and extensions:
55-
56-
::: canCopy
57-
```ts
58-
import { useCombobox } from '@baleada/vue-features'
59-
60-
const combobox = useCombobox()
61-
// Internally composes:
62-
// - useTextbox (for the input)
63-
// - useButton (for the trigger)
64-
// - useListbox (for the options)
65-
// - usePopup (for show/hide behavior)
66-
```
67-
:::
68-
69-
70-
:::
71-
## Mix and match layers
72-
:::
73-
74-
You can combine features from any layer to build exactly what you need.
75-
76-
Need a custom select that uses your own trigger instead of a button? Compose a listbox with a popup yourself:
77-
78-
::: canCopy
79-
```ts
80-
import { useListbox, usePopup } from '@baleada/vue-features'
13+
import { useListbox, useFocus, bind, on } from '@baleada/vue-features'
8114

8215
const listbox = useListbox()
83-
const popup = usePopup(listbox)
84-
85-
// Wire up your custom trigger
86-
watch(customTrigger.activated, popup.toggle)
87-
```
88-
:::
89-
90-
Need press detection with custom behavior that isn't covered by the built-in button? Use the extension directly:
91-
92-
::: canCopy
93-
```ts
94-
import { usePress } from '@baleada/vue-features'
95-
96-
const press = usePress(element, {
97-
pointer: {
98-
minDuration: 500, // Long press
99-
},
100-
})
101-
```
102-
:::
10316

17+
// Extend with focus tracking
18+
const focus = useFocus(listbox)
10419

105-
:::
106-
## Compose extensions onto interfaces
107-
:::
108-
109-
Extensions can enhance interfaces after the fact. For example, add focus tracking to a button:
110-
111-
::: canCopy
112-
```ts
113-
import { useButton, useFocus } from '@baleada/vue-features'
114-
115-
const button = useButton()
116-
const focus = useFocus(button.root)
117-
118-
// Now you have both button behavior and focus state
119-
watch(focus.status, status => {
120-
console.log(`Button focus: ${status}`)
121-
})
122-
```
123-
:::
124-
125-
Or add hover detection to a listbox option:
126-
127-
::: canCopy
128-
```ts
129-
import { useListbox, useHover } from '@baleada/vue-features'
130-
131-
const listbox = useListbox()
20+
// Bind a custom class to the root element
21+
bind(
22+
listbox.root.element,
23+
{ class: 'my-listbox' }
24+
)
13225

133-
// Track hover on a specific option
134-
const optionHover = useHover(listbox.options.list.value[0])
26+
// Add a custom event listener to the root element
27+
on(
28+
listbox.root.element,
29+
{ keydown: event => console.log('keydown', event.key) }
30+
)
13531
```
13632
:::
13733

138-
Composability means you're never locked into a single approach. Start with a high-level combo, drop down to interfaces when you need more control, and use extensions and affordances when you need to build something truly custom.
34+
Baleada Features is a love letter to the Vue 3 Composition API, showcasing the composability it unlocks.

0 commit comments

Comments
 (0)