Hawk/src/js/components/toolbar.js
Mahdi Dibaiee 764554c6b9 feat multiselection: select multiple files and act on them
fix breadcrumb: fixed breadcrumb history not working properly when clicking on "sdcard"
fix dialogs/menus: fixed clicking out of menus and dialogs triggering actions other than hiding the dialog/event
2015-09-05 16:09:09 +04:30

40 lines
1.3 KiB
JavaScript

import React, { Component } from 'react';
import { toggle as toggleView, refresh, selectView } from 'actions/files-view';
import { show as showDialog } from 'actions/dialog';
import { show as showMenu } from 'actions/menu';
import store, { bind } from 'store';
import { MENU_WIDTH } from './menu';
export default class Toolbar extends Component {
render() {
return (
<div className='toolbar'>
<button className='icon-plus' onClick={this.newFile} />
<button className='icon-view' onClick={bind(toggleView())} />
<button className='icon-refresh' onClick={bind(refresh())} />
<button className='icon-select' onClick={bind(selectView('toggle'))} />
<button className='icon-more' onClick={this.showMore.bind(this)} ref='more' />
</div>
);
}
showMore() {
let rect = React.findDOMNode(this.refs.more).getBoundingClientRect();
let {x, y, width, height} = rect;
let left = x + width - MENU_WIDTH,
top = y + height;
let transform = 'translate(0, -100%)';
store.dispatch(showMenu('moreMenu', {style: {left, top, transform}}));
}
newFile() {
let cwd = store.getState().get('cwd');
let action = showDialog('createDialog', {
description: `Enter a name for the new file to be created in ${cwd}`
});
store.dispatch(action);
}
}