Skip to content

Commit

Permalink
Make the vertical align button work, add more styling options for too…
Browse files Browse the repository at this point in the history
…lbar buttons
  • Loading branch information
Tug committed Aug 6, 2019
1 parent ad467de commit bc94b51
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
4 changes: 3 additions & 1 deletion packages/block-library/src/media-text/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ class MediaTextEdit extends Component {
const containerStyles = {
...styles[ 'wp-block-media-text' ],
...styles[ `is-vertically-aligned-${ verticalAlignment }` ],
...( isStackedOnMobile ? styles[ 'is-stacked-on-mobile' ] : {} ),
...( mediaPosition === 'right' ? styles[ 'has-media-on-the-right' ] : {} ),
...( isStackedOnMobile ? styles[ 'is-stacked-on-mobile' ] : {} ),
...( isStackedOnMobile && mediaPosition === 'right' ? styles[ 'is-stacked-on-mobile.has-media-on-the-right' ] : {} ),
backgroundColor: backgroundColor.color,
};
const innerBlockWidth = 100 - temporaryMediaWidth;
Expand Down Expand Up @@ -162,6 +163,7 @@ class MediaTextEdit extends Component {
<BlockVerticalAlignmentToolbar
onChange={ onVerticalAlignmentChange }
value={ verticalAlignment }
isCollapsed={ false }
/>
</BlockControls>
<View style={ containerStyles }>
Expand Down
27 changes: 9 additions & 18 deletions packages/block-library/src/media-text/style.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@
display: flex;
align-items: flex-start;
flex-direction: row;
}

.has-media-on-the-right {
flex-direction: row-reverse;
}

.is-stacked-on-mobile {
flex-direction: column;

&.has-media-on-the-right {
flex-direction: row-reverse;
flex-direction: column-reverse;
}
}

Expand All @@ -19,20 +27,3 @@
.is-vertically-aligned-bottom {
align-items: flex-end;
}

/*
* Here we here not able to use a mobile first CSS approach.
* Custom widths are set using inline styles, and on mobile,
* we need 100% width, so we use important to overwrite the inline style.
* If the style were set on mobile first, on desktop styles,
* we would have no way of setting the style again to the inline style.
*/
@media (max-width: #{ ($break-small) }) {
.wp-block-media-text.is-stacked-on-mobile {
flex-direction: column;
}

.wp-block-media-text.is-stacked-on-mobile.has-media-on-the-right {
flex-direction: column-reverse;
}
}
6 changes: 3 additions & 3 deletions packages/components/src/icon-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import classnames from 'classnames';
import { isArray, isString } from 'lodash';
import { isArray } from 'lodash';

/**
* WordPress dependencies
Expand All @@ -14,7 +14,7 @@ import { forwardRef } from '@wordpress/element';
*/
import Tooltip from '../tooltip';
import Button from '../button';
import Dashicon from '../dashicon';
import Icon from '../icon';

function IconButton( props, ref ) {
const {
Expand Down Expand Up @@ -56,7 +56,7 @@ function IconButton( props, ref ) {
className={ classes }
ref={ ref }
>
{ isString( icon ) ? <Dashicon icon={ icon } ariaPressed={ ariaPressed } /> : icon }
<Icon icon={ icon } ariaPressed={ ariaPressed } className={ classes } />
{ children }
</Button>
);
Expand Down
4 changes: 4 additions & 0 deletions packages/components/src/icon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ function Icon( { icon = null, size, ...additionalProps } ) {
return <Dashicon icon={ icon } size={ iconSize } { ...additionalProps } />;
}

if ( Dashicon === icon.type ) {
return icon;
}

// Any other icons should be 24x24 by default
iconSize = size || 24;

Expand Down
6 changes: 4 additions & 2 deletions packages/components/src/primitives/svg/style.native.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
.dashicon {
.dashicon,
.components-toolbar__control {
color: #7b9ab1;
fill: currentColor;
}

.dashicon-active {
.dashicon-active,
.is-active {
color: #fff;
fill: currentColor;
}
Expand Down

0 comments on commit bc94b51

Please sign in to comment.