2022-06-17 03:43:26 +00:00
|
|
|
import * as commands from 'app/client/components/commands';
|
2022-10-28 16:11:08 +00:00
|
|
|
import {makeT} from 'app/client/lib/localization';
|
2022-06-17 03:43:26 +00:00
|
|
|
import {cssLinkText, cssPageEntryMain, cssPageIcon, cssPageLink} from 'app/client/ui/LeftPanelCommon';
|
2022-09-06 01:51:57 +00:00
|
|
|
import {theme} from 'app/client/ui2018/cssVars';
|
2022-06-17 03:43:26 +00:00
|
|
|
import {icon} from 'app/client/ui2018/icons';
|
2022-12-20 02:06:39 +00:00
|
|
|
import {cssModalCloseButton, modal} from 'app/client/ui2018/modals';
|
2022-06-17 03:43:26 +00:00
|
|
|
import {commonUrls, shouldHideUiElement} from 'app/common/gristUrls';
|
|
|
|
import {dom, makeTestId, styled} from 'grainjs';
|
|
|
|
|
2022-10-28 16:11:08 +00:00
|
|
|
const t = makeT('OpenVideoTour');
|
|
|
|
|
2022-06-17 03:43:26 +00:00
|
|
|
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(''),
|
2022-12-20 02:06:39 +00:00
|
|
|
cssModalCloseButton(
|
2022-06-17 03:43:26 +00:00
|
|
|
cssCloseIcon('CrossBig'),
|
|
|
|
dom.on('click', () => ctl.close()),
|
|
|
|
testId('close'),
|
|
|
|
),
|
|
|
|
cssVideoWrap(
|
|
|
|
cssVideo(
|
|
|
|
{
|
|
|
|
src: commonUrls.videoTour,
|
2022-10-28 16:11:08 +00:00
|
|
|
title: t('YouTubeVideoPlayer'),
|
2022-06-17 03:43:26 +00:00
|
|
|
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'),
|
2022-10-28 16:11:08 +00:00
|
|
|
t('GristVideoTour'),
|
2022-06-17 03:43:26 +00:00
|
|
|
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'),
|
2022-10-28 16:11:08 +00:00
|
|
|
cssLinkText(t('VideoTour')),
|
2022-06-17 03:43:26 +00:00
|
|
|
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', `
|
2022-09-06 01:51:57 +00:00
|
|
|
color: ${theme.controlFg};
|
2022-06-17 03:43:26 +00:00
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
&:hover {
|
2022-09-06 01:51:57 +00:00
|
|
|
color: ${theme.controlHoverFg};
|
2022-06-17 03:43:26 +00:00
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
const cssVideoIcon = styled(icon, `
|
2022-09-06 01:51:57 +00:00
|
|
|
background-color: ${theme.controlFg};
|
2022-06-17 03:43:26 +00:00
|
|
|
cursor: pointer;
|
|
|
|
margin: 0px 4px 3px 0;
|
|
|
|
|
|
|
|
.${cssVideoTourTextButton.className}:hover > & {
|
2022-09-06 01:51:57 +00:00
|
|
|
background-color: ${theme.controlHoverFg};
|
2022-06-17 03:43:26 +00:00
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
const cssCloseIcon = styled(icon, `
|
|
|
|
padding: 12px;
|
|
|
|
`);
|