mirror of
https://github.com/modernweb-dev/rocket.git
synced 2026-03-21 15:54:57 +00:00
Compare commits
16 Commits
@rocket/cl
...
@mdjs/mdjs
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5a1d7e8d1 | ||
|
|
74dd8d1bcc | ||
|
|
72f631ac86 | ||
|
|
fafb99b0fa | ||
|
|
f5769b9aa9 | ||
|
|
12d9cc3b44 | ||
|
|
ef9b373aa1 | ||
|
|
560234d663 | ||
|
|
024514e901 | ||
|
|
66c2d781e6 | ||
|
|
14721d1e0f | ||
|
|
0f6709ac4b | ||
|
|
ed86ff2346 | ||
|
|
c675820163 | ||
|
|
f4a0ab559f | ||
|
|
a8cdaebab1 |
@@ -1,5 +1,11 @@
|
|||||||
# check-html-links
|
# check-html-links
|
||||||
|
|
||||||
|
## 0.2.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 66c2d78: fix: windows path issue
|
||||||
|
|
||||||
## 0.2.1
|
## 0.2.1
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "check-html-links",
|
"name": "check-html-links",
|
||||||
"version": "0.2.1",
|
"version": "0.2.2",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { createRequire } from 'module';
|
|||||||
|
|
||||||
import { listFiles } from './listFiles.js';
|
import { listFiles } from './listFiles.js';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import slash from 'slash';
|
||||||
|
|
||||||
/** @typedef {import('../types/main').Link} Link */
|
/** @typedef {import('../types/main').Link} Link */
|
||||||
/** @typedef {import('../types/main').LocalFile} LocalFile */
|
/** @typedef {import('../types/main').LocalFile} LocalFile */
|
||||||
@@ -45,7 +46,7 @@ function extractReferences(htmlFilePath) {
|
|||||||
if (ev === SaxEventType.Attribute) {
|
if (ev === SaxEventType.Attribute) {
|
||||||
const data = /** @type {Attribute} */ (/** @type {any} */ (_data));
|
const data = /** @type {Attribute} */ (/** @type {any} */ (_data));
|
||||||
const attributeName = data.name.toString();
|
const attributeName = data.name.toString();
|
||||||
const value = data.value.toString();
|
const value = slash(data.value.toString());
|
||||||
const entry = {
|
const entry = {
|
||||||
attribute: attributeName,
|
attribute: attributeName,
|
||||||
value,
|
value,
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
# @rocket/cli
|
# @rocket/cli
|
||||||
|
|
||||||
|
## 0.6.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- ed86ff2: Do not set `data-localize-lang` in the simulator iframe html tag
|
||||||
|
- f4a0ab5: Pass document shadowRoot to iframe
|
||||||
|
- c675820: fix: windows path issue avoid filtering of index section of collections
|
||||||
|
|
||||||
## 0.6.1
|
## 0.6.1
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rocket/cli",
|
"name": "@rocket/cli",
|
||||||
"version": "0.6.1",
|
"version": "0.6.2",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -73,6 +73,7 @@
|
|||||||
"fs-extra": "^9.0.1",
|
"fs-extra": "^9.0.1",
|
||||||
"micromatch": "^4.0.2",
|
"micromatch": "^4.0.2",
|
||||||
"plugins-manager": "^0.2.1",
|
"plugins-manager": "^0.2.1",
|
||||||
|
"slash": "^3.0.0",
|
||||||
"utf8": "^3.0.0"
|
"utf8": "^3.0.0"
|
||||||
},
|
},
|
||||||
"types": "dist-types/index.d.ts"
|
"types": "dist-types/index.d.ts"
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
if (urlParts.get('language')) {
|
if (urlParts.get('language')) {
|
||||||
document.documentElement.setAttribute('lang', urlParts.get('language'));
|
document.documentElement.setAttribute('lang', urlParts.get('language'));
|
||||||
document.documentElement.setAttribute('data-lang', urlParts.get('language'));
|
document.documentElement.setAttribute('data-lang', urlParts.get('language'));
|
||||||
document.documentElement.setAttribute('data-localize-lang', urlParts.get('language'));
|
|
||||||
}
|
}
|
||||||
if (urlParts.get('story-key')) {
|
if (urlParts.get('story-key')) {
|
||||||
document.documentElement.setAttribute('story-key', urlParts.get('story-key'));
|
document.documentElement.setAttribute('story-key', urlParts.get('story-key'));
|
||||||
@@ -47,7 +46,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const mod = await import(urlParts.get('story-file'));
|
const mod = await import(urlParts.get('story-file'));
|
||||||
render(mod[urlParts.get('story-key')](), document.body);
|
render(mod[urlParts.get('story-key')]({ shadowRoot: document }), document.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('hashchange', onHashChange, false);
|
window.addEventListener('hashchange', onHashChange, false);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const slash = require('slash');
|
||||||
const { readdirSync } = require('fs');
|
const { readdirSync } = require('fs');
|
||||||
|
|
||||||
function getDirectories(source) {
|
function getDirectories(source) {
|
||||||
@@ -23,7 +24,7 @@ const rocketCollections = {
|
|||||||
let docs = [
|
let docs = [
|
||||||
...collection.getFilteredByGlob(`${_inputDirCwdRelative}/${section}/**/*.md`),
|
...collection.getFilteredByGlob(`${_inputDirCwdRelative}/${section}/**/*.md`),
|
||||||
];
|
];
|
||||||
docs = docs.filter(page => page.inputPath !== `./${indexSection}`);
|
docs = docs.filter(page => page.inputPath !== `./${slash(indexSection)}`);
|
||||||
|
|
||||||
return docs;
|
return docs;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
"preset"
|
"preset"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rocket/drawer": "^0.1.2",
|
"@rocket/drawer": "^0.1.3",
|
||||||
"@rocket/navigation": "^0.2.1"
|
"@rocket/navigation": "^0.2.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
"remark"
|
"remark"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mdjs/mdjs-preview": "^0.4.0",
|
"@mdjs/mdjs-preview": "^0.4.1",
|
||||||
"@mdjs/mdjs-story": "^0.2.0",
|
"@mdjs/mdjs-story": "^0.2.0",
|
||||||
"@types/unist": "^2.0.3",
|
"@types/unist": "^2.0.3",
|
||||||
"es-module-lexer": "^0.3.26",
|
"es-module-lexer": "^0.3.26",
|
||||||
|
|||||||
@@ -1,5 +1,19 @@
|
|||||||
# @mdjs/mdjs-preview
|
# @mdjs/mdjs-preview
|
||||||
|
|
||||||
|
## 0.4.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 72f631a: Improve customizations by hiding empty themes, platforms and adding parts to be styled.
|
||||||
|
- 74dd8d1: Autoheight will not grow bigger than the current size height
|
||||||
|
- 72f631a: Add a copy code button
|
||||||
|
|
||||||
|
## 0.4.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 0f6709a: Make sure initial settings are taken from the element if nothing is yet stored
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mdjs/mdjs-preview",
|
"name": "@mdjs/mdjs-preview",
|
||||||
"version": "0.4.0",
|
"version": "0.4.2",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ export class MdJsPreview extends LitElement {
|
|||||||
edgeDistance: { type: Boolean },
|
edgeDistance: { type: Boolean },
|
||||||
autoHeight: { type: Boolean },
|
autoHeight: { type: Boolean },
|
||||||
rememberSettings: { type: Boolean },
|
rememberSettings: { type: Boolean },
|
||||||
|
__copyButtonText: { type: String },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,18 +62,21 @@ export class MdJsPreview extends LitElement {
|
|||||||
this.key = '';
|
this.key = '';
|
||||||
this.contentHeight = 0;
|
this.contentHeight = 0;
|
||||||
this.simulatorUrl = '';
|
this.simulatorUrl = '';
|
||||||
|
this.__supportsClipboard = 'clipboard' in navigator;
|
||||||
|
this.__copyButtonText = 'Copy Code';
|
||||||
|
|
||||||
this.theme = 'light';
|
this.theme = 'light';
|
||||||
|
/** @type {{ key: string, name: string }[]} */
|
||||||
this.themes = [
|
this.themes = [
|
||||||
{ key: 'light', name: 'Light' },
|
// { key: 'light', name: 'Light' },
|
||||||
{ key: 'dark', name: 'Dark' },
|
// { key: 'dark', name: 'Dark' },
|
||||||
];
|
];
|
||||||
|
|
||||||
this.language = 'en-US';
|
this.language = 'en-US';
|
||||||
this.languages = [
|
this.languages = [
|
||||||
{ key: 'en', name: 'English' },
|
{ key: 'en', name: 'English' },
|
||||||
{ key: 'en-US', name: 'English (United States)' },
|
{ key: 'en-US', name: 'English (United States)' },
|
||||||
{ key: 'en-US', name: 'English (United Kingdom)' },
|
{ key: 'en-GB', name: 'English (United Kingdom)' },
|
||||||
{ key: 'de', name: 'German' },
|
{ key: 'de', name: 'German' },
|
||||||
{ key: 'es', name: 'Spanish' },
|
{ key: 'es', name: 'Spanish' },
|
||||||
{ key: 'fi', name: 'Finnish' },
|
{ key: 'fi', name: 'Finnish' },
|
||||||
@@ -83,16 +87,17 @@ export class MdJsPreview extends LitElement {
|
|||||||
{ key: 'pt', name: 'Portuguese' },
|
{ key: 'pt', name: 'Portuguese' },
|
||||||
{ key: 'ro', name: 'Romanian' },
|
{ key: 'ro', name: 'Romanian' },
|
||||||
{ key: 'sv', name: 'Swedish' },
|
{ key: 'sv', name: 'Swedish' },
|
||||||
{ key: 'sv', name: 'Swedish' },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
this.platform = 'web';
|
this.platform = 'web';
|
||||||
|
|
||||||
|
/** @type {{ key: string, name: string }[]} */
|
||||||
this.platforms = [
|
this.platforms = [
|
||||||
{ key: 'web', name: 'Web' },
|
// { key: 'web', name: 'Web' },
|
||||||
// { key: 'web-windows', name: 'Windows' },
|
// { key: 'web-windows', name: 'Windows' },
|
||||||
// { key: 'web-mac', name: 'Mac' },
|
// { key: 'web-mac', name: 'Mac' },
|
||||||
{ key: 'android', name: 'Android' },
|
// { key: 'android', name: 'Android' },
|
||||||
{ key: 'ios', name: 'iOS' },
|
// { key: 'ios', name: 'iOS' },
|
||||||
];
|
];
|
||||||
|
|
||||||
this.size = 'webSmall';
|
this.size = 'webSmall';
|
||||||
@@ -178,10 +183,11 @@ export class MdJsPreview extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get deviceHeight() {
|
get deviceHeight() {
|
||||||
|
const maxHeight = this.sizeData?.height || 50;
|
||||||
if (this.autoHeight) {
|
if (this.autoHeight) {
|
||||||
return this.contentHeight + 10;
|
return Math.min(this.contentHeight, maxHeight);
|
||||||
}
|
}
|
||||||
return this.sizeData?.height || 50;
|
return maxHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -269,10 +275,19 @@ export class MdJsPreview extends LitElement {
|
|||||||
this.size = sizes[0].key;
|
this.size = sizes[0].key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async onCopy() {
|
||||||
|
if (this.textContent) {
|
||||||
|
await navigator.clipboard.writeText(this.textContent.trim());
|
||||||
|
this.__copyButtonText = 'Copied ✅';
|
||||||
|
setTimeout(() => {
|
||||||
|
this.__copyButtonText = 'Copy code';
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
renderPlatforms() {
|
renderPlatforms() {
|
||||||
return html`
|
if (this.platforms.length) {
|
||||||
<div>
|
return html`
|
||||||
<h3>Platform</h3>
|
|
||||||
<h4>Platform</h4>
|
<h4>Platform</h4>
|
||||||
<div
|
<div
|
||||||
class="segmented-control"
|
class="segmented-control"
|
||||||
@@ -298,14 +313,24 @@ export class MdJsPreview extends LitElement {
|
|||||||
`,
|
`,
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
`;
|
||||||
`;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
renderPlatform() {
|
||||||
|
if (this.platforms.length) {
|
||||||
|
return html`
|
||||||
|
<div>
|
||||||
|
<h3>Platform</h3>
|
||||||
|
${this.renderPlatforms()}
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
renderSizes() {
|
renderSizes() {
|
||||||
return html`
|
if (this.sizes.length) {
|
||||||
<div>
|
return html`
|
||||||
<h3>Viewport</h3>
|
|
||||||
<h4>Size</h4>
|
<h4>Size</h4>
|
||||||
<div
|
<div
|
||||||
class="segmented-control"
|
class="segmented-control"
|
||||||
@@ -331,16 +356,22 @@ export class MdJsPreview extends LitElement {
|
|||||||
`,
|
`,
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
${this.renderAutoHeight()}
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
renderViewport() {
|
||||||
|
return html`
|
||||||
|
<div>
|
||||||
|
<h3>Viewport</h3>
|
||||||
|
${this.renderSizes()} ${this.renderAutoHeight()}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderThemes() {
|
renderThemes() {
|
||||||
return html`
|
if (this.themes.length) {
|
||||||
<div>
|
return html`
|
||||||
<h3>Visual</h3>
|
|
||||||
<h4>Theme</h4>
|
|
||||||
<div
|
<div
|
||||||
class="segmented-control"
|
class="segmented-control"
|
||||||
@change=${
|
@change=${
|
||||||
@@ -365,15 +396,22 @@ export class MdJsPreview extends LitElement {
|
|||||||
`,
|
`,
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
${this.renderEdgeDistance()}
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
renderVisual() {
|
||||||
|
return html`
|
||||||
|
<div>
|
||||||
|
<h3>Visual</h3>
|
||||||
|
${this.renderThemes()} ${this.renderEdgeDistance()}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderLanguages() {
|
renderLanguages() {
|
||||||
return html`
|
if (this.languages.length) {
|
||||||
<div>
|
return html`
|
||||||
<h3>Localization</h3>
|
|
||||||
<label>
|
<label>
|
||||||
Language
|
Language
|
||||||
<select
|
<select
|
||||||
@@ -394,6 +432,15 @@ export class MdJsPreview extends LitElement {
|
|||||||
)}
|
)}
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
renderLocalization() {
|
||||||
|
return html`
|
||||||
|
<div>
|
||||||
|
<h3>Localization</h3>
|
||||||
|
${this.renderLanguages()}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -403,7 +450,7 @@ export class MdJsPreview extends LitElement {
|
|||||||
<div>
|
<div>
|
||||||
<label class="${this.edgeDistance ? 'switch selected' : 'switch'}">
|
<label class="${this.edgeDistance ? 'switch selected' : 'switch'}">
|
||||||
Apply distance to edge
|
Apply distance to edge
|
||||||
<span class="switch-button"></span>
|
<span part="switch-button"></span>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
@@ -426,7 +473,7 @@ export class MdJsPreview extends LitElement {
|
|||||||
<div>
|
<div>
|
||||||
<label class="${this.autoHeight ? 'switch selected' : 'switch'}">
|
<label class="${this.autoHeight ? 'switch selected' : 'switch'}">
|
||||||
Fit height to content
|
Fit height to content
|
||||||
<span class="switch-button"></span>
|
<span part="switch-button"></span>
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
?checked=${this.autoHeight}
|
?checked=${this.autoHeight}
|
||||||
@@ -448,7 +495,7 @@ export class MdJsPreview extends LitElement {
|
|||||||
<div>
|
<div>
|
||||||
<label class="${this.sameSettings ? 'switch selected' : 'switch'}">
|
<label class="${this.sameSettings ? 'switch selected' : 'switch'}">
|
||||||
Same settings for all simulations
|
Same settings for all simulations
|
||||||
<span class="switch-button"></span>
|
<span part="switch-button"></span>
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
?checked=${this.sameSettings}
|
?checked=${this.sameSettings}
|
||||||
@@ -473,7 +520,7 @@ export class MdJsPreview extends LitElement {
|
|||||||
<div>
|
<div>
|
||||||
<label class="${this.rememberSettings ? 'switch selected' : 'switch'}">
|
<label class="${this.rememberSettings ? 'switch selected' : 'switch'}">
|
||||||
Remember settings
|
Remember settings
|
||||||
<span class="switch-button"></span>
|
<span part="switch-button"></span>
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
?checked=${this.rememberSettings}
|
?checked=${this.rememberSettings}
|
||||||
@@ -506,11 +553,12 @@ export class MdJsPreview extends LitElement {
|
|||||||
? html`<div>${this.story({ shadowRoot: this.shadowRoot })}</div>`
|
? html`<div>${this.story({ shadowRoot: this.shadowRoot })}</div>`
|
||||||
: html`
|
: html`
|
||||||
<iframe
|
<iframe
|
||||||
|
part="iframe"
|
||||||
csp=${`script-src ${document.location.origin} 'unsafe-inline'; connect-src ws://${document.location.host}/`}
|
csp=${`script-src ${document.location.origin} 'unsafe-inline'; connect-src ws://${document.location.host}/`}
|
||||||
.src=${this.iframeUrl}
|
.src=${this.iframeUrl}
|
||||||
style=${`width: ${this.sizeData.width}px; height: ${this.deviceHeight}px;`}
|
style=${`width: ${this.sizeData.width}px; height: ${this.deviceHeight}px;`}
|
||||||
></iframe>
|
></iframe>
|
||||||
<p class="frame-description" style=${`width: ${this.sizeData.width + 4}px;`}>
|
<p part="frame-description" style=${`width: ${this.sizeData.width + 4}px;`}>
|
||||||
${this.sizeData.name} - ${this.deviceHeight}x${this.sizeData.width}
|
${this.sizeData.name} - ${this.deviceHeight}x${this.sizeData.width}
|
||||||
</p>
|
</p>
|
||||||
`}
|
`}
|
||||||
@@ -523,8 +571,8 @@ export class MdJsPreview extends LitElement {
|
|||||||
</h3>
|
</h3>
|
||||||
<div slot="content">
|
<div slot="content">
|
||||||
<div class="settings-wrapper">
|
<div class="settings-wrapper">
|
||||||
${this.renderPlatforms()} ${this.renderSizes()} ${this.renderThemes()}
|
${this.renderPlatform()} ${this.renderViewport()} ${this.renderVisual()}
|
||||||
${this.renderLanguages()} ${this.renderSyncSettings()}
|
${this.renderLocalization()} ${this.renderSyncSettings()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
@@ -533,7 +581,10 @@ export class MdJsPreview extends LitElement {
|
|||||||
<button>Code</button>
|
<button>Code</button>
|
||||||
</h3>
|
</h3>
|
||||||
<div slot="content">
|
<div slot="content">
|
||||||
<slot></slot>
|
<slot id="code-slot"></slot>
|
||||||
|
<button part="copy-button" @click="${this.onCopy}" ?hidden="${!this.__supportsClipboard}">
|
||||||
|
${this.__copyButtonText}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</lion-accordion>
|
</lion-accordion>
|
||||||
${this.simulatorUrl
|
${this.simulatorUrl
|
||||||
@@ -564,26 +615,45 @@ export class MdJsPreview extends LitElement {
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[part='copy-button'] {
|
||||||
|
border: 1px solid var(--primary-color, #3f51b5);
|
||||||
|
border-radius: 9px;
|
||||||
|
padding: 7px;
|
||||||
|
background: none;
|
||||||
|
font-weight: bold;
|
||||||
|
color: var(--primary-color, #3f51b5);
|
||||||
|
text-align: center;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 12px;
|
||||||
|
float: right;
|
||||||
|
margin-top: -10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
[part='copy-button']:hover {
|
||||||
|
background-color: var(--primary-color, #3f51b5);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
.switch {
|
.switch {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.switch:focus-within .switch-button {
|
.switch:focus-within [part='switch-button'] {
|
||||||
box-shadow: 0 0 0 1px hsl(0deg 0% 100% / 40%), 0 0 0 4px rgb(31 117 203 / 48%);
|
box-shadow: 0 0 0 1px hsl(0deg 0% 100% / 40%), 0 0 0 4px rgb(31 117 203 / 48%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.switch-button {
|
[part='switch-button'] {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 44px;
|
width: 44px;
|
||||||
background: grey;
|
background: #808080;
|
||||||
height: 25px;
|
height: 25px;
|
||||||
border-radius: 15px;
|
border-radius: 15px;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.switch-button::after {
|
[part='switch-button']::after {
|
||||||
content: ' ';
|
content: ' ';
|
||||||
width: 18px;
|
width: 18px;
|
||||||
height: 18px;
|
height: 18px;
|
||||||
@@ -595,16 +665,16 @@ export class MdJsPreview extends LitElement {
|
|||||||
left: 4px;
|
left: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.switch.selected .switch-button {
|
.switch.selected [part='switch-button'] {
|
||||||
background: green;
|
background: var(--primary-color, #008000);
|
||||||
}
|
}
|
||||||
|
|
||||||
.switch.selected .switch-button::after {
|
.switch.selected [part='switch-button']::after {
|
||||||
left: auto;
|
left: auto;
|
||||||
right: 4px;
|
right: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.frame-description {
|
[part='frame-description'] {
|
||||||
margin: -5px 0 10px 0;
|
margin: -5px 0 10px 0;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
@@ -640,23 +710,23 @@ export class MdJsPreview extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.controls a {
|
.controls a {
|
||||||
color: #3f51b5;
|
color: var(--primary-color, #3f51b5);
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 37px;
|
line-height: 37px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.simulation-toggle {
|
.simulation-toggle {
|
||||||
border: 1px solid #3f51b5;
|
border: 1px solid var(--primary-color, #3f51b5);
|
||||||
border-radius: 9px;
|
border-radius: 9px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
background: none;
|
background: none;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #3f51b5;
|
color: var(--primary-color, #3f51b5);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.simulation-toggle:hover {
|
.simulation-toggle:hover {
|
||||||
background-color: #3f51b5;
|
background-color: var(--primary-color, #3f51b5);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -705,7 +775,7 @@ export class MdJsPreview extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.segmented-control {
|
.segmented-control {
|
||||||
border: 1px solid #3f51b5;
|
border: 1px solid var(--primary-color, #3f51b5);
|
||||||
border-radius: 18px;
|
border-radius: 18px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
@@ -728,7 +798,7 @@ export class MdJsPreview extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.segmented-control label.selected span {
|
.segmented-control label.selected span {
|
||||||
background: #3f51b5;
|
background: var(--primary-color, #3f51b5);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ function storeSettings() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let hasGlobalStateBeenSetBefore = false;
|
||||||
|
|
||||||
function restoreSettings() {
|
function restoreSettings() {
|
||||||
for (const _sharedStateKey of Object.keys(_sharedStates)) {
|
for (const _sharedStateKey of Object.keys(_sharedStates)) {
|
||||||
const sharedStateKey = /** @type {keyof _sharedStates} */ (_sharedStateKey);
|
const sharedStateKey = /** @type {keyof _sharedStates} */ (_sharedStateKey);
|
||||||
@@ -55,6 +57,7 @@ function restoreSettings() {
|
|||||||
default:
|
default:
|
||||||
_sharedStates[sharedStateKey] = restoredValue;
|
_sharedStates[sharedStateKey] = restoredValue;
|
||||||
}
|
}
|
||||||
|
hasGlobalStateBeenSetBefore = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,27 +69,30 @@ restoreSettings();
|
|||||||
* @param {import('./MdJsPreview.js').MdJsPreview} target
|
* @param {import('./MdJsPreview.js').MdJsPreview} target
|
||||||
*/
|
*/
|
||||||
export function applySharedStates(target) {
|
export function applySharedStates(target) {
|
||||||
for (const _sharedStateKey of Object.keys(_sharedStates)) {
|
if (hasGlobalStateBeenSetBefore) {
|
||||||
const sharedStateKey = /** @type {keyof _sharedStates} */ (_sharedStateKey);
|
for (const _sharedStateKey of Object.keys(_sharedStates)) {
|
||||||
switch (sharedStateKey) {
|
const sharedStateKey = /** @type {keyof _sharedStates} */ (_sharedStateKey);
|
||||||
case 'autoHeight':
|
switch (sharedStateKey) {
|
||||||
case 'deviceMode':
|
case 'autoHeight':
|
||||||
case 'rememberSettings':
|
case 'deviceMode':
|
||||||
case 'edgeDistance':
|
case 'rememberSettings':
|
||||||
target[sharedStateKey] = _sharedStates[sharedStateKey];
|
case 'edgeDistance':
|
||||||
break;
|
target[sharedStateKey] = _sharedStates[sharedStateKey];
|
||||||
default:
|
break;
|
||||||
target[sharedStateKey] = _sharedStates[sharedStateKey];
|
default:
|
||||||
|
target[sharedStateKey] = _sharedStates[sharedStateKey];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
_saveToSharedStates(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {import('./MdJsPreview.js').MdJsPreview} target
|
* @param {import('./MdJsPreview.js').MdJsPreview} target
|
||||||
* @param {Function} subscribedFn
|
|
||||||
*/
|
*/
|
||||||
export function saveToSharedStates(target, subscribedFn) {
|
function _saveToSharedStates(target) {
|
||||||
let updated = false;
|
let updated = false;
|
||||||
for (const _sharedStateKey of Object.keys(_sharedStates)) {
|
for (const _sharedStateKey of Object.keys(_sharedStates)) {
|
||||||
const sharedStateKey = /** @type {keyof _sharedStates} */ (_sharedStateKey);
|
const sharedStateKey = /** @type {keyof _sharedStates} */ (_sharedStateKey);
|
||||||
@@ -102,8 +108,19 @@ export function saveToSharedStates(target, subscribedFn) {
|
|||||||
_sharedStates[sharedStateKey] = target[sharedStateKey];
|
_sharedStates[sharedStateKey] = target[sharedStateKey];
|
||||||
}
|
}
|
||||||
updated = true;
|
updated = true;
|
||||||
|
hasGlobalStateBeenSetBefore = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return updated;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {import('./MdJsPreview.js').MdJsPreview} target
|
||||||
|
* @param {Function} subscribedFn
|
||||||
|
*/
|
||||||
|
export function saveToSharedStates(target, subscribedFn) {
|
||||||
|
const updated = _saveToSharedStates(target);
|
||||||
if (updated) {
|
if (updated) {
|
||||||
storeSettings();
|
storeSettings();
|
||||||
for (const subscribeFn of subscribeFns) {
|
for (const subscribeFn of subscribeFns) {
|
||||||
|
|||||||
@@ -9,7 +9,18 @@ export default {
|
|||||||
absoluteBaseUrl: absoluteBaseUrlNetlify('http://localhost:8080'),
|
absoluteBaseUrl: absoluteBaseUrlNetlify('http://localhost:8080'),
|
||||||
setupUnifiedPlugins: [
|
setupUnifiedPlugins: [
|
||||||
adjustPluginOptions('mdjsSetupCode', {
|
adjustPluginOptions('mdjsSetupCode', {
|
||||||
simulationSettings: { simulatorUrl: '/simulator/' },
|
simulationSettings: {
|
||||||
|
simulatorUrl: '/simulator/',
|
||||||
|
themes: [
|
||||||
|
{ key: 'light', name: 'Light' },
|
||||||
|
{ key: 'dark', name: 'Dark' },
|
||||||
|
],
|
||||||
|
platforms: [
|
||||||
|
{ key: 'web', name: 'Web' },
|
||||||
|
{ key: 'android', name: 'Android' },
|
||||||
|
{ key: 'ios', name: 'iOS' },
|
||||||
|
],
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user