PromucFlow_constructor/app/client/src/constants/DefaultTheme.tsx

497 lines
12 KiB
TypeScript
Raw Normal View History

2019-09-05 17:47:50 +00:00
import * as styledComponents from "styled-components";
import { Colors, Color } from "./Colors";
2019-09-05 17:47:50 +00:00
import * as FontFamilies from "./Fonts";
import tinycolor from "tinycolor2";
import _ from "lodash";
2020-02-06 07:01:25 +00:00
import { Classes } from "@blueprintjs/core";
2020-02-25 11:33:07 +00:00
import { AlertIcons } from "icons/AlertIcons";
import { IconProps } from "constants/IconConstants";
import { JSXElementConstructor } from "react";
export type FontFamily = typeof FontFamilies[keyof typeof FontFamilies];
2019-02-10 15:06:57 +00:00
const {
default: styled,
css,
keyframes,
createGlobalStyle,
2019-09-05 17:47:50 +00:00
ThemeProvider,
} = styledComponents as styledComponents.ThemedStyledComponentsModule<Theme>;
2019-02-10 15:06:57 +00:00
2019-12-16 08:49:10 +00:00
export const IntentColors: Record<string, Color> = {
primary: Colors.GREEN,
success: Colors.PURPLE,
secondary: Colors.BLACK_PEARL,
2019-12-16 08:49:10 +00:00
danger: Colors.RED,
none: Colors.GEYSER_LIGHT,
warning: Colors.JAFFA,
};
export type Intent = typeof IntentColors[keyof typeof IntentColors];
2020-02-25 11:33:07 +00:00
export const IntentIcons: Record<Intent, JSXElementConstructor<IconProps>> = {
primary: AlertIcons.SUCCESS,
success: AlertIcons.SUCCESS,
secondary: AlertIcons.INFO,
danger: AlertIcons.ERROR,
none: AlertIcons.INFO,
warning: AlertIcons.WARNING,
};
2020-05-29 06:07:18 +00:00
export enum Skin {
LIGHT,
DARK,
}
2020-02-06 07:01:25 +00:00
export const BlueprintControlTransform = css`
&& {
.${Classes.CONTROL} {
& input:checked ~ .${Classes.CONTROL_INDICATOR} {
background: ${props => props.theme.colors.primary};
box-shadow: none;
border: 2px solid ${props => props.theme.colors.primary};
}
& input:not(:disabled):active ~ .${Classes.CONTROL_INDICATOR} {
box-shadow: none;
background: none;
border: 2px solid ${Colors.SLATE_GRAY};
}
& input:not(:disabled):active:checked ~ .${Classes.CONTROL_INDICATOR} {
box-shadow: none;
background: none;
border: 2px solid ${Colors.SLATE_GRAY};
}
&:hover .${Classes.CONTROL_INDICATOR} {
box-shadow: none;
background: none;
border: 2px solid ${Colors.SLATE_GRAY};
}
}
.${Classes.CONTROL_INDICATOR} {
box-shadow: none;
background: none;
border: 2px solid ${Colors.SLATE_GRAY};
&::before {
position: absolute;
left: -2px;
top: -2px;
}
}
}
`;
2020-02-11 09:56:21 +00:00
export const invisible = css`
&& > * {
opacity: 0.6;
}
`;
2020-02-06 07:01:25 +00:00
export const BlueprintCSSTransform = css`
&&&& {
.${Classes.BUTTON} {
box-shadow: none;
border-radius: 4px;
background: white;
2020-02-06 07:01:25 +00:00
border: 1px solid ${Colors.GEYSER};
}
.${Classes.INTENT_PRIMARY} {
background: ${IntentColors.primary};
}
.${Classes.INTENT_SUCCESS} {
background: ${IntentColors.success};
}
.${Classes.INTENT_DANGER} {
background: ${IntentColors.danger};
}
.${Classes.INTENT_WARNING} {
background: ${IntentColors.warning};
}
}
`;
export const darken = (color: Color, intensity: number) => {
return new tinycolor(color).darken(intensity).toString();
};
export const darkenHover = (color: Color) => {
return darken(color, 8);
};
export const darkenActive = (color: Color) => {
return darken(color, 16);
};
2020-02-06 07:01:25 +00:00
const getButtonHoverAndActiveStyles = (color: Color, filled = true) => {
return css`
background: ${color};
border-color: ${filled ? color : "auto"};
color: ${filled ? Colors.WHITE : "auto"};
&:hover {
background: ${darkenHover(color)};
border-color: ${darkenHover(color)};
box-shadow: none;
}
&:active {
background: ${darkenActive(color)};
border-color: ${darkenActive(color)};
box-shadow: none;
}
`;
};
export const BlueprintButtonIntentsCSS = css`
2020-02-06 07:01:25 +00:00
&&.${Classes.BUTTON} {
box-shadow: none;
display: flex;
border-width: 1px;
border-style: solid;
outline: none;
2020-01-28 08:21:22 +00:00
min-width: 50px;
color: ${IntentColors.secondary};
border-color: ${IntentColors.none};
& span.bp3-icon {
color: ${IntentColors.none};
}
2020-01-28 08:21:22 +00:00
& span {
font-weight: ${props => props.theme.fontWeights[3]};
}
background: ${Colors.WHITE};
}
2020-02-06 07:01:25 +00:00
&&&.${Classes.BUTTON}.${Classes.INTENT_PRIMARY}:not(.${Classes.MINIMAL}) {
background: ${IntentColors.primary};
2020-02-06 07:01:25 +00:00
${getButtonHoverAndActiveStyles(IntentColors.primary)}
}
2020-02-06 07:01:25 +00:00
&&&.${Classes.BUTTON}.bp3-intent-secondary:not(.${Classes.MINIMAL}) {
background: ${IntentColors.secondary};
2020-02-06 07:01:25 +00:00
${getButtonHoverAndActiveStyles(IntentColors.secondary)}
}
2020-02-06 07:01:25 +00:00
&&&.${Classes.BUTTON}.${Classes.INTENT_DANGER}:not(.${Classes.MINIMAL}) {
background: ${IntentColors.danger};
2020-02-06 07:01:25 +00:00
${getButtonHoverAndActiveStyles(IntentColors.danger)}
}
2020-02-06 07:01:25 +00:00
&&&.${Classes.BUTTON}.${Classes.INTENT_SUCCESS}:not(.${Classes.MINIMAL}) {
background: ${IntentColors.success};
2020-02-06 07:01:25 +00:00
${getButtonHoverAndActiveStyles(IntentColors.success)}
}
2020-02-06 07:01:25 +00:00
&&&.${Classes.BUTTON}.${Classes.INTENT_WARNING}:not(.${Classes.MINIMAL}) {
background: ${IntentColors.warning};
2020-02-06 07:01:25 +00:00
${getButtonHoverAndActiveStyles(IntentColors.warning)}
}
2020-02-06 07:01:25 +00:00
&&.${Classes.MINIMAL}.${Classes.BUTTON} {
border: none;
border-color: ${IntentColors.none};
& span.bp3-icon {
color: ${IntentColors.none};
}
2019-12-16 08:49:10 +00:00
}
2020-02-06 07:01:25 +00:00
&&&.${Classes.MINIMAL}.${Classes.INTENT_PRIMARY} {
2019-12-16 08:49:10 +00:00
color: ${IntentColors.primary};
border-color: ${IntentColors.primary};
2019-12-16 08:49:10 +00:00
}
2020-02-06 07:01:25 +00:00
&&&.${Classes.MINIMAL}.bp3-intent-secondary {
2019-12-16 08:49:10 +00:00
color: ${IntentColors.secondary};
border-color: ${IntentColors.secondary};
2019-12-16 08:49:10 +00:00
}
2020-02-06 07:01:25 +00:00
&&&.${Classes.MINIMAL}.${Classes.INTENT_DANGER} {
2019-12-16 08:49:10 +00:00
color: ${IntentColors.danger};
border-color: ${IntentColors.danger};
2019-12-16 08:49:10 +00:00
}
2020-02-06 07:01:25 +00:00
&&&.${Classes.MINIMAL}.${Classes.INTENT_WARNING} {
2019-12-16 08:49:10 +00:00
color: ${IntentColors.warning};
border-color: ${IntentColors.warning};
2019-12-16 08:49:10 +00:00
}
2020-02-06 07:01:25 +00:00
&&&.${Classes.MINIMAL}.${Classes.INTENT_SUCCESS} {
2019-12-16 08:49:10 +00:00
color: ${IntentColors.success};
border-color: ${IntentColors.success};
2019-12-16 08:49:10 +00:00
}
2020-02-25 11:33:07 +00:00
&&&&&&.${Classes.DISABLED} {
color: ${Colors.SLATE_GRAY};
background: ${Colors.MERCURY};
border-color: ${Colors.MERCURY};
}
2019-12-16 08:49:10 +00:00
`;
2019-11-21 10:52:49 +00:00
2020-02-06 07:01:25 +00:00
export const BlueprintInputTransform = css`
&& {
.${Classes.INPUT} {
border-radius: ${props => props.theme.radii[1]}px;
box-shadow: none;
border: ${props => getBorderCSSShorthand(props.theme.borders[2])};
&:focus {
border: ${props => getBorderCSSShorthand(props.theme.borders[2])};
box-shadow: none;
}
}
}
`;
export type ThemeBorder = {
thickness: number;
style: "dashed" | "solid";
color: Color;
};
type PropertyPaneTheme = {
width: number;
height: number;
dividerColor: Color;
};
2019-09-05 17:47:50 +00:00
export type Theme = {
radii: Array<number>;
fontSizes: Array<number>;
2019-10-21 15:12:45 +00:00
drawerWidth: string;
2019-09-05 17:47:50 +00:00
spaces: Array<number>;
fontWeights: Array<number>;
colors: Record<string, Color>;
lineHeights: Array<number>;
fonts: Array<FontFamily>;
borders: ThemeBorder[];
propertyPane: PropertyPaneTheme;
2019-10-18 08:16:26 +00:00
headerHeight: string;
sidebarWidth: string;
canvasPadding: string;
sideNav: {
minWidth: number;
maxWidth: number;
bgColor: Color;
fontColor: Color;
2019-11-01 05:28:56 +00:00
activeItemBGColor: Color;
navItemHeight: number;
};
card: {
minWidth: number;
minHeight: number;
2019-11-21 10:52:49 +00:00
titleHeight: number;
divider: ThemeBorder;
hoverBG: Color;
hoverBGOpacity: number;
};
2020-05-19 06:53:37 +00:00
dropdown: {
2020-05-29 06:07:18 +00:00
[Skin.LIGHT]: {
2020-05-19 06:53:37 +00:00
hoverBG: Color;
hoverText: Color;
inActiveBG: Color;
inActiveText: Color;
};
2020-05-29 06:07:18 +00:00
[Skin.DARK]: {
2020-05-19 06:53:37 +00:00
hoverBG: Color;
hoverText: Color;
inActiveBG: Color;
inActiveText: Color;
border: Color;
2020-05-19 06:53:37 +00:00
};
};
2019-12-16 08:49:10 +00:00
authCard: {
width: number;
borderRadius: number;
background: Color;
padding: number;
dividerSpacing: number;
shadow: string;
};
shadows: string[];
2019-11-07 11:17:53 +00:00
widgets: {
tableWidget: {
selectHighlightColor: Color;
};
};
pageContentWidth: number;
2020-02-18 10:41:52 +00:00
alert: Record<string, { color: Color }>;
2020-05-24 09:59:22 +00:00
lightningMenu: {
iconSize: number;
2020-05-29 06:07:18 +00:00
[Skin.DARK]: { color: Color };
[Skin.LIGHT]: { color: Color };
2020-05-24 09:59:22 +00:00
};
2019-09-05 17:47:50 +00:00
};
2019-02-10 15:06:57 +00:00
2019-10-08 06:19:10 +00:00
export const getColorWithOpacity = (color: Color, opacity: number) => {
color = color.slice(1);
const val = parseInt(color, 16);
const r = (val >> 16) & 255;
const g = (val >> 8) & 255;
const b = val & 255;
return `rgba(${r},${g},${b},${opacity})`;
};
export const getBorderCSSShorthand = (border?: ThemeBorder): string => {
const values: string[] = [];
_.forIn(border, (value, key) => {
values.push(key === "thickness" ? value + "px" : value);
});
return values.join(" ");
};
2020-01-28 08:21:22 +00:00
export const labelStyle = css`
font-weight: ${props => props.theme.fontWeights[3]};
`;
2019-09-05 17:47:50 +00:00
export const theme: Theme = {
radii: [0, 4, 8, 10, 20, 50],
fontSizes: [0, 10, 12, 14, 16, 18, 24, 28, 32, 48, 64],
2019-11-01 05:28:56 +00:00
spaces: [0, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 30, 36],
2019-09-05 17:47:50 +00:00
fontWeights: [0, 400, 500, 700],
propertyPane: {
2020-01-28 08:21:22 +00:00
width: 270,
height: 600,
dividerColor: Colors.MAKO,
},
2019-10-21 15:12:45 +00:00
drawerWidth: "80%",
2019-09-05 17:47:50 +00:00
colors: {
primary: Colors.GREEN,
2019-10-21 15:12:45 +00:00
primaryDarker: Colors.JUNGLE_GREEN,
primaryDarkest: Colors.JUNGLE_GREEN_DARKER,
secondary: Colors.GEYSER_LIGHT,
secondaryDarker: Colors.CONCRETE,
secondaryDarkest: Colors.MERCURY,
2019-09-05 17:47:50 +00:00
error: Colors.RED,
2019-10-21 15:12:45 +00:00
info: Colors.SLATE_GRAY,
2019-09-06 11:40:00 +00:00
hover: Colors.POLAR,
2020-02-24 12:58:16 +00:00
inputActiveBorder: Colors.HIT_GRAY,
2019-10-21 15:12:45 +00:00
inputInactiveBG: Colors.AQUA_HAZE,
2019-09-06 11:40:00 +00:00
textDefault: Colors.BLACK_PEARL,
textOnDarkBG: Colors.WHITE,
2019-09-06 11:40:00 +00:00
textAnchor: Colors.PURPLE,
border: Colors.GEYSER,
paneCard: Colors.SHARK,
paneInputBG: Colors.SHARK,
2019-09-06 11:40:00 +00:00
paneBG: Colors.OUTER_SPACE,
paneText: Colors.GRAY_CHATEAU,
2020-04-15 11:42:11 +00:00
paneTextBG: Colors.DEEP_SPACE,
2020-03-20 09:45:44 +00:00
paneTextUnderline: Colors.LIGHT_GREYISH_BLUE,
paneSectionLabel: Colors.CADET_BLUE,
2019-11-13 11:34:11 +00:00
navBG: Colors.SHARK,
2020-01-16 11:46:21 +00:00
grid: Colors.GEYSER_LIGHT,
containerBorder: Colors.FRENCH_PASS,
2019-10-18 08:16:26 +00:00
menuButtonBGInactive: Colors.JUNGLE_MIST,
menuIconColorInactive: Colors.OXFORD_BLUE,
2019-11-21 10:52:49 +00:00
bodyBG: Colors.ATHENS_GRAY,
builderBodyBG: Colors.WHITE,
widgetBorder: Colors.MINT_TULIP,
widgetSecondaryBorder: Colors.MERCURY,
2020-02-25 11:33:07 +00:00
messageBG: Colors.CONCRETE,
paneIcon: Colors.TROUT,
2020-05-28 18:10:26 +00:00
notification: Colors.JAFFA,
bindingTextDark: Colors.SOFT_ORANGE,
bindingText: Colors.PURE_ORANGE,
2019-09-05 17:47:50 +00:00
},
lineHeights: [0, 14, 18, 22, 24, 28, 36, 48, 64, 80],
fonts: [
FontFamilies.DMSans,
FontFamilies.AppsmithWidget,
FontFamilies.FiraCode,
],
borders: [
{
thickness: 1,
style: "dashed",
color: Colors.FRENCH_PASS,
},
{
thickness: 2,
style: "solid",
color: Colors.FRENCH_PASS,
},
{
thickness: 1,
style: "solid",
color: Colors.GEYSER_LIGHT,
},
2019-12-16 08:49:10 +00:00
{
thickness: 1,
style: "solid",
color: Colors.FRENCH_PASS,
},
2020-01-17 12:34:58 +00:00
{
thickness: 3,
style: "solid",
color: Colors.MYSTIC,
},
],
2020-05-05 06:46:54 +00:00
sidebarWidth: "320px",
2019-10-18 08:16:26 +00:00
headerHeight: "50px",
canvasPadding: "20px 0 200px 0",
sideNav: {
maxWidth: 220,
minWidth: 50,
bgColor: Colors.OXFORD_BLUE,
fontColor: Colors.WHITE,
2019-11-01 05:28:56 +00:00
activeItemBGColor: Colors.SHARK,
navItemHeight: 42,
},
card: {
2019-11-21 10:52:49 +00:00
minWidth: 282,
minHeight: 220,
titleHeight: 48,
divider: {
thickness: 1,
style: "solid",
color: Colors.GEYSER_LIGHT,
},
hoverBG: Colors.BLACK,
hoverBGOpacity: 0.5,
},
2020-05-19 06:53:37 +00:00
dropdown: {
2020-05-29 06:07:18 +00:00
[Skin.LIGHT]: {
2020-05-19 06:53:37 +00:00
hoverBG: Colors.GREEN,
hoverText: Colors.WHITE,
inActiveBG: Colors.WHITE,
inActiveText: Colors.BLACK_PEARL,
2020-05-19 06:53:37 +00:00
},
2020-05-29 06:07:18 +00:00
[Skin.DARK]: {
hoverBG: Colors.TROUT_DARK,
hoverText: Colors.WHITE,
inActiveBG: Colors.BLUE_CHARCOAL,
inActiveText: Colors.WHITE,
border: Colors.TROUT_DARK,
2020-05-19 06:53:37 +00:00
},
},
2019-12-16 08:49:10 +00:00
authCard: {
width: 612,
borderRadius: 16,
background: Colors.WHITE,
padding: 40,
dividerSpacing: 32,
shadow: "0px 4px 8px rgba(9, 30, 66, 0.25)",
},
2020-01-17 12:34:58 +00:00
shadows: [
"0px 2px 4px rgba(67, 70, 74, 0.14)",
`0px 2px 4px ${Colors.MYSTIC}`,
2020-04-15 11:42:11 +00:00
`inset -1px 0px 0px ${Colors.ATHENS_GRAY}, inset 1px 0px 0px ${Colors.ATHENS_GRAY}, inset 0px 4px 0px ${Colors.GREEN}`,
`inset -1px 0px 0px ${Colors.ATHENS_GRAY}, inset 1px 0px 0px ${Colors.ATHENS_GRAY}, inset 0px 1px 0px ${Colors.ATHENS_GRAY}`,
2020-01-17 12:34:58 +00:00
],
2019-11-07 11:17:53 +00:00
widgets: {
tableWidget: {
selectHighlightColor: Colors.GEYSER_LIGHT,
},
},
pageContentWidth: 1224,
2020-02-18 10:41:52 +00:00
alert: {
info: {
color: Colors.AZURE_RADIANCE,
},
success: {
color: Colors.OCEAN_GREEN,
},
error: {
color: Colors.RED,
},
warning: {
color: Colors.BUTTER_CUP,
},
},
2020-05-24 09:59:22 +00:00
lightningMenu: {
iconSize: 14,
2020-05-29 06:07:18 +00:00
[Skin.DARK]: {
2020-05-24 09:59:22 +00:00
color: Colors.WHITE,
},
2020-05-29 06:07:18 +00:00
[Skin.LIGHT]: {
2020-05-24 09:59:22 +00:00
color: Colors.HIT_GRAY,
},
},
2019-09-05 17:47:50 +00:00
};
2019-02-10 15:06:57 +00:00
2019-09-05 17:47:50 +00:00
export { css, createGlobalStyle, keyframes, ThemeProvider };
export default styled;