Skip to content
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

Add Condensed Display Prop for EuiTabs & EuiTabbedContent #1904

Merged
merged 20 commits into from
May 2, 2019
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b23953f
initial props, style and test additions
MichaelMarcialis Apr 30, 2019
bb46141
css alpha rules ocd
MichaelMarcialis Apr 30, 2019
28054b8
update snapshots
MichaelMarcialis Apr 30, 2019
fc6f7cd
added prop description
MichaelMarcialis Apr 30, 2019
8f62019
add display prop to tabbed_content
MichaelMarcialis Apr 30, 2019
7d99fbf
Merge branch 'master' of https://github.com/elastic/eui into feature/…
MichaelMarcialis Apr 30, 2019
b780305
update changelog
MichaelMarcialis Apr 30, 2019
3a14d19
Merge branch 'master' of https://github.com/elastic/eui into feature/…
MichaelMarcialis May 1, 2019
7fd6186
comments and desc updates
MichaelMarcialis May 1, 2019
af13b83
added carolines suggested docs changes
MichaelMarcialis May 1, 2019
ce11e65
Merge branch 'master' of https://github.com/elastic/eui into feature/…
MichaelMarcialis May 1, 2019
001855d
rm extraneous div
MichaelMarcialis May 2, 2019
4b7ddf3
add prop to ts defs
MichaelMarcialis May 2, 2019
6ecc913
add example snippets
MichaelMarcialis May 2, 2019
7e6f5bf
change div to fragment
MichaelMarcialis May 2, 2019
e3a7001
update tests and snapshots
MichaelMarcialis May 2, 2019
ff33ed2
correct misplaced description
MichaelMarcialis May 2, 2019
2881bce
switch from complex not selector to overrides
MichaelMarcialis May 2, 2019
d48b54d
Merge branch 'master' of https://github.com/elastic/eui into feature/…
MichaelMarcialis May 2, 2019
af383a2
add missing EuiTab props, update snippets
MichaelMarcialis May 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Added `display` prop to `EuiTabs` and `EuiTabbedContent` components for ability to use an alternative `condensed` style ([#1904](https://github.com/elastic/eui/pull/1904))
- Added `selectable` prop to `EuiCard` ([#1895](https://github.com/elastic/eui/pull/1895))
- Converted `EuiValidatableControl` to TS ([#1879](https://github.com/elastic/eui/pull/1879))

Expand Down
55 changes: 26 additions & 29 deletions src-docs/src/views/tabs/tabs.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
import React, { Component } from 'react';

import {
EuiTabs,
EuiTab,
EuiSpacer,
} from '../../../../src/components';
import { EuiTabs, EuiTab, EuiSpacer } from '../../../../src/components';

class EuiTabsExample extends Component {
constructor(props) {
super(props);

this.tabs = [{
id: 'cobalt',
name: 'Cobalt',
disabled: false,
}, {
id: 'dextrose',
name: 'Dextrose',
disabled: false,
}, {
id: 'hydrogen',
name: 'Hydrogen',
disabled: true,
}, {
id: 'monosodium_glutammate',
name: 'Monosodium Glutamate',
disabled: false,
}];
this.tabs = [
{
id: 'cobalt',
name: 'Cobalt',
disabled: false,
},
{
id: 'dextrose',
name: 'Dextrose',
disabled: false,
},
{
id: 'hydrogen',
name: 'Hydrogen',
disabled: true,
},
{
id: 'monosodium_glutammate',
name: 'Monosodium Glutamate',
disabled: false,
},
];

this.state = {
selectedTabId: 'cobalt',
Expand All @@ -37,7 +38,7 @@ class EuiTabsExample extends Component {
this.setState({
selectedTabId: id,
});
}
};

renderTabs() {
return this.tabs.map((tab, index) => (
Expand All @@ -55,15 +56,11 @@ class EuiTabsExample extends Component {
render() {
return (
<div>
<EuiTabs>
{this.renderTabs()}
</EuiTabs>
<EuiTabs>{this.renderTabs()}</EuiTabs>

<EuiSpacer />

<EuiTabs size="s">
{this.renderTabs()}
</EuiTabs>
<EuiTabs size="s">{this.renderTabs()}</EuiTabs>
</div>
);
}
Expand Down
65 changes: 65 additions & 0 deletions src-docs/src/views/tabs/tabs_condensed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React, { Component } from 'react';

import { EuiTabs, EuiTab } from '../../../../src/components';

class EuiTabsExample extends Component {
constructor(props) {
super(props);

this.tabs = [
{
id: 'cobalt',
name: 'Cobalt',
disabled: false,
},
{
id: 'dextrose',
name: 'Dextrose',
disabled: false,
},
{
id: 'hydrogen',
name: 'Hydrogen',
disabled: true,
},
{
id: 'monosodium_glutammate',
name: 'Monosodium Glutamate',
disabled: false,
},
];

this.state = {
selectedTabId: 'cobalt',
};
}

onSelectedTabChanged = id => {
this.setState({
selectedTabId: id,
});
};

renderTabs() {
return this.tabs.map((tab, index) => (
<EuiTab
onClick={() => this.onSelectedTabChanged(tab.id)}
isSelected={tab.id === this.state.selectedTabId}
disabled={tab.disabled}
key={index}
>
{tab.name}
</EuiTab>
));
}

render() {
return (
<div>
<EuiTabs display="condensed">{this.renderTabs()}</EuiTabs>
</div>
);
}
}

export default EuiTabsExample;
171 changes: 106 additions & 65 deletions src-docs/src/views/tabs/tabs_example.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import React from 'react';
import { renderToHtml } from '../../services';

import {
GuideSectionTypes,
} from '../../components';
import { GuideSectionTypes } from '../../components';

import {
EuiCode,
EuiTabs,
EuiTabbedContent,
} from '../../../../src/components';
import { EuiCode, EuiTabs, EuiTabbedContent } from '../../../../src/components';

import Tabs from './tabs';
const tabsSource = require('!!raw-loader!./tabs');
const tabsHtml = renderToHtml(Tabs);

import TabsCondensed from './tabs_condensed';
const tabsCondensedSource = require('!!raw-loader!./tabs_condensed');
const tabsCondensedHtml = renderToHtml(TabsCondensed);

import TabbedContent from './tabbed_content';
const tabbedContentSource = require('!!raw-loader!./tabbed_content');
const tabbedContentHtml = renderToHtml(TabbedContent);
Expand All @@ -25,64 +23,107 @@ const controlledHtml = renderToHtml(Controlled);

export const TabsExample = {
title: 'Tabs',
sections: [{
source: [{
type: GuideSectionTypes.JS,
code: tabsSource,
}, {
type: GuideSectionTypes.HTML,
code: tabsHtml,
}],
text: (
<p>
<EuiCode>EuiTabs</EuiCode> allow a <EuiCode>size</EuiCode> prop. In general
you should always use the default size, but in rare cases (like putting tabs
within a popover of other small menu) it is OK to use the smaller sizing.
</p>
),
props: {
EuiTabs,
sections: [
{
source: [
{
type: GuideSectionTypes.JS,
code: tabsSource,
},
{
type: GuideSectionTypes.HTML,
code: tabsHtml,
},
],
text: (
<p>
<EuiCode>EuiTabs</EuiCode> allow a <EuiCode>size</EuiCode> prop. In
general you should always use the default size, but in rare cases
(like putting tabs within a popover of other small menu) it is OK to
use the smaller sizing.
</p>
),
props: {
EuiTabs,
},
demo: <Tabs />,
},
{
title: 'Condensed tabs',
source: [
{
type: GuideSectionTypes.JS,
code: tabsCondensedSource,
},
{
type: GuideSectionTypes.HTML,
code: tabsCondensedHtml,
},
],
text: (
<p>
<EuiCode>EuiTabs</EuiCode> allow a <EuiCode>display</EuiCode> prop. In
general you should always use the default display. However, it is
acceptable to use the alternative <EuiCode>condensed</EuiCode> display
in situations where it is desirable to display a bolder, more compact
and borderless tab interface (for use as primary navigation within
your application or to establish a higher level hierarchy of tabs).
</p>
),
props: {
EuiTabs,
},
demo: <TabsCondensed />,
},
demo: <Tabs />,
}, {
title: 'Tabbed content',
source: [{
type: GuideSectionTypes.JS,
code: tabbedContentSource,
}, {
type: GuideSectionTypes.HTML,
code: tabbedContentHtml,
}],
text: (
<p>
<EuiCode>EuiTabbedContent</EuiCode> makes it easier to associate tabs with content based
on the selected tab. Use the <EuiCode>initialSelectedTab</EuiCode> prop to specify which
tab to initially select.
</p>
),
props: {
EuiTabbedContent,
{
title: 'Tabbed content',
source: [
{
type: GuideSectionTypes.JS,
code: tabbedContentSource,
},
{
type: GuideSectionTypes.HTML,
code: tabbedContentHtml,
},
],
text: (
<p>
<EuiCode>EuiTabbedContent</EuiCode> makes it easier to associate tabs
with content based on the selected tab. Use the{' '}
<EuiCode>initialSelectedTab</EuiCode> prop to specify which tab to
initially select.
</p>
),
props: {
EuiTabbedContent,
},
demo: <TabbedContent />,
},
demo: <TabbedContent />,
}, {
title: 'Controlled tabbed content',
source: [{
type: GuideSectionTypes.JS,
code: controlledSource,
}, {
type: GuideSectionTypes.HTML,
code: controlledHtml,
}],
text: (
<p>
You can also use the <EuiCode>selectedTab</EuiCode> and <EuiCode>onTabClick</EuiCode> props
to take complete control over tab selection. This can be useful if you want to change tabs
based on user interaction with another part of the UI.
</p>
),
props: {
EuiTabbedContent,
{
title: 'Controlled tabbed content',
source: [
{
type: GuideSectionTypes.JS,
code: controlledSource,
},
{
type: GuideSectionTypes.HTML,
code: controlledHtml,
},
],
text: (
<p>
You can also use the <EuiCode>selectedTab</EuiCode> and{' '}
<EuiCode>onTabClick</EuiCode> props to take complete control over tab
selection. This can be useful if you want to change tabs based on user
interaction with another part of the UI.
</p>
),
props: {
EuiTabbedContent,
},
demo: <Controlled />,
},
demo: <Controlled />,
}],
],
};
7 changes: 7 additions & 0 deletions src/components/tabs/__snapshots__/tabs.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiTabs props display is rendered 1`] = `
<div
class="euiTabs euiTabs--condensed"
role="tablist"
/>
`;

exports[`EuiTabs props expand is rendered 1`] = `
<div
class="euiTabs euiTabs--expand"
Expand Down
Loading