Skip to content

Commit 6f8225c

Browse files
authored
Next batch of Vue components (#282)
* add little editor hack By adding a html`..` to the template strings editors can get syntax highlighting for these template strings. Even better, prettier can even format the contents inside those because now it is "aware" of what kind of content is inside of these template strings. You might notice that for the Menu component I have a jsx`..`, this is another little hack, this only provides us with syntax highlighting and not with prettier support. The reason why we have this is that for some reason, when you have: html` <MenuItem> ` It will be formatted as: html` <menuitem> ` There might exist a better name we can use instead of jsx, but for now, this will do. Having syntax highlighting is already 10x better than what we had before! * add Alert component * update changelog * update REACT readme for Alert component * expose Alert component * add Disclosure component * expose Disclosure component * add FocusTrap component * add FocusTrap example * expose FocusTrap * update test utils We've been making some changes in the React utils, so we have to update them here as well! * add Popover component * expose Popover * drop unused state * type Disclosure's API object * add Portal component * add Portal example * expose Portal component * use correct containElement assertion * add useInertOthers hook * add Dialog component * fix various typo's * expose Dialog * add Popover example * force focus on the Popover button on click * drop own id when using labels We are nesting the Label and Description components, if we also add the id of ourselves we get strange results when using Voice Over. First you would hear the contents (which includes the labels and descriptions) then you would hear the labels and descriptions again. We don't want to hear things twice! * add Dialog example * ensure to stop propagation Otherwise if you nest a Menu inside a Dialog and you press `Escape` the Dialog will close as well, which is not the expected behaviour. * improve focus management When you trigger a Popover using a `click` event, then start using `Tab` the next `a`-tags do not contain the default focus styles. These only happen when you trigger it using the keyboard first. Using a tabindex="0" does make it "focusable" and the default browser styles will be visible. If we remove the tabindex in a requestAnimationFrame or a setTimeout then the focus styles will be removed as well. This should not cause to many issues (fingers crossed) because the document.activeElement was already referring to the correct element! * remove Alert component There are a lot of unknowns and context dependendant questions to implement Alerts in a good way. The current Alert component just had a role set, and it had no JS attached. We will revisit this, once we start working on Alert Dialogs, Notification center notifications (dismissable, hide after x time, ...) * ensure Popover.Overlay auto shows/hides based on Popover state * enable focus trapping based on `open` prop Only enable focus trapping in the Dialog when `open` is true, regardless of the `static` prop. * handle attrs on Dialog manually * add low level Description component * add low level Label component * add RadioGroup component * expose RadioGroup * update README with links to new components * update changelog with all the changes * add RadioGroup example * improve type in test * cleanup internal Dialog Description We have a low level Description component abstraction that can be used instead of the Dialog specifiction Description. * refactor raw window events to a shared useWindowEvent * passthrough prop bag via context for abstract Description The Description component is a generic low level component that is re-used. This causes an issue that the render prop "bag"/"slot" doesn't contain the data from let's say a Dialog component. This commit will ensure that you can specify a bag (React) and slot (Vue) on the DescriptionProvider, so that the Description component can read it from the context. * improve render function in React These contain a few changes that are purely internal changes. Nothing changes / breaks in the public API of the components. - Instead of using multiple arguments in your `render()` functions, we now use an object. - `propsBag` / `bag` is renamed to `slot`. - We also provide a `name` to the render function, so that we can use that to improve error messages. * use the new internal render api (React) * improve render function in Vue * use the new internal render api (Vue)
1 parent bf27f88 commit 6f8225c

File tree

83 files changed

+10486
-954
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+10486
-954
lines changed

CHANGELOG.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222

2323
- Add `Disclosure`, `Disclosure.Button` and `Disclosure.Panel` components ([#220](https://github.com/tailwindlabs/headlessui/pull/220))
2424
- Add `Dialog`, `Dialog.Overlay`, `Dialog.Tile` and `Dialog.Description` components ([#220](https://github.com/tailwindlabs/headlessui/pull/220))
25-
- Add `Portal` component ([#220](https://github.com/tailwindlabs/headlessui/pull/220))
25+
- Add `Portal` and `Portal.Group` component ([#220](https://github.com/tailwindlabs/headlessui/pull/220))
2626
- Add `Switch.Description` component, which adds the `aria-describedby` to the actual Switch ([#220](https://github.com/tailwindlabs/headlessui/pull/220))
2727
- Add `FocusTrap` component ([#220](https://github.com/tailwindlabs/headlessui/pull/220))
28-
- Add `Popover` component ([#220](https://github.com/tailwindlabs/headlessui/pull/220))
28+
- Add `Popover`, `Popover.Button`, `Popover.Overlay`, `Popover.Panel` and `Popover.Group` components ([#220](https://github.com/tailwindlabs/headlessui/pull/220))
2929
- All components that accept a `className`, can now also receive a function with the renderProp argument ([#257](https://github.com/tailwindlabs/headlessui/pull/257))
30-
- Add `RadioGroup` component ([#274](https://github.com/tailwindlabs/headlessui/pull/274))
31-
- Add `Alert` component ([#274](https://github.com/tailwindlabs/headlessui/pull/274))
30+
- Add `RadioGroup`, `RadioGroup.Option`, `RadioGroup.Label` and `RadioGroup.Description` components ([#274](https://github.com/tailwindlabs/headlessui/pull/274))
3231

3332
## [Unreleased - Vue]
3433

3534
### Fixes
3635

3736
- Fix incorrect `DOM` node from ref ([#249](https://github.com/tailwindlabs/headlessui/pull/249))
3837
- Fix broken behaviour since Vue 3.0.5 ([#279](https://github.com/tailwindlabs/headlessui/pull/279))
38+
- Stop propagating keyboard/mouse events ([#282](https://github.com/tailwindlabs/headlessui/pull/282))
3939

4040
### Added
4141

4242
- Add `SwitchDescription` component, which adds the `aria-describedby` to the actual Switch ([#220](https://github.com/tailwindlabs/headlessui/pull/220))
43+
- Add `Disclosure`, `DisclosureButton`, `DisclosurePanel` components ([#282](https://github.com/tailwindlabs/headlessui/pull/282))
44+
- Add `Dialog`, `DialogOverlay`, `DialogTitle` and `DialogDescription` components ([#282](https://github.com/tailwindlabs/headlessui/pull/282))
45+
- Add `Portal` and `PortalGroup` components ([#282](https://github.com/tailwindlabs/headlessui/pull/282))
46+
- Add `FocusTrap` component ([#282](https://github.com/tailwindlabs/headlessui/pull/282))
47+
- Add `Popover`, `PopoverButton`, `PopoverOverlay`, `PopoverPanel` and `PopoverGroup` components ([#282](https://github.com/tailwindlabs/headlessui/pull/282))
48+
- Add `RadioGroup`, `RadioGroupOption`, `RadioGroupLabel` and `RadioGroupDescription` components ([#282](https://github.com/tailwindlabs/headlessui/pull/282))
4349

4450
## [@headlessui/react@v0.3.2] - 2021-04-02
4551

packages/@headlessui-react/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ _This project is still in early development. New components will be added regula
3737
- [Dialog](./src/components/dialog/README.md)
3838
- [Popover](./src/components/popover/README.md)
3939
- [Radio Group](./src/components/radio-group/README.md)
40-
- [Alert](./src/components/alert/README.md)
4140

4241
### Roadmap
4342

packages/@headlessui-react/pages/dialog/dialog-with-alert.tsx

Lines changed: 0 additions & 126 deletions
This file was deleted.

packages/@headlessui-react/pages/popover/popover.tsx

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { forwardRef } from 'react'
2-
import { Popover, Portal } from '@headlessui/react'
1+
import React, { forwardRef, Fragment } from 'react'
2+
import { Popover, Portal, Transition } from '@headlessui/react'
33
import { usePopper } from '../../playground-utils/hooks/use-popper'
44
import { PropsOf as Props } from '../../src/types'
55

@@ -43,14 +43,36 @@ export default function Home() {
4343

4444
<Popover.Group as="nav" ar-label="Mythical University" className="flex space-x-3">
4545
<Popover as="div" className="relative">
46-
<Button>Normal</Button>
47-
<Popover.Panel className="absolute flex flex-col w-64 bg-gray-100 border-2 border-blue-900">
48-
{links.map((link, i) => (
49-
<Link key={link} hidden={i === 2}>
50-
Normal - {link}
51-
</Link>
52-
))}
53-
</Popover.Panel>
46+
{({ open }) => (
47+
<>
48+
<Transition
49+
as={Fragment}
50+
show={open}
51+
enter="transition ease-out duration-300 transform"
52+
enterFrom="opacity-0"
53+
enterTo="opacity-100"
54+
leave="transition ease-in duration-300 transform"
55+
leaveFrom="opacity-100"
56+
leaveTo="opacity-0"
57+
>
58+
<Popover.Overlay
59+
static
60+
className="bg-opacity-75 bg-gray-500 fixed inset-0 z-20"
61+
></Popover.Overlay>
62+
</Transition>
63+
64+
<Popover.Button className="px-3 py-2 bg-gray-300 border-2 border-transparent focus:outline-none focus:border-blue-900 relative z-30">
65+
Normal
66+
</Popover.Button>
67+
<Popover.Panel className="absolute flex flex-col w-64 bg-gray-100 border-2 border-blue-900 z-30">
68+
{links.map((link, i) => (
69+
<Link key={link} hidden={i === 2}>
70+
Normal - {link}
71+
</Link>
72+
))}
73+
</Popover.Panel>
74+
</>
75+
)}
5476
</Popover>
5577

5678
<Popover as="div" className="relative">

packages/@headlessui-react/src/components/alert/README.md

Lines changed: 0 additions & 49 deletions
This file was deleted.

packages/@headlessui-react/src/components/alert/alert.test.tsx

Lines changed: 0 additions & 31 deletions
This file was deleted.

packages/@headlessui-react/src/components/alert/alert.tsx

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)