Skip to content

Commit

Permalink
Add viewbox fine tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBatdorf committed Nov 18, 2023
1 parent 43700e2 commit f14bee1
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
4 changes: 4 additions & 0 deletions block.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
"type": "string",
"default": "smooth"
},
"viewBoxOffset": {
"type": "number",
"default": 0
},
"align": {
"type": "string",
"default": "full"
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Contributors: kbat82
Tags: hr, waves, divider, block, wavy, separator, svg, gradient
Tested up to: 6.4
Stable tag: 1.5.0
Stable tag: 1.6.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -55,6 +55,9 @@ Within the block inserter, under the Patterns tab, select 'Wavy Divider' from th

== Changelog ==

= 1.6.0 =
- Feature: Add viewBox fine tuning to fix instances where a tiny pixel gap my appear

= 1.5.0 =
- Feature: Center wave when only 1 point is selected and is smooth

Expand Down
17 changes: 16 additions & 1 deletion src/Controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import {
import { dice } from './icons'

export const Controls = ({ attributes, setAttributes }) => {
const { points, smoothness, startingPeak, opacity, height } = attributes
const { points, smoothness, startingPeak, opacity, height, viewBoxOffset } =
attributes
const showCenteredCurve = points === 1 && smoothness === 'smooth'
return (
<InspectorControls>
Expand Down Expand Up @@ -81,6 +82,20 @@ export const Controls = ({ attributes, setAttributes }) => {
value={opacity}
onChange={(opacity) => setAttributes({ opacity })}
/>
<RangeControl
label={__('ViewBox offset', 'wavy-divider')}
help={__(
'Adjust the svg viewBox value to account for tiny pixel offsets.',
'wavy-divider',
)}
step={1}
min={-5}
max={5}
value={attributes.viewBoxOffset || 0}
onChange={(viewBoxOffset) => {
setAttributes({ viewBoxOffset })
}}
/>
</BaseControl>
<InfoTip />
</PanelBody>
Expand Down
7 changes: 4 additions & 3 deletions src/Wave.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const Wave = ({
opacity,
path,
fill,
viewBoxOffset = 0,
}) => {
// Fill is passed in only for the example currently
if (!fill) {
Expand All @@ -20,7 +21,7 @@ export const Wave = ({
<svg
fill="none"
role="separator"
viewBox={`0 0 100 ${height}`}
viewBox={`0 0 100 ${height + viewBoxOffset}`}
preserveAspectRatio="none"
aria-orientation="horizontal"
aria-hidden={true}
Expand All @@ -29,8 +30,7 @@ export const Wave = ({
height: `${height}px`,
width: '100%',
display: 'block',
}}
>
}}>
<path
style={{ transition: 'all .5s ease', opacity }}
fill={fill}
Expand All @@ -47,4 +47,5 @@ Wave.propTypes = {
opacity: PropTypes.number,
path: PropTypes.string,
fill: PropTypes.string,
viewBoxOffset: PropTypes.number,
}
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ registerBlockType('wavy/wavy-divider', {
opacity: 1,
height: 200,
fill: '#bbbbbb',
path:
'M 0,180 S 21,138 28,87 S 46,141 53,144 S 71,141 78,141 S 96,162 100,198 V 300 H 0 Z',
viewBoxOffset: 0,
path: 'M 0,180 S 21,138 28,87 S 46,141 53,144 S 71,141 78,141 S 96,162 100,198 V 300 H 0 Z',
},
},
edit: ({ attributes, setAttributes }) => {
Expand Down
2 changes: 1 addition & 1 deletion wavy-divider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: A creative, fun, lightweight wavy svg divider block to energize your website with character and pizazz
* Requires at least: 5.8
* Requires PHP: 7.0
* Version: 1.5.0
* Version: 1.6.0
* Author: Kevin Batdorf
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down

0 comments on commit f14bee1

Please sign in to comment.