Skip to content

Commit

Permalink
allow corner radius for rectangle spotlight & update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonykoerber committed May 11, 2016
1 parent f9e0973 commit 6c5f9ad
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
22 changes: 15 additions & 7 deletions src/strand-guide-canvas/strand-guide-canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@
ctx.restore();
}

function drawRectangle(ctx, x, y, w, h, style) {
function drawRectangle(ctx, x, y, w, h, r, style) {
if (w < 2 * r) r = w / 2;
if (h < 2 * r) r = h / 2;

ctx.save();
ctx.fillRect(x, y, w, h);
if(style)
ctx.strokeStyle = style;
ctx.stroke();
ctx.beginPath();
ctx.moveTo(x+r, y);
ctx.arcTo(x+w, y, x+w, y+h, r);
ctx.arcTo(x+w, y+h, x, y+h, r);
ctx.arcTo(x, y+h, x, y, r);
ctx.arcTo(x, y, x+w, y, r);
ctx.closePath();
ctx.restore();
}

Expand Down Expand Up @@ -54,7 +60,8 @@
observer: '_currentStepChanged'
},
spotlightType: String,
spotlightOffset: Number
spotlightOffset: Number,
cornerRadius: Number
},

resize: function() {
Expand Down Expand Up @@ -106,7 +113,8 @@
rect.x - this.spotlightOffset,
rect.y - this.spotlightOffset,
rect.width + this.spotlightOffset*2,
rect.height + this.spotlightOffset*2
rect.height + this.spotlightOffset*2,
this.cornerRadius
);
}

Expand Down
10 changes: 9 additions & 1 deletion src/strand-guide/doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"type":"String",
"description":"Instructs the component to draw it's 'spotlight' mask as either a circle or ellipse around the desired target.",
"optional":true,
"options":["circle", "ellipse"],
"options":["circle", "rectangle"],
"default":"circle",
"attribute":"spotlight-type"
},
Expand All @@ -94,6 +94,14 @@
"default":"10",
"attribute":"spotlight-offset"
},
{
"name":"cornerRadius",
"type":"Number",
"description":"If spotlightType is set to 'rectangle', instructs the component to draw it's 'spotlight' mask with a a corner radius of the specified number, in pixels (only if 'showFocus' is true - see: 'showFocus').",
"optional":true,
"default":"5",
"attribute":"corner-radius"
},
{
"name":"data",
"type":"Array",
Expand Down
1 change: 1 addition & 0 deletions src/strand-guide/strand-guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
hidden="{{hidden}}"
spotlight-offset="{{spotlightOffset}}"
spotlight-type="{{spotlightType}}"
corner-Radius="{{cornerRadius}}"
opacity="{{opacity}}"
data="{{_tooltipData}}"
current-step="{{_currentStep}}"></strand-guide-canvas>
Expand Down
4 changes: 4 additions & 0 deletions src/strand-guide/strand-guide.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
type: Number,
value: 10
},
cornerRadius: {
type: Number,
value: 5
},
_currentStep: {
type: Number,
notify: true
Expand Down

0 comments on commit 6c5f9ad

Please sign in to comment.