btn-publish.html
html
{{define "btn-publish"}}
<div id="publish-controls" class="flex items-center gap-3">
  <label class="swap swap-flip">
    <input type="checkbox"
      {{if .IsPublished}}checked{{end}}
      hx-post="/decks/{{.ID}}/{{if .IsPublished}}unpublish{{else}}publish{{end}}"
      hx-target="#publish-controls"
      hx-swap="outerHTML" />
    <div class="swap-on text-xs text-success font-medium">Published</div>
    <div class="swap-off text-xs text-base-content/50">Draft</div>
  </label>
  {{if .IsPublished}}
  <a href="/deck/{{.ID}}" class="btn btn-ghost btn-sm gap-1" title="View published deck" hx-boost="true">
    <svg class="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path stroke-linecap="round" stroke-linejoin="round" d="M13.5 6H5.25A2.25 2.25 0 003 8.25v10.5A2.25 2.25 0 005.25 21h10.5A2.25 2.25 0 0018 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25" />
    </svg>
  </a>
  {{end}}
  <!-- No hx-boost on Present link - needs full page load for scripts -->
  <a href="{{if .IsPublished}}/deck/{{.ID}}/present{{else}}/preview/{{.ID}}{{end}}" class="btn btn-primary btn-sm gap-1">
    <svg class="w-4 h-4" viewBox="0 0 24 24" fill="currentColor">
      <path d="M8 5v14l11-7z"/>
    </svg>
    <span class="hidden sm:inline">Present</span>
  </a>
</div>
{{end}}
72f0edf

Add rich text formatting and block styling to editor

Connor McCutcheon
@connor
0 stars

Pitch decks to help promote Skyscape Apps

Sign in to comment Sign In