2020-10-02 15:10:00 +00:00
|
|
|
/**
|
|
|
|
* These styles are used in HomeLeftPanel, and in Tools for the document left panel.
|
|
|
|
* They work in a structure like this:
|
|
|
|
*
|
|
|
|
* import * as css from 'app/client/ui/LeftPanelStyles';
|
|
|
|
* css.cssLeftPanel(
|
|
|
|
* css.cssScrollPane(
|
|
|
|
* css.cssTools(
|
|
|
|
* css.cssSectionHeader(...),
|
|
|
|
* css.cssPageEntry(css.cssPageLink(cssPageIcon(...), css.cssLinkText(...))),
|
|
|
|
* css.cssPageEntry(css.cssPageLink(cssPageIcon(...), css.cssLinkText(...))),
|
|
|
|
* )
|
|
|
|
* )
|
|
|
|
* )
|
|
|
|
*/
|
|
|
|
import {beaconOpenMessage} from 'app/client/lib/helpScout';
|
2022-10-28 16:11:08 +00:00
|
|
|
import {makeT} from 'app/client/lib/localization';
|
2020-10-02 15:10:00 +00:00
|
|
|
import {AppModel} from 'app/client/models/AppModel';
|
2022-09-06 01:51:57 +00:00
|
|
|
import {testId, theme, vars} from 'app/client/ui2018/cssVars';
|
2020-10-02 15:10:00 +00:00
|
|
|
import {icon} from 'app/client/ui2018/icons';
|
2022-05-27 11:03:56 +00:00
|
|
|
import {commonUrls, shouldHideUiElement} from 'app/common/gristUrls';
|
2020-10-02 15:10:00 +00:00
|
|
|
import {dom, DomContents, Observable, styled} from 'grainjs';
|
|
|
|
|
2022-10-28 16:11:08 +00:00
|
|
|
const t = makeT('LeftPanelCommon');
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
/**
|
|
|
|
* Creates the "help tools", a button/link to open HelpScout beacon, and one to open the
|
|
|
|
* HelpCenter in a new tab.
|
|
|
|
*/
|
2022-06-17 03:43:26 +00:00
|
|
|
export function createHelpTools(appModel: AppModel): DomContents {
|
2022-05-27 11:03:56 +00:00
|
|
|
if (shouldHideUiElement("helpCenter")) {
|
|
|
|
return [];
|
|
|
|
}
|
2022-06-17 03:43:26 +00:00
|
|
|
return cssSplitPageEntry(
|
|
|
|
cssPageEntryMain(
|
|
|
|
cssPageLink(cssPageIcon('Help'),
|
2022-12-06 13:57:29 +00:00
|
|
|
cssLinkText(t("Help Center")),
|
2022-06-17 03:43:26 +00:00
|
|
|
dom.cls('tour-help-center'),
|
|
|
|
dom.on('click', (ev) => beaconOpenMessage({appModel})),
|
|
|
|
testId('left-feedback'),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
cssPageEntrySmall(
|
|
|
|
cssPageLink(cssPageIcon('FieldLink'),
|
|
|
|
{href: commonUrls.help, target: '_blank'},
|
2021-07-19 08:49:44 +00:00
|
|
|
),
|
2020-10-02 15:10:00 +00:00
|
|
|
),
|
2022-06-17 03:43:26 +00:00
|
|
|
);
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a basic left panel, used in error and billing pages. It only contains the help tools.
|
|
|
|
*/
|
|
|
|
export function leftPanelBasic(appModel: AppModel, panelOpen: Observable<boolean>) {
|
|
|
|
return cssLeftPanel(
|
|
|
|
cssScrollPane(
|
|
|
|
cssTools(
|
|
|
|
cssTools.cls('-collapsed', (use) => !use(panelOpen)),
|
2022-06-17 03:43:26 +00:00
|
|
|
cssSpacer(),
|
2020-10-02 15:10:00 +00:00
|
|
|
createHelpTools(appModel),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const cssLeftPanel = styled('div', `
|
|
|
|
flex: 1 1 0px;
|
|
|
|
font-size: ${vars.mediumFontSize};
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
`);
|
|
|
|
|
|
|
|
export const cssScrollPane = styled('div', `
|
|
|
|
flex: 1 1 0px;
|
|
|
|
overflow: hidden auto;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
`);
|
|
|
|
|
|
|
|
export const cssTools = styled('div', `
|
|
|
|
flex: none;
|
|
|
|
margin-top: auto;
|
|
|
|
padding: 16px 0 16px 0;
|
|
|
|
`);
|
|
|
|
|
|
|
|
export const cssSectionHeader = styled('div', `
|
|
|
|
margin: 24px 0 8px 24px;
|
2022-09-06 01:51:57 +00:00
|
|
|
color: ${theme.lightText};
|
2020-10-02 15:10:00 +00:00
|
|
|
text-transform: uppercase;
|
|
|
|
font-weight: 500;
|
|
|
|
font-size: ${vars.xsmallFontSize};
|
|
|
|
letter-spacing: 1px;
|
|
|
|
.${cssTools.className}-collapsed > & {
|
|
|
|
visibility: hidden;
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
export const cssPageEntry = styled('div', `
|
|
|
|
margin: 0px 16px 0px 0px;
|
|
|
|
border-radius: 0 3px 3px 0;
|
2022-09-06 01:51:57 +00:00
|
|
|
color: ${theme.text};
|
|
|
|
--icon-color: ${theme.lightText};
|
2020-10-02 15:10:00 +00:00
|
|
|
cursor: default;
|
|
|
|
|
|
|
|
&:hover, &.weasel-popup-open, &-renaming {
|
2022-09-06 01:51:57 +00:00
|
|
|
background-color: ${theme.pageHoverBg};
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
&-selected, &-selected:hover, &-selected.weasel-popup-open {
|
2022-09-06 01:51:57 +00:00
|
|
|
background-color: ${theme.activePageBg};
|
|
|
|
color: ${theme.activePageFg};
|
|
|
|
--icon-color: ${theme.activePageFg};
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
2021-03-01 16:51:30 +00:00
|
|
|
&-disabled, &-disabled:hover, &-disabled.weasel-popup-open {
|
|
|
|
background-color: initial;
|
2022-09-06 01:51:57 +00:00
|
|
|
color: ${theme.disabledPageFg};
|
|
|
|
--icon-color: ${theme.disabledPageFg};
|
2021-03-01 16:51:30 +00:00
|
|
|
}
|
2020-10-02 15:10:00 +00:00
|
|
|
.${cssTools.className}-collapsed > & {
|
|
|
|
margin-right: 0;
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
export const cssPageLink = styled('a', `
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
height: 32px;
|
|
|
|
line-height: 32px;
|
|
|
|
padding-left: 24px;
|
|
|
|
outline: none;
|
|
|
|
cursor: pointer;
|
|
|
|
&, &:hover, &:focus {
|
|
|
|
text-decoration: none;
|
|
|
|
outline: none;
|
|
|
|
color: inherit;
|
|
|
|
}
|
|
|
|
.${cssTools.className}-collapsed & {
|
|
|
|
padding-left: 16px;
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
export const cssLinkText = styled('span', `
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
.${cssTools.className}-collapsed & {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
export const cssPageIcon = styled(icon, `
|
|
|
|
flex: none;
|
|
|
|
margin-right: var(--page-icon-margin, 8px);
|
|
|
|
.${cssTools.className}-collapsed & {
|
|
|
|
margin-right: 0;
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
export const cssSpacer = styled('div', `
|
|
|
|
height: 18px;
|
|
|
|
`);
|
2021-12-07 05:37:37 +00:00
|
|
|
|
2022-01-04 00:20:58 +00:00
|
|
|
export const cssSplitPageEntry = styled('div', `
|
2021-12-07 05:37:37 +00:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
`);
|
|
|
|
|
2022-01-04 00:20:58 +00:00
|
|
|
export const cssPageEntryMain = styled(cssPageEntry, `
|
2021-12-07 05:37:37 +00:00
|
|
|
flex: auto;
|
|
|
|
margin: 0;
|
2022-01-04 00:20:58 +00:00
|
|
|
min-width: 0px;
|
2021-12-07 05:37:37 +00:00
|
|
|
`);
|
|
|
|
|
2022-01-04 00:20:58 +00:00
|
|
|
export const cssPageEntrySmall = styled(cssPageEntry, `
|
2021-12-07 05:37:37 +00:00
|
|
|
flex: none;
|
|
|
|
border-radius: 3px;
|
2022-09-06 01:51:57 +00:00
|
|
|
--icon-color: ${theme.controlFg};
|
2021-12-07 05:37:37 +00:00
|
|
|
& > .${cssPageLink.className} {
|
|
|
|
padding: 0 8px 0 16px;
|
|
|
|
}
|
|
|
|
&:hover {
|
2022-09-06 01:51:57 +00:00
|
|
|
--icon-color: ${theme.controlHoverFg};
|
2021-12-07 05:37:37 +00:00
|
|
|
}
|
|
|
|
.${cssTools.className}-collapsed & {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
`);
|