Archived
razer should be a-ok
This commit is contained in:
1 parent
7fd47915ae
commit
7693697990
142 files changed
+22252
No files matched your search
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"amber": {
|
||||
"base": "#FFD54F",
|
||||
"accent": "#A28832"
|
||||
},
|
||||
"blue": {
|
||||
"base": "#2196F3",
|
||||
"accent": "#FFFFFF"
|
||||
},
|
||||
"blueGrey": {
|
||||
"base": "#607D8B",
|
||||
"accent": "#FFFFFF"
|
||||
},
|
||||
"brown": {
|
||||
"base": "#795548",
|
||||
"accent": "#FFFFFF"
|
||||
},
|
||||
"cyan": {
|
||||
"base": "#80DEEA",
|
||||
"accent": "#528C94"
|
||||
},
|
||||
"green": {
|
||||
"base": "#AAD875",
|
||||
"accent": "#6F8853"
|
||||
},
|
||||
"grey": {
|
||||
"base": "#7E7E7E",
|
||||
"accent": "#FFFFFF"
|
||||
},
|
||||
"indigo": {
|
||||
"base": "#5C6BC0",
|
||||
"accent": "#FFFFFF"
|
||||
},
|
||||
"lime": {
|
||||
"base": "#CDDC39",
|
||||
"accent": "#737F10"
|
||||
},
|
||||
"orange": {
|
||||
"base": "#FFA726",
|
||||
"accent": "#9F6918"
|
||||
},
|
||||
"pink": {
|
||||
"base": "#EC407A",
|
||||
"accent": "#46FFC1"
|
||||
},
|
||||
"purple": {
|
||||
"base": "#7E57C2",
|
||||
"accent": "#B0E457"
|
||||
},
|
||||
"red": {
|
||||
"base": "#EF5350",
|
||||
"accent": "#59FCFF"
|
||||
},
|
||||
"teal": {
|
||||
"base": "#009688",
|
||||
"accent": "#FFFFFF"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
'use babel';
|
||||
|
||||
import tinycolor from 'tinycolor2';
|
||||
|
||||
export default function buildColorSettings(baseColor = '#009688', accentColor = '#FFFFFF') {
|
||||
const newAccent = (typeof accentColor === 'object') ?
|
||||
accentColor.toHexString() :
|
||||
accentColor;
|
||||
|
||||
const newBase = (typeof baseColor === 'object') ?
|
||||
baseColor.toHexString() :
|
||||
baseColor;
|
||||
|
||||
const luminance = tinycolor(newBase).getLuminance();
|
||||
let accentTextColor = '#666';
|
||||
|
||||
if (luminance <= 0.3 && luminance > 0.22) {
|
||||
accentTextColor = 'rgba(255,255,255,0.9)';
|
||||
} else if (luminance <= 0.22) {
|
||||
accentTextColor = 'rgba(255,255,255,0.8)';
|
||||
} else if (luminance > 0.3) {
|
||||
accentTextColor = 'rgba(0,0,0,0.6)';
|
||||
}
|
||||
|
||||
return `
|
||||
@accent-color: ${newAccent};
|
||||
@accent-text-color: ${accentTextColor};
|
||||
@base-color: ${newBase};
|
||||
`;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
'use babel';
|
||||
|
||||
import tinycolor from 'tinycolor2';
|
||||
import writeConfigFile from '../helper/write-config-file';
|
||||
import toggleClassName from '../helper/toggle-class-name';
|
||||
import toCamelCase from '../helper/to-camel-case';
|
||||
import colorTemplates from '../color-templates.json';
|
||||
import buildColorSettings from './build-color-settings';
|
||||
|
||||
atom.config.onDidChange('atom-material-ui.colors.abaseColor', ({ newValue }) => {
|
||||
if (atom.config.get('atom-material-ui.colors.genAccent')) {
|
||||
const accentColor = tinycolor(newValue.toHexString())
|
||||
.complement()
|
||||
.saturate(20)
|
||||
.lighten(5);
|
||||
|
||||
return atom.config.set('atom-material-ui.colors.accentColor', accentColor.toRgbString());
|
||||
}
|
||||
|
||||
return writeConfigFile(
|
||||
buildColorSettings(
|
||||
newValue, atom.config.get('atom-material-ui.colors.accentColor'),
|
||||
),
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
atom.config.onDidChange('atom-material-ui.colors.predefinedColor', (value) => {
|
||||
const newValue = toCamelCase(value.newValue);
|
||||
|
||||
atom.config.set('atom-material-ui.colors.abaseColor', colorTemplates[newValue].base);
|
||||
atom.config.set('atom-material-ui.colors.accentColor', colorTemplates[newValue].accent);
|
||||
});
|
||||
|
||||
atom.config.onDidChange('atom-material-ui.colors.accentColor', ({ newValue }) => (
|
||||
writeConfigFile(
|
||||
buildColorSettings(
|
||||
atom.config.get('atom-material-ui.colors.abaseColor'), newValue,
|
||||
),
|
||||
true,
|
||||
)
|
||||
));
|
||||
|
||||
atom.config.observe('atom-material-ui.colors.paintCursor', value => toggleClassName('amu-paint-cursor', value));
|
||||
@@ -0,0 +1,5 @@
|
||||
'use babel';
|
||||
|
||||
import setFontSize from './set-font-size';
|
||||
|
||||
atom.config.observe('atom-material-ui.fonts.fontSize', size => setFontSize(size));
|
||||
@@ -0,0 +1,6 @@
|
||||
'use babel';
|
||||
|
||||
export default function setFontSize(size) {
|
||||
const fontSize = size ? `${size}px` : null;
|
||||
document.documentElement.style.fontSize = fontSize;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
'use babel';
|
||||
|
||||
export default function toCamelCase(str) {
|
||||
return str
|
||||
.replace(/-/g, ' ')
|
||||
.replace(/_/g, ' ')
|
||||
.replace(/\s(.)/g, $1 => $1.toUpperCase())
|
||||
.replace(/\s/g, '')
|
||||
.replace(/^(.)/, $1 => $1.toLowerCase());
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
'use babel';
|
||||
|
||||
export default function toggleClassName(className, mustAddClass) {
|
||||
const root = document.documentElement;
|
||||
|
||||
if (mustAddClass) {
|
||||
root.classList.add(className);
|
||||
} else {
|
||||
root.classList.remove(className);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
'use babel';
|
||||
|
||||
import fs from 'fs';
|
||||
|
||||
function writeConfigFile(content, reload = false) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!content) return reject({ success: false, error: 'No content given' });
|
||||
|
||||
fs.writeFile(`${__dirname}/../../styles/user-settings.less`, content, 'utf8', (error) => {
|
||||
if (error) return reject({ success: false, error: 'Failed to write settings file' });
|
||||
|
||||
if (reload) {
|
||||
const amuPackage = atom.packages.getLoadedPackage('atom-material-ui');
|
||||
|
||||
if (amuPackage) {
|
||||
amuPackage.deactivate();
|
||||
setImmediate(() => amuPackage.activate());
|
||||
}
|
||||
}
|
||||
|
||||
return resolve({ success: true, error: null });
|
||||
});
|
||||
|
||||
return resolve({ success: true, error: null });
|
||||
});
|
||||
}
|
||||
|
||||
export default writeConfigFile;
|
||||
@@ -0,0 +1,40 @@
|
||||
'use babel';
|
||||
|
||||
import setFontSize from './fonts/set-font-size';
|
||||
import toggleClassName from './helper/toggle-class-name';
|
||||
import './colors';
|
||||
import './fonts';
|
||||
import './tab-bar';
|
||||
import './user-interface';
|
||||
|
||||
const classNames = {
|
||||
// Fonts
|
||||
'amu-paint-cursor': atom.config.get('atom-material-ui.colors.paintCursor'),
|
||||
|
||||
// Tabs settings
|
||||
'amu-compact-tab-bar': atom.config.get('atom-material-ui.tabs.compactTabs'),
|
||||
'amu-no-tab-min-width': atom.config.get('atom-material-ui.tabs.noTabMinWidth'),
|
||||
'amu-tinted-tab-bar': atom.config.get('atom-material-ui.tabs.tintedTabBar'),
|
||||
'amu-stretched-tabs': atom.config.get('atom-material-ui.tabs.stretchedTabs'),
|
||||
|
||||
// General UI settings
|
||||
'amu-use-animations': atom.config.get('atom-material-ui.ui.useAnimations'),
|
||||
'amu-panel-contrast': atom.config.get('atom-material-ui.ui.panelContrast'),
|
||||
'amu-panel-shadows': atom.config.get('atom-material-ui.ui.panelShadows'),
|
||||
};
|
||||
|
||||
export default {
|
||||
activate() {
|
||||
Object.keys(classNames).forEach(className => (
|
||||
toggleClassName(className, classNames[className])),
|
||||
);
|
||||
|
||||
setFontSize(atom.config.get('atom-material-ui.fonts.fontSize'));
|
||||
},
|
||||
|
||||
deactivate() {
|
||||
// Reset all the things!
|
||||
Object.keys(classNames).forEach(className => toggleClassName(className, false));
|
||||
setFontSize(null);
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
'use babel';
|
||||
|
||||
import toggleClassName from '../helper/toggle-class-name';
|
||||
|
||||
atom.config.observe('atom-material-ui.tabs.tintedTabBar', (value) => {
|
||||
toggleClassName('amu-tinted-tab-bar', value);
|
||||
});
|
||||
|
||||
atom.config.observe('atom-material-ui.tabs.compactTabs', (value) => {
|
||||
toggleClassName('amu-compact-tab-bar', value);
|
||||
});
|
||||
|
||||
atom.config.observe('atom-material-ui.tabs.noTabMinWidth', (value) => {
|
||||
toggleClassName('amu-no-tab-min-width', value);
|
||||
});
|
||||
|
||||
atom.config.observe('atom-material-ui.tabs.stretchedTabs', (value) => {
|
||||
toggleClassName('amu-stretched-tabs', value);
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
'use babel';
|
||||
|
||||
import toggleClassName from '../helper/toggle-class-name';
|
||||
|
||||
atom.config.observe('atom-material-ui.ui.panelShadows', (value) => {
|
||||
toggleClassName('amu-panel-shadows', value);
|
||||
});
|
||||
|
||||
atom.config.observe('atom-material-ui.ui.panelContrast', (value) => {
|
||||
toggleClassName('amu-panel-contrast', value);
|
||||
});
|
||||
|
||||
atom.config.observe('atom-material-ui.ui.useAnimations', (value) => {
|
||||
toggleClassName('amu-use-animations', value);
|
||||
});
|
||||
Reference in new issue
Block a user