-
Notifications
You must be signed in to change notification settings - Fork 839
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into header_sections
- Loading branch information
Showing
125 changed files
with
1,245 additions
and
423 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,3 +1 @@ | ||
export { toggleTheme } from './theme_actions'; | ||
|
||
export { toggleLocale } from './locale_actions'; |
This file was deleted.
Oops, something went wrong.
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
77 changes: 23 additions & 54 deletions
77
src-docs/src/components/guide_theme_selector/guide_theme_selector.js
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,59 +1,28 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
|
||
import { ThemeContext } from '../with_theme'; | ||
import { EuiSelect, EuiFormRow } from '../../../../src/components'; | ||
import { EUI_THEMES } from '../../../../src/themes'; | ||
|
||
export class GuideThemeSelector extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.themeOptions = [ | ||
{ | ||
text: 'Light', | ||
value: 'light', | ||
}, | ||
{ | ||
text: 'Dark', | ||
value: 'dark', | ||
}, | ||
{ | ||
text: 'Amsterdam: Light', | ||
value: 'amsterdam-light', | ||
}, | ||
{ | ||
text: 'Amsterdam: Dark', | ||
value: 'amsterdam-dark', | ||
}, | ||
]; | ||
|
||
this.state = { | ||
value: this.themeOptions[0].value, | ||
}; | ||
} | ||
|
||
onChange = e => { | ||
this.setState({ | ||
value: e.target.value, | ||
}); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<EuiFormRow label="Theme"> | ||
<EuiSelect | ||
options={this.themeOptions} | ||
value={this.props.selectedTheme} | ||
onChange={e => { | ||
this.props.onToggleTheme(e.target.value); | ||
}} | ||
aria-label="Switch the theme" | ||
/> | ||
</EuiFormRow> | ||
); | ||
} | ||
} | ||
export const GuideThemeSelector = () => { | ||
return ( | ||
<ThemeContext.Consumer> | ||
{context => <GuideThemeSelectorComponent context={context} />} | ||
</ThemeContext.Consumer> | ||
); | ||
}; | ||
|
||
GuideThemeSelector.propTypes = { | ||
onToggleTheme: PropTypes.func.isRequired, | ||
selectedTheme: PropTypes.string.isRequired, | ||
const GuideThemeSelectorComponent = ({ context }) => { | ||
return ( | ||
<EuiFormRow label="Theme"> | ||
<EuiSelect | ||
options={EUI_THEMES} | ||
value={context.theme} | ||
onChange={e => { | ||
context.changeTheme(e.target.value); | ||
}} | ||
aria-label="Switch the theme" | ||
/> | ||
</EuiFormRow> | ||
); | ||
}; |
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 was deleted.
Oops, something went wrong.
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 @@ | ||
export { ThemeProvider, ThemeContext } from './theme_context'; |
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,51 @@ | ||
import React from 'react'; | ||
import { EUI_THEMES, EUI_THEME } from '../../../../src/themes'; | ||
// @ts-ignore | ||
import { applyTheme } from '../../services'; | ||
|
||
const defaultState = { | ||
theme: EUI_THEMES[0].value, | ||
changeTheme: (themeValue: EUI_THEME['value']) => { | ||
applyTheme(themeValue); | ||
}, | ||
}; | ||
|
||
interface State { | ||
theme: EUI_THEME['value']; | ||
} | ||
|
||
export const ThemeContext = React.createContext(defaultState); | ||
|
||
export class ThemeProvider extends React.Component<object, State> { | ||
constructor(props: object) { | ||
super(props); | ||
|
||
const theme = localStorage.getItem('theme') || defaultState.theme; | ||
applyTheme(theme); | ||
|
||
this.state = { | ||
theme, | ||
}; | ||
} | ||
|
||
changeTheme = (themeValue: EUI_THEME['value']) => { | ||
this.setState({ theme: themeValue }, () => { | ||
localStorage.setItem('theme', themeValue); | ||
applyTheme(themeValue); | ||
}); | ||
}; | ||
|
||
render() { | ||
const { children } = this.props; | ||
const { theme } = this.state; | ||
return ( | ||
<ThemeContext.Provider | ||
value={{ | ||
theme, | ||
changeTheme: this.changeTheme, | ||
}}> | ||
{children} | ||
</ThemeContext.Provider> | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,50 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
EuiAccordion, | ||
EuiText, | ||
EuiCode, | ||
EuiSpacer, | ||
} from '../../../../src/components'; | ||
|
||
export default () => ( | ||
<div> | ||
<EuiAccordion | ||
id="accordion10" | ||
buttonContent="Arrows default to the left" | ||
paddingSize="s"> | ||
<EuiText> | ||
<p> | ||
Any content inside of <EuiCode>EuiAccordion</EuiCode> will appear | ||
here. | ||
</p> | ||
</EuiText> | ||
</EuiAccordion> | ||
<EuiSpacer /> | ||
<EuiAccordion | ||
id="accordion11" | ||
arrowDisplay="right" | ||
buttonContent="This one has it on the right" | ||
paddingSize="s"> | ||
<EuiText> | ||
<p> | ||
Any content inside of <EuiCode>EuiAccordion</EuiCode> will appear | ||
here. | ||
</p> | ||
</EuiText> | ||
</EuiAccordion> | ||
<EuiSpacer /> | ||
<EuiAccordion | ||
id="accordion12" | ||
arrowDisplay="none" | ||
buttonContent="This one has it removed entirely" | ||
paddingSize="s"> | ||
<EuiText> | ||
<p> | ||
Any content inside of <EuiCode>EuiAccordion</EuiCode> will appear | ||
here. | ||
</p> | ||
</EuiText> | ||
</EuiAccordion> | ||
</div> | ||
); |
Oops, something went wrong.