Skip to content

Commit 819042e

Browse files
authored
Merge pull request #702 from tailwindlabs/develop
Next release
2 parents b961a18 + 4f3c5fa commit 819042e

File tree

24 files changed

+6350
-107
lines changed

24 files changed

+6350
-107
lines changed

CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased - React]
99

10-
- Nothing yet!
10+
### Added
11+
12+
- Add new `Tabs` component ([#674](https://github.com/tailwindlabs/headlessui/pull/674), [#698](https://github.com/tailwindlabs/headlessui/pull/698))
13+
- Make `Disclosure.Button` close the disclosure inside a `Disclosure.Panel` ([#682](https://github.com/tailwindlabs/headlessui/pull/682))
14+
- Add `aria-orientation` to `Listbox`, which swaps Up/Down with Left/Right keys ([#683](https://github.com/tailwindlabs/headlessui/pull/683))
15+
- Expose `close` function from the render prop for `Disclosure`, `Disclosure.Panel`, `Popover` and `Popover.Panel` ([#697](https://github.com/tailwindlabs/headlessui/pull/697))
1116

1217
## [Unreleased - Vue]
1318

14-
- Nothing yet!
19+
### Added
20+
21+
- Add new `Tabs` component ([#674](https://github.com/tailwindlabs/headlessui/pull/674), [#698](https://github.com/tailwindlabs/headlessui/pull/698))
22+
- Make `DisclosureButton` close the disclosure inside a `DisclosurePanel` ([#682](https://github.com/tailwindlabs/headlessui/pull/682))
23+
- Add `aria-orientation` to `Listbox`, which swaps Up/Down with Left/Right keys ([#683](https://github.com/tailwindlabs/headlessui/pull/683))
24+
- Expose `close` function from the scoped slot for `Disclosure`, `DisclosurePanel`, `Popover` and `PopoverPanel` ([#697](https://github.com/tailwindlabs/headlessui/pull/697))
1525

1626
## [@headlessui/react@v1.3.0] - 2021-06-21
1727

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import React, { useState } from 'react'
2+
import { Tab, Switch } from '@headlessui/react'
3+
4+
import { classNames } from '../../src/utils/class-names'
5+
6+
export default function Home() {
7+
let tabs = [
8+
{ name: 'My Account', content: 'Tab content for my account' },
9+
{ name: 'Company', content: 'Tab content for company', disabled: true },
10+
{ name: 'Team Members', content: 'Tab content for team members' },
11+
{ name: 'Billing', content: 'Tab content for billing' },
12+
]
13+
14+
let [manual, setManual] = useState(false)
15+
16+
return (
17+
<div className="flex flex-col items-start w-screen h-full p-12 bg-gray-50 space-y-12">
18+
<Switch.Group as="div" className="flex items-center space-x-4">
19+
<Switch.Label>Manual keyboard activation</Switch.Label>
20+
21+
<Switch
22+
as="button"
23+
checked={manual}
24+
onChange={setManual}
25+
className={({ checked }) =>
26+
classNames(
27+
'relative inline-flex flex-shrink-0 h-6 border-2 border-transparent rounded-full cursor-pointer w-11 focus:outline-none focus:shadow-outline transition-colors ease-in-out duration-200',
28+
checked ? 'bg-indigo-600' : 'bg-gray-200'
29+
)
30+
}
31+
>
32+
{({ checked }) => (
33+
<span
34+
className={classNames(
35+
'inline-block w-5 h-5 bg-white rounded-full transform transition ease-in-out duration-200',
36+
checked ? 'translate-x-5' : 'translate-x-0'
37+
)}
38+
/>
39+
)}
40+
</Switch>
41+
</Switch.Group>
42+
43+
<Tab.Group className="flex flex-col max-w-3xl w-full" as="div" manual={manual}>
44+
<Tab.List className="relative z-0 rounded-lg shadow flex divide-x divide-gray-200">
45+
{tabs.map((tab, tabIdx) => (
46+
<Tab
47+
key={tab.name}
48+
disabled={tab.disabled}
49+
className={({ selected }) =>
50+
classNames(
51+
selected ? 'text-gray-900' : 'text-gray-500 hover:text-gray-700',
52+
tabIdx === 0 ? 'rounded-l-lg' : '',
53+
tabIdx === tabs.length - 1 ? 'rounded-r-lg' : '',
54+
tab.disabled && 'opacity-50',
55+
'group relative min-w-0 flex-1 overflow-hidden bg-white py-4 px-4 text-sm font-medium text-center hover:bg-gray-50 focus:z-10'
56+
)
57+
}
58+
>
59+
{({ selected }) => (
60+
<>
61+
<span>{tab.name}</span>
62+
{tab.disabled && <small className="inline-block px-4 text-xs">(disabled)</small>}
63+
<span
64+
aria-hidden="true"
65+
className={classNames(
66+
selected ? 'bg-indigo-500' : 'bg-transparent',
67+
'absolute inset-x-0 bottom-0 h-0.5'
68+
)}
69+
/>
70+
</>
71+
)}
72+
</Tab>
73+
))}
74+
</Tab.List>
75+
76+
<Tab.Panels className="mt-4">
77+
{tabs.map(tab => (
78+
<Tab.Panel className="bg-white rounded-lg p-4 shadow" key={tab.name}>
79+
{tab.content}
80+
</Tab.Panel>
81+
))}
82+
</Tab.Panels>
83+
</Tab.Group>
84+
</div>
85+
)
86+
}

0 commit comments

Comments
 (0)