Skip to content

Commit

Permalink
fix(regions): Fix applying regions class
Browse files Browse the repository at this point in the history
update ".bb-region rect" rule to not interfere applying
regions.class rule

Fix naver#3611
  • Loading branch information
netil authored Jan 23, 2024
1 parent a52dba3 commit 7e4fa71
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/module/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,12 +477,12 @@ const toArray = (v: CSSStyleDeclaration | any): any => [].slice.call(v);
* @private
*/
function addCssRules(style, selector: string, prop: string[]): number {
const {rootSelctor, sheet} = style;
const {rootSelector = "", sheet} = style;
const getSelector = s => s
.replace(/\s?(bb-)/g, ".$1")
.replace(/\.+/g, ".");

const rule = `${rootSelctor} ${getSelector(selector)} {${prop.join(";")}}`;
const rule = `${rootSelector} ${getSelector(selector)} {${prop.join(";")}}`;

return sheet[sheet.insertRule ? "insertRule" : "addRule"](
rule,
Expand Down
3 changes: 2 additions & 1 deletion src/scss/billboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@
}
/*-- Region --*/
.bb-region {
fill: steelblue;

rect {
fill: steelblue;
fill-opacity: .1;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/scss/theme/dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ rect.bb-circle, use.bb-circle {

/*-- Region --*/
.bb-region {
fill: steelblue;

rect {
fill: steelblue;
fill-opacity: 0.5;
}

Expand Down
3 changes: 2 additions & 1 deletion src/scss/theme/datalab.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ $text-font-size: 11px;

/*-- Region --*/
.bb-region {
fill: steelblue;

rect {
fill: steelblue;
fill-opacity: 0.1;
}

Expand Down
3 changes: 2 additions & 1 deletion src/scss/theme/graph.scss
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ rect.bb-circle, use.bb-circle {

/*-- Region --*/
.bb-region {
fill: steelblue;

rect {
fill: steelblue;
fill-opacity: 0.1;
}

Expand Down
3 changes: 2 additions & 1 deletion src/scss/theme/insight.scss
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,9 @@ rect.bb-circle, use.bb-circle {

/*-- Region --*/
.bb-region {
fill: steelblue;

rect {
fill: steelblue;
fill-opacity: 0.1;
}

Expand Down
3 changes: 2 additions & 1 deletion src/scss/theme/modern.scss
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,9 @@ rect.bb-circle, use.bb-circle {

/*-- Region --*/
.bb-region {
fill: #71808d;

rect {
fill: #71808d;
fill-opacity: 0.1;
}

Expand Down
4 changes: 4 additions & 0 deletions test/assets/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
align-items: center;
justify-content: center;
}

.regions_class1{
fill: red;
}
10 changes: 9 additions & 1 deletion test/internals/rergions-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
/* eslint-disable */
import {expect} from "chai";
import {window} from "../../src/module/browser";
import util from "../assets/util";

// exported to be used from /test/api/region-spec.ts
Expand Down Expand Up @@ -131,13 +132,20 @@ describe("REGIONS", function() {
const {$el, scale} = chart.internal;

setTimeout(() => {
$el.region.list.each(function(d) {
$el.region.list.each(function(d, i) {
const axis = scale[d.axis];
const isX = d.axis === "x";
const rect = this.querySelector("rect");
const start = +rect.getAttribute(isX ? "x" : "y");
const size = +rect.getAttribute(isX ? "width" : "height");

// first <rect> should apply .regions_class1 rule
if (i === 0) {
const {fill} = window.getComputedStyle(this.querySelector("rect"));

expect(fill).to.be.equal("rgb(255, 0, 0)");
}

// check the diemsion
expect(start).to.be.equal(axis(isX ? d.start : d.end));
expect(start + size).to.be.equal(axis(isX ? d.end : d.start));
Expand Down

0 comments on commit 7e4fa71

Please sign in to comment.