From a6f992ce5b6f1665663e77aa0f28827eb1f90687 Mon Sep 17 00:00:00 2001 From: Tyler Long Date: Tue, 12 Sep 2017 22:54:50 +0800 Subject: [PATCH] Allow user to configure theme --- dist/index.html | 2 +- package.json | 2 +- src/mermaidAPI.js | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/dist/index.html b/dist/index.html index 2f9c9c031..efb911731 100644 --- a/dist/index.html +++ b/dist/index.html @@ -99,7 +99,7 @@ Class08 <--> C2: Cool label diff --git a/package.json b/package.json index 4b07b7452..698e488f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mermaid", - "version": "7.0.15", + "version": "7.0.16", "description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.", "main": "dist/mermaid.core.js", "keywords": [ diff --git a/src/mermaidAPI.js b/src/mermaidAPI.js index ba3056618..3d1b75b1f 100644 --- a/src/mermaidAPI.js +++ b/src/mermaidAPI.js @@ -35,7 +35,18 @@ import gitGraphAst from './diagrams/gitGraph/gitGraphAst' import d3 from './d3' import pkg from '../package.json' +import darkStyle from './less/dark/mermaid.less' +import defaultStyle from './less/default/mermaid.less' import forestStyle from './less/forest/mermaid.less' +import neutralStyle from './less/neutral/mermaid.less' + +const themes = { + dark: darkStyle, + default: defaultStyle, + forest: forestStyle, + neutral: neutralStyle +} +const defaultTheme = forestStyle /** * ## Configuration @@ -49,6 +60,8 @@ import forestStyle from './less/forest/mermaid.less' * ``` */ var config = { + theme: defaultTheme, + /** * logLevel , decides the amount of logging to be used. * * debug: 1 @@ -425,7 +438,7 @@ var render = function (id, txt, cb, container) { // insert inline style into svg const svg = element.firstChild const s = document.createElement('style') - s.innerHTML = forestStyle + s.innerHTML = themes[config.theme] || defaultTheme svg.insertBefore(s, svg.firstChild) d3.select('#d' + id).selectAll('foreignobject div').attr('xmlns', 'http://www.w3.org/1999/xhtml')