siriwatknp / mui-treasury

A collection of ready-to-use components based on Material-UI
https://mui-treasury.com
MIT License
2.38k stars 151 forks source link

Add Fullscreen Button #139

Open yordis opened 5 years ago

yordis commented 5 years ago

Using Fullscreen and FullscreenExit combined with Fullscreen API is a common component to have in some backoffice driven apps.

Maybe would be nice to publish this component under Mui Treasure, it depends of #72

Actual code, copied from https://www.npmjs.com/package/@straw-hat/react-fullscreen (I am the author)

import IconButton from '@material-ui/core/IconButton';
import FullscreenIcon from '@material-ui/icons/Fullscreen';
import FullscreenExitIcon from '@material-ui/icons/FullscreenExit';
import * as React from 'react';
import { useFullscreen } from '@straw-hat/react-fullscreen';

export function FullscreenButton() {
  const target = React.useRef(window.document.body);
  const { isFullscreen, toggleFullscreen } = useFullscreen(target);

  return (
    <IconButton color="inherit" onClick={toggleFullscreen}>
      {isFullscreen ? <FullscreenExitIcon /> : <FullscreenIcon />}
    </IconButton>
  );
}

Cheers,

siriwatknp commented 4 years ago

@yordis Do you still want to add this component? if yes, I will reopen this issue

yordis commented 4 years ago

@siriwatknp for some reason I just saw this notification,

Honestly, up to you, I know many people love to add this button to admin dashboard and stuff like that so it may be beneficial for multiple people.

Close it if you feel, it doesn't add value.