Skip to content

Commit e81b77f

Browse files
gerjanvangeestdaKmoR
authored andcommitted
fix(mdjs-preview): separate preview and viewer theme styling
1 parent 456b8e7 commit e81b77f

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

.changeset/purple-meals-count.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@mdjs/mdjs-preview': patch
3+
---
4+
5+
Change theme attribute into preview-theme attribute to separate theme styling of the preview section and the full mdjs viewer.

packages/mdjs-preview/src/MdJsPreview.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
6161
platforms: { type: Array },
6262
size: { type: String },
6363
sizes: { type: Array },
64-
theme: { type: String, reflect: true },
64+
previewTheme: { type: String, reflect: true, attribute: 'preview-theme' },
6565
themes: { type: Array },
6666
language: { type: String },
6767
languages: { type: Array },
@@ -82,7 +82,7 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
8282
this.__supportsClipboard = 'clipboard' in navigator;
8383
this.__copyButtonText = 'Copy Code';
8484

85-
this.theme = 'light';
85+
this.previewTheme = 'light';
8686
/** @type {{ key: string, name: string }[]} */
8787
this.themes = [
8888
// { key: 'light', name: 'Light' },
@@ -286,7 +286,7 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
286286
const params = new URLSearchParams();
287287
params.set('story-file', sanitize(mdjsSetupScript.src, 'js'));
288288
params.set('story-key', this.key);
289-
params.set('theme', this.theme);
289+
params.set('theme', this.previewTheme);
290290
params.set('platform', this.platform);
291291
params.set('language', this.language);
292292
params.set('edge-distance', this.edgeDistance.toString());
@@ -439,20 +439,20 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
439439
@change=${
440440
/** @param {Event} ev */ ev => {
441441
if (ev.target) {
442-
this.theme = /** @type {HTMLInputElement} */ (ev.target).value;
442+
this.previewTheme = /** @type {HTMLInputElement} */ (ev.target).value;
443443
}
444444
}
445445
}
446446
>
447447
${this.themes.map(
448-
theme => html`
449-
<label class="${this.theme === theme.key ? 'selected' : ''}">
450-
<span>${theme.name}</span>
448+
previewTheme => html`
449+
<label class="${this.previewTheme === previewTheme.key ? 'selected' : ''}">
450+
<span>${previewTheme.name}</span>
451451
<input
452452
type="radio"
453453
name="theme"
454-
value="${theme.key}"
455-
?checked=${this.theme === theme.key}
454+
value="${previewTheme.key}"
455+
?checked=${this.previewTheme === previewTheme.key}
456456
/>
457457
</label>
458458
`,

packages/mdjs-preview/src/mdjsViewerSharedStates.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const _sharedStates = {
22
platform: 'web',
33
size: 'webSmall',
4-
theme: 'light',
4+
previewTheme: 'light',
55
language: 'en',
66
autoHeight: true,
77
deviceMode: false,

0 commit comments

Comments
 (0)