799 Commits

Author SHA1 Message Date
Arno Schutijzer ef25b08cb2 docs: fix typo (#29) 2020-10-02 22:59:07 +02:00
Robin Malfait 99ecdaefd4 update branding
Replace Tailwind UI with Headless UI
2020-10-02 13:56:47 +02:00
Robin Malfait 58ff88698b feat: add Listbox component (#3)
* make jest monorepo aware

* add @testing-library/jest-dom for custom matchers

This way we can use expect(element).toHaveAttribute(key, value?)

* abstract keys enum

* change type to unknown, because we don't know the return value

* update use-id hook, make it suspense aware

Thanks Reach UI!

* hoist the disposables collection

* add accessbility assertions for listbox

Also made it consistent for the Menu component and simplified some of the assertions

* add use-computed hook

This allows us re-render when hooks change, but also return a value. So this is a combination of useEffect and a useState value.

* add Listbox component

* bump dependencies

* add listbox example

* add lint-staged

This way we will only lint the files that have been staged and ready to be committed instead of the whole codebase

* add missing prevent defaults

* improve tests to verify that we can actually update the value of the listbox

* scroll the active listbox item into view

* small optimization, only focus "Nothing" on pointer leave when we are the active item

We used to always go to "Nothing" on pointer leave. And while this code
doesn't get called often, it *gets* called if you are using your arrow
keys and the mouse pointer is still over the list.

* bump dependencies

Also moved the tailwind dependencies to the root

* fix typo

* drop the default Transition inside the Menu and Listbox components

* update examples to reflect drop of default Transition wrapper

* rename Listbox.{Items,Item} to Listbox.{Options,Option}

Also rename all instances of `item` to `option` in tests and comments
and what have you...

* fix typo

* drop disabled prop, use aria-disabled only
2020-10-02 11:05:41 +02:00
Bhanu Teja Pachipulusu 412cc950aa docs: fix typo in React README (#22) 2020-09-30 10:25:30 +02:00
Robin Malfait 7877632299 mark fallthrough as expected 2020-09-29 15:52:54 +02:00
Robin Malfait 279b021a2b implement type ahead mode on Menu
This will allow us to do 2 things:

- When we are in "type ahead" mode, aka search, we can use spaces to
  search. E.g.: "Account Settings" (notice the space)
- When we are not in "type ahead" mode, we can use `Space` to invoke the
  menu item. We used to only allow `Enter` and `Click`.
2020-09-29 15:34:17 +02:00
Robin Malfait 57ad598202 be consistent with pointer/mouse events 2020-09-29 13:55:19 +02:00
Robin Malfait 4b2aacfdf2 simplify the click / pointer up handling on Menu Item
Thank you @MartinMa for pointing this complexity out!
2020-09-29 12:54:42 +02:00
Robin Malfait 878e417139 version 0.1.3 2020-09-29 00:01:50 +02:00
Robin Malfait fedfc0cc1b ensure to prevent the default behaviour of keyboard navigation 2020-09-28 23:47:50 +02:00
Robin Malfait 93e8b8f4ba fix: outside click behaviour (#19)
* add failing tests to prove the outside-click issue

* fix outside click when we have multiple menu's

- We removed the `toggleMenu` since we only used it in a single spot,
  and had to do some side effect logic (focus & event.preventDefault).
  Wanted to make this consistent between React and Vue.
- If, in the "outside click" logic we detect that we clicked on the
  button, we also ignore it.
- If, we click on the button we will toggle the menu.

Fixes: #18
2020-09-28 15:52:00 +02:00
Robin Malfait e9fd05e06d ensure that anchor links are still clickable
This is an issue in the Vue version (it just works in the React version)
but I added tests for them anyway.

While this solution "works" I am not 100% happy with it. Let me explain
what's happening here and why I am not that happy about it:

- For starters, the Vue `nextTick` is apparently too fast. So what we do
  is when we get the pointer up event, we will close the menu and
  re-focus the button. We ran this code in a `nextTick` so that we can
  ensure that we close the menu *after* all the click events are
  finished. However because this is too fast, the menu is already closed
  and the anchor link is already unmounted and thus not clickable
  anymore. So instead we use a double requestAnimationFrame (to mimick a
  `nextFrame` as seen in the `disposables` from the React code). This
  works, but a bit messy, oh well.
- The next reason why I am not that happy is because I can't reproduce
  it in JSDOM (Jest tests). When you *click* a link in JSDOM it doesn't
  update the `window.location.hash` or `window.location.href`. To mimick
  that behaviour I put a `@click` event on the anchor to verify that we
  actually clicked it. However this already works, even before the
  "fix". So I left a TODO in there so that we can hopefully fix the
  test, so that we _can_ reproduce this behaviour.

Fixes: #14
2020-09-28 12:30:52 +02:00
Robin Malfait 93f315b066 add prepublishOnly hooks 2020-09-25 16:11:52 +02:00
Robin Malfait 3709ed5b77 only passthrough the aria-disabled prop when true
Drop the disabled prop itself because doesn't make much sense
2020-09-25 16:10:47 +02:00
Robin Malfait 2747745891 ensure that you can not click disabled items 2020-09-25 16:09:40 +02:00
Robin Malfait c5b83ec381 drop unneeded types in tsconfig.json 2020-09-25 12:41:57 +02:00
Robin Malfait 57caacdce8 add extra tests to verify that @click works on MenuItem as='button' 2020-09-25 12:40:56 +02:00
Juan Luis Rojas León 46a33b2fbd docs(React): jsx wrapped in enclosing tags (@headlessui-react/readme.md) (#10) 2020-09-25 10:54:16 +02:00
Utkarsh Kukreti 6d6be636d3 docs(React): fix "Transition" link href in @headlessui-react readme (#9) 2020-09-25 10:51:37 +02:00
Nathan Jaremko 20ddb3e639 docs(React): improve documentation for Menu transitions (#7)
* Improve documentation for Menu transitions

* Update README.md
2020-09-25 10:49:56 +02:00
Adam Wathan b051f13d80 docs: Add demo links 2020-09-24 13:41:16 -04:00
Robin Malfait 8add6f43f7 version 0.1.1 2020-09-24 12:56:25 +02:00
Robin Malfait 4a6048ef6c make examples between Vue and React consistent 2020-09-21 23:25:09 +02:00
Robin Malfait f7d26b55a1 use correct prettier settings 2020-09-21 16:34:53 +02:00
Robin Malfait 55c9adaa8a build code snippets for the Vue playground 2020-09-21 16:29:12 +02:00
Robin Malfait 1f29594414 add Menu examples in React 2020-09-21 12:50:44 +02:00
Robin Malfait 8cc424c820 use absolute path instead of relative 2020-09-21 12:50:44 +02:00
Robin Malfait f6883677f5 add Menu examples in Vue 2020-09-21 12:50:39 +02:00
Robin Malfait bd389b3b1e fix vercel build for the Vue playground 2020-09-20 21:46:06 +02:00
Robin Malfait d479be59dd configure vercel for routing 2020-09-20 21:29:56 +02:00
Robin Malfait 458466aa2a add playground:build script 2020-09-20 21:18:39 +02:00
Robin Malfait eed9f85b93 prerender 404 pages with a table of contents of all examples 2020-09-20 21:18:27 +02:00
Robin Malfait 2ddb607f8c fix vite package alias 2020-09-20 20:47:00 +02:00
Robin Malfait eb441a13b0 generate all example paths at build time 2020-09-19 00:25:37 +02:00
Robin Malfait 110a01790b make the vue playground buildable for Vercel 2020-09-18 23:20:46 +02:00
Robin Malfait 62243344e3 bump dependencies 2020-09-18 17:20:45 +02:00
Robin Malfait b989ba4fdc Merge pull request #1 from tailwindlabs/document-react-components
docs: Document React Menu, tweak Transition and Vue docs to be consistent
2020-09-18 16:41:04 +02:00
Robin Malfait b7d53fdf3e add vue as a peer dependency 2020-09-18 14:32:39 +02:00
Robin Malfait 93508e97a3 remove test code, use mocks instead 2020-09-18 14:05:22 +02:00
Robin Malfait 273c0d9fda improve tsdx build 2020-09-17 23:25:16 +02:00
Robin Malfait 1b896b4992 add some dead code elimination markers 2020-09-17 23:24:40 +02:00
Robin Malfait 5f377b946e use headlessui identifier instead of tailwindui 2020-09-17 16:00:50 +02:00
Robin Malfait 59870594c1 inline defaultState
Otherwise we will be mutating the refs, and items from the first Menu on the page
2020-09-17 15:58:37 +02:00
Robin Malfait 6757fad6a4 use correct package reference 2020-09-17 11:01:51 +02:00
Robin Malfait 76c24680c5 make render logic consistent with the Vue implementation 2020-09-16 23:44:38 +02:00
Adam Wathan 4b0207ad71 docs: Document React Menu, tweak Transition and Vue docs to be consistent 2020-09-16 15:07:02 -04:00
Adam Wathan 7dcf6211f4 docs: Add 'Dropdown' alias next to Menu Button in TOC 2020-09-16 13:06:12 -04:00
Robin Malfait 8b546f054b setup @headlessui/react package 2020-09-16 18:20:49 +02:00
Robin Malfait f20b7f845b setup @headlessui/vue package 2020-09-16 18:19:54 +02:00