Skip to content

Instantly share code, notes, and snippets.

@blackmiaool
Last active September 19, 2017 13:02
Show Gist options
  • Select an option

  • Save blackmiaool/d721310fa0e1797a67da8b81932c181a to your computer and use it in GitHub Desktop.

Select an option

Save blackmiaool/d721310fa0e1797a67da8b81932c181a to your computer and use it in GitHub Desktop.
hyper plugin
'use strict';
const hashbow = require('hashbow');
exports.getTabProps = function (uid, parentProps, props) {
const ret = {};
Object.assign(ret, props, {
dabColor: hashbow(props.text)
});
ret.text = ret.text.replace(/blackmiaool@blackmiaool-OptiPlex-9020:/, "")
return ret;
};
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, {
termCSS:`
.unicode-node{
width:12.22px !important;
}
`,
css: `
${config.css || ''}
.tab_dibdab {
position: absolute;
left: 13px;
top: 13px;
width: 10px;
height: 10px;
border-radius: 50%;
}
.header_header{
position:static;
}
.header_windowHeader{
position:static;
}
.tabs_nav{
position:static;
height:auto;
}
.tab_tab{
min-width: 150px;
cursor:pointer;
}
.tab_tab.tab_active{
background-color: steelblue !important;
cursor:auto;
}
.tabs_list{
flex-wrap:wrap;
}
.hyper_main{
display:flex;
flex-direction:column;
}
.terms_terms{
flex:1;
position:static;
margin-top:0;
}
.tabs_list{
max-height:none;
}
`
});
};
@blackmiaool
Copy link
Author

blackmiaool commented Aug 12, 2017

image

  • Supports mutiline tab
  • Highlight active tab
  • Reduce tab title (edit the rule yourself)
  • 修复中文宽度

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment