1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00
joplin/ReactNativeClient/lib/components/global-style.js

131 lines
3.3 KiB
JavaScript
Raw Normal View History

const Setting = require('lib/models/Setting.js');
const { Platform } = require('react-native');
2017-08-01 19:59:01 +02:00
2017-07-21 23:40:02 +02:00
const globalStyle = {
2017-07-30 23:04:26 +02:00
fontSize: 16,
2017-07-21 23:40:02 +02:00
margin: 15, // No text and no interactive component should be within this margin
2017-07-30 23:04:26 +02:00
itemMarginTop: 10,
itemMarginBottom: 10,
2017-07-21 23:40:02 +02:00
backgroundColor: "#ffffff",
2017-07-22 17:55:09 +02:00
color: "#555555", // For regular text
2017-08-01 19:59:01 +02:00
colorError: "red",
colorWarn: "#9A5B00",
2017-07-22 17:55:09 +02:00
colorFaded: "#777777", // For less important text
2017-07-30 23:04:26 +02:00
fontSizeSmaller: 14,
2017-07-21 23:40:02 +02:00
dividerColor: "#dddddd",
strongDividerColor: "#aaaaaa",
selectedColor: '#e5e5e5',
disabledOpacity: 0.2,
colorUrl: '#7B81FF',
textSelectionColor: "#0096FF",
2017-07-21 23:40:02 +02:00
2017-07-27 19:34:43 +02:00
raisedBackgroundColor: "#0080EF",
raisedColor: "#003363",
raisedHighlightedColor: "#ffffff",
2017-12-30 21:57:34 +02:00
warningBackgroundColor: "#FFD08D",
2017-07-21 23:40:02 +02:00
// For WebView - must correspond to the properties above
htmlFontSize: '16px',
2019-02-07 01:52:29 +02:00
htmlColor: '#222222',
htmlBackgroundColor: 'white',
2019-02-07 01:52:29 +02:00
htmlDividerColor: 'rgb(230,230,230)',
htmlLinkColor: 'rgb(80,130,190)',
htmlLineHeight: '1.6em',
htmlCodeBackgroundColor: 'rgb(243, 243, 243)',
htmlCodeBorderColor: 'rgb(220, 220, 220)',
htmlCodeColor: 'rgb(0,0,0)',
codeThemeCss: 'hljs-atom-one-light.css',
2017-07-21 23:40:02 +02:00
};
globalStyle.marginRight = globalStyle.margin;
globalStyle.marginLeft = globalStyle.margin;
2017-07-22 17:55:09 +02:00
globalStyle.marginTop = globalStyle.margin;
globalStyle.marginBottom = globalStyle.margin;
globalStyle.htmlMarginLeft = ((globalStyle.marginLeft / 10) * 0.6).toFixed(2) + 'em';
2017-07-21 23:40:02 +02:00
2017-08-01 19:59:01 +02:00
let themeCache_ = {};
function addExtraStyles(style) {
style.icon = {
color: style.color,
fontSize: 30,
};
style.lineInput = {
color: style.color,
backgroundColor: style.backgroundColor,
borderBottomWidth: 1,
borderColor: style.strongDividerColor,
paddingBottom: 0,
};
if (Platform.OS === 'ios') {
2019-02-03 18:57:29 +02:00
delete style.lineInput.borderBottomWidth;
delete style.lineInput.borderColor;
}
style.buttonRow = {
flexDirection: 'row',
borderTopWidth: 1,
borderTopColor: style.dividerColor,
paddingTop: 10,
};
style.normalText = {
color: style.color,
fontSize: style.fontSize,
};
2018-03-27 19:41:19 +02:00
style.urlText = {
color: style.colorUrl,
fontSize: style.fontSize,
};
return style;
}
2017-08-01 19:59:01 +02:00
function themeStyle(theme) {
if (!theme) {
console.warn('Theme not set!! Defaulting to Light theme');
theme = Setting.THEME_LIGHT;
}
2018-03-27 19:41:19 +02:00
2017-08-01 19:59:01 +02:00
if (themeCache_[theme]) return themeCache_[theme];
let output = Object.assign({}, globalStyle);
if (theme == Setting.THEME_LIGHT) return addExtraStyles(output);
2017-08-01 19:59:01 +02:00
output.backgroundColor = '#1D2024';
output.color = '#dddddd';
output.colorFaded = '#777777';
output.dividerColor = '#555555';
output.strongDividerColor = '#888888';
output.selectedColor = '#333333';
output.textSelectionColor = '#00AEFF';
2017-08-01 19:59:01 +02:00
output.raisedBackgroundColor = "#0F2051";
2017-08-01 20:29:01 +02:00
output.raisedColor = "#788BC3";
2017-08-01 19:59:01 +02:00
output.raisedHighlightedColor = "#ffffff";
output.htmlColor = 'rgb(220,220,220)';
output.htmlBackgroundColor = 'rgb(29,32,36)';
output.htmlLinkColor = 'rgb(166,166,255)';
2017-08-01 20:53:50 +02:00
2019-02-07 01:52:29 +02:00
output.htmlDividerColor = '#3D444E';
output.htmlLinkColor = 'rgb(166,166,255)';
output.htmlCodeColor = '#ffffff';
output.htmlCodeBackgroundColor = 'rgb(47, 48, 49)';
output.htmlCodeBorderColor = 'rgb(70, 70, 70)';
output.codeThemeCss = 'hljs-atom-one-dark-reasonable.css';
output.colorUrl = '#7B81FF';
2017-08-01 19:59:01 +02:00
themeCache_[theme] = output;
return addExtraStyles(themeCache_[theme]);
2017-08-01 19:59:01 +02:00
}
module.exports = { globalStyle, themeStyle };