-
Notifications
You must be signed in to change notification settings - Fork 808
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
Tiled gallery: rounded corners #14704
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
*/ | ||
import { __, sprintf } from '@wordpress/i18n'; | ||
import { Component } from '@wordpress/element'; | ||
import classnames from 'classnames'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed that this doesn't end up to built bundle meant for frontend |
||
|
||
/** | ||
* Internal dependencies | ||
|
@@ -12,6 +13,7 @@ import GalleryImageSave from '../gallery-image/save'; | |
import Mosaic from './mosaic'; | ||
import Square from './square'; | ||
import { isSquareishLayout, photonizedImgProps } from '../utils'; | ||
import { LAYOUT_CIRCLE, MAX_ROUNDED_CORNERS } from '../constants'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed that this doesn't pull in |
||
|
||
export default class Layout extends Component { | ||
// This is tricky: | ||
|
@@ -73,14 +75,18 @@ export default class Layout extends Component { | |
} | ||
|
||
render() { | ||
const { align, children, className, columns, images, layoutStyle } = this.props; | ||
|
||
const { align, children, className, columns, images, layoutStyle, roundedCorners } = this.props; | ||
const LayoutRenderer = isSquareishLayout( layoutStyle ) ? Square : Mosaic; | ||
|
||
const renderedImages = this.props.images.map( this.renderImage, this ); | ||
const roundedCornersValue = | ||
layoutStyle !== LAYOUT_CIRCLE ? Math.min( roundedCorners, MAX_ROUNDED_CORNERS ) : 0; | ||
|
||
return ( | ||
<div className={ className }> | ||
<div | ||
className={ classnames( className, { | ||
[ `has-rounded-corners-${ roundedCornersValue }` ]: roundedCornersValue > 0, | ||
} ) } | ||
> | ||
<LayoutRenderer | ||
align={ align } | ||
columns={ columns } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
@import './css-gram.scss'; | ||
|
||
$tiled-gallery-max-column-count: 20; | ||
$tiled-gallery-max-rounded-corners: 20; // See constants.js for JS counterpart | ||
|
||
.wp-block-jetpack-tiled-gallery { | ||
margin: 0 auto $jetpack-block-margin-bottom; | ||
|
@@ -33,6 +34,12 @@ $tiled-gallery-max-column-count: 20; | |
display: flex; | ||
} | ||
} | ||
|
||
@for $i from 1 through $tiled-gallery-max-rounded-corners { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will generate 20 lines of CSS like this. Figured it's lightweight enough addition when limited to 20 or so. Alternatively (maybe in another PR) we can have this in a separate CSS file which we enqueue only when they have rounded corners Another alternative is to generate this in PHP for the exact number as inline CSS, allowing the setting to become unlimited instead of capped to 20. |
||
&.has-rounded-corners-#{$i} .tiled-gallery__item img { | ||
border-radius: #{$i}px; | ||
} | ||
} | ||
} | ||
|
||
.tiled-gallery__gallery { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
borderRadius
could be another name and match CSS rule, but figured this is more self-explanatory.