2020-10-02 15:10:00 +00:00
|
|
|
import {GristLoadConfig} from 'app/common/gristUrls';
|
|
|
|
import {styled} from 'grainjs';
|
|
|
|
|
2023-05-05 01:09:51 +00:00
|
|
|
export type ProductFlavor = 'grist' | 'fieldlink';
|
2020-10-02 15:10:00 +00:00
|
|
|
|
|
|
|
export interface CustomTheme {
|
|
|
|
bodyClassName?: string;
|
|
|
|
wideLogo?: boolean; // Stretch the logo and hide the org name.
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getFlavor(org?: string): ProductFlavor {
|
|
|
|
// Using a URL parameter e.g. __themeOrg=fieldlink allows overriding the org used for custom
|
|
|
|
// theming, for testing.
|
|
|
|
const themeOrg = new URLSearchParams(window.location.search).get('__themeOrg');
|
|
|
|
if (themeOrg) { org = themeOrg; }
|
|
|
|
|
|
|
|
if (!org) {
|
|
|
|
const gristConfig: GristLoadConfig = (window as any).gristConfig;
|
|
|
|
org = gristConfig && gristConfig.org;
|
|
|
|
}
|
|
|
|
if (org === 'fieldlink') {
|
|
|
|
return 'fieldlink';
|
|
|
|
}
|
|
|
|
return 'grist';
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getTheme(flavor: ProductFlavor): CustomTheme {
|
|
|
|
switch (flavor) {
|
|
|
|
case 'fieldlink':
|
|
|
|
return {
|
|
|
|
wideLogo: true,
|
|
|
|
bodyClassName: cssFieldLinkBody.className,
|
|
|
|
};
|
|
|
|
default:
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const cssFieldLinkBody = styled('body', `
|
|
|
|
--icon-GristLogo: url("icons/logo-fieldlink.png");
|
|
|
|
--icon-GristWideLogo: url("icons/logo-fieldlink.png");
|
|
|
|
--grist-logo-bg: white;
|
|
|
|
`);
|