Skip to content

Commit

Permalink
Merge pull request #55 from solidjs-community/develop
Browse files Browse the repository at this point in the history
feat(accortion,textfield): add primitives
  • Loading branch information
fabien-ml authored Jul 15, 2022
2 parents 7b43600 + 5c594a6 commit 6a0d8d0
Show file tree
Hide file tree
Showing 58 changed files with 2,718 additions and 902 deletions.
17 changes: 17 additions & 0 deletions .changeset/strange-ears-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
"@solid-aria/collection": minor
"@solid-aria/listbox": minor
"@solid-aria/menu": minor
"@solid-aria/primitives": minor
"@solid-aria/select": minor
"@solid-aria/accordion": patch
"@solid-aria/meter": patch
"@solid-aria/progress": patch
"@solid-aria/separator": patch
"@solid-aria/textfield": patch
"@solid-aria/types": patch
"@solid-aria/utils": patch
---

- add textfield, accordion
- fix title and children render twice when used via `item.props` in collection item (breaking changes)
87 changes: 45 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,98 +8,101 @@ A library of high-quality primitives that help you build accessible user interfa

> ⚠️ Solid Aria is in early stage and **not ready** for production ⚠️
## Primitives
## All in one package

- [@solid-aria/primitives](./packages/primitives/) - Export all Solid Aria primitives in a single convenient package.
[@solid-aria/primitives](./packages/primitives/) - Export all Solid Aria primitives in a single convenient package.

### Buttons
## Separate packages

- [button](./packages/button/) - Provides the behavior and accessibility implementation for button and toggle button components.

### Collections

- [collection](./packages/collection/) - Primitives for dealing with collection of items.
- [list](./packages/list/) - Primitives for managing list collections.
- [listbox](./packages/listbox/) - Provides the behavior and accessibility implementation for listbox component.
- [selection](./packages/selection/) - Primitives for managing selection in collections.
- [tree](./packages/tree/) - Primitives for managing tree collections.
### General

### Content

- [separator](./packages/separator/) - Provides the accessibility implementation for a separator.

### Interactions

- [focus](./packages/focus/) - Primitives for dealing with focus rings and focus management.
- [interactions](./packages/interactions/) - Primitives for dealing with user interactions like press, hover, etc.
- [button](./packages/button/) - Provides the behavior and accessibility implementation for button and toggle button components.

### Forms
### Data entry

- [checkbox](./packages/checkbox/) - Provides the behavior and accessibility implementation for checkbox and checkbox group components.
- [label](./packages/label/) - Provides the behavior and accessibility implementation for labels and their associated elements.
- [radio](./packages/radio/) - Provides the behavior and accessibility implementation for radio and radio group components.
- [select](./packages/select/) - Provides the behavior and accessibility implementation for select component.
- [switch](./packages/switch/) - Provides the behavior and accessibility implementation for switch component.
- [textfield](./packages/textfield/) - Provides the behavior and accessibility implementation for text field component.
- [toggle](./packages/toggle/) - Handles interactions for toggle elements, e.g. checkboxes and switches.

### Data display

- [accordion](./packages/accordion/) - Provides the accessibility implementation for an accordion.
- [listbox](./packages/listbox/) - Provides the behavior and accessibility implementation for listbox component.
- [separator](./packages/separator/) - Provides the accessibility implementation for a separator.

### Navigation

- [breadcrumbs](./packages/breadcrumbs/) - Provides the behavior and accessibility implementation for a breadcrumbs component.
- [link](./packages/link/) - Provides the behavior and accessibility implementation for a link component.

### Overlays
### Feedback

- [meter](./packages/meter/) - Provides the accessibility implementation for a meter component.
- [progress](./packages/progress/) - Provides the accessibility implementation for a progress bar component.

### Overlay

- [dialog](./packages/dialog/) - Provides the behavior and accessibility implementation for a dialog component.
- [menu](./packages/menu/) - Provides the behavior and accessibility implementation for a menu component.
- [overlays](./packages/overlays/) - Provides the behavior and accessibility implementation for overlay components such as dialogs, popovers, and menus.

### Status
### Collection

- [meter](./packages/meter/) - Provides the accessibility implementation for a meter component.
- [progress](./packages/progress/) - Provides the accessibility implementation for a progress bar component.
- [collection](./packages/collection/) - Primitives for dealing with collection of items.
- [list](./packages/list/) - Primitives for managing list collections.
- [selection](./packages/selection/) - Primitives for managing selection in collections.
- [tree](./packages/tree/) - Primitives for managing tree collections.

### Utilities
### Interaction

- [focus](./packages/focus/) - Primitives for dealing with focus rings and focus management.
- [interactions](./packages/interactions/) - Primitives for dealing with user interactions like press, hover, etc.

### Utility

- [i18n](./packages/i18n/) - Primitives for dealing with locale and layout direction.
- [visually-hidden](./packages/visually-hidden/) - Hides its children visually, while keeping content visible to screen readers.

## Roadmap

- [ ] Accordion
- [ ] AutoComplete
- [x] Accordion
- [x] Breadcrumbs
- [x] Button
- [ ] Calendar
- [x] Checkbox
- [ ] Combobox
- [ ] DatePicker
- [x] Dialog
- [x] Label
- [x] Link
- [ ] List
- [x] Listbox
- [ ] LiveAnnouncer
- [x] Menu
- [x] Meter
- [ ] NumberField
- [x] Overlays
- [ ] Pagination
- [x] Progress
- [x] Radio
- [ ] SearchField
- [x] Select
- [x] Separator
- [ ] Slider
- [ ] SpinButton
- [x] Switch
- [x] TextField
- [x] Toggle
- [x] Visually-hidden

- [ ] AutoComplete
- [ ] Calendar
- [ ] Combobox
- [ ] DatePicker
- [ ] List
- [ ] LiveAnnouncer
- [ ] NumberField
- [ ] Pagination
- [ ] SearchField
- [ ] Slider
- [ ] Table
- [ ] Tabs
- [ ] Tag
- [ ] TextField
- [ ] Toast
- [x] Toggle
- [ ] Tooltip
- [x] Visually-hidden
- [ ] Virtualizer

## Acknowledgment
Expand Down
Empty file added packages/accordion/CHANGELOG.md
Empty file.
21 changes: 21 additions & 0 deletions packages/accordion/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Solid Aria Working Group

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
139 changes: 139 additions & 0 deletions packages/accordion/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<p>
<img width="100%" src="https://assets.solidjs.com/banner?type=Aria&background=tiles&project=Accordion" alt="Solid Aria - Accordion">
</p>

# @solid-aria/accordion

[![pnpm](https://img.shields.io/badge/maintained%20with-pnpm-cc00ff.svg?style=for-the-badge&logo=pnpm)](https://pnpm.io/)
[![turborepo](https://img.shields.io/badge/built%20with-turborepo-cc00ff.svg?style=for-the-badge&logo=turborepo)](https://turborepo.org/)
[![size](https://img.shields.io/bundlephobia/minzip/@solid-aria/accordion?style=for-the-badge&label=size)](https://bundlephobia.com/package/@solid-aria/accordion)
[![version](https://img.shields.io/npm/v/@solid-aria/accordion?style=for-the-badge)](https://www.npmjs.com/package/@solid-aria/accordion)
[![stage](https://img.shields.io/endpoint?style=for-the-badge&url=https%3A%2F%2Fraw.githubusercontent.com%2Fsolidjs-community%2Fsolid-primitives%2Fmain%2Fassets%2Fbadges%2Fstage-0.json)](https://github.com/solidjs-community/solid-aria#contribution-process)

Accordion display a list of high-level options that can expand/collapse to reveal more information.

- [`createAccordion` and `createAccordionItem`](#createaccordion-and-createaccordionitem) - Provides the behavior and accessibility implementation for an accordion component.

## Installation

```bash
npm install @solid-aria/accordion
# or
yarn add @solid-aria/accordion
# or
pnpm add @solid-aria/accordion
```

## `createAccordion` and `createAccordionItem`

Provides the behavior and accessibility implementation for an accordion component.

### Features

An accordion is a vertically stacked set of interactive headings that each contain a title, content snippet, or thumbnail representing a section of content. The headings function as controls that enable users to reveal or hide their associated sections of content. `createAccordion` and `createAccordionItem` help implement these in an accessible way.

- Exposed to assistive technology using ARIA
- Support for disabled items
- Labeling support for accessibility
- Support for mouse, touch, and keyboard interactions
- Keyboard navigation support including arrow keys and home/end

### How to use it

```tsx
import {
AriaAccordionItemProps,
AriaAccordionProps,
createAccordion,
createAccordionItem
} from "@solid-aria/accordion";
import { ForItems, Item } from "@solid-aria/collection";
import { filterDOMProps } from "@solid-aria/utils";

import { createMemo, mergeProps } from "solid-js";

function AccordionItem(props: AriaAccordionItemProps) {
let ref: HTMLButtonElement | undefined;

const { buttonProps, regionProps, isExpanded } = createAccordionItem(props, () => ref);

return (
<div>
<h3 style={{ margin: 0, padding: 0 }}>
<button
{...buttonProps}
ref={ref}
style={{
appearance: "none",
border: "none",
display: "block",
margin: 0,
padding: "1em 1.5em",
"text-align": "left",
width: "100%"
}}
>
{props.item.title}
</button>
</h3>
<div
{...regionProps}
style={{
display: isExpanded() ? "block" : "none",
margin: 0,
padding: "1em 1.5em"
}}
>
{props.item.children}
</div>
</div>
);
}

function Accordion(props: AriaAccordionProps) {
let ref: HTMLDivElement | undefined;

const { AccordionProvider, accordionProps, state } = createAccordion(props, () => ref);

const domProps = createMemo(() => filterDOMProps(props));

const rootProps = mergeProps(domProps, accordionProps);

return (
<div
{...rootProps}
ref={ref}
style={{
margin: 0,
padding: 0,
border: "2px solid gray",
width: "10rem"
}}
>
<AccordionProvider>
<ForItems in={state.collection()}>{item => <AccordionItem item={item()} />}</ForItems>
</AccordionProvider>
</div>
);
}

function App() {
return (
<Accordion>
<Item key="one" title="Section One">
Content One
</Item>
<Item key="two" title="Section Two">
Content Two
</Item>
<Item key="three" title="Section Three">
Content Three
</Item>
</Accordion>
);
}
```

## Changelog

All notable changes are described in the [CHANGELOG.md](./CHANGELOG.md) file.
14 changes: 14 additions & 0 deletions packages/accordion/dev/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>Solid App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script src="./index.tsx" type="module"></script>
</body>
</html>
7 changes: 7 additions & 0 deletions packages/accordion/dev/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { render } from "solid-js/web";

function App() {
return <div>Hello Solid Aria!</div>;
}

render(() => <App />, document.getElementById("root") as HTMLDivElement);
3 changes: 3 additions & 0 deletions packages/accordion/dev/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { viteConfig } from "../../../configs/vite.config";

export default viteConfig;
5 changes: 5 additions & 0 deletions packages/accordion/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const baseJest = require("../../configs/jest.config.cjs");

module.exports = {
...baseJest
};
Loading

0 comments on commit 6a0d8d0

Please sign in to comment.