Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add heading level and alignment to inspector #1383

Merged
merged 4 commits into from
Jun 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
35 changes: 31 additions & 4 deletions blocks/library/heading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { isString, isObject } from 'lodash';
*/
import { __, sprintf } from 'i18n';
import { concatChildren } from 'element';
import { Toolbar } from 'components';

/**
* Internal dependencies
Expand All @@ -16,6 +17,8 @@ import './style.scss';
import { registerBlockType, createBlock, query } from '../../api';
import Editable from '../../editable';
import BlockControls from '../../block-controls';
import InspectorControls from '../../inspector-controls';
import AlignmentToolbar from '../../alignment-toolbar';

const { children, prop } = query;

Expand Down Expand Up @@ -86,14 +89,14 @@ registerBlockType( 'core/heading', {
},

edit( { attributes, setAttributes, focus, setFocus, mergeBlocks, insertBlockAfter } ) {
const { content, nodeName = 'H2' } = attributes;
const { align, content, nodeName = 'H2' } = attributes;

return [
focus && (
<BlockControls
key="controls"
controls={
'123456'.split( '' ).map( ( level ) => ( {
'234'.split( '' ).map( ( level ) => ( {
icon: 'heading',
title: sprintf( __( 'Heading %s' ), level ),
isActive: 'H' + level === nodeName,
Expand All @@ -103,6 +106,29 @@ registerBlockType( 'core/heading', {
}
/>
),
focus && (
<InspectorControls key="inspector">
<h3>{ __( 'Heading Size' ) }</h3>
<Toolbar
controls={
'123456'.split( '' ).map( ( level ) => ( {
icon: 'heading',
title: sprintf( __( 'Heading %s' ), level ),
isActive: 'H' + level === nodeName,
onClick: () => setAttributes( { nodeName: 'H' + level } ),
subscript: level,
} ) )
}
/>
<h3>{ __( 'Text Alignment' ) }</h3>
<AlignmentToolbar
value={ align }
onChange={ ( nextAlign ) => {
setAttributes( { align: nextAlign } );
} }
/>
</InspectorControls>
),
<Editable
key="editable"
tagName={ nodeName.toLowerCase() }
Expand All @@ -118,16 +144,17 @@ registerBlockType( 'core/heading', {
content: after,
} ) );
} }
style={ { textAlign: align } }
/>,
];
},

save( { attributes } ) {
const { nodeName = 'H2', content } = attributes;
const { align, nodeName = 'H2', content } = attributes;
const Tag = nodeName.toLowerCase();

return (
<Tag>
<Tag style={ { textAlign: align } } >
{ content }
</Tag>
);
Expand Down
4 changes: 2 additions & 2 deletions components/panel/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}

.components-panel__body {
padding: 15px;
padding: $panel-padding;
border-top: 1px solid $light-gray-500;
border-bottom: 1px solid $light-gray-500;
}
Expand All @@ -28,7 +28,7 @@
justify-content: space-between;
align-items: center;
background: $light-gray-300;
padding: 0 15px;
padding: 0 $panel-padding;
height: 50px;
border-top: 1px solid $light-gray-500;
border-bottom: 1px solid $light-gray-500;
Expand Down
4 changes: 2 additions & 2 deletions components/toolbar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
border: 1px solid $light-gray-500;
box-shadow: $shadow-popover;
background-color: $white;
display: inline-flex;
}

.editor-visual-editor__block-controls ul.components-toolbar,
.block-editable__inline-toolbar ul.components-toolbar {
ul.components-toolbar {
list-style-type: none;

&> li {
Expand Down
Binary file added docs/.DS_Store
Binary file not shown.
Binary file added docs/tinymce-single-react-ui/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions editor/assets/stylesheets/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ $text-editor-font-size: 14px;
$editor-line-height: 1.8;
$big-font-size: 18px;
$item-spacing: 10px;
$panel-padding: 16px;
$header-height: 56px;
$sidebar-width: 280px;
$admin-bar-height: 32px;
Expand Down
1 change: 0 additions & 1 deletion editor/modes/visual-editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ $sticky-bottom-offset: 20px;
}

.editor-visual-editor__block-controls .components-toolbar {
display: inline-flex;
margin-right: -1px;

@include break-small() {
Expand Down
4 changes: 2 additions & 2 deletions editor/sidebar/post-taxonomies/style.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.editor-post-taxonomies__tags-selector,
.editor-post-taxonomies__categories-selector {
margin-top: 15px;
margin-top: $panel-padding;
}

.editor-post-taxonomies__tags-selector-title,
Expand All @@ -19,5 +19,5 @@

.editor-post-taxonomies__categories-subchoices {
margin-top: 5px;
margin-left: 15px;
margin-left: $panel-padding;
}
11 changes: 11 additions & 0 deletions editor/sidebar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@
margin-bottom: -1px;
}
}

h3 {
font-size: $default-font-size;
margin-top: 0;
margin-bottom: .5em;
}

ul.components-toolbar {
box-shadow: none;
margin-bottom: $panel-padding;
}
}

/* Visual and Text editor both */
Expand Down