Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/frontend/app/fullscreen-button.tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { useIntl } from "react-intl";67import {8CSS,9React,10useActions,11useTypedRedux,12} from "@cocalc/frontend/app-framework";13import { Icon, Tip } from "@cocalc/frontend/components";14import track from "@cocalc/frontend/user-tracking";15import { COLORS } from "@cocalc/util/theme";16import {17NAV_HEIGHT_PX,18PageStyle,19TOP_BAR_ELEMENT_CLASS,20} from "./top-nav-consts";2122const TIP_STYLE_FULLSCREEN: CSS = {23position: "fixed",24zIndex: 100,25right: 0,26top: 0,27} as const;2829interface Props {30pageStyle: PageStyle;31}3233export const FullscreenButton: React.FC<Props> = React.memo((props: Props) => {34const { pageStyle } = props;35const { fontSizeIcons } = pageStyle;3637const intl = useIntl();38const fullscreen = useTypedRedux("page", "fullscreen");39const page_actions = useActions("page");4041if (fullscreen == "kiosk" || fullscreen == "project") {42// no button, since can't get out.43return <></>;44}4546const icon = fullscreen ? "compress" : "expand";47const icon_style: CSS = {48fontSize: fontSizeIcons,49color: COLORS.GRAY,50cursor: "pointer",51...(fullscreen52? {53background: "white",54opacity: 0.7,55border: "1px solid grey",56}57: {58display: "flex",59alignItems: "center",60justifyContent: "center",61height: `${NAV_HEIGHT_PX}px`,62width: `${NAV_HEIGHT_PX}px`,63}),64};6566const tooltip = intl.formatMessage({67id: "app.fullscreen-button.tooltip",68defaultMessage: "Fullscreen mode, focused on the current document or page.",69});7071return (72<Tip73style={fullscreen === "default" ? TIP_STYLE_FULLSCREEN : undefined}74title={tooltip}75placement={"bottomRight"}76delayShow={2000}77>78<Icon79className={TOP_BAR_ELEMENT_CLASS}80style={icon_style}81name={icon}82onClick={(_) => {83track("top_nav", {84name: "fullscreen",85enabled: !fullscreen,86});87page_actions.toggle_fullscreen();88}}89/>90</Tip>91);92});939495