Skip to content

Commit

Permalink
fix(labeler/segmentlabel): Add border color, radius, width params.
Browse files Browse the repository at this point in the history
  • Loading branch information
binh-dam-ibigroup committed Apr 16, 2021
1 parent f59fca7 commit 84520ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/labeler/segmentlabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default class SegmentLabel extends Label {
if (!text) return null
const x = this.labelAnchor.x - this.containerWidth / 2
const y = this.labelAnchor.y - this.containerHeight / 2
const borderRadius = display.styler.compute2('segment_labels', 'border-radius', this.parent)
// Draw rounded rectangle for label.
display.drawRect({
x,
Expand All @@ -26,8 +27,10 @@ export default class SegmentLabel extends Label {
fill: display.styler.compute2('segment_labels', 'background', this.parent),
width: this.containerWidth,
height: this.containerHeight,
rx: this.containerHeight / 2,
ry: this.containerHeight / 2
rx: Math.min(borderRadius, this.containerHeight / 2),
ry: Math.min(borderRadius, this.containerHeight / 2),
stroke: display.styler.compute2('segment_labels', 'border-color', this.parent),
'stroke-width': display.styler.compute2('segment_labels', 'border-width', this.parent)
})

const fontSize = display.styler.compute2('segment_labels', 'font-size', this.parent)
Expand Down
3 changes: 3 additions & 0 deletions stories/Transitive.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ ItineraryWithAlternativeStyling.args = {
"font-family": "serif"
},
segment_labels: {
"border-color": "#FF0000",
"border-radius": 6,
"border-width": 3,
color: "#FFDD00",
"font-size": "24px"
}
Expand Down

0 comments on commit 84520ba

Please sign in to comment.