-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tabs2 ➡️ Tabs #1900
Tabs2 ➡️ Tabs #1900
Changes from 2 commits
f963dbb
0279359
34a64f9
71131e7
87644f7
73be3ea
0c282e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ | |
@page sliders | ||
@page table | ||
@page tabs | ||
@page tabs2 | ||
@page tag | ||
@page tag-input | ||
@page text | ||
|
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
@# Tabs | ||
|
||
<div class="pt-callout pt-intent-danger pt-icon-error"> | ||
<h5>The `Tabs` JavaScript API is deprecated since v1.11.0</h5> | ||
The following `Tabs` React components been deprecated in v1.11.0 favor of the [simpler and more flexible | ||
`Tabs2` API](#core/components/tabs2). `Tabs2` will replace `Tabs` in version 2.0. The CSS API has not been changed. | ||
</div> | ||
|
||
@## CSS API | ||
|
||
In addition to the [JavaScript API](#core/components/tabs2.javascript-api), Blueprint also offers tab styles with the | ||
In addition to the [JavaScript API](#core/components/tabs.javascript-api), Blueprint also offers tab styles with the | ||
class `pt-tabs`. You should add the proper accessibility attributes (`role`, `aria-selected`, and | ||
`aria-hidden`) if you choose to implement tabs with CSS. | ||
|
||
|
@@ -18,67 +12,56 @@ JavaScript component does this by default). | |
|
||
@css pt-tabs | ||
|
||
@## Deprecated JavaScript API | ||
|
||
<div class="pt-callout pt-intent-danger pt-icon-error"> | ||
These components are deprecated since v1.11.0. Please use the [`Tabs2` API](#core/components/tabs2) instead. | ||
</div> | ||
@## JavaScript API | ||
|
||
The `Tabs`, `TabList`, `Tab`, and `TabPanel` components are available in the __@blueprintjs/core__ | ||
The `Tabs` and `Tab` components are available in the __@blueprintjs/core__ | ||
package. Make sure to review the [general usage docs for JS components](#blueprint.usage). | ||
|
||
Four components are necessary to render tabs: `Tabs`, `TabList`, `Tab`, and `TabPanel`. | ||
|
||
For performance reasons, only the currently active `TabPanel` is rendered into the DOM. When the | ||
user switches tabs, data stored in the DOM is lost. This is not an issue in React applications | ||
because of how the library manages the virtual DOM for you. | ||
Tab selection is managed by `id`, much like the HTML `<select>` element respects `<option value>`. This is more reliable than using a numeric index (it's also deterministic), and | ||
does not require translating between numbers and tab names. It does, however, require that | ||
every `Tab` have a locally unique `id` prop. | ||
|
||
@### Sample usage | ||
Arbitrary elements are supported in the tab list, and order is respected. Yes, you can even | ||
insert things _between_ `Tab`s. | ||
|
||
```tsx | ||
<Tabs> | ||
<TabList> | ||
<Tab>First tab</Tab> | ||
<Tab>Second tab</Tab> | ||
<Tab>Third tab</Tab> | ||
<Tab isDisabled={true}>Fourth tab</Tab> | ||
</TabList> | ||
<TabPanel> | ||
First panel | ||
</TabPanel> | ||
<TabPanel> | ||
Second panel | ||
</TabPanel> | ||
<TabPanel> | ||
Third panel | ||
</TabPanel> | ||
<TabPanel> | ||
Fourth panel | ||
</TabPanel> | ||
import { Tab, Tabs } from "@blueprintjs/core"; | ||
|
||
<Tabs id="TabsExample" onChange={this.handleTabChange} selectedTabId="rx"> | ||
<Tab id="ng" title="Angular" panel={<AngularPanel />} /> | ||
<Tab id="mb" title="Ember" panel={<EmberPanel />} /> | ||
<Tab id="rx" title="React" panel={<ReactPanel />} /> | ||
<Tab id="bb" disabled title="Backbone" panel={<BackbonePanel />} /> | ||
<Tabs.Expander /> | ||
<input className="pt-input" type="text" placeholder="Search..." /> | ||
</Tabs> | ||
``` | ||
|
||
Every component accepts a `className` prop that can be used to set additional classes on the | ||
component's root element. You can get larger tabs by using the `pt-large` class on `TabList`. | ||
@reactExample TabsExample | ||
|
||
You can use the `Tabs` API in controlled or uncontrolled mode. The props you supply will differ | ||
between these approaches. | ||
@### Tabs | ||
|
||
@reactExample TabsExample | ||
`Tabs` is the top-level component responsible for rendering the tab list and coordinating selection. | ||
It can be used in controlled mode by providing `selectedTabId` and `onChange` props, or in | ||
uncontrolled mode by optionally providing `defaultSelectedTabId` and `onChange`. | ||
|
||
@### Tabs props | ||
Children of the `Tabs` are rendered in order in the tab list, which is a flex container. | ||
`Tab` children are managed by the component; clicking one will change selection. Arbitrary other | ||
children are simply rendered in order; interactions are your responsibility. | ||
|
||
<div class="pt-callout pt-intent-danger pt-icon-error"> | ||
This component is deprecated since v1.11.0. Please use the [`Tabs2` API](#core/components/tabs2) instead. | ||
</div> | ||
Insert a `<Tabs.Expander />` between any two children to right-align all subsequent children (or bottom-align when `vertical`). | ||
|
||
@interface ITabsProps | ||
|
||
@### Tab props | ||
@### Tab | ||
|
||
`Tab` is a minimal wrapper with no functionality of its own—it is managed entirely by its | ||
parent `Tabs` wrapper. Tab title text can be set either via `title` prop or via React children | ||
(for more complex content). | ||
|
||
<div class="pt-callout pt-intent-danger pt-icon-error"> | ||
This component is deprecated since v1.11.0. Please use the [`Tabs2` API](#core/components/tabs2) instead. | ||
</div> | ||
The associated tab `panel` will be visible when the `Tab` is active. Omitting `panel` is perfectly | ||
safe and allows you to control exactly where the panel appears in the DOM (by rendering it yourself | ||
as needed). | ||
|
||
@interface ITabProps | ||
|
||
|
@@ -91,27 +74,18 @@ applications. Here's how you might configure tabs to work with it: | |
```tsx | ||
import { render } from "react-dom"; | ||
import { Router, Route } from "react-router"; | ||
import { Tabs, TabList, Tab, TabPanel } from "@blueprintjs/core"; | ||
import { Tabs, Tab } from "@blueprintjs/core"; | ||
|
||
const App = () => { ... }; | ||
|
||
// keys are necessary in JSX.Element lists to keep React happy | ||
const contents = [ | ||
<TabList key={0}> | ||
<Tab>Home</Tab> | ||
<Tab>Projects</Tab> | ||
</TabList>, | ||
<TabPanel key={1}> | ||
home things | ||
</TabPanel>, | ||
<TabPanel key={2}> | ||
projects things | ||
</TabPanel>, | ||
<Tab key="home" id="home" title="Home" panel={<HomePanel />}>, | ||
<Tab key="proj" id="projects" title="Projects" panel={<ProjectsPanel />}>, | ||
]; | ||
|
||
// using SFCs from TS 1.8, but easy to do without them | ||
export const Home = () => <Tabs selectedTabIndex={0}>{contents}</Tabs>; | ||
export const Projects = () => <Tabs selectedTabIndex={1}>{contents}</Tabs>; | ||
export const Home = () => <Tabs selectedTabId="home">{contents}</Tabs>; | ||
export const Projects = () => <Tabs selectedTabId="projects">{contents}</Tabs>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @adidahiya are these updates correct? is this section still useful? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, we should probably remove this react router section because it probably doesn't work with react-router v4. we can add it back if requested by users. |
||
|
||
render( | ||
<Router path="/" component={App}> | ||
|
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.
🤔 original date?
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.
I'm down to leave the original date.
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.
I like to use
2015-present
since it's never out of date