2018-03-09 22:59:12 +02:00
|
|
|
const Setting = require('lib/models/Setting.js');
|
2019-10-30 11:55:45 +02:00
|
|
|
const nordStyle = require('./gui/style/theme/nord');
|
2017-11-06 22:54:58 +02:00
|
|
|
|
2018-11-08 00:37:13 +02:00
|
|
|
// globalStyle should be used for properties that do not change across themes
|
|
|
|
// i.e. should not be used for colors
|
2017-11-06 22:54:58 +02:00
|
|
|
const globalStyle = {
|
2019-01-10 20:34:58 +02:00
|
|
|
fontSize: 12,
|
2018-03-09 22:59:12 +02:00
|
|
|
fontFamily: 'sans-serif',
|
2017-11-06 22:54:58 +02:00
|
|
|
margin: 15, // No text and no interactive component should be within this margin
|
|
|
|
itemMarginTop: 10,
|
|
|
|
itemMarginBottom: 10,
|
|
|
|
fontSizeSmaller: 14,
|
|
|
|
disabledOpacity: 0.3,
|
2017-11-08 19:51:55 +02:00
|
|
|
buttonMinWidth: 50,
|
|
|
|
buttonMinHeight: 30,
|
2019-01-10 20:34:58 +02:00
|
|
|
editorFontSize: 12,
|
|
|
|
textAreaLineHeight: 17,
|
2017-11-06 22:54:58 +02:00
|
|
|
|
2017-11-09 00:23:26 +02:00
|
|
|
headerHeight: 35,
|
|
|
|
headerButtonHPadding: 6,
|
|
|
|
|
2017-11-30 01:03:10 +02:00
|
|
|
toolbarHeight: 35,
|
2018-11-08 00:16:05 +02:00
|
|
|
tagItemPadding: 3,
|
2017-11-06 22:54:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
globalStyle.marginRight = globalStyle.margin;
|
|
|
|
globalStyle.marginLeft = globalStyle.margin;
|
|
|
|
globalStyle.marginTop = globalStyle.margin;
|
|
|
|
globalStyle.marginBottom = globalStyle.margin;
|
2019-09-19 23:51:18 +02:00
|
|
|
globalStyle.htmlMarginLeft = `${((globalStyle.marginLeft / 10) * 0.6).toFixed(2)}em`;
|
2017-11-06 22:54:58 +02:00
|
|
|
|
|
|
|
globalStyle.icon = {
|
|
|
|
fontSize: 30,
|
|
|
|
};
|
|
|
|
|
|
|
|
globalStyle.lineInput = {
|
2018-03-26 19:33:55 +02:00
|
|
|
fontFamily: globalStyle.fontFamily,
|
2019-05-06 22:35:29 +02:00
|
|
|
maxHeight: 22,
|
|
|
|
height: 22,
|
|
|
|
paddingLeft: 5,
|
2017-11-06 22:54:58 +02:00
|
|
|
};
|
|
|
|
|
2019-01-28 01:15:56 +02:00
|
|
|
globalStyle.headerStyle = {
|
|
|
|
fontFamily: globalStyle.fontFamily,
|
|
|
|
};
|
2018-11-08 00:37:13 +02:00
|
|
|
|
|
|
|
globalStyle.inputStyle = {
|
|
|
|
border: '1px solid',
|
2019-04-01 21:43:13 +02:00
|
|
|
height: 24,
|
2019-05-06 22:35:29 +02:00
|
|
|
maxHeight: 24,
|
2019-04-01 21:43:13 +02:00
|
|
|
paddingLeft: 5,
|
|
|
|
paddingRight: 5,
|
|
|
|
boxSizing: 'border-box',
|
2018-11-08 00:37:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
globalStyle.containerStyle = {
|
|
|
|
overflow: 'auto',
|
|
|
|
overflowY: 'auto',
|
|
|
|
};
|
|
|
|
|
|
|
|
globalStyle.buttonStyle = {
|
2019-05-06 22:35:29 +02:00
|
|
|
// marginRight: 10,
|
2018-11-08 00:37:13 +02:00
|
|
|
border: '1px solid',
|
2019-05-06 22:35:29 +02:00
|
|
|
minHeight: 26,
|
2019-01-28 01:44:16 +02:00
|
|
|
minWidth: 80,
|
2020-03-13 19:42:50 +02:00
|
|
|
// maxWidth: 220,
|
2019-01-29 20:02:34 +02:00
|
|
|
paddingLeft: 12,
|
|
|
|
paddingRight: 12,
|
2019-09-11 01:53:01 +02:00
|
|
|
paddingTop: 6,
|
|
|
|
paddingBottom: 6,
|
2019-05-06 22:35:29 +02:00
|
|
|
boxShadow: '0px 1px 1px rgba(0,0,0,0.3)',
|
2019-09-11 01:53:01 +02:00
|
|
|
fontSize: globalStyle.fontSize,
|
|
|
|
borderRadius: 4,
|
2018-11-08 00:37:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const lightStyle = {
|
2019-07-30 09:35:42 +02:00
|
|
|
backgroundColor: '#ffffff',
|
2018-11-08 00:37:13 +02:00
|
|
|
backgroundColorTransparent: 'rgba(255,255,255,0.9)',
|
2019-07-30 09:35:42 +02:00
|
|
|
oddBackgroundColor: '#dddddd',
|
|
|
|
color: '#222222', // For regular text
|
|
|
|
colorError: 'red',
|
|
|
|
colorWarn: '#9A5B00',
|
|
|
|
colorFaded: '#777777', // For less important text
|
|
|
|
colorBright: '#000000', // For important text
|
|
|
|
dividerColor: '#dddddd',
|
2018-11-08 00:37:13 +02:00
|
|
|
selectedColor: '#e5e5e5',
|
|
|
|
urlColor: '#155BDA',
|
|
|
|
|
2019-07-30 09:35:42 +02:00
|
|
|
backgroundColor2: '#162B3D',
|
2019-06-11 00:44:51 +02:00
|
|
|
depthColor: 'rgb(100, 182, 253, OPACITY)',
|
2019-07-30 09:35:42 +02:00
|
|
|
color2: '#f5f5f5',
|
|
|
|
selectedColor2: '#0269C2',
|
|
|
|
colorError2: '#ff6c6c',
|
2018-11-08 00:37:13 +02:00
|
|
|
|
2019-07-30 09:35:42 +02:00
|
|
|
raisedBackgroundColor: '#e5e5e5',
|
|
|
|
raisedColor: '#222222',
|
2018-11-08 00:37:13 +02:00
|
|
|
|
2019-07-30 09:35:42 +02:00
|
|
|
warningBackgroundColor: '#FFD08D',
|
2018-11-08 00:37:13 +02:00
|
|
|
|
2019-09-30 00:11:36 +02:00
|
|
|
htmlColor: '#222222',
|
2018-11-08 00:37:13 +02:00
|
|
|
htmlBackgroundColor: 'white',
|
2019-02-06 01:55:09 +02:00
|
|
|
htmlDividerColor: 'rgb(230,230,230)',
|
|
|
|
htmlLinkColor: 'rgb(80,130,190)',
|
2019-02-07 10:01:38 +02:00
|
|
|
htmlTableBackgroundColor: 'rgb(247, 247, 247)',
|
2019-02-06 01:55:09 +02:00
|
|
|
htmlCodeBackgroundColor: 'rgb(243, 243, 243)',
|
|
|
|
htmlCodeBorderColor: 'rgb(220, 220, 220)',
|
|
|
|
htmlCodeColor: 'rgb(0,0,0)',
|
2018-11-08 00:37:13 +02:00
|
|
|
|
2019-07-30 09:35:42 +02:00
|
|
|
editorTheme: 'chrome',
|
|
|
|
codeThemeCss: 'atom-one-light.css',
|
2018-11-08 00:37:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const darkStyle = {
|
|
|
|
backgroundColor: '#1D2024',
|
|
|
|
backgroundColorTransparent: 'rgba(255,255,255,0.9)',
|
2019-07-30 09:35:42 +02:00
|
|
|
oddBackgroundColor: '#dddddd',
|
2018-11-08 00:37:13 +02:00
|
|
|
color: '#dddddd',
|
2019-07-30 09:35:42 +02:00
|
|
|
colorError: 'red',
|
|
|
|
colorWarn: '#9A5B00',
|
|
|
|
colorFaded: '#777777', // For less important text
|
|
|
|
colorBright: '#ffffff', // For important text
|
2018-11-08 00:37:13 +02:00
|
|
|
dividerColor: '#555555',
|
|
|
|
selectedColor: '#333333',
|
|
|
|
urlColor: '#4E87EE',
|
|
|
|
|
2019-07-30 09:35:42 +02:00
|
|
|
backgroundColor2: '#181A1D',
|
2019-06-11 00:44:51 +02:00
|
|
|
depthColor: 'rgb(200, 200, 200, OPACITY)',
|
2019-07-30 09:35:42 +02:00
|
|
|
color2: '#ffffff',
|
|
|
|
selectedColor2: '#013F74',
|
|
|
|
colorError2: '#ff6c6c',
|
2018-11-08 00:37:13 +02:00
|
|
|
|
2019-07-30 09:35:42 +02:00
|
|
|
raisedBackgroundColor: '#474747',
|
|
|
|
raisedColor: '#ffffff',
|
2018-11-08 00:37:13 +02:00
|
|
|
|
2019-07-30 09:35:42 +02:00
|
|
|
warningBackgroundColor: '#CC6600',
|
2018-11-08 00:37:13 +02:00
|
|
|
|
2019-02-07 01:52:29 +02:00
|
|
|
htmlColor: 'rgb(220,220,220)',
|
2018-11-08 00:37:13 +02:00
|
|
|
htmlBackgroundColor: 'rgb(29,32,36)',
|
2019-02-07 01:52:29 +02:00
|
|
|
htmlDividerColor: '#3D444E',
|
|
|
|
htmlCodeColor: '#ffffff',
|
2018-11-08 00:37:13 +02:00
|
|
|
htmlLinkColor: 'rgb(166,166,255)',
|
2019-02-07 10:01:38 +02:00
|
|
|
htmlTableBackgroundColor: 'rgb(40, 41, 42)',
|
2019-02-06 01:55:09 +02:00
|
|
|
htmlCodeBackgroundColor: 'rgb(47, 48, 49)',
|
2018-11-08 00:37:13 +02:00
|
|
|
htmlCodeBorderColor: 'rgb(70, 70, 70)',
|
|
|
|
|
|
|
|
editorTheme: 'twilight',
|
2019-07-30 09:35:42 +02:00
|
|
|
codeThemeCss: 'atom-one-dark-reasonable.css',
|
2019-09-11 01:53:01 +02:00
|
|
|
|
|
|
|
highlightedColor: '#0066C7',
|
2018-11-08 00:37:13 +02:00
|
|
|
};
|
|
|
|
|
2019-07-21 18:27:42 +02:00
|
|
|
// Solarized Styles
|
|
|
|
const solarizedLightStyle = {
|
2019-07-30 09:35:42 +02:00
|
|
|
backgroundColor: '#fdf6e3',
|
|
|
|
backgroundColorTransparent: 'rgba(253, 246, 227, 0.9)',
|
|
|
|
oddBackgroundColor: '#eee8d5',
|
|
|
|
color: '#657b83', // For regular text
|
|
|
|
colorError: '#dc322f',
|
|
|
|
colorWarn: '#cb4b16',
|
|
|
|
colorFaded: '#839496', // For less important text;
|
|
|
|
colorBright: '#073642', // For important text;
|
|
|
|
dividerColor: '#eee8d5',
|
|
|
|
selectedColor: '#eee8d5',
|
|
|
|
urlColor: '#268bd2',
|
|
|
|
|
|
|
|
backgroundColor2: '#002b36',
|
2019-07-29 12:08:49 +02:00
|
|
|
depthColor: 'rgb(100, 182, 253, OPACITY)',
|
2019-07-30 09:35:42 +02:00
|
|
|
color2: '#eee8d5',
|
|
|
|
selectedColor2: '#6c71c4',
|
|
|
|
colorError2: '#cb4b16',
|
|
|
|
|
|
|
|
raisedBackgroundColor: '#eee8d5',
|
|
|
|
raisedColor: '#073642',
|
|
|
|
|
2019-11-28 19:09:52 +02:00
|
|
|
warningBackgroundColor: '#b5890055',
|
2019-07-30 09:35:42 +02:00
|
|
|
|
|
|
|
htmlColor: '#657b83',
|
|
|
|
htmlBackgroundColor: '#fdf6e3',
|
|
|
|
htmlDividerColor: '#eee8d5',
|
|
|
|
htmlLinkColor: '#268bd2',
|
|
|
|
htmlTableBackgroundColor: '#fdf6e3',
|
|
|
|
htmlCodeBackgroundColor: '#fdf6e3',
|
|
|
|
htmlCodeBorderColor: '#eee8d5',
|
|
|
|
htmlCodeColor: '#002b36',
|
|
|
|
|
|
|
|
editorTheme: 'solarized_light',
|
|
|
|
codeThemeCss: 'atom-one-light.css',
|
2019-07-21 18:27:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const solarizedDarkStyle = {
|
2019-07-30 09:35:42 +02:00
|
|
|
backgroundColor: '#002b36',
|
|
|
|
backgroundColorTransparent: 'rgba(0, 43, 54, 0.9)',
|
|
|
|
oddBackgroundColor: '#073642',
|
|
|
|
color: '#93a1a1', // For regular text
|
|
|
|
colorError: '#dc322f',
|
|
|
|
colorWarn: '#cb4b16',
|
|
|
|
colorFaded: '#657b83', // For less important text;
|
|
|
|
colorBright: '#eee8d5', // For important text;
|
|
|
|
dividerColor: '#586e75',
|
|
|
|
selectedColor: '#073642',
|
|
|
|
urlColor: '#268bd2',
|
|
|
|
|
|
|
|
backgroundColor2: '#073642',
|
2019-07-29 12:08:49 +02:00
|
|
|
depthColor: 'rgb(200, 200, 200, OPACITY)',
|
2019-07-30 09:35:42 +02:00
|
|
|
color2: '#eee8d5',
|
|
|
|
selectedColor2: '#6c71c4',
|
|
|
|
colorError2: '#cb4b16',
|
2019-07-21 18:27:42 +02:00
|
|
|
|
2019-07-30 09:35:42 +02:00
|
|
|
raisedBackgroundColor: '#073642',
|
|
|
|
raisedColor: '#839496',
|
2019-07-21 18:27:42 +02:00
|
|
|
|
2019-11-28 19:09:52 +02:00
|
|
|
warningBackgroundColor: '#b5890055',
|
2019-07-21 18:27:42 +02:00
|
|
|
|
2019-07-30 09:35:42 +02:00
|
|
|
htmlColor: '#93a1a1',
|
|
|
|
htmlBackgroundColor: '#002b36',
|
|
|
|
htmlDividerColor: '#073642',
|
|
|
|
htmlLinkColor: '#268bd2',
|
|
|
|
htmlTableBackgroundColor: '#002b36',
|
|
|
|
htmlCodeBackgroundColor: '#002b36',
|
2020-03-01 23:33:57 +02:00
|
|
|
htmlCodeBorderColor: '#696969',
|
2019-07-30 09:35:42 +02:00
|
|
|
htmlCodeColor: '#fdf6e3',
|
2019-07-21 18:27:42 +02:00
|
|
|
|
|
|
|
editorTheme: 'solarized_dark',
|
2019-07-30 09:35:42 +02:00
|
|
|
codeThemeCss: 'atom-one-dark-reasonable.css',
|
2019-07-21 18:27:42 +02:00
|
|
|
};
|
|
|
|
|
2019-10-01 13:23:32 +02:00
|
|
|
const draculaStyle = {
|
|
|
|
backgroundColor: '#282a36',
|
|
|
|
backgroundColorTransparent: 'rgba(40, 42, 54, 0.9)',
|
|
|
|
oddBackgroundColor: '#282a36',
|
|
|
|
color: '#f8f8f2', // For regular text
|
|
|
|
colorError: '#ff5555',
|
|
|
|
colorWarn: '#ffb86c',
|
|
|
|
colorFaded: '#6272a4', // For less important text;
|
|
|
|
colorBright: '#50fa7b', // For important text;
|
|
|
|
dividerColor: '#bd93f9',
|
|
|
|
selectedColor: '#44475a',
|
|
|
|
urlColor: '#8be9fd',
|
|
|
|
|
|
|
|
backgroundColor2: '#21222C',
|
|
|
|
depthColor: 'rgb(200, 200, 200, OPACITY)',
|
|
|
|
color2: '#bd93f9',
|
|
|
|
selectedColor2: '#44475a',
|
|
|
|
colorError2: '#ff5555',
|
|
|
|
|
|
|
|
raisedBackgroundColor: '#44475a',
|
|
|
|
raisedColor: '#bd93f9',
|
|
|
|
|
|
|
|
warningBackgroundColor: '#ffb86c',
|
|
|
|
|
|
|
|
htmlColor: '#f8f8f2',
|
|
|
|
htmlBackgroundColor: '#282a36',
|
|
|
|
htmlDividerColor: '#f8f8f2',
|
|
|
|
htmlLinkColor: '#8be9fd',
|
|
|
|
htmlTableBackgroundColor: '#6272a4',
|
|
|
|
htmlCodeBackgroundColor: '#44475a',
|
|
|
|
htmlCodeBorderColor: '#f8f8f2',
|
|
|
|
htmlCodeColor: '#50fa7b',
|
|
|
|
|
|
|
|
editorTheme: 'dracula',
|
|
|
|
codeThemeCss: 'atom-one-dark-reasonable.css',
|
|
|
|
};
|
|
|
|
|
2018-11-08 00:47:34 +02:00
|
|
|
function addExtraStyles(style) {
|
|
|
|
style.tagStyle = {
|
|
|
|
fontSize: style.fontSize,
|
|
|
|
fontFamily: style.fontFamily,
|
|
|
|
marginTop: style.itemMarginTop * 0.4,
|
|
|
|
marginBottom: style.itemMarginBottom * 0.4,
|
|
|
|
marginRight: style.margin * 0.3,
|
|
|
|
paddingTop: style.tagItemPadding,
|
|
|
|
paddingBottom: style.tagItemPadding,
|
|
|
|
paddingRight: style.tagItemPadding * 2,
|
|
|
|
paddingLeft: style.tagItemPadding * 2,
|
|
|
|
backgroundColor: style.raisedBackgroundColor,
|
|
|
|
color: style.raisedColor,
|
|
|
|
};
|
|
|
|
|
2019-01-10 20:34:58 +02:00
|
|
|
style.toolbarStyle = {
|
|
|
|
height: style.toolbarHeight,
|
2019-03-15 23:57:58 +02:00
|
|
|
// minWidth: style.toolbarHeight,
|
2019-01-10 20:34:58 +02:00
|
|
|
display: 'flex',
|
|
|
|
alignItems: 'center',
|
|
|
|
paddingLeft: style.headerButtonHPadding,
|
|
|
|
paddingRight: style.headerButtonHPadding,
|
|
|
|
textDecoration: 'none',
|
|
|
|
fontFamily: style.fontFamily,
|
|
|
|
fontSize: style.fontSize,
|
|
|
|
boxSizing: 'border-box',
|
|
|
|
cursor: 'default',
|
|
|
|
justifyContent: 'center',
|
|
|
|
color: style.color,
|
2019-03-15 23:57:58 +02:00
|
|
|
whiteSpace: 'nowrap',
|
2019-01-10 20:34:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
style.textStyle = {
|
|
|
|
fontFamily: globalStyle.fontFamily,
|
|
|
|
fontSize: style.fontSize,
|
|
|
|
lineHeight: '1.6em',
|
2019-07-30 09:35:42 +02:00
|
|
|
color: style.color,
|
2019-01-10 20:34:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
style.textStyle2 = Object.assign({}, style.textStyle,
|
2019-07-30 09:35:42 +02:00
|
|
|
{ color: style.color2 }
|
2019-01-10 20:34:58 +02:00
|
|
|
);
|
|
|
|
|
2020-04-02 19:16:11 +02:00
|
|
|
style.textStyleMinor = Object.assign({}, style.textStyle,
|
|
|
|
{
|
|
|
|
color: style.colorFaded,
|
|
|
|
fontSize: style.fontSize * 0.8,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2019-01-10 20:34:58 +02:00
|
|
|
style.urlStyle = Object.assign({}, style.textStyle,
|
|
|
|
{
|
|
|
|
textDecoration: 'underline',
|
2019-07-30 09:35:42 +02:00
|
|
|
color: style.urlColor,
|
2019-01-10 20:34:58 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
style.h1Style = Object.assign({},
|
|
|
|
style.textStyle,
|
|
|
|
{
|
|
|
|
color: style.color,
|
|
|
|
fontSize: style.textStyle.fontSize * 1.5,
|
2019-07-30 09:35:42 +02:00
|
|
|
fontWeight: 'bold',
|
2019-01-10 20:34:58 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
style.h2Style = Object.assign({},
|
|
|
|
style.textStyle,
|
|
|
|
{
|
|
|
|
color: style.color,
|
|
|
|
fontSize: style.textStyle.fontSize * 1.3,
|
2019-07-30 09:35:42 +02:00
|
|
|
fontWeight: 'bold',
|
2019-01-10 20:34:58 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2019-04-01 21:43:13 +02:00
|
|
|
style.dialogModalLayer = {
|
|
|
|
zIndex: 9999,
|
|
|
|
display: 'flex',
|
|
|
|
position: 'absolute',
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
|
|
|
width: '100%',
|
|
|
|
height: '100%',
|
|
|
|
backgroundColor: 'rgba(0,0,0,0.6)',
|
|
|
|
alignItems: 'flex-start',
|
|
|
|
justifyContent: 'center',
|
|
|
|
};
|
|
|
|
|
2020-02-25 11:43:31 +02:00
|
|
|
style.controlBox = {
|
|
|
|
marginBottom: '1em',
|
|
|
|
color: 'black', // This will apply for the calendar
|
|
|
|
display: 'flex',
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center',
|
|
|
|
};
|
|
|
|
|
|
|
|
style.controlBoxLabel = {
|
|
|
|
marginRight: '1em',
|
|
|
|
width: '10em',
|
|
|
|
display: 'inline-block',
|
|
|
|
fontWeight: 'bold',
|
|
|
|
};
|
|
|
|
|
|
|
|
style.controlBoxValue = {
|
|
|
|
display: 'inline-block',
|
|
|
|
};
|
|
|
|
|
2019-04-01 21:43:13 +02:00
|
|
|
style.dialogBox = {
|
|
|
|
backgroundColor: style.backgroundColor,
|
|
|
|
padding: 16,
|
|
|
|
boxShadow: '6px 6px 20px rgba(0,0,0,0.5)',
|
|
|
|
marginTop: 20,
|
2019-07-30 09:35:42 +02:00
|
|
|
};
|
2019-04-01 21:43:13 +02:00
|
|
|
|
2019-07-21 17:49:53 +02:00
|
|
|
style.buttonIconStyle = {
|
|
|
|
color: style.color,
|
|
|
|
marginRight: 6,
|
2019-07-30 09:35:42 +02:00
|
|
|
};
|
2019-07-21 17:49:53 +02:00
|
|
|
|
2019-04-01 21:43:13 +02:00
|
|
|
style.dialogTitle = Object.assign({}, style.h1Style, { marginBottom: '1.2em' });
|
|
|
|
|
2019-05-06 22:35:29 +02:00
|
|
|
style.dropdownList = Object.assign({}, style.inputStyle);
|
|
|
|
|
2020-04-03 20:12:14 +02:00
|
|
|
style.colorHover = style.color;
|
|
|
|
style.backgroundHover = `${style.selectedColor2}44`;
|
|
|
|
|
2019-09-11 01:53:01 +02:00
|
|
|
// In general the highlighted color, used to highlight text or icons, should be the same as selectedColor2
|
|
|
|
// but some times, depending on the theme, it might be too dark or too light, so it can be
|
|
|
|
// specified directly by the theme too.
|
|
|
|
if (!style.highlightedColor) style.highlightedColor = style.selectedColor2;
|
|
|
|
|
2018-11-08 00:47:34 +02:00
|
|
|
return style;
|
|
|
|
}
|
2018-11-08 00:16:05 +02:00
|
|
|
|
2020-03-14 01:46:14 +02:00
|
|
|
const themeCache_ = {};
|
2017-11-06 22:54:58 +02:00
|
|
|
|
|
|
|
function themeStyle(theme) {
|
2018-03-09 22:59:12 +02:00
|
|
|
if (!theme) throw new Error('Theme must be specified');
|
2019-01-10 20:34:58 +02:00
|
|
|
|
2020-03-14 01:46:14 +02:00
|
|
|
const zoomRatio = 1; // Setting.value('style.zoom') / 100;
|
|
|
|
const editorFontSize = Setting.value('style.editor.fontSize');
|
2019-01-10 20:34:58 +02:00
|
|
|
|
|
|
|
const cacheKey = [theme, zoomRatio, editorFontSize].join('-');
|
|
|
|
if (themeCache_[cacheKey]) return themeCache_[cacheKey];
|
|
|
|
|
2019-06-06 00:11:18 +02:00
|
|
|
// Font size are not theme specific, but they must be referenced
|
|
|
|
// and computed here to allow them to respond to settings changes
|
|
|
|
// without the need to restart
|
2020-03-14 01:46:14 +02:00
|
|
|
const fontSizes = {
|
2019-06-06 00:11:18 +02:00
|
|
|
fontSize: Math.round(globalStyle.fontSize * zoomRatio),
|
2019-01-10 20:34:58 +02:00
|
|
|
editorFontSize: editorFontSize,
|
2019-06-06 00:11:18 +02:00
|
|
|
textAreaLineHeight: Math.round(globalStyle.textAreaLineHeight * editorFontSize / 12),
|
2019-01-10 20:34:58 +02:00
|
|
|
|
|
|
|
// For WebView - must correspond to the properties above
|
2019-09-19 23:51:18 +02:00
|
|
|
htmlFontSize: `${Math.round(15 * zoomRatio)}px`,
|
2019-10-09 21:35:13 +02:00
|
|
|
htmlLineHeight: '1.6em', // Math.round(20 * zoomRatio) + 'px'
|
2019-02-06 01:55:09 +02:00
|
|
|
|
|
|
|
htmlCodeFontSize: '.9em',
|
2019-07-30 09:35:42 +02:00
|
|
|
};
|
2017-11-06 22:54:58 +02:00
|
|
|
|
2018-11-08 00:37:13 +02:00
|
|
|
let output = {};
|
2019-01-10 20:34:58 +02:00
|
|
|
output.zoomRatio = zoomRatio;
|
|
|
|
output.editorFontSize = editorFontSize;
|
2019-07-29 12:05:58 +02:00
|
|
|
|
|
|
|
// All theme are based on the light style, and just override the
|
|
|
|
// relevant properties
|
|
|
|
output = Object.assign({}, globalStyle, fontSizes, lightStyle);
|
|
|
|
|
2019-10-30 11:55:45 +02:00
|
|
|
switch (theme) {
|
|
|
|
case Setting.THEME_DARK :
|
|
|
|
output = Object.assign({}, output, darkStyle); break;
|
|
|
|
case Setting.THEME_SOLARIZED_LIGHT :
|
|
|
|
output = Object.assign({}, output, solarizedLightStyle); break;
|
|
|
|
case Setting.THEME_SOLARIZED_DARK :
|
|
|
|
output = Object.assign({}, output, solarizedDarkStyle); break;
|
|
|
|
case Setting.THEME_DRACULA :
|
|
|
|
output = Object.assign({}, output, draculaStyle); break;
|
|
|
|
case Setting.THEME_NORD :
|
|
|
|
output = Object.assign({}, output, nordStyle); break;
|
2019-10-01 13:23:32 +02:00
|
|
|
}
|
2018-11-08 00:37:13 +02:00
|
|
|
|
2019-01-18 19:56:56 +02:00
|
|
|
// Note: All the theme specific things should go in addExtraStyles
|
2018-11-08 00:47:34 +02:00
|
|
|
// so that their definition is not split between here and the
|
|
|
|
// beginning of the file. At least new styles should go in
|
|
|
|
// addExtraStyles.
|
|
|
|
|
2018-11-08 00:37:13 +02:00
|
|
|
output.icon = Object.assign({},
|
|
|
|
output.icon,
|
|
|
|
{ color: output.color }
|
|
|
|
);
|
|
|
|
|
|
|
|
output.lineInput = Object.assign({},
|
|
|
|
output.lineInput,
|
|
|
|
{
|
|
|
|
color: output.color,
|
|
|
|
backgroundColor: output.backgroundColor,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
output.headerStyle = Object.assign({},
|
|
|
|
output.headerStyle,
|
|
|
|
{
|
|
|
|
color: output.color,
|
|
|
|
backgroundColor: output.backgroundColor,
|
|
|
|
}
|
|
|
|
);
|
2017-11-06 22:54:58 +02:00
|
|
|
|
2018-11-08 00:37:13 +02:00
|
|
|
output.inputStyle = Object.assign({},
|
|
|
|
output.inputStyle,
|
|
|
|
{
|
|
|
|
color: output.color,
|
|
|
|
backgroundColor: output.backgroundColor,
|
|
|
|
borderColor: output.dividerColor,
|
|
|
|
}
|
|
|
|
);
|
2017-11-06 22:54:58 +02:00
|
|
|
|
2018-11-08 00:37:13 +02:00
|
|
|
output.containerStyle = Object.assign({},
|
|
|
|
output.containerStyle,
|
|
|
|
{
|
|
|
|
color: output.color,
|
|
|
|
backgroundColor: output.backgroundColor,
|
|
|
|
}
|
|
|
|
);
|
2017-11-06 22:54:58 +02:00
|
|
|
|
2018-11-08 00:37:13 +02:00
|
|
|
output.buttonStyle = Object.assign({},
|
|
|
|
output.buttonStyle,
|
|
|
|
{
|
|
|
|
color: output.color,
|
|
|
|
backgroundColor: output.backgroundColor,
|
|
|
|
borderColor: output.dividerColor,
|
|
|
|
}
|
|
|
|
);
|
2017-11-06 22:54:58 +02:00
|
|
|
|
2018-11-08 00:47:34 +02:00
|
|
|
output = addExtraStyles(output);
|
|
|
|
|
2019-01-10 20:34:58 +02:00
|
|
|
themeCache_[cacheKey] = output;
|
|
|
|
return themeCache_[cacheKey];
|
2017-11-06 22:54:58 +02:00
|
|
|
}
|
|
|
|
|
2019-12-13 03:16:34 +02:00
|
|
|
const cachedStyles_ = {};
|
|
|
|
|
|
|
|
function buildStyle(cacheKey, themeId, callback) {
|
|
|
|
if (cachedStyles_[cacheKey]) cachedStyles_[cacheKey].style;
|
|
|
|
|
|
|
|
const s = callback(themeStyle(themeId));
|
|
|
|
|
|
|
|
cachedStyles_[cacheKey] = {
|
|
|
|
style: s,
|
|
|
|
timestamp: Date.now(),
|
|
|
|
};
|
|
|
|
|
|
|
|
return cachedStyles_[cacheKey].style;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { themeStyle, buildStyle };
|