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

feature request: full screen toggle button #56

Open
cag-oss opened this issue Feb 2, 2018 · 3 comments
Open

feature request: full screen toggle button #56

cag-oss opened this issue Feb 2, 2018 · 3 comments

Comments

@cag-oss
Copy link

cag-oss commented Feb 2, 2018

And by full screen I mean toggling that panel to be the only one visible, and taking up all of the available space.

@abenhamdine
Copy link

Would be very useful IMHO, because often the user want to focus on a sole topic on screen, so don't need to see other windows then.

@nomcopter
Copy link
Owner

This is pretty complicated to do at the Mosaic level given the flexibility it gives to the consumer to fill the tiles. This should be doable at the consumer level by adding a button that when pressed, sets the current node to the current window, and stores the original state within. It is then up to the consumer to hide the other buttons and make disable close, split, etc from that state.

@bradennapier
Copy link

bradennapier commented Jun 23, 2018

Just got done doing this FYI. Below is a rough example for anyone interested.

import {
  MosaicWindow, Mosaic, ExpandButton, RemoveButton,
} from 'react-mosaic-component';

function handleFullscreen(id) {
  const elem = document.getElementById(id);
  launchFullscreen(elem);
}

function handleChange() {}

export default class DynamicGrid extends React.Component<*> {
  static defaultProps = {
    grid: {
      direction: 'row',
      first: {
        direction: 'column',
        first: 'Information',
        second: 'Chart',
        splitPercentage: 25,
      },
      second: {
        first: 'Order Book',
        second: 'Depth Chart',
        splitPercentage: 80,
        direction: 'column',
      },
      splitPercentage: 50,
      new: 'New Window',
    },
  };

  render() {
    return (
      <GridWrapper>
        <GridProvider>
          <GridContainer>
            <GridToolbar />
            <GridMosaicWrapper>
              <Mosaic
                className={styles.grid}
                initialValue={this.props.grid}
                onChange={handleChange.bind(this)}
                renderTile={(id, path) => {
                  const windowID = `grid-window-${id}`;
                  const toolbarControls = [
                    <button
                      key="fs"
                      data-tip="Fullscreen"
                      key="fs"
                      className={styles.fullscreen}
                      onClick={() => handleFullscreen(windowID)}
                    />,
                    <div data-tip="Expand" key="expand">
                      <ExpandButton onClick={() => this.props.onExpand && this.props.onExpand(widget)} />
                    </div>,
                    <div data-tip="Remove" key="remove">
                      <RemoveButton onClick={() => this.props.onRemove && this.props.onRemove(widget)} />
                    </div>,
                  ];
                  const mosaicWindowProps = {
                    title: id,
                    path,
                    toolbarControls,
                  };
                  return (
                    <div key={windowID} id={windowID}>
                      <MosaicWindow {...mosaicWindowProps}>
                        <GridWidgetWrapper>
                          Rendering
                          {id}
                        </GridWidgetWrapper>
                      </MosaicWindow>
                    </div>
                  );
                }}
              />
            </GridMosaicWrapper>
          </GridContainer>
        </GridProvider>
      </GridWrapper>
    );
  }
}

With launchFullscreen:

export function launchFullscreen(elem = document.documentElement) {
  const { screen } = window;
  if (
    window.fullScreen
    || document.webkitIsFullScreen
    || elem.fullscreenElement
    || document.fullscreenElement
    || (window.innerWidth === screen.width && window.innerHeight === screen.height)
  ) {
    return exitFullscreen();
  }
  if (elem.requestFullscreen) {
    elem.requestFullscreen();
  } else if (elem.mozRequestFullScreen) {
    elem.mozRequestFullScreen();
  } else if (elem.webkitRequestFullscreen) {
    elem.webkitRequestFullscreen();
  } else if (elem.webkitRequestFullScreen) {
    elem.webkitRequestFullScreen();
  } else if (elem.msRequestFullscreen) {
    elem.msRequestFullscreen();
  }
}

export function exitFullscreen(elem = document.documentElement) {
  if (document.exitFullscreen) {
    document.exitFullscreen();
  } else if (document.webkitExitFullscreen) {
    document.webkitExitFullscreen();
  } else if (document.mozCancelFullScreen) {
    document.mozCancelFullScreen();
  } else if (elem.exitFullscreen) {
    elem.exitFullscreen();
  } else if (elem.mozCancelFullScreen) {
    elem.mozCancelFullScreen();
  } else if (elem.webkitExitFullscreen) {
    elem.webkitExitFullscreen();
  } else if (elem.webkitExitFullScreen) {
    elem.webkitExitFullScreen();
  } else if (elem.msExitFullscreen) {
    elem.msExitFullscreen();
  }
}

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants