2023-09-09 18:50:32 +00:00
|
|
|
import {hooks} from 'app/client/Hooks';
|
2020-10-02 15:10:00 +00:00
|
|
|
import {loadUserManager} from 'app/client/lib/imports';
|
|
|
|
import {AppModel, reportError} from 'app/client/models/AppModel';
|
|
|
|
import {DocInfo, DocPageModel} from 'app/client/models/DocPageModel';
|
2023-09-06 18:35:46 +00:00
|
|
|
import {docUrl, getLoginOrSignupUrl, urlState} from 'app/client/models/gristUrlState';
|
2023-08-18 10:54:03 +00:00
|
|
|
import {downloadDocModal, makeCopy, replaceTrunkWithFork} from 'app/client/ui/MakeCopyMenu';
|
2021-07-21 08:46:03 +00:00
|
|
|
import {sendToDrive} from 'app/client/ui/sendToDrive';
|
2022-10-19 23:06:05 +00:00
|
|
|
import {hoverTooltip, withInfoTooltip} from 'app/client/ui/tooltips';
|
2020-10-02 15:10:00 +00:00
|
|
|
import {cssHoverCircle, cssTopBarBtn} from 'app/client/ui/TopBarCss';
|
|
|
|
import {primaryButton} from 'app/client/ui2018/buttons';
|
2022-09-06 01:51:57 +00:00
|
|
|
import {mediaXSmall, testId, theme} from 'app/client/ui2018/cssVars';
|
2020-10-02 15:10:00 +00:00
|
|
|
import {icon} from 'app/client/ui2018/icons';
|
2020-12-09 05:59:42 +00:00
|
|
|
import {menu, menuAnnotate, menuDivider, menuIcon, menuItem, menuItemLink, menuText} from 'app/client/ui2018/menus';
|
2023-05-20 23:58:41 +00:00
|
|
|
import {buildUrlId, isFeatureEnabled, parseUrlId} from 'app/common/gristUrls';
|
2020-10-02 15:10:00 +00:00
|
|
|
import * as roles from 'app/common/roles';
|
|
|
|
import {Document} from 'app/common/UserAPI';
|
|
|
|
import {dom, DomContents, styled} from 'grainjs';
|
2023-11-20 00:46:32 +00:00
|
|
|
import {cssMenuItem, MenuCreateFunc} from 'popweasel';
|
2022-10-28 16:11:08 +00:00
|
|
|
import {makeT} from 'app/client/lib/localization';
|
|
|
|
|
|
|
|
const t = makeT('ShareMenu');
|
2020-10-02 15:10:00 +00:00
|
|
|
|
|
|
|
function buildOriginalUrlId(urlId: string, isSnapshot: boolean): string {
|
|
|
|
const parts = parseUrlId(urlId);
|
|
|
|
return isSnapshot ? buildUrlId({...parts, snapshotId: undefined}) : parts.trunkId;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds the content of the export menu. The menu button and contents render differently for
|
|
|
|
* different modes (normal, pre-fork, fork, snapshot).
|
|
|
|
*/
|
|
|
|
export function buildShareMenuButton(pageModel: DocPageModel): DomContents {
|
|
|
|
// The menu needs pageModel.currentDoc to render the button. It further needs pageModel.gristDoc
|
|
|
|
// to render its contents, but we handle by merely skipping such content if gristDoc is not yet
|
|
|
|
// available (a user quick enough to open the menu in this state would have to re-open it).
|
|
|
|
return dom.maybe(pageModel.currentDoc, (doc) => {
|
2023-09-06 18:35:46 +00:00
|
|
|
const saveCopy = () => handleSaveCopy({pageModel, doc, modalTitle: t("Save Document")});
|
2023-04-11 05:56:26 +00:00
|
|
|
if (doc.isSnapshot) {
|
2020-10-02 15:10:00 +00:00
|
|
|
const backToCurrent = () => urlState().pushUrl({doc: buildOriginalUrlId(doc.id, true)});
|
2022-12-06 13:57:29 +00:00
|
|
|
return shareButton(t("Back to Current"), () => [
|
2020-10-02 15:10:00 +00:00
|
|
|
menuManageUsers(doc, pageModel),
|
2023-09-06 18:35:46 +00:00
|
|
|
menuSaveCopy({pageModel, doc, saveActionTitle: t("Save Copy")}),
|
|
|
|
menuOriginal(doc, pageModel, {isSnapshot: true}),
|
2020-10-02 15:10:00 +00:00
|
|
|
menuExports(doc, pageModel),
|
|
|
|
], {buttonAction: backToCurrent});
|
2023-03-22 13:48:50 +00:00
|
|
|
} else if (doc.isTutorialFork) {
|
2023-06-22 13:31:29 +00:00
|
|
|
return shareButton(t("Save Copy"), () => [
|
2023-09-06 18:35:46 +00:00
|
|
|
menuSaveCopy({pageModel, doc, saveActionTitle: t("Save Copy")}),
|
|
|
|
menuOriginal(doc, pageModel, {isTutorialFork: true}),
|
2023-06-22 13:31:29 +00:00
|
|
|
menuExports(doc, pageModel),
|
|
|
|
], {buttonAction: saveCopy});
|
2020-10-02 15:10:00 +00:00
|
|
|
} else if (doc.isPreFork || doc.isBareFork) {
|
|
|
|
// A new unsaved document, or a fiddle, or a public example.
|
2022-12-06 13:57:29 +00:00
|
|
|
const saveActionTitle = doc.isBareFork ? t("Save Document") : t("Save Copy");
|
2020-10-02 15:10:00 +00:00
|
|
|
return shareButton(saveActionTitle, () => [
|
|
|
|
menuManageUsers(doc, pageModel),
|
2023-09-06 18:35:46 +00:00
|
|
|
menuSaveCopy({pageModel, doc, saveActionTitle}),
|
2020-10-02 15:10:00 +00:00
|
|
|
menuExports(doc, pageModel),
|
|
|
|
], {buttonAction: saveCopy});
|
|
|
|
} else if (doc.isFork) {
|
|
|
|
// For forks, the main actions are "Replace Original" and "Save Copy". When "Replace
|
|
|
|
// Original" is unavailable (for samples, forks of public docs, etc), we'll consider "Save
|
|
|
|
// Copy" primary and keep it as an action button on top. Otherwise, show a tag without a
|
|
|
|
// default action; click opens the menu where the user can choose.
|
|
|
|
if (!roles.canEdit(doc.trunkAccess || null)) {
|
2022-12-06 13:57:29 +00:00
|
|
|
return shareButton(t("Save Copy"), () => [
|
2020-10-02 15:10:00 +00:00
|
|
|
menuManageUsers(doc, pageModel),
|
2023-09-06 18:35:46 +00:00
|
|
|
menuSaveCopy({pageModel, doc, saveActionTitle: t("Save Copy")}),
|
|
|
|
menuOriginal(doc, pageModel),
|
2020-10-02 15:10:00 +00:00
|
|
|
menuExports(doc, pageModel),
|
|
|
|
], {buttonAction: saveCopy});
|
|
|
|
} else {
|
2022-12-06 13:57:29 +00:00
|
|
|
return shareButton(t("Unsaved"), () => [
|
2020-10-02 15:10:00 +00:00
|
|
|
menuManageUsers(doc, pageModel),
|
2023-09-06 18:35:46 +00:00
|
|
|
menuSaveCopy({pageModel, doc, saveActionTitle: t("Save Copy")}),
|
|
|
|
menuOriginal(doc, pageModel),
|
2020-10-02 15:10:00 +00:00
|
|
|
menuExports(doc, pageModel),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return shareButton(null, () => [
|
|
|
|
menuManageUsers(doc, pageModel),
|
2023-09-06 18:35:46 +00:00
|
|
|
menuSaveCopy({pageModel, doc, saveActionTitle: t("Duplicate Document")}),
|
2020-10-02 15:10:00 +00:00
|
|
|
menuWorkOnCopy(pageModel),
|
|
|
|
menuExports(doc, pageModel),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the share button, possibly as a text+icon pair when buttonText is not null. The text
|
|
|
|
* portion can be an independent action button (when buttonAction is given), or simply a more
|
|
|
|
* visible extension of the icon that opens the menu.
|
|
|
|
*/
|
|
|
|
function shareButton(buttonText: string|null, menuCreateFunc: MenuCreateFunc,
|
|
|
|
options: {buttonAction?: () => void} = {},
|
|
|
|
) {
|
|
|
|
if (!buttonText) {
|
|
|
|
// Regular circular button that opens a menu.
|
|
|
|
return cssHoverCircle({ style: `margin: 5px;` },
|
2021-07-19 08:49:44 +00:00
|
|
|
cssTopBarBtn('Share', dom.cls('tour-share-icon')),
|
2020-10-02 15:10:00 +00:00
|
|
|
menu(menuCreateFunc, {placement: 'bottom-end'}),
|
2023-07-16 16:52:13 +00:00
|
|
|
hoverTooltip(t('Share'), {key: 'topBarBtnTooltip'}),
|
2020-10-02 15:10:00 +00:00
|
|
|
testId('tb-share'),
|
|
|
|
);
|
|
|
|
} else if (options.buttonAction) {
|
|
|
|
// Split button: the left text part calls `buttonAction`, and the circular icon opens menu.
|
|
|
|
return cssShareButton(
|
|
|
|
cssShareAction(buttonText,
|
|
|
|
dom.on('click', options.buttonAction),
|
|
|
|
testId('tb-share-action'),
|
|
|
|
),
|
|
|
|
cssShareCircle(
|
|
|
|
cssShareIcon('Share'),
|
|
|
|
menu(menuCreateFunc, {placement: 'bottom-end'}),
|
2023-07-16 16:52:13 +00:00
|
|
|
hoverTooltip(t('Share'), {key: 'topBarBtnTooltip'}),
|
2020-10-02 15:10:00 +00:00
|
|
|
testId('tb-share'),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
// Combined button: the left text part and circular icon open the menu as a single button.
|
|
|
|
return cssShareButton(
|
|
|
|
cssShareButton.cls('-combined'),
|
|
|
|
cssShareAction(buttonText),
|
|
|
|
cssShareCircle(
|
|
|
|
cssShareIcon('Share')
|
|
|
|
),
|
|
|
|
menu(menuCreateFunc, {placement: 'bottom-end'}),
|
2023-07-16 16:52:13 +00:00
|
|
|
hoverTooltip(t('Share'), {key: 'topBarBtnTooltip'}),
|
2020-10-02 15:10:00 +00:00
|
|
|
testId('tb-share'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-06 18:35:46 +00:00
|
|
|
async function handleSaveCopy(options: {
|
|
|
|
pageModel: DocPageModel,
|
|
|
|
doc: Document,
|
|
|
|
modalTitle: string,
|
|
|
|
}) {
|
|
|
|
const {pageModel} = options;
|
|
|
|
const {appModel} = pageModel;
|
|
|
|
if (!appModel.currentValidUser) {
|
|
|
|
pageModel.clearUnsavedChanges();
|
|
|
|
window.location.href = getLoginOrSignupUrl({srcDocId: urlState().state.get().doc});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return makeCopy(options);
|
|
|
|
}
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
// Renders "Manage Users" menu item.
|
|
|
|
function menuManageUsers(doc: DocInfo, pageModel: DocPageModel) {
|
|
|
|
return [
|
2022-04-12 19:31:41 +00:00
|
|
|
menuItem(() => manageUsers(doc, pageModel),
|
2022-12-06 13:57:29 +00:00
|
|
|
roles.canEditAccess(doc.access) ? t("Manage Users") : t("Access Details"),
|
2022-04-12 19:31:41 +00:00
|
|
|
dom.cls('disabled', doc.isFork),
|
2020-10-02 15:10:00 +00:00
|
|
|
testId('tb-share-option')
|
|
|
|
),
|
|
|
|
menuDivider(),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2023-06-22 13:31:29 +00:00
|
|
|
interface MenuOriginalOptions {
|
|
|
|
/** Defaults to false. */
|
|
|
|
isSnapshot?: boolean;
|
|
|
|
/** Defaults to false. */
|
|
|
|
isTutorialFork?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders "Return to Original" and "Replace Original" menu items.
|
|
|
|
*
|
|
|
|
* When used with snapshots, we say "Current Version" in place of the word "Original".
|
|
|
|
*
|
|
|
|
* When used with tutorial forks, the "Return to Original" and "Compare to Original" menu
|
|
|
|
* items are excluded. Note that it's still possible to return to the original by manually
|
|
|
|
* setting the open mode in the URL to "/m/default" - if the menu item were to ever be included
|
|
|
|
* again, it should likely be a shortcut to setting the open mode back to default.
|
|
|
|
*/
|
2023-09-06 18:35:46 +00:00
|
|
|
function menuOriginal(doc: Document, pageModel: DocPageModel, options: MenuOriginalOptions = {}) {
|
2023-06-22 13:31:29 +00:00
|
|
|
const {isSnapshot = false, isTutorialFork = false} = options;
|
2022-12-06 13:57:29 +00:00
|
|
|
const termToUse = isSnapshot ? t("Current Version") : t("Original");
|
2020-10-02 15:10:00 +00:00
|
|
|
const origUrlId = buildOriginalUrlId(doc.id, isSnapshot);
|
|
|
|
const originalUrl = urlState().makeUrl({doc: origUrlId});
|
2020-12-09 05:59:42 +00:00
|
|
|
|
|
|
|
// When comparing forks, show changes from the original to the fork. When comparing a snapshot,
|
|
|
|
// show changes from the snapshot to the original, which seems more natural. The per-snapshot
|
|
|
|
// comparison links in DocHistory use the same order.
|
|
|
|
const [leftDocId, rightDocId] = isSnapshot ? [doc.id, origUrlId] : [origUrlId, doc.id];
|
|
|
|
|
|
|
|
// Preserve the current state in order to stay on the selected page. TODO: Should auto-switch to
|
|
|
|
// first page when the requested page is not in the document.
|
|
|
|
const compareHref = dom.attr('href', (use) => urlState().makeUrl({
|
|
|
|
...use(urlState().state), doc: leftDocId, params: {compare: rightDocId}}));
|
|
|
|
|
|
|
|
const compareUrlId = urlState().state.get().params?.compare;
|
|
|
|
const comparingSnapshots: boolean = isSnapshot && Boolean(compareUrlId && parseUrlId(compareUrlId).snapshotId);
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
function replaceOriginal() {
|
2023-09-06 18:35:46 +00:00
|
|
|
replaceTrunkWithFork(doc, pageModel, origUrlId).catch(reportError);
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
return [
|
2023-06-22 13:31:29 +00:00
|
|
|
isTutorialFork ? null : cssMenuSplitLink({href: originalUrl},
|
2023-09-06 18:35:46 +00:00
|
|
|
cssMenuSplitLinkText(t("Return to {{termToUse}}", {termToUse})),
|
|
|
|
cssMenuIconLink({href: originalUrl, target: '_blank'},
|
2020-10-02 15:10:00 +00:00
|
|
|
cssMenuIcon('FieldLink'),
|
2023-09-06 18:35:46 +00:00
|
|
|
testId('open-original'),
|
|
|
|
),
|
|
|
|
dom.on('click', () => { pageModel.clearUnsavedChanges(); }),
|
|
|
|
testId('return-to-original'),
|
2020-10-02 15:10:00 +00:00
|
|
|
),
|
2022-12-06 13:57:29 +00:00
|
|
|
menuItem(replaceOriginal, t("Replace {{termToUse}}...", {termToUse}),
|
2020-12-09 05:59:42 +00:00
|
|
|
// Disable if original is not writable, and also when comparing snapshots (since it's
|
|
|
|
// unclear which of the versions to use).
|
|
|
|
dom.cls('disabled', !roles.canEdit(doc.trunkAccess || null) || comparingSnapshots),
|
2020-10-02 15:10:00 +00:00
|
|
|
testId('replace-original'),
|
|
|
|
),
|
2023-06-22 13:31:29 +00:00
|
|
|
isTutorialFork ? null : menuItemLink(compareHref, {target: '_blank'}, t("Compare to {{termToUse}}", {termToUse}),
|
2020-12-09 05:59:42 +00:00
|
|
|
menuAnnotate('Beta'),
|
2023-09-06 18:35:46 +00:00
|
|
|
dom.on('click', () => { pageModel.clearUnsavedChanges(); }),
|
2020-11-11 20:25:37 +00:00
|
|
|
testId('compare-original'),
|
|
|
|
),
|
2020-10-02 15:10:00 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Renders "Save Copy..." and "Copy as Template..." menu items. The name of the first action is
|
|
|
|
// specified in saveActionTitle.
|
2023-09-06 18:35:46 +00:00
|
|
|
function menuSaveCopy(options: {
|
|
|
|
pageModel: DocPageModel,
|
|
|
|
doc: Document,
|
|
|
|
saveActionTitle: string,
|
|
|
|
}) {
|
|
|
|
const {pageModel, doc, saveActionTitle} = options;
|
|
|
|
const saveCopy = () => handleSaveCopy({pageModel, doc, modalTitle: saveActionTitle});
|
2020-10-02 15:10:00 +00:00
|
|
|
return [
|
|
|
|
// TODO Disable these when user has no accessible destinations.
|
|
|
|
menuItem(saveCopy, `${saveActionTitle}...`, testId('save-copy')),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Renders "Work on a Copy" menu item.
|
|
|
|
function menuWorkOnCopy(pageModel: DocPageModel) {
|
|
|
|
const gristDoc = pageModel.gristDoc.get();
|
|
|
|
if (!gristDoc) { return null; }
|
|
|
|
|
|
|
|
const makeUnsavedCopy = async function() {
|
|
|
|
const {urlId} = await gristDoc.docComm.fork();
|
|
|
|
await urlState().pushUrl({doc: urlId});
|
|
|
|
};
|
|
|
|
|
|
|
|
return [
|
2022-12-06 13:57:29 +00:00
|
|
|
menuItem(makeUnsavedCopy, t("Work on a Copy"), testId('work-on-copy')),
|
2022-10-19 23:06:05 +00:00
|
|
|
menuText(
|
|
|
|
withInfoTooltip(
|
2022-12-06 13:57:29 +00:00
|
|
|
t("Edit without affecting the original"),
|
2024-02-13 17:49:00 +00:00
|
|
|
'workOnACopy',
|
2023-10-23 05:51:08 +00:00
|
|
|
{popupOptions: {attach: null}}
|
2022-10-19 23:06:05 +00:00
|
|
|
)
|
|
|
|
),
|
2020-10-02 15:10:00 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The part of the menu with "Download" and "Export CSV" items.
|
|
|
|
*/
|
|
|
|
function menuExports(doc: Document, pageModel: DocPageModel) {
|
|
|
|
const isElectron = (window as any).isRunningUnderElectron;
|
|
|
|
const gristDoc = pageModel.gristDoc.get();
|
|
|
|
if (!gristDoc) { return null; }
|
|
|
|
|
|
|
|
// Note: This line adds the 'show in folder' option for electron and a download option for hosted.
|
|
|
|
return [
|
|
|
|
menuDivider(),
|
|
|
|
(isElectron ?
|
|
|
|
menuItem(() => gristDoc.app.comm.showItemInFolder(doc.name),
|
2022-12-06 13:57:29 +00:00
|
|
|
t("Show in folder"), testId('tb-share-option')) :
|
2023-08-18 10:54:03 +00:00
|
|
|
menuItem(() => downloadDocModal(doc, pageModel),
|
|
|
|
menuIcon('Download'), t("Download..."), testId('tb-share-option'))
|
2020-10-02 15:10:00 +00:00
|
|
|
),
|
2023-09-09 18:50:32 +00:00
|
|
|
menuItemLink(hooks.maybeModifyLinkAttrs({ href: gristDoc.getCsvLink(), target: '_blank', download: ''}),
|
2022-12-06 13:57:29 +00:00
|
|
|
menuIcon('Download'), t("Export CSV"), testId('tb-share-option')),
|
2023-09-09 18:50:32 +00:00
|
|
|
menuItemLink(hooks.maybeModifyLinkAttrs({
|
2021-09-01 21:07:53 +00:00
|
|
|
href: pageModel.appModel.api.getDocAPI(doc.id).getDownloadXlsxUrl(),
|
|
|
|
target: '_blank', download: ''
|
2023-09-09 18:50:32 +00:00
|
|
|
}), menuIcon('Download'), t("Export XLSX"), testId('tb-share-option')),
|
2023-05-20 23:58:41 +00:00
|
|
|
(!isFeatureEnabled("sendToDrive") ? null : menuItem(() => sendToDrive(doc, pageModel),
|
2023-04-15 20:22:56 +00:00
|
|
|
menuIcon('Download'), t("Send to Google Drive"), testId('tb-share-option'))),
|
2020-10-02 15:10:00 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens the user-manager for the doc.
|
|
|
|
*/
|
|
|
|
async function manageUsers(doc: DocInfo, docPageModel: DocPageModel) {
|
|
|
|
const appModel: AppModel = docPageModel.appModel;
|
|
|
|
const api = appModel.api;
|
|
|
|
const user = appModel.currentValidUser;
|
|
|
|
(await loadUserManager()).showUserManagerModal(api, {
|
|
|
|
permissionData: api.getDocAccess(doc.id),
|
2022-05-19 04:51:48 +00:00
|
|
|
activeUser: user,
|
2020-10-02 15:10:00 +00:00
|
|
|
resourceType: 'document',
|
|
|
|
resourceId: doc.id,
|
2022-04-12 19:31:41 +00:00
|
|
|
resource: doc,
|
2020-10-02 15:10:00 +00:00
|
|
|
docPageModel,
|
2021-10-25 16:54:04 +00:00
|
|
|
appModel: docPageModel.appModel,
|
2024-01-24 04:12:46 +00:00
|
|
|
linkToCopy: makeShareDocUrl(doc),
|
2020-10-02 15:10:00 +00:00
|
|
|
// On save, re-fetch the document info, to toggle the "Public Access" icon if it changed.
|
2022-04-12 19:31:41 +00:00
|
|
|
// Skip if personal, since personal cannot affect "Public Access", and the only
|
|
|
|
// change possible is to remove the user (which would make refreshCurrentDoc fail)
|
|
|
|
onSave: async (personal) => !personal && docPageModel.refreshCurrentDoc(doc),
|
2021-10-25 16:54:04 +00:00
|
|
|
reload: () => api.getDocAccess(doc.id),
|
2020-10-02 15:10:00 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-01-24 04:12:46 +00:00
|
|
|
export function makeShareDocUrl(doc: Document) {
|
|
|
|
const url = new URL(urlState().makeUrl(docUrl(doc)));
|
|
|
|
url.searchParams.set('utm_id', 'share-doc');
|
|
|
|
return url.href;
|
|
|
|
}
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
const cssShareButton = styled('div', `
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
position: relative;
|
|
|
|
z-index: 0;
|
|
|
|
margin: 5px;
|
|
|
|
white-space: nowrap;
|
|
|
|
|
2022-09-06 01:51:57 +00:00
|
|
|
--share-btn-bg: ${theme.controlPrimaryBg};
|
2020-10-02 15:10:00 +00:00
|
|
|
&-combined:hover, &-combined.weasel-popup-open {
|
2022-09-06 01:51:57 +00:00
|
|
|
--share-btn-bg: ${theme.controlPrimaryHoverBg};
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
2021-02-28 05:27:34 +00:00
|
|
|
// Hide this on very small screens, since it takes up a lot of space and its action is also
|
|
|
|
// available in the associated menu.
|
2020-10-02 15:10:00 +00:00
|
|
|
const cssShareAction = styled(primaryButton, `
|
|
|
|
margin-right: -16px;
|
|
|
|
padding-right: 24px;
|
|
|
|
background-color: var(--share-btn-bg);
|
|
|
|
border-color: var(--share-btn-bg);
|
2021-02-28 05:27:34 +00:00
|
|
|
|
|
|
|
@media ${mediaXSmall} {
|
|
|
|
& {
|
|
|
|
display: none !important;
|
|
|
|
}
|
|
|
|
}
|
2020-10-02 15:10:00 +00:00
|
|
|
`);
|
|
|
|
|
|
|
|
const cssShareCircle = styled(cssHoverCircle, `
|
|
|
|
z-index: 1;
|
|
|
|
background-color: var(--share-btn-bg);
|
2022-09-06 01:51:57 +00:00
|
|
|
border: 1px solid ${theme.topHeaderBg};
|
2020-10-02 15:10:00 +00:00
|
|
|
&:hover, &.weasel-popup-open {
|
2022-09-06 01:51:57 +00:00
|
|
|
background-color: ${theme.controlPrimaryHoverBg};
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
const cssShareIcon = styled(cssTopBarBtn, `
|
2022-09-06 01:51:57 +00:00
|
|
|
background-color: ${theme.controlPrimaryFg};
|
2020-10-02 15:10:00 +00:00
|
|
|
height: 30px;
|
|
|
|
width: 30px;
|
|
|
|
`);
|
|
|
|
|
|
|
|
const cssMenuSplitLink = styled(menuItemLink, `
|
|
|
|
padding: 0;
|
|
|
|
align-items: stretch;
|
|
|
|
`);
|
|
|
|
|
|
|
|
const cssMenuSplitLinkText = styled('div', `
|
|
|
|
flex: auto;
|
|
|
|
padding: var(--weaseljs-menu-item-padding, 8px 24px);
|
|
|
|
&:not(:hover) {
|
2022-09-06 01:51:57 +00:00
|
|
|
background-color: ${theme.menuBg};
|
|
|
|
color: ${theme.menuItemFg};
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
const cssMenuIconLink = styled('a', `
|
|
|
|
display: block;
|
|
|
|
flex: none;
|
|
|
|
padding: 8px 24px;
|
2023-09-21 16:57:58 +00:00
|
|
|
--icon-color: ${theme.controlFg};
|
2020-10-02 15:10:00 +00:00
|
|
|
|
2023-11-20 00:46:32 +00:00
|
|
|
.${cssMenuItem.className}-sel > & {
|
|
|
|
--icon-color: ${theme.menuItemIconSelectedFg};
|
|
|
|
}
|
|
|
|
|
|
|
|
.${cssMenuItem.className}.disabled & {
|
|
|
|
--icon-color: ${theme.menuItemDisabledFg};
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
const cssMenuIcon = styled(icon, `
|
|
|
|
display: block;
|
|
|
|
`);
|