mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
implement custom CSS from config
This commit is contained in:
parent
1aa537b025
commit
1e5e3576cd
2 changed files with 19 additions and 8 deletions
|
|
@ -74,7 +74,7 @@ export default class HyperTerm extends Component {
|
|||
}
|
||||
|
||||
render () {
|
||||
const { backgroundColor, borderColor } = this.props.config;
|
||||
const { backgroundColor, borderColor, css } = this.props.config;
|
||||
return <div onClick={ this.focusActive }>
|
||||
<div style={{ borderColor }} className={ classes('main', { mac: this.state.mac }) }>
|
||||
<header style={{ backgroundColor }} onMouseDown={this.onHeaderMouseDown}>
|
||||
|
|
@ -98,12 +98,13 @@ export default class HyperTerm extends Component {
|
|||
this.state.sessions.map((uid, i) => {
|
||||
const active = i === this.state.active;
|
||||
const { config } = this.props;
|
||||
return <div key={`d${uid}`} className={classes('term', { active })} style={{ width: '100%', height: '100%' }} ref='term'>
|
||||
return <div key={`d${uid}`} className={classes('term', { active })} style={{ width: '100%', height: '100%' }}>
|
||||
<Term
|
||||
key={uid}
|
||||
ref={`term-${uid}`}
|
||||
cols={this.state.cols}
|
||||
rows={this.state.rows}
|
||||
customCSS={config.termCSS}
|
||||
fontSize={this.state.fontSize}
|
||||
cursorColor={config.cursorColor}
|
||||
fontFamily={config.fontFamily}
|
||||
|
|
@ -130,6 +131,7 @@ export default class HyperTerm extends Component {
|
|||
<a href='' onClick={this.quitAndInstall}>Restart</a>
|
||||
to apply <span className='close' onClick={this.dismissUpdate}>[x]</span>
|
||||
</div>
|
||||
<style dangerouslySetInnerHTML={{ __html: Array.from(css || '').join('\n') }} />
|
||||
</div>;
|
||||
}
|
||||
|
||||
|
|
|
|||
21
app/term.js
21
app/term.js
|
|
@ -22,12 +22,7 @@ export default class Term extends Component {
|
|||
this.term.prefs_.set('background-color', props.backgroundColor);
|
||||
this.term.prefs_.set('color-palette-overrides', props.colors);
|
||||
|
||||
this.term.prefs_.set('user-css', URL.createObjectURL(new Blob([`
|
||||
.cursor-node[focus="false"] {
|
||||
border-width: 1px !important;
|
||||
}
|
||||
${Array.from(props.customCSS || '').join('\n')}
|
||||
`]), { type: 'text/css' }));
|
||||
this.term.prefs_.set('user-css', this.getStylesheet(props.customCSS));
|
||||
|
||||
this.term.onTerminalReady = () => {
|
||||
const io = this.term.io.push();
|
||||
|
|
@ -46,6 +41,16 @@ export default class Term extends Component {
|
|||
return this.term.document_;
|
||||
}
|
||||
|
||||
getStylesheet (css) {
|
||||
const blob = new Blob([`
|
||||
.cursor-node[focus="false"] {
|
||||
border-width: 1px !important;
|
||||
}
|
||||
${Array.from(css || '').join('\n')}
|
||||
`]);
|
||||
return URL.createObjectURL(blob, { type: 'text/css' });
|
||||
}
|
||||
|
||||
componentWillReceiveProps (nextProps) {
|
||||
if (this.props.fontSize !== nextProps.fontSize) {
|
||||
this.term.prefs_.set('font-size', nextProps.fontSize);
|
||||
|
|
@ -66,6 +71,10 @@ export default class Term extends Component {
|
|||
if (this.props.colors.toString() !== nextProps.colors.toString()) {
|
||||
this.term.prefs_.set('color-palette-overrides', nextProps.colors);
|
||||
}
|
||||
|
||||
if (this.props.customCSS.toString() !== nextProps.customCSS.toString()) {
|
||||
this.term.prefs_.set('user-css', this.getStylesheet(nextProps.customCSS));
|
||||
}
|
||||
}
|
||||
|
||||
shouldComponentUpdate (nextProps) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue