Skip to content

Add Design Hyperlink for embedding Meshery designs #713

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

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
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
99 changes: 89 additions & 10 deletions layouts/shortcodes/meshery-design-embed.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,21 @@
to visualize, explore, and collaborate on service mesh designs.

-- Usage:
{{/*< meshery-design-embed src="path/to/embed.js" id="unique-id" size="full|half" >*/}}
{{/*< meshery-design-embed src="path/to/embed.js" id="unique-id" size="full|half" link="design-url" >*/}}
size: "full" for full-width (default), "half" for half-width display
link: Optional URL to link to the original design. If not provided, will auto-generate from design ID
id: Container ID, usually in format "embedded-design-<design_id>"

-- Parameters:
- src: Path to the JavaScript file for the embedded design
- id: Full container ID (e.g., "embedded-design-7d183e77-09e1-4b69-a5ee-3e3870e9c5f4")
- size: "full" for full-width (default), "half" for half-width display
- link: Optional URL to override auto-generated Meshery link

-- Auto-link generation:
If 'link' parameter is not provided and ID follows the pattern "embedded-design-{uuid}",
the shortcode will automatically generate:
https://playground.meshery.io/extension/meshmap?mode=design&design={uuid}

More Information:
Learn more about embedding Meshery designs at:
Expand All @@ -34,26 +47,88 @@
-->
{{ $size := .Get "size" | default "full" }}

<!--
Retrieve the optional link to the original design.
This enables hyperlink functionality for the embedded design.
-->
{{ $link := .Get "link" }}

<!-- Always try to generate auto-link from ID -->
{{ $autoLink := "" }}
{{ if strings.HasPrefix $id "embedded-design-" }}
{{ $designId := strings.Replace $id "embedded-design-" "" 1 }}
{{ if $designId }}
{{ $autoLink = printf "https://playground.meshery.io/extension/meshmap?mode=design&design=%s" $designId }}
{{ end }}
{{ end }}

<!-- Use provided link or auto-link -->
{{ $finalLink := $link }}
{{ if not $finalLink }}
{{ $finalLink = $autoLink }}
{{ end }}

<style>
.meshery-embed-container {
border: 1px solid #eee;
border-radius: 4px;
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 12px;
margin: 1rem auto;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
position: relative;
transition: all 0.3s ease;
aspect-ratio: 4 / 3;
}
.meshery-embed-container.full {
width: 100%;
height: 30rem;
}
.meshery-embed-container.half {
width: 50%;
height: 30rem;
}
@media (max-width: 768px) {
.meshery-embed-container.half {
width: 70%;
}
}
.meshery-embed-container .cy-container {
width: 100%;
height: 100%;
border-radius: 11px;
}
</style>

{{ if $finalLink }}
<style>
.meshery-embed-container {
cursor: pointer;
}
.meshery-embed-container:hover {
transform: translateY(-4px);
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
border-color: rgba(0, 179, 159, 0.5);
background: rgba(255, 255, 255, 0.15);
}
.meshery-link-button {
position: absolute;
top: 12px;
right: 12px;
background: rgba(0, 179, 159, 0.9);
color: white;
padding: 6px 12px;
border-radius: 20px;
font-size: 12px;
font-weight: 500;
text-decoration: none;
opacity: 1;
transition: opacity 0.3s ease;
z-index: 10;
}
.meshery-embed-container:hover .meshery-link-button {
opacity: 1;
}
</style>
{{ end }}

<!--
Embedding Container:
Expand All @@ -65,10 +140,14 @@
- Width: 100% (responsive to container width)
- Border: 1px solid #eee (light border for visibility)
-->
<div
id="{{ $id }}"
class="meshery-embed-container {{ $size }}"
></div>

<div id="{{ $id }}" class="meshery-embed-container {{ $size }}">
{{ if $finalLink }}
<a href="{{ $finalLink }}" target="_blank" rel="noopener" class="meshery-link-button">
🔗 Open in Meshery
</a>
{{ end }}
</div>

<!--
Embed Script:
Expand Down