-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add EuiTabbedContent.
- Loading branch information
Showing
10 changed files
with
676 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import React, { Component, Fragment } from 'react'; | ||
|
||
import { | ||
EuiButton, | ||
EuiTabbedContent, | ||
EuiTitle, | ||
EuiText, | ||
EuiSpacer, | ||
} from '../../../../src/components'; | ||
|
||
class EuiTabsExample extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.tabs = [{ | ||
id: 'cobalt', | ||
name: 'Cobalt', | ||
content: ( | ||
<Fragment> | ||
<EuiSpacer /> | ||
<EuiTitle><h3>Cobalt</h3></EuiTitle> | ||
<EuiText>Cobalt is a chemical element with symbol Co and atomic number 27. Like nickel, cobalt is found in the Earth’s crust only in chemically combined form, save for small deposits found in alloys of natural meteoric iron. The free element, produced by reductive smelting, is a hard, lustrous, silver-gray metal.</EuiText> | ||
</Fragment> | ||
), | ||
}, { | ||
id: 'dextrose', | ||
name: 'Dextrose', | ||
content: ( | ||
<Fragment> | ||
<EuiSpacer /> | ||
<EuiTitle><h3>Dextrose</h3></EuiTitle> | ||
<EuiText>Intravenous sugar solution, also known as dextrose solution, is a mixture of dextrose (glucose) and water. It is used to treat low blood sugar or water loss without electrolyte loss.</EuiText> | ||
</Fragment> | ||
), | ||
}, { | ||
id: 'hydrogen', | ||
name: 'Hydrogen', | ||
content: ( | ||
<Fragment> | ||
<EuiSpacer /> | ||
<EuiTitle><h3>Hydrogen</h3></EuiTitle> | ||
<EuiText>Hydrogen is a chemical element with symbol H and atomic number 1. With a standard atomic weight of 1.008, hydrogen is the lightest element on the periodic table</EuiText> | ||
</Fragment> | ||
), | ||
}, { | ||
id: 'monosodium_glutammate', | ||
name: 'Monosodium Glutamate', | ||
content: ( | ||
<Fragment> | ||
<EuiSpacer /> | ||
<EuiTitle><h3>Monosodium Glutamate</h3></EuiTitle> | ||
<EuiText>Monosodium glutamate (MSG, also known as sodium glutamate) is the sodium salt of glutamic acid, one of the most abundant naturally occurring non-essential amino acids. Monosodium glutamate is found naturally in tomatoes, cheese and other foods.</EuiText> | ||
</Fragment> | ||
), | ||
}]; | ||
|
||
this.state = { | ||
selectedTab: this.tabs[1], | ||
}; | ||
} | ||
|
||
onTabClick = (selectedTab) => { | ||
this.setState({ selectedTab }); | ||
}; | ||
|
||
cycleTab = () => { | ||
const selectedTabIndex = this.tabs.indexOf(this.state.selectedTab) | ||
const nextTabIndex = selectedTabIndex < this.tabs.length - 1 ? selectedTabIndex + 1 : 0; | ||
this.setState({ | ||
selectedTab: this.tabs[nextTabIndex], | ||
}); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<Fragment> | ||
<EuiButton | ||
iconType="arrowRight" | ||
iconSide="right" | ||
onClick={this.cycleTab} | ||
> | ||
Cycle through the tabs | ||
</EuiButton> | ||
|
||
<EuiSpacer size="m" /> | ||
|
||
<EuiTabbedContent | ||
tabs={this.tabs} | ||
selectedTab={this.state.selectedTab} | ||
onTabClick={this.onTabClick} | ||
/> | ||
</Fragment> | ||
); | ||
} | ||
} | ||
|
||
export default EuiTabsExample; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React, { Component, Fragment } from 'react'; | ||
|
||
import { | ||
EuiTabbedContent, | ||
EuiTitle, | ||
EuiText, | ||
EuiSpacer, | ||
} from '../../../../src/components'; | ||
|
||
class EuiTabsExample extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.tabs = [{ | ||
id: 'cobalt', | ||
name: 'Cobalt', | ||
content: ( | ||
<Fragment> | ||
<EuiSpacer /> | ||
<EuiTitle><h3>Cobalt</h3></EuiTitle> | ||
<EuiText>Cobalt is a chemical element with symbol Co and atomic number 27. Like nickel, cobalt is found in the Earth’s crust only in chemically combined form, save for small deposits found in alloys of natural meteoric iron. The free element, produced by reductive smelting, is a hard, lustrous, silver-gray metal.</EuiText> | ||
</Fragment> | ||
), | ||
}, { | ||
id: 'dextrose', | ||
name: 'Dextrose', | ||
content: ( | ||
<Fragment> | ||
<EuiSpacer /> | ||
<EuiTitle><h3>Dextrose</h3></EuiTitle> | ||
<EuiText>Intravenous sugar solution, also known as dextrose solution, is a mixture of dextrose (glucose) and water. It is used to treat low blood sugar or water loss without electrolyte loss.</EuiText> | ||
</Fragment> | ||
), | ||
}, { | ||
id: 'hydrogen', | ||
name: 'Hydrogen', | ||
content: ( | ||
<Fragment> | ||
<EuiSpacer /> | ||
<EuiTitle><h3>Hydrogen</h3></EuiTitle> | ||
<EuiText>Hydrogen is a chemical element with symbol H and atomic number 1. With a standard atomic weight of 1.008, hydrogen is the lightest element on the periodic table</EuiText> | ||
</Fragment> | ||
), | ||
}, { | ||
id: 'monosodium_glutammate', | ||
name: 'Monosodium Glutamate', | ||
content: ( | ||
<Fragment> | ||
<EuiSpacer /> | ||
<EuiTitle><h3>Monosodium Glutamate</h3></EuiTitle> | ||
<EuiText>Monosodium glutamate (MSG, also known as sodium glutamate) is the sodium salt of glutamic acid, one of the most abundant naturally occurring non-essential amino acids. Monosodium glutamate is found naturally in tomatoes, cheese and other foods.</EuiText> | ||
</Fragment> | ||
), | ||
}]; | ||
} | ||
|
||
render() { | ||
return ( | ||
<EuiTabbedContent | ||
tabs={this.tabs} | ||
initialSelectedTab={this.tabs[1]} | ||
onTabClick={(tab) => { console.log('clicked tab', tab); }} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
export default EuiTabsExample; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { EuiTab } from './tab'; | ||
export { EuiTabs } from './tabs'; | ||
export { EuiTabbedContent } from './tabbed_content'; |
Oops, something went wrong.