fix rte markdown toggle position for small screens

This commit is contained in:
Shawn Erquhart 2017-04-18 12:50:11 -04:00
parent 86b7b84637
commit 1a12c6f5aa
3 changed files with 24 additions and 21 deletions

View File

@ -44,3 +44,9 @@
.depth { .depth {
box-shadow: var(--shadowColor) 0 1px 6px; box-shadow: var(--shadowColor) 0 1px 6px;
} }
.clearfix:after {
content: '';
display: table;
clear: both;
}

View File

@ -1,15 +1,12 @@
@import "../../../UI/theme"; @import "../../../UI/theme";
.Toolbar { .Toolbar {
composes: clearfix;
z-index: 1000; z-index: 1000;
list-style: none;
display: inline-block;
} }
.Toggle { .Toggle {
position: absolute; float: right;
top: 0;
right: 0;
& button { & button {
font-size: 12px; font-size: 12px;

View File

@ -19,24 +19,24 @@ export default class Toolbar extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
openPlugin: null, activePlugin: null,
}; };
} }
handlePlugin(plugin) { handlePluginFormDisplay(plugin) {
return (e) => { return (e) => {
e.preventDefault(); e.preventDefault();
this.setState({ openPlugin: plugin }); this.setState({ activePlugin: plugin });
}; };
} }
handleSubmit = (plugin, pluginData) => { handlePluginFormSubmit = (plugin, pluginData) => {
this.props.onSubmit(plugin, pluginData); this.props.onSubmit(plugin, pluginData);
this.setState({ openPlugin: null }); this.setState({ activePlugin: null });
}; };
handleCancel = (e) => { handlePluginFormCancel = (e) => {
this.setState({ openPlugin: null }); this.setState({ activePlugin: null });
}; };
render() { render() {
@ -54,7 +54,7 @@ export default class Toolbar extends React.Component {
getAsset, getAsset,
} = this.props; } = this.props;
const { openPlugin } = this.state; const { activePlugin } = this.state;
return ( return (
<div className={styles.Toolbar}> <div className={styles.Toolbar}>
@ -63,27 +63,27 @@ export default class Toolbar extends React.Component {
<ToolbarButton label="Bold" icon="bold" action={onBold}/> <ToolbarButton label="Bold" icon="bold" action={onBold}/>
<ToolbarButton label="Italic" icon="italic" action={onItalic}/> <ToolbarButton label="Italic" icon="italic" action={onItalic}/>
<ToolbarButton label="Link" icon="link" action={onLink}/> <ToolbarButton label="Link" icon="link" action={onLink}/>
<div className={styles.Toggle}>
<ToolbarButton label="Toggle Markdown" action={onToggleMode} active={rawMode}/>
</div>
{plugins.map(plugin => ( {plugins.map(plugin => (
<ToolbarButton <ToolbarButton
key={`plugin-${plugin.get('id')}`} key={`plugin-${plugin.get('id')}`}
label={plugin.get('label')} label={plugin.get('label')}
icon={plugin.get('icon')} icon={plugin.get('icon')}
action={this.handlePlugin(plugin)} action={this.handlePluginFormDisplay(plugin)}
/> />
))} ))}
{openPlugin && {activePlugin &&
<ToolbarPluginForm <ToolbarPluginForm
plugin={openPlugin} plugin={activePlugin}
onSubmit={this.handleSubmit} onSubmit={this.handlePluginFormSubmit}
onCancel={this.handleCancel} onCancel={this.handlePluginFormCancel}
onAddAsset={onAddAsset} onAddAsset={onAddAsset}
onRemoveAsset={onRemoveAsset} onRemoveAsset={onRemoveAsset}
getAsset={getAsset} getAsset={getAsset}
/> />
} }
<div className={styles.Toggle}>
<ToolbarButton label="Toggle Markdown" action={onToggleMode} active={rawMode}/>
</div>
</div> </div>
); );
} }