mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
* `child_pty` => `pty.js` * Create a frameless window on Windows and Linux * Add a brand new UI for Linux and Windows 💅 * [Windows] Fix plugin installation * [Windows] Fix the `build` script * [Windows] Add a bigger `icon.ico` * [Mac] Add `WebKitAppRegion: drag` when running on macOS * Fix code style 🤔 * Add `appveyor.yml` * Fix code style (again) * [Windows] Fix AppVeyor's `install` script * [Windows] Try a new AppVeyor config * [Windows] Set the binary path so Spectron can run the tests * [Windows] Try to build on x64 * Try again to build on x64 * Try one more time 😩 * Throw an error to indicate that `pty.js` was built incorrectly * [Win/Linux] Add `display: hidden` to <Tabs /> if tabs.length === 1 * [Win/Linux] Reorganize SVGs – via @CodeTheory * [Win/Linux] Fix the hamburger menu height * Make the SVGs look better with `shape-rendering: crispEdges;` * [Win/Linux] Add config options for the window controls and the 🍔 menu * Add `electron-squirrel-startup` dependency * [Win] Handle Squirrel commands * [Win/Linux] Fix default color for the 🍔 and window controls – via @CodeTheory * [Win/Linux] Add some padding - via @CodeTheory * [Win/Linux] Add hover states – via @CodeTheory * [Win] Fix empty window/tab titles * [Win] Fix opening Preferences (#978) * [Win] Fix opening Preferences * Update ui.js * Update ui.js * Enhance messages and default editor * [Win] Add dependency instructions to the README.md [skip ci] * Fix code style * [Win/Linux] Check the number of open windows before quitting the app
194 lines
4 KiB
JavaScript
194 lines
4 KiB
JavaScript
import React from 'react';
|
|
import Component from '../component';
|
|
|
|
export default class Tab extends Component {
|
|
constructor() {
|
|
super();
|
|
|
|
this.handleHover = this.handleHover.bind(this);
|
|
this.handleBlur = this.handleBlur.bind(this);
|
|
this.handleClick = this.handleClick.bind(this);
|
|
|
|
this.state = {
|
|
hovered: false
|
|
};
|
|
}
|
|
|
|
shouldComponentUpdate() {
|
|
return true;
|
|
}
|
|
|
|
handleHover() {
|
|
this.setState({
|
|
hovered: true
|
|
});
|
|
}
|
|
|
|
handleBlur() {
|
|
this.setState({
|
|
hovered: false
|
|
});
|
|
}
|
|
|
|
handleClick(event) {
|
|
const isLeftClick = event.nativeEvent.which === 1;
|
|
const isMiddleClick = event.nativeEvent.which === 2;
|
|
|
|
if (isLeftClick && !this.props.isActive) {
|
|
this.props.onSelect();
|
|
} else if (isMiddleClick) {
|
|
this.props.onClose();
|
|
}
|
|
}
|
|
|
|
template(css) {
|
|
const {isActive, isFirst, isLast, borderColor, hasActivity} = this.props;
|
|
const {hovered} = this.state;
|
|
|
|
return (<li
|
|
onMouseEnter={this.handleHover}
|
|
onMouseLeave={this.handleBlur}
|
|
onClick={this.props.onClick}
|
|
style={{borderColor}}
|
|
className={css(
|
|
'tab',
|
|
isFirst && 'first',
|
|
isActive && 'active',
|
|
isFirst && isActive && 'firstActive',
|
|
hasActivity && 'hasActivity'
|
|
)}
|
|
>
|
|
{ this.props.customChildrenBefore }
|
|
<span
|
|
className={css(
|
|
'text',
|
|
isLast && 'textLast',
|
|
isActive && 'textActive'
|
|
)}
|
|
onClick={this.handleClick}
|
|
>
|
|
<span className={css('textInner')}>
|
|
{ this.props.text }
|
|
</span>
|
|
</span>
|
|
<i
|
|
className={css(
|
|
'icon',
|
|
hovered && 'iconHovered'
|
|
)}
|
|
onClick={this.props.onClose}
|
|
>
|
|
<svg className={css('shape')}>
|
|
<use xlinkHref="./dist/assets/icons.svg#close-tab"/>
|
|
</svg>
|
|
</i>
|
|
{ this.props.customChildren }
|
|
</li>);
|
|
}
|
|
|
|
styles() {
|
|
return {
|
|
tab: {
|
|
color: '#ccc',
|
|
borderColor: '#ccc',
|
|
borderBottomWidth: 1,
|
|
borderBottomStyle: 'solid',
|
|
borderLeftWidth: 1,
|
|
borderLeftStyle: 'solid',
|
|
listStyleType: 'none',
|
|
flexGrow: 1,
|
|
position: 'relative',
|
|
':hover': {
|
|
color: '#ccc'
|
|
}
|
|
},
|
|
|
|
first: {
|
|
borderLeftWidth: 0,
|
|
paddingLeft: 1
|
|
},
|
|
|
|
firstActive: {
|
|
borderLeftWidth: 1,
|
|
paddingLeft: 0
|
|
},
|
|
|
|
active: {
|
|
color: '#fff',
|
|
borderBottomWidth: 0,
|
|
':hover': {
|
|
color: '#fff'
|
|
}
|
|
},
|
|
|
|
hasActivity: {
|
|
color: '#50E3C2',
|
|
':hover': {
|
|
color: '#50E3C2'
|
|
}
|
|
},
|
|
|
|
text: {
|
|
transition: 'color .2s ease',
|
|
height: '34px',
|
|
display: 'block',
|
|
width: '100%',
|
|
position: 'relative',
|
|
overflow: 'hidden'
|
|
},
|
|
|
|
textInner: {
|
|
position: 'absolute',
|
|
left: 0,
|
|
right: 0,
|
|
top: 0,
|
|
bottom: 0,
|
|
textAlign: 'center'
|
|
},
|
|
|
|
icon: {
|
|
transition: `opacity .2s ease, color .2s ease,
|
|
transform .25s ease, background-color .1s ease`,
|
|
pointerEvents: 'none',
|
|
position: 'absolute',
|
|
right: '7px',
|
|
top: '10px',
|
|
display: 'inline-block',
|
|
width: '14px',
|
|
height: '14px',
|
|
borderRadius: '100%',
|
|
color: '#e9e9e9',
|
|
opacity: 0,
|
|
transform: 'scale(.95)',
|
|
|
|
':hover': {
|
|
backgroundColor: 'rgba(255,255,255, .13)',
|
|
color: '#fff'
|
|
},
|
|
|
|
':active': {
|
|
backgroundColor: 'rgba(255,255,255, .1)',
|
|
color: '#909090'
|
|
}
|
|
},
|
|
|
|
iconHovered: {
|
|
opacity: 1,
|
|
transform: 'none',
|
|
pointerEvents: 'all'
|
|
},
|
|
|
|
shape: {
|
|
position: 'absolute',
|
|
left: '4px',
|
|
top: '4px',
|
|
width: '6px',
|
|
height: '6px',
|
|
verticalAlign: 'middle',
|
|
fill: 'currentColor',
|
|
shapeRendering: 'crispEdges'
|
|
}
|
|
};
|
|
}
|
|
|
|
}
|