-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from solidjs-community/develop
feat(accortion,textfield): add primitives
- Loading branch information
Showing
58 changed files
with
2,718 additions
and
902 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
[](https://pnpm.io/) | ||
[](https://turborepo.org/) | ||
[](https://bundlephobia.com/package/@solid-aria/accordion) | ||
[](https://www.npmjs.com/package/@solid-aria/accordion) | ||
[](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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { viteConfig } from "../../../configs/vite.config"; | ||
|
||
export default viteConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const baseJest = require("../../configs/jest.config.cjs"); | ||
|
||
module.exports = { | ||
...baseJest | ||
}; |
Oops, something went wrong.