mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
ec157dc469
Summary: Adds initial implementation of dark mode. Preferences for dark mode are available on the account settings page. Dark mode is currently a beta feature as there are still some small bugs to squash and a few remaining UI elements to style. Test Plan: Browser tests. Reviewers: jarek Reviewed By: jarek Subscribers: paulfitz, jarek Differential Revision: https://phab.getgrist.com/D3587
143 lines
3.3 KiB
TypeScript
143 lines
3.3 KiB
TypeScript
import * as commands from 'app/client/components/commands';
|
|
import {cssLinkText, cssPageEntryMain, cssPageIcon, cssPageLink} from 'app/client/ui/LeftPanelCommon';
|
|
import {theme} from 'app/client/ui2018/cssVars';
|
|
import {icon} from 'app/client/ui2018/icons';
|
|
import {modal} from 'app/client/ui2018/modals';
|
|
import {commonUrls, shouldHideUiElement} from 'app/common/gristUrls';
|
|
import {dom, makeTestId, styled} from 'grainjs';
|
|
|
|
const testId = makeTestId('test-video-tour-');
|
|
|
|
/**
|
|
* Opens a modal containing a video tour of Grist.
|
|
*/
|
|
export function openVideoTour(refElement: HTMLElement) {
|
|
return modal(
|
|
(ctl) => {
|
|
return [
|
|
cssModal.cls(''),
|
|
cssCloseButton(
|
|
cssCloseIcon('CrossBig'),
|
|
dom.on('click', () => ctl.close()),
|
|
testId('close'),
|
|
),
|
|
cssVideoWrap(
|
|
cssVideo(
|
|
{
|
|
src: commonUrls.videoTour,
|
|
title: 'YouTube video player',
|
|
frameborder: '0',
|
|
allow: 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture',
|
|
allowfullscreen: '',
|
|
},
|
|
),
|
|
),
|
|
testId('modal'),
|
|
];
|
|
},
|
|
{
|
|
refElement,
|
|
variant: 'collapsing',
|
|
}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Creates a text button that shows the video tour on click.
|
|
*/
|
|
export function createVideoTourTextButton(): HTMLDivElement {
|
|
const elem: HTMLDivElement = cssVideoTourTextButton(
|
|
cssVideoIcon('Video'),
|
|
'Grist Video Tour',
|
|
dom.on('click', () => openVideoTour(elem)),
|
|
testId('text-button'),
|
|
);
|
|
|
|
return elem;
|
|
}
|
|
|
|
/**
|
|
* Creates the "Video Tour" button for the "Tools" section of the left panel.
|
|
*
|
|
* Shows the video tour on click.
|
|
*/
|
|
export function createVideoTourToolsButton(): HTMLDivElement | null {
|
|
if (shouldHideUiElement('helpCenter')) { return null; }
|
|
|
|
let iconElement: HTMLElement;
|
|
|
|
const commandsGroup = commands.createGroup({
|
|
videoTourToolsOpen: () => openVideoTour(iconElement),
|
|
}, null, true);
|
|
|
|
return cssPageEntryMain(
|
|
dom.autoDispose(commandsGroup),
|
|
cssPageLink(
|
|
iconElement = cssPageIcon('Video'),
|
|
cssLinkText('Video Tour'),
|
|
dom.cls('tour-help-center'),
|
|
dom.on('click', () => openVideoTour(iconElement)),
|
|
testId('tools-button'),
|
|
),
|
|
);
|
|
}
|
|
|
|
const cssModal = styled('div', `
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 16px;
|
|
padding: 16px;
|
|
width: 100%;
|
|
max-width: 864px;
|
|
`);
|
|
|
|
const cssVideoWrap = styled('div', `
|
|
position: relative;
|
|
padding-bottom: 56.25%;
|
|
height: 0;
|
|
`);
|
|
|
|
const cssVideo = styled('iframe', `
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
`);
|
|
|
|
const cssVideoTourTextButton = styled('div', `
|
|
color: ${theme.controlFg};
|
|
cursor: pointer;
|
|
|
|
&:hover {
|
|
color: ${theme.controlHoverFg};
|
|
}
|
|
`);
|
|
|
|
const cssVideoIcon = styled(icon, `
|
|
background-color: ${theme.controlFg};
|
|
cursor: pointer;
|
|
margin: 0px 4px 3px 0;
|
|
|
|
.${cssVideoTourTextButton.className}:hover > & {
|
|
background-color: ${theme.controlHoverFg};
|
|
}
|
|
`);
|
|
|
|
const cssCloseButton = styled('div', `
|
|
align-self: flex-end;
|
|
margin: -8px;
|
|
padding: 4px;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
--icon-color: ${theme.modalCloseButtonFg};
|
|
|
|
&:hover {
|
|
background-color: ${theme.hover};
|
|
}
|
|
`);
|
|
|
|
const cssCloseIcon = styled(icon, `
|
|
padding: 12px;
|
|
`);
|