Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Catalog] Use light/dark snapshot version #1593

Merged
merged 4 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions _includes/card.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


<div class= "card link">
<div class="card-inner">
<div class="front">
Expand All @@ -6,7 +8,12 @@
</div>
<h4 class="pattern-name">{{pattern.name}}</h4>
<div class="pattern-image-container">
<img class= "pattern-image" src="https://raw.githubusercontent.com/layer5labs/meshery-extensions-packages/master/action-assets/design-assets/{{pattern.patternId}}.png" onerror="this.src='/assets/images/patterns/service-mesh.svg'" loading="lazy"/>
<img class= "pattern-image pattern-snapshot"
data-snapshot-light="https://raw.githubusercontent.com/layer5labs/meshery-extensions-packages/master/action-assets/design-assets/{{pattern.patternId}}-light.png"
data-snapshot-dark="https://raw.githubusercontent.com/layer5labs/meshery-extensions-packages/master/action-assets/design-assets/{{pattern.patternId}}-dark.png"
src="https://raw.githubusercontent.com/layer5labs/meshery-extensions-packages/master/action-assets/design-assets/{{pattern.patternId}}-dark.png"
onerror="this.src='/assets/images/patterns/service-mesh.svg'"
loading="lazy"/>
</div>
<h6 class="pattern-id">
<img class="smp"
Expand All @@ -15,7 +22,7 @@ <h6 class="pattern-id">
<span id="patId{{pattern.patternId}}" class="pat">
{% assign bigPatId = pattern.patternId%}
{% assign patId = bigPatId | split: "-" %}

{% if patId[2] %}
MESHERY{{patId[2]}}
{%else%}
Expand All @@ -34,4 +41,5 @@ <h6 class="pattern-id">
.chip{
float: left;
}
</style>
</style>

5 changes: 5 additions & 0 deletions _includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ <h2><a {% if column.new_window %}target="_blank" {% endif %}

function setMode() {
document.body.classList.toggle("dark-mode")

let layer5Logos = document.querySelectorAll("#layer5-logo");
let allLogos = document.querySelectorAll("#logo-dark-light");
if (document.body.classList.contains("dark-mode")) {
Expand All @@ -151,6 +152,10 @@ <h2><a {% if column.new_window %}target="_blank" {% endif %}
} else {
localStorage.setItem("mode", "light-mode")
}
document.dispatchEvent(new CustomEvent("themeChange",{
detail : {value : localStorage.getItem("mode")},
bubbles: true ,
}))
}

</script>
Expand Down
6 changes: 6 additions & 0 deletions _includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
allLogos.forEach(e => {
e.src = body.classList.contains("dark-mode") ? e.dataset.logoForDark : e.dataset.logoForLight;
});

// emit the theme event
document.dispatchEvent(new CustomEvent("themeChange",{
detail : {value : localStorage.getItem("mode")},
bubbles: true ,
}))
});
</script>

Expand Down
6 changes: 5 additions & 1 deletion _includes/modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ <h6 class="pattern-type"> {{pattern.type | upcase }}</h6>
{%if pattern.filters.type == "wasm filter" %}
<img class="image-class" src="https://raw.githubusercontent.com/layer5labs/meshery-extensions-packages/master/action-assets/design-assets/{{pattern.patternId}}.png" onerror="this.src='/assets/images/webassembly_logo.svg'" loading="lazy" onclick="toggleFullScreenImage('{{ pattern.patternId }}')" />
{%else%}
<img class="image-class" src="https://raw.githubusercontent.com/layer5labs/meshery-extensions-packages/master/action-assets/design-assets/{{pattern.patternId}}.png" onerror="this.src='/assets/images/patterns/service-mesh.svg'" loading="lazy" onclick="toggleFullScreenImage('{{ pattern.patternId }}')" />
<img class="image-class pattern-snapshot"
data-snapshot-light="https://raw.githubusercontent.com/layer5labs/meshery-extensions-packages/master/action-assets/design-assets/{{pattern.patternId}}-light.png"
data-snapshot-dark="https://raw.githubusercontent.com/layer5labs/meshery-extensions-packages/master/action-assets/design-assets/{{pattern.patternId}}-dark.png"
src="https://raw.githubusercontent.com/layer5labs/meshery-extensions-packages/master/action-assets/design-assets/{{pattern.patternId}}-dark.png"
onerror="this.src='/assets/images/patterns/service-mesh.svg'" loading="lazy" onclick="toggleFullScreenImage('{{ pattern.patternId }}')" />
{%endif%}
<h4 class="related-patterns">RELATED PATTERNS</h4>
{% include related-patterns.html %}
Expand Down
6 changes: 5 additions & 1 deletion _includes/partials/mini-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
<small class="modal-pattern-type"> {{pttrn.type}}</small>
</div>
<h5 class="modal-pattern-name">{{pttrn.name}}</h5>
<img class= "modal-pattern-image" src="https://raw.githubusercontent.com/layer5labs/meshery-extensions-packages/master/action-assets/design-assets/{{pttrn.patternId}}.png" onerror="this.src='/assets/images/patterns/service-mesh.svg'" loading="lazy"/>
<img class= "modal-pattern-image pattern-snapshot"
data-snapshot-light="https://raw.githubusercontent.com/layer5labs/meshery-extensions-packages/master/action-assets/design-assets/{{pattern.patternId}}-light.png"
data-snapshot-dark="https://raw.githubusercontent.com/layer5labs/meshery-extensions-packages/master/action-assets/design-assets/{{pattern.patternId}}-dark.png"
src="https://raw.githubusercontent.com/layer5labs/meshery-extensions-packages/master/action-assets/design-assets/{{pattern.patternId}}-dark.png"
onerror="this.src='/assets/images/patterns/service-mesh.svg'" loading="lazy"/>
<div>
<h6 class="modal-pattern-id">
<img class="modal-smp"
Expand Down
8 changes: 8 additions & 0 deletions catalog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,12 @@ <h2 class="not-found" style="display: none;" id="not-found">
}
});
});

document.addEventListener("themeChange",(e)=> {
// load the snapshot version based on theme
document.querySelectorAll(".pattern-image").forEach(e => {
e.src = event.detail.value == "dark-mode" ? e.dataset.snapshotDark : e.dataset.snapshotLight;
});

})
</script>
Loading