Skip to content

Commit

Permalink
Merge pull request #50 from jboeijenga/main
Browse files Browse the repository at this point in the history
feat(): Added default Mermaid theme when backstage theme variant is dark
  • Loading branch information
johanneswuerbach authored May 23, 2024
2 parents 87c0c75 + 7c02e68 commit 91426d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Mermaid/Mermaid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('Mermaid', () => {
describe('selectConfig', () => {
const legacyConfig = { config: { fontFamily: 'legacy-config' } };
const lightConfig = { lightConfig: { fontFamily: 'light-config' } };
const darkConfig = { darkConfig: { fontFamily: 'dark-config' } };
const darkConfig = { darkConfig: { fontFamily: 'dark-config', theme: 'dark' } };

it('legacy config is preferred for backwards-compatibility', () => {
let config = selectConfig('light', { ...legacyConfig });
Expand All @@ -97,5 +97,10 @@ describe('Mermaid', () => {
const config = selectConfig('dark', { ...lightConfig, ...darkConfig });
expect(config).toEqual(darkConfig.darkConfig);
});

it('dark theme is set by default when variant is dark', () => {
const config = selectConfig('dark', {});
expect(config).toEqual({ theme: 'dark'});
});
});
});
2 changes: 1 addition & 1 deletion src/Mermaid/Mermaid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function selectConfig(backstagePalette: PaletteType, properties: MermaidP
return properties.lightConfig || {};
}

return properties.darkConfig || {};
return Object.assign({ theme: 'dark' }, properties.darkConfig);
}

/**
Expand Down

0 comments on commit 91426d0

Please sign in to comment.