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

DO NOT MERGE: Add K6 overrides to light theme. #153

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion src-docs/src/actions/theme_actions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import ActionTypes from './action_types';

export const toggleTheme = () => ({
export const toggleTheme = theme => ({
type: ActionTypes.TOGGLE_THEME,
data: {
theme,
},
});
22 changes: 11 additions & 11 deletions src-docs/src/components/guide_page/guide_page_chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from 'react-router';

import {
EuiButtonEmpty,
EuiFieldSearch,
EuiFlexGroup,
EuiFlexItem,
Expand All @@ -16,6 +15,10 @@ import {
EuiSpacer,
} from '../../../../src/components';

import {
GuideThemeSelector,
} from '../guide_theme_selector';

export class GuidePageChrome extends Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -66,16 +69,10 @@ export class GuidePageChrome extends Component {
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiButtonEmpty
size="xs"
onClick={this.props.onToggleTheme}
className="euiLink"
iconSide="right"
color="text"
iconType="invert"
>
Flip theme
</EuiButtonEmpty>
<GuideThemeSelector
onToggleTheme={this.props.onToggleTheme}
selectedTheme={this.props.selectedTheme}
/>
</EuiFlexItem>
</EuiFlexGroup>
);
Expand Down Expand Up @@ -203,6 +200,9 @@ export class GuidePageChrome extends Component {

GuidePageChrome.propTypes = {
currentRouteName: PropTypes.string.isRequired,
onToggleTheme: PropTypes.func.isRequired,
selectedTheme: PropTypes.string.isRequired,
guidelines: PropTypes.array.isRequired,
components: PropTypes.array.isRequired,
sandboxes: PropTypes.array.isRequired,
};
24 changes: 14 additions & 10 deletions src-docs/src/components/guide_sandbox/guide_sandbox_chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,25 @@ import {
Link,
} from 'react-router';

import {
GuideSandboxChromeToggle,
} from './guide_sandbox_chrome_toggle';

import {
EuiIcon,
EuiFlexGroup,
EuiFlexItem,
} from '../../../../src/components';

import {
GuideThemeSelector,
} from '../guide_theme_selector';

import {
GuideSandboxChromeToggle,
} from './guide_sandbox_chrome_toggle';

export const GuideSandboxChrome = ({
isVisible,
onToggleTheme,
onToggleSandboxChrome,
selectedTheme,
}) => {
const toggle = <GuideSandboxChromeToggle onClick={onToggleSandboxChrome} />;

Expand All @@ -36,12 +41,10 @@ export const GuideSandboxChrome = ({
</EuiFlexItem>

<EuiFlexItem grow={false}>
<button
onClick={onToggleTheme}
className="guideSandboxChrome__link"
>
Theme
</button>
<GuideThemeSelector
onToggleTheme={onToggleTheme}
selectedTheme={selectedTheme}
/>
</EuiFlexItem>
</EuiFlexGroup>

Expand All @@ -54,5 +57,6 @@ GuideSandboxChrome.propTypes = {
routes: PropTypes.array.isRequired,
onToggleTheme: PropTypes.func.isRequired,
onToggleSandboxChrome: PropTypes.func.isRequired,
selectedTheme: PropTypes.string.isRequired,
isVisible: PropTypes.bool,
};
2 changes: 2 additions & 0 deletions src-docs/src/components/guide_section/guide_section.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class GuideSection extends Component {
routes={Routes.getAppRoutes()}
onToggleTheme={this.props.toggleTheme}
onToggleSandboxChrome={this.onToggleSandboxChrome}
selectedTheme={this.props.theme}
isVisible={this.state.sandbox.isChromeVisible}
/>
);
Expand Down Expand Up @@ -156,4 +157,5 @@ GuideSection.propTypes = {
children: PropTypes.any,
isSandbox: PropTypes.bool,
toggleTheme: PropTypes.func.isRequired,
theme: PropTypes.string.isRequired,
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { GuideSection } from './guide_section';

import {
getIsSandbox,
getTheme,
} from '../../store';

import {
Expand All @@ -13,6 +14,7 @@ import {
function mapStateToProps(state) {
return {
isSandbox: getIsSandbox(state),
theme: getTheme(state),
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';

import {
EuiButtonEmpty,
EuiContextMenuItem,
EuiContextMenuPanel,
EuiPopover,
} from '../../../../src/components';

export class GuideThemeSelector extends Component {
constructor(props) {
super(props);

this.state = {
isThemePopoverOpen: false,
};
}

onThemeButtonClick = () => {
this.setState({
isThemePopoverOpen: !this.state.isThemePopoverOpen,
});
};

closeThemePopover = () => {
this.setState({
isThemePopoverOpen: false,
});
};

render() {
const themeButton = (
<EuiButtonEmpty
size="s"
color="text"
iconType="arrowDown"
iconSide="right"
onClick={this.onThemeButtonClick}
>
Theme
</EuiButtonEmpty>
);

const themeOptions = [{
name: 'Light',
value: 'light',
}, {
name: 'Dark',
value: 'dark',
}, {
name: 'K6',
value: 'k6',
}, {
name: 'K6 dark',
value: 'k6_dark',
}].map(option => {
const { name, value } = option;

return (
<EuiContextMenuItem
key={value}
icon={value === this.props.selectedTheme ? 'check' : 'empty'}
onClick={() => { this.closeThemePopover(); this.props.onToggleTheme(value); }}
>
{`${name}`}
</EuiContextMenuItem>
);
});

return (
<EuiPopover
id="pageChromeThemePopover"
button={themeButton}
isOpen={this.state.isThemePopoverOpen}
closePopover={this.closeThemePopover}
panelPaddingSize="none"
withTitle
anchorPosition="downRight"
>
<EuiContextMenuPanel
style={{ width: '120px' }}
items={themeOptions}
/>
</EuiPopover>
);
}
}

GuideThemeSelector.propTypes = {
onToggleTheme: PropTypes.func.isRequired,
selectedTheme: PropTypes.string.isRequired,
};
1 change: 1 addition & 0 deletions src-docs/src/components/guide_theme_selector/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { GuideThemeSelector } from './guide_theme_selector';
10 changes: 10 additions & 0 deletions src-docs/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {

import themeLight from './theme_light.scss';
import themeDark from './theme_dark.scss';
import themeK6 from './theme_k6.scss';
import themeK6Dark from './theme_k6_dark.scss';

registerTheme('light', [
themeLight
Expand All @@ -29,6 +31,14 @@ registerTheme('dark', [
themeDark
]);

registerTheme('k6', [
themeK6
]);

registerTheme('k6_dark', [
themeK6Dark
]);

// Set up app

const store = configureStore();
Expand Down
2 changes: 1 addition & 1 deletion src-docs/src/store/reducers/theme_reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function sectionsReducer(state = defaultState, action) {
switch (action.type) {
case ActionTypes.TOGGLE_THEME: {
return {
theme: (state.theme === 'light') ? 'dark' : 'light',
theme: action.data.theme,
};
}

Expand Down
2 changes: 2 additions & 0 deletions src-docs/src/theme_k6.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import "../../src/theme_k6";
@import "./components/guide_components";
2 changes: 2 additions & 0 deletions src-docs/src/theme_k6_dark.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import "../../src/theme_k6_dark";
@import "./components/guide_components";
25 changes: 15 additions & 10 deletions src-docs/src/views/app_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,18 @@ export class AppView extends Component {
}

renderContent() {
if (this.props.isSandbox) {
const {
children,
currentRoute,
isSandbox,
toggleTheme,
theme,
} = this.props;

if (isSandbox) {
return (
<div className="guideSandbox">
{this.props.children}
{children}
</div>
);
} else {
Expand All @@ -69,9 +77,9 @@ export class AppView extends Component {
<EuiPageBody>
<EuiPageSideBar>
<GuidePageChrome
currentRouteName={this.props.currentRoute.name}
onToggleTheme={this.props.toggleTheme}
routes={this.props.routes}
currentRouteName={currentRoute.name}
onToggleTheme={toggleTheme}
selectedTheme={theme}
guidelines={Routes.guidelines}
components={Routes.components}
sandboxes={Routes.sandboxes}
Expand All @@ -80,7 +88,7 @@ export class AppView extends Component {

<EuiPageContent>
<EuiPageContentBody>
{this.props.children}
{children}
</EuiPageContentBody>
</EuiPageContent>
</EuiPageBody>
Expand All @@ -101,14 +109,11 @@ export class AppView extends Component {
AppView.propTypes = {
children: PropTypes.any,
currentRoute: PropTypes.object.isRequired,
sections: PropTypes.array,
isSandbox: PropTypes.bool,
toggleTheme: PropTypes.func.isRequired,
theme: PropTypes.string.isRequired,
sections: PropTypes.array.isRequired,
toggleTheme: PropTypes.func.isRequired,
};

AppView.defaultProps = {
currentRoute: {},
sections: [],
};
5 changes: 5 additions & 0 deletions src/global_styling/k6/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import 'size';
@import 'typography';
// @import 'borders';
// @import 'shadows';
// @import 'z_index';
7 changes: 7 additions & 0 deletions src/global_styling/k6/_size.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$euiSizeXS: 4px;
$euiSizeS: 8px;
$euiSizeM: 11px;
$euiSize: 14px;
$euiSizeL: 18px;
$euiSizeXL: 22px;
$euiSizeXXL: 26px;
10 changes: 10 additions & 0 deletions src/global_styling/k6/_typography.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
$euiFontSizeXS: 12px;
$euiFontSizeS: 14px;
$euiFontSizeM: 14px;
$euiFontSize: 14px;
$euiFontSizeL: 18px;
$euiFontSizeXL: 22px;
$euiFontSizeXXL: 28px;

// Make titles bold.
$euiFontWeightLight: 500;
1 change: 1 addition & 0 deletions src/global_styling/mixins/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
@import 'responsive';
@import 'shadow';
@import 'size';
@import 'typography';
@import 'helpers';
Loading