Skip to content

Commit a6bba88

Browse files
authored
Merge pull request #10 from KevinBatdorf/add-viewbox-offset
Add viewbox fine tuning
2 parents 43700e2 + f14bee1 commit a6bba88

File tree

6 files changed

+31
-8
lines changed

6 files changed

+31
-8
lines changed

block.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
"type": "string",
5454
"default": "smooth"
5555
},
56+
"viewBoxOffset": {
57+
"type": "number",
58+
"default": 0
59+
},
5660
"align": {
5761
"type": "string",
5862
"default": "full"

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Contributors: kbat82
33
Tags: hr, waves, divider, block, wavy, separator, svg, gradient
44
Tested up to: 6.4
5-
Stable tag: 1.5.0
5+
Stable tag: 1.6.0
66
License: GPL-2.0-or-later
77
License URI: https://www.gnu.org/licenses/gpl-2.0.html
88

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

5656
== Changelog ==
5757

58+
= 1.6.0 =
59+
- Feature: Add viewBox fine tuning to fix instances where a tiny pixel gap my appear
60+
5861
= 1.5.0 =
5962
- Feature: Center wave when only 1 point is selected and is smooth
6063

src/Controls.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import {
2121
import { dice } from './icons'
2222

2323
export const Controls = ({ attributes, setAttributes }) => {
24-
const { points, smoothness, startingPeak, opacity, height } = attributes
24+
const { points, smoothness, startingPeak, opacity, height, viewBoxOffset } =
25+
attributes
2526
const showCenteredCurve = points === 1 && smoothness === 'smooth'
2627
return (
2728
<InspectorControls>
@@ -81,6 +82,20 @@ export const Controls = ({ attributes, setAttributes }) => {
8182
value={opacity}
8283
onChange={(opacity) => setAttributes({ opacity })}
8384
/>
85+
<RangeControl
86+
label={__('ViewBox offset', 'wavy-divider')}
87+
help={__(
88+
'Adjust the svg viewBox value to account for tiny pixel offsets.',
89+
'wavy-divider',
90+
)}
91+
step={1}
92+
min={-5}
93+
max={5}
94+
value={attributes.viewBoxOffset || 0}
95+
onChange={(viewBoxOffset) => {
96+
setAttributes({ viewBoxOffset })
97+
}}
98+
/>
8499
</BaseControl>
85100
<InfoTip />
86101
</PanelBody>

src/Wave.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const Wave = ({
77
opacity,
88
path,
99
fill,
10+
viewBoxOffset = 0,
1011
}) => {
1112
// Fill is passed in only for the example currently
1213
if (!fill) {
@@ -20,7 +21,7 @@ export const Wave = ({
2021
<svg
2122
fill="none"
2223
role="separator"
23-
viewBox={`0 0 100 ${height}`}
24+
viewBox={`0 0 100 ${height + viewBoxOffset}`}
2425
preserveAspectRatio="none"
2526
aria-orientation="horizontal"
2627
aria-hidden={true}
@@ -29,8 +30,7 @@ export const Wave = ({
2930
height: `${height}px`,
3031
width: '100%',
3132
display: 'block',
32-
}}
33-
>
33+
}}>
3434
<path
3535
style={{ transition: 'all .5s ease', opacity }}
3636
fill={fill}
@@ -47,4 +47,5 @@ Wave.propTypes = {
4747
opacity: PropTypes.number,
4848
path: PropTypes.string,
4949
fill: PropTypes.string,
50+
viewBoxOffset: PropTypes.number,
5051
}

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ registerBlockType('wavy/wavy-divider', {
1818
opacity: 1,
1919
height: 200,
2020
fill: '#bbbbbb',
21-
path:
22-
'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',
21+
viewBoxOffset: 0,
22+
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',
2323
},
2424
},
2525
edit: ({ attributes, setAttributes }) => {

wavy-divider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Description: A creative, fun, lightweight wavy svg divider block to energize your website with character and pizazz
55
* Requires at least: 5.8
66
* Requires PHP: 7.0
7-
* Version: 1.5.0
7+
* Version: 1.6.0
88
* Author: Kevin Batdorf
99
* License: GPL-2.0-or-later
1010
* License URI: https://www.gnu.org/licenses/gpl-2.0.html

0 commit comments

Comments
 (0)