-
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: ensure consistent *item naming convention (#882)
- Loading branch information
1 parent
a415b6d
commit fd71ad9
Showing
96 changed files
with
583 additions
and
404 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,40 @@ | ||
--- | ||
"@zag-js/rating-group": minor | ||
"@zag-js/toggle-group": minor | ||
"@zag-js/radio-group": minor | ||
"@zag-js/tags-input": minor | ||
"@zag-js/accordion": minor | ||
"@zag-js/checkbox": minor | ||
"@zag-js/popover": minor | ||
"@zag-js/select": minor | ||
"@zag-js/menu": minor | ||
--- | ||
|
||
- Refactor component anatomy to use consistent naming convention across all machines. | ||
|
||
- **Accordion** | ||
|
||
- `getTriggerProps` => `getItemTriggerProps` | ||
- `getContentProps` => `getItemContentProps` | ||
|
||
- **Radio** | ||
|
||
- `getRadioProps` => `getItemProps` | ||
- `getRadioControlProps` => `getItemControlProps` | ||
- `getRadioLabelProps` => `getItemTextProps` | ||
- `getRatingState` => `getItemState` | ||
- `getRatingProps` => `getItemProps` | ||
|
||
- **TagsInput** | ||
|
||
- `getTagProps` => `getItemProps` | ||
- `getTagDeleteTriggerProps` => `getItemDeleteTriggerProps` | ||
- `getTagInputProps` => `getItemInputProps` | ||
|
||
- **Toggle Group** | ||
- `getToggleProps` => `getItemProps` | ||
|
||
- **ToggleGroup**: Allow deselecting item when `multiple` is `false`. | ||
|
||
- Add indicator part to some components for ease of styling. Added `AccordionItemIndicator`, `SelectIndicator`, | ||
`MenuIndicator`, `PopoverIndicator` |
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
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
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,88 @@ | ||
import { expect, type Page, test, type Locator } from "@playwright/test" | ||
import { a11y, controls, part } from "./__utils" | ||
|
||
class PageModel { | ||
constructor(public readonly page: Page) {} | ||
get bold() { | ||
return this.page.locator(part("item")).nth(0) | ||
} | ||
get italic() { | ||
return this.page.locator(part("item")).nth(1) | ||
} | ||
get underline() { | ||
return this.page.locator(part("item")).nth(2) | ||
} | ||
expectToBeFocused(locator: Locator) { | ||
return expect(locator).toHaveAttribute("data-highlighted", "") | ||
} | ||
expectNotToBeFocused(locator: Locator) { | ||
return expect(locator).not.toHaveAttribute("data-highlighted", "") | ||
} | ||
expectToBeSelected(locator: Locator) { | ||
return expect(locator).toHaveAttribute("data-state", "on") | ||
} | ||
expectNotToBeSelected(locator: Locator) { | ||
return expect(locator).not.toHaveAttribute("data-state", "on") | ||
} | ||
setMultiple() { | ||
return controls(this.page).bool("multiple") | ||
} | ||
} | ||
|
||
test.describe("toggle-group", () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto("/toggle-group") | ||
}) | ||
|
||
test("should have no accessibility violation", async ({ page }) => { | ||
await a11y(page) | ||
}) | ||
|
||
test("[single] should select on click", async ({ page }) => { | ||
const screen = new PageModel(page) | ||
|
||
await screen.bold.click() | ||
await screen.expectToBeSelected(screen.bold) | ||
|
||
await screen.italic.click() | ||
await screen.expectToBeSelected(screen.italic) | ||
await screen.expectNotToBeSelected(screen.bold) | ||
}) | ||
|
||
test("[single] should select and deselect", async ({ page }) => { | ||
const screen = new PageModel(page) | ||
|
||
await screen.bold.click() | ||
await screen.expectToBeSelected(screen.bold) | ||
|
||
await screen.bold.click() | ||
await screen.expectNotToBeSelected(screen.bold) | ||
}) | ||
|
||
test("[multiple] should select multiple", async ({ page }) => { | ||
const screen = new PageModel(page) | ||
await screen.setMultiple() | ||
|
||
await screen.bold.click() | ||
await screen.italic.click() | ||
|
||
await screen.expectToBeSelected(screen.bold) | ||
await screen.expectToBeSelected(screen.italic) | ||
}) | ||
|
||
test("[keyboard] when no toggle is selected, focus first toggle", async ({ page }) => { | ||
const screen = new PageModel(page) | ||
|
||
// focus on outside button | ||
const outsideButton = page.getByRole("button", { name: "Outside" }) | ||
await outsideButton.focus() | ||
await page.keyboard.press("Tab") | ||
|
||
await expect(screen.bold).toBeFocused() | ||
|
||
// shift tab back to outside button | ||
await page.keyboard.press("Shift+Tab") | ||
await expect(screen.bold).not.toBeFocused() | ||
await expect(outsideButton).toBeFocused() | ||
}) | ||
}) |
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
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
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
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
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
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
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,16 @@ | ||
<template> | ||
<svg viewBox="0 0 273 260" data-part="star"> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M135.977 214.086L52.1294 259.594L69.6031 165.229L0 99.1561L95.1465 86.614L135.977 1.04785V214.086Z" | ||
fill="currentColor" | ||
/> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M135.977 213.039L219.826 258.546L202.352 164.181L271.957 98.1082L176.808 85.5661L135.977 0V213.039Z" | ||
fill="#bdbdbd" | ||
/> | ||
</svg> | ||
</template> |
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,8 @@ | ||
<template> | ||
<svg viewBox="0 0 273 260" data-part="star"> | ||
<path | ||
d="M136.5 0L177.83 86.614L272.977 99.1561L203.374 165.229L220.847 259.594L136.5 213.815L52.1528 259.594L69.6265 165.229L0.0233917 99.1561L95.1699 86.614L136.5 0Z" | ||
fill="currentColor" | ||
/> | ||
</svg> | ||
</template> |
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
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
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
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
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
Oops, something went wrong.
fd71ad9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
zag-website – ./website
zag-website-git-main-chakra-ui.vercel.app
zagjs.com
zag-website.vercel.app
www.zagjs.com
zag-website-chakra-ui.vercel.app
fd71ad9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
zag-solid – ./examples/solid-ts
zag-solid.vercel.app
zag-solid-chakra-ui.vercel.app
zag-solid-git-main-chakra-ui.vercel.app
fd71ad9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
zag-nextjs – ./examples/next-ts
zag-two.vercel.app
zag-nextjs-git-main-chakra-ui.vercel.app
zag-nextjs-chakra-ui.vercel.app
fd71ad9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
zag-vue – ./examples/vue-ts
zag-vue-git-main-chakra-ui.vercel.app
zag-vue.vercel.app
zag-vue-chakra-ui.vercel.app