Skip to content

Commit

Permalink
Latest
Browse files Browse the repository at this point in the history
  • Loading branch information
ProfessorManhattan committed Apr 26, 2024
1 parent 0401047 commit 92cb27b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 28 deletions.
Empty file added .trunk/configs/.eslintrc.js
Empty file.
51 changes: 30 additions & 21 deletions src/components/code-snippet/code-snippet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ export class CodeSnippet {
if (Build.isServer) return;
if (!window.prismLoaded) {
window.prismLoaded = true;
importResource({ propertyName: 'Prism', link: `${CodeSnippet.prismCdn}/prism.min.js`, async: true }, () => {
importResource({ propertyName: 'Prism', link: `${CodeSnippet.prismCdn}/prism.min.js` }, () => {
this.loadInPrismLanguage();
});
} else {
this.loadInPrismLanguage();
const prismInterval = setInterval(() => {
if (window.Prism) {
clearInterval(prismInterval);
this.loadInPrismLanguage();
}
}, 50);
}
}

Expand All @@ -39,37 +44,41 @@ export class CodeSnippet {
{
propertyName: `Prism.languages.${this.language}`,
link: `${CodeSnippet.prismCdn}/prism-${this.language}.min.js`,
defer: true,
},
this.highlightCode
() => {
this.highlightCode();
}
);
} else {
this.highlightCode();
}
};

highlightCode = async () => {
if (Build.isServer) return;
const prismInterval = setInterval(async () => {
if (window.Prism && window.Prism.languages && window.Prism.languages[this.language]) {
clearInterval(prismInterval);
await customElements.whenDefined('code-snippet');

await customElements.whenDefined('code-snippet');
window.Prism.hooks.add('before-insert', (env) => {
switch (env.language) {
case 'shell-session':
const lines = env.code.split('\n');

window.Prism.hooks.add('before-insert', (env) => {
switch (env.language) {
case 'shell-session':
const lines = env.code.split('\n');
const code = lines.map((line) => {
return line.trim() === '' || line.trim()[0] === '#'
? `<span class="token output">${line}</span>\n`
: `<span class="dollar-sign token output">${line}</span>\n`;
});
env.highlightedCode = code.join('');
break;
default:
}
});

const code = lines.map((line) => {
return line.trim() === '' || line.trim()[0] === '#'
? `<span class="token output">${line}</span>\n`
: `<span class="dollar-sign token output">${line}</span>\n`;
});
env.highlightedCode = code.join('');
break;
default:
window.Prism.highlightElement(this.codeEl, false);
}
});

window.Prism.highlightElement(this.codeEl, false);
}, 50);
};

render() {
Expand Down
6 changes: 1 addition & 5 deletions src/components/docs-search/docs-search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ export class DocsSearch implements ComponentInterface {
} = {};

componentDidLoad() {
console.log('Algolia loaded');
console.log((window as any).algoliaLoaded);
if (!(window as any).algoliaLoaded) {
(window as any).algoliaLoaded = true;
const algolia = `/assets/js/docsearch.min.js`;
importResource({ propertyName: 'docsearch', link: algolia, async: true }, () => this.setupSearch());
}

Expand Down Expand Up @@ -81,7 +80,6 @@ export class DocsSearch implements ComponentInterface {
}

setupSearch() {
console.log('setting up search');
setTimeout(() => {
window.docsearch({
appId: this.defaults.algolia.appId,
Expand Down Expand Up @@ -181,5 +179,3 @@ export class DocsSearch implements ComponentInterface {
);
}
}

const algolia = `/assets/js/docsearch.min.js`;
10 changes: 8 additions & 2 deletions src/global/style-default.scss
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ h2.ui-heading.ui-heading-2.ui-theme--editorial > a {
}

top-parallax #start {
padding-top: 11.44vh;
padding-top: 8.14vh;
}

landing-page {
Expand Down Expand Up @@ -953,8 +953,14 @@ fieldset .field:last-child {
.success-color {
color: var(--c-green-50) !important;
}
top-parallax {
height: calc(100vh - 64px) !important;
display: block;
width: 100%;
background-color: black;
}
#slider {
height: calc(100vh - 64px);
height: calc(100vh - 64px) !important;
width: 100%;
position: absolute;
top: 64px;
Expand Down

0 comments on commit 92cb27b

Please sign in to comment.