Skip to content

Commit

Permalink
Components: Fix the icon button level prop (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Apr 18, 2017
1 parent aa7fc94 commit 3d9b30f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions blocks/library/heading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ registerBlock( 'core/heading', {
controls: [
...'123456'.split( '' ).map( ( level ) => ( {
icon: 'heading',
text: level,
title: wp.i18n.sprintf( wp.i18n.__( 'Heading %s' ), level ),
isActive: ( { tag } ) => 'H' + level === tag,
onClick( attributes, setAttributes ) {
setAttributes( { tag: 'H' + level } );
}
},
level
} ) )
],

Expand Down
3 changes: 2 additions & 1 deletion editor/components/icon-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ function IconButton( { icon, children, label, className, ...additionalProps } )
const classes = classnames( 'editor-icon-button', className );

return (
<Button { ...additionalProps } aria-label={ label } className={ classes } data-level={ children ? children : null }>
<Button { ...additionalProps } aria-label={ label } className={ classes }>
<Dashicon icon={ icon } />
{ children }
</Button>
);
}
Expand Down
10 changes: 0 additions & 10 deletions editor/components/icon-button/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,4 @@
color: $blue-medium;
}
}

&:after {
content: attr( data-level );
font-family: $default-font;
font-size: 10px;
font-weight: bold;
position: absolute;
bottom: 8px;
right: 4px;
}
}
5 changes: 2 additions & 3 deletions editor/components/toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ function Toolbar( { controls } ) {
key={ index }
icon={ control.icon }
label={ control.title }
data-level={ control.level }
onClick={ ( event ) => {
event.stopPropagation();
control.onClick();
} }
className={ classNames( 'editor-toolbar__control', {
'is-active': control.isActive && control.isActive()
} ) }>
{ control.text }
</IconButton>
} ) } />
) ) }
</ul>
);
Expand Down
10 changes: 10 additions & 0 deletions editor/components/toolbar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
background-color: $dark-gray-500;
color: $white;
}

&[data-level]:after {
content: attr( data-level );
font-family: $default-font;
font-size: 10px;
font-weight: bold;
position: absolute;
bottom: 8px;
right: 5px;
}
}

.editor-toolbar__control .dashicon {
Expand Down
2 changes: 1 addition & 1 deletion languages/gutenberg.pot
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ msgstr ""
msgid "Heading"
msgstr ""

#: blocks/library/heading/index.js:26
#: blocks/library/heading/index.js:25
msgid "Heading %s"
msgstr ""

Expand Down

0 comments on commit 3d9b30f

Please sign in to comment.