-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
48 lines (42 loc) · 1.12 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use strict';
const hashbow = require('hashbow');
function getOverrides(path) {
return window.config.getConfig()['hyperterm-dibdabs'].overrides[path];
}
function getColor(path) {
return getOverrides(path) || hashbow(path);
}
exports.getTabProps = function (uid, parentProps, props) {
return Object.assign({}, props, {
dabColor: getColor(props.text)
});
};
exports.decorateTab = function (Tab, { React }) {
return class extends Tab {
render() {
const dab = React.createElement('span', {
className: 'tab_dibdab',
style: {
'background-color': this.props.dabColor
}
});
const customChildrenBefore = Array.from(this.props.customChildrenBefore || []).concat(dab);
return React.createElement(Tab, Object.assign({}, this.props, { customChildrenBefore }));
}
}
};
exports.decorateConfig = function (config) {
return Object.assign({}, config, {
css: `
${config.css || ''}
.tab_dibdab {
position: absolute;
left: 13px;
top: 13px;
width: 10px;
height: 10px;
border-radius: 50%;
}
`
});
};