use ToolbarButton for plugins
This commit is contained in:
parent
c5d9f44de2
commit
c7d3de0fc8
@ -6,27 +6,12 @@
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.Button {
|
|
||||||
display: inline-block;
|
|
||||||
|
|
||||||
& button {
|
|
||||||
padding: 6px;
|
|
||||||
border: none;
|
|
||||||
background-color: transparent;
|
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
@nest .ButtonActive& {
|
|
||||||
background-color: var(--highlightFGAltColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.Toggle {
|
.Toggle {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
|
|
||||||
& .Button button {
|
& button {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
|
@ -7,7 +7,7 @@ import styles from './Toolbar.css';
|
|||||||
function Toolbar(props) {
|
function Toolbar(props) {
|
||||||
const { onH1, onH2, onBold, onItalic, onLink, onToggleMode, rawMode } = props;
|
const { onH1, onH2, onBold, onItalic, onLink, onToggleMode, rawMode } = props;
|
||||||
return (
|
return (
|
||||||
<ul className={styles.Toolbar}>
|
<div className={styles.Toolbar}>
|
||||||
<ToolbarButton label="Header 1" icon="h1" action={onH1}/>
|
<ToolbarButton label="Header 1" icon="h1" action={onH1}/>
|
||||||
<ToolbarButton label="Header 2" icon="h2" action={onH2}/>
|
<ToolbarButton label="Header 2" icon="h2" action={onH2}/>
|
||||||
<ToolbarButton label="Bold" icon="bold" action={onBold}/>
|
<ToolbarButton label="Bold" icon="bold" action={onBold}/>
|
||||||
@ -16,7 +16,7 @@ function Toolbar(props) {
|
|||||||
<div className={styles.Toggle}>
|
<div className={styles.Toggle}>
|
||||||
<ToolbarButton label="Toggle Markdown" action={onToggleMode} active={rawMode}/>
|
<ToolbarButton label="Toggle Markdown" action={onToggleMode} active={rawMode}/>
|
||||||
</div>
|
</div>
|
||||||
</ul>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
@import "../../UI/theme";
|
||||||
|
|
||||||
|
.button {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 6px;
|
||||||
|
border: none;
|
||||||
|
background-color: transparent;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.active {
|
||||||
|
background-color: var(--highlightFGAltColor);
|
||||||
|
}
|
@ -1,14 +1,16 @@
|
|||||||
import React, { PropTypes } from 'react';
|
import React, { PropTypes } from 'react';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { Icon } from '../../UI';
|
import { Icon } from '../../UI';
|
||||||
import styles from './Toolbar.css';
|
import styles from './ToolbarButton.css';
|
||||||
|
|
||||||
const ToolbarButton = ({ label, icon, action, active }) => (
|
const ToolbarButton = ({ label, icon, action, active }) => (
|
||||||
<li className={classnames(styles.Button, { [styles.ButtonActive]: active })}>
|
<button
|
||||||
<button className={styles[label]} onClick={action} title={label}>
|
className={classnames(styles.button, { [styles.active]: active })}
|
||||||
|
onClick={action}
|
||||||
|
title={label}
|
||||||
|
>
|
||||||
{ icon ? <Icon type={icon} /> : label }
|
{ icon ? <Icon type={icon} /> : label }
|
||||||
</button>
|
</button>
|
||||||
</li>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
ToolbarButton.propTypes = {
|
ToolbarButton.propTypes = {
|
||||||
|
@ -3,6 +3,7 @@ import { fromJS } from 'immutable';
|
|||||||
import { Button } from 'react-toolbox/lib/button';
|
import { Button } from 'react-toolbox/lib/button';
|
||||||
import { Icon } from '../../UI';
|
import { Icon } from '../../UI';
|
||||||
import { resolveWidget } from '../../Widgets';
|
import { resolveWidget } from '../../Widgets';
|
||||||
|
import ToolbarButton from './ToolbarButton';
|
||||||
import toolbarStyles from './Toolbar.css';
|
import toolbarStyles from './Toolbar.css';
|
||||||
import styles from './ToolbarPlugins.css';
|
import styles from './ToolbarPlugins.css';
|
||||||
|
|
||||||
@ -30,14 +31,6 @@ export default class ToolbarPlugins extends Component {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonFor(plugin) {
|
|
||||||
return (<li key={`plugin-${ plugin.get('id') }`} className={toolbarStyles.Button}>
|
|
||||||
<button className={styles[plugin.get('label')]} onClick={this.handlePlugin(plugin)} title={plugin.get('label')}>
|
|
||||||
<Icon type={plugin.get('icon')} />
|
|
||||||
</button>
|
|
||||||
</li>);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleSubmit = (e) => {
|
handleSubmit = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const { openPlugin, pluginData } = this.state;
|
const { openPlugin, pluginData } = this.state;
|
||||||
@ -109,9 +102,14 @@ export default class ToolbarPlugins extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (<div className={classNames.join(' ')}>
|
return (<div className={classNames.join(' ')}>
|
||||||
<ul className={styles.menu}>
|
{plugins.map(plugin => (
|
||||||
{plugins.map(plugin => this.buttonFor(plugin))}
|
<ToolbarButton
|
||||||
</ul>
|
key={`plugin-${plugin.get('id')}`}
|
||||||
|
label={plugin.get('label')}
|
||||||
|
icon={plugin.get('icon')}
|
||||||
|
action={this.handlePlugin(plugin)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
{openPlugin && this.pluginForm(openPlugin)}
|
{openPlugin && this.pluginForm(openPlugin)}
|
||||||
</div>);
|
</div>);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user