Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass css_classes as option to render function #472

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/render/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as clades from "./clades";
import * as render_nodes from "./nodes";
import * as render_edges from "./edges";
import * as events from "./events";
import { css_classes } from "./options";
import { css_classes, initializeCssClasses } from "./options";
import * as opt from "./options";
import * as menus from "./menus";

Expand All @@ -22,6 +22,7 @@ function constant(x) {

class TreeRender {
constructor(phylotree, options = {}) {
initializeCssClasses(options['css-classes']);
this.css_classes = css_classes;
this.phylotree = phylotree;
this.container = options.container;
Expand Down
6 changes: 6 additions & 0 deletions src/render/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export const css_classes = {
node_text: "phylotree-node-text"
};

export function initializeCssClasses(classes = {}) {
Object.keys(classes).forEach(key => {
css_classes[key] = classes[key]
})
}

export function internalNames(attr) {
if (!arguments.length) return this.options["internal-names"];
this.options["internal-names"] = attr;
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4252,4 +4252,4 @@ yargs@^16.2.0:
yarn@^1.22.11:
version "1.22.18"
resolved "https://registry.yarnpkg.com/yarn/-/yarn-1.22.18.tgz#05b822ade8c672987bab8858635145da0850f78a"
integrity sha512-oFffv6Jp2+BTUBItzx1Z0dpikTX+raRdqupfqzeMKnoh7WD6RuPAxcqDkMUy9vafJkrB0YaV708znpuMhEBKGQ==
integrity sha512-oFffv6Jp2+BTUBItzx1Z0dpikTX+raRdqupfqzeMKnoh7WD6RuPAxcqDkMUy9vafJkrB0YaV708znpuMhEBKGQ==