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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds fullscreen button to viz Options button group #897

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/cms/src/components/Viz/Options.jsx
Expand Up @@ -48,7 +48,6 @@ const getBackground = elem => {
};

class Options extends Component {

constructor(props) {
super(props);

Expand Down Expand Up @@ -323,7 +322,7 @@ class Options extends Component {

render() {
const {backgroundColor, imageContext, imageFormat, imageProcessing, includeSlug, dialogOpen, results, focusOptions} = this.state;
const {data, iconOnly, slug, t, transitionDuration} = this.props;
const {data, iconOnly, isFullscreen, onToggleFullscreen, slug, t, transitionDuration} = this.props;

// construct URL from a combination of redux & context (#537)
const domain = this.props.location.origin;
Expand Down Expand Up @@ -414,6 +413,10 @@ class Options extends Component {
<Button className="options-button" icon="share" key="share-button" iconOnly={iconOnly} fontSize="xxxs" iconPosition="left" id={`options-button-${slug}-share`} onClick={this.toggleDialog.bind(this, "share")}>
{t("CMS.Options.Share")}
</Button>

<Button key="fs" fontSize="xxxs" icon={isFullscreen ? "minimize" : "fullscreen"} onClick={() => onToggleFullscreen()}>
{isFullscreen ? "minimize" : "enlarge"}
</Button>
</ButtonGroup>

<Dialog className="options-dialog"
Expand Down
21 changes: 21 additions & 0 deletions packages/cms/src/components/Viz/Viz.css
Expand Up @@ -88,4 +88,25 @@
position: static !important;
}
}

&.is-fullscreen {
@mixin absolute-expand;
position: fixed !important;
z-index: 2;
background-color: var(--section-bg-odd);

& .cp-viz-header,
& .cp-viz-figure {
padding: var(--gutter-xs);
}

& .cp-viz-figure {
@mixin vertical-overflow-container;
height: calc(100% - var(--gutter-xl));
max-height: calc(100% - var(--gutter-md));
top: var(--gutter-lg);
margin-bottom: 0;
bottom: 0;
}
}
}
11 changes: 11 additions & 0 deletions packages/cms/src/components/Viz/Viz.jsx
Expand Up @@ -17,6 +17,12 @@ import defaultConfig from "./defaultConfig";
const vizTypes = Object.assign({PercentageBar}, {Table}, {Graphic}, d3plus);

class Viz extends Component {
constructor() {
super();
this.state = {
isFullscreen: false
};
}

getChildContext() {
const context = {...this.context};
Expand All @@ -43,6 +49,7 @@ class Viz extends Component {
sectionTitle,
showTitle
} = this.props;
const {isFullscreen} = this.state;

// Variables come from props in the CMS, and Context in the Front-end.
const variables = this.props.variables || this.context.variables;
Expand Down Expand Up @@ -99,6 +106,8 @@ class Viz extends Component {
className ? ` ${className}` : ""
}${
type ? ` ${namespace}-${toKebabCase(type)}-viz-container` : ""
}${
isFullscreen ? " is-fullscreen" : ""
}`}
ref={ comp => this.viz = comp }
>
Expand All @@ -118,6 +127,8 @@ class Viz extends Component {
slug={slug }
title={title || sectionTitle || slug}
iconOnly={size && size.width < 320 ? true : false}
isFullscreen={isFullscreen}
onToggleFullscreen={() => this.setState({isFullscreen: !isFullscreen})}
/> : ""
}
</div>
Expand Down