Skip to content

Commit

Permalink
Add story preview when creating or editing
Browse files Browse the repository at this point in the history
  • Loading branch information
bad-mushroom committed Jul 15, 2022
1 parent e785417 commit 56be8ee
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 23 deletions.
19 changes: 19 additions & 0 deletions resources/views/manage/livewire/modals/preview.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div wire:ignore.self class="modal fade" id="previewStory" tabindex="-1" aria-labelledby="previewStory" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="previewStoryLabel">Story Preview</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<h3 id="preview-story-subject">{{ $subject }}</h3>
<div class="py-2 story-markdown" id="preview-story-summary">{{ $summary }}</div>
<hr>
<div id="preview-story-body" class="py-2 story-markdown">{{ $body }}</div>
</div>
<div class="modal-footer">
<button type="button" data-bs-dismiss="modal" class="btn btn-success text-light">OK</button>
</div>
</div>
</div>
</div>
41 changes: 24 additions & 17 deletions resources/views/manage/livewire/story-form-edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,31 @@

@includeIf('manage.partials.forms.' . $type)
<div class="row">
<div class="col-md-6">
<button type="button" class="btn btn-danger text-light" wire:click="setDeleteId('{{ $story->id }}')" data-bs-toggle="modal"
data-bs-target="#confirmDelete">
<div class="col">
<button type="button" class="btn btn-danger text-light" wire:click="setDeleteId('{{ $story->id }}')"
data-bs-toggle="modal" data-bs-target="#confirmDelete">
<i class="bi bi-trash me-2"></i>Delete
</button>

</div>
<div class="col-md-6 text-end">
<div class="col text-end">
<button type="button" class="btn btn-info text-dark me-4" data-bs-toggle="modal" data-bs-target="#previewStory">
<i class="bi bi-eye me-2"></i>Preview
</button>

@if ($story->published_at)
<button type="button" class="btn btn-secondary text-light" wire:click="saveDraft">
<i class="bi bi-cloud-fill me-2"></i>Convert to draft
</button>
@else
<button type="button" class="btn btn-secondary text-light" wire:click="saveDraft">
<i class="bi bi-cloud me-2"></i>Save Draft
</button>
@endif
<button type="button" class="btn btn-success text-light" wire:click="publish">
<i class="bi bi-cloud-fill me-2"></i>Save and Publish
</button>
</div>
@if ($story->published_at)
<button type="button" class="btn btn-secondary text-light" wire:click="saveDraft">
<i class="bi bi-cloud-fill me-2"></i>Convert to draft
</button>
@else
<button type="button" class="btn btn-secondary text-light" wire:click="saveDraft">
<i class="bi bi-cloud me-2"></i>Save Draft
</button>
@endif
<button type="button" class="btn btn-success text-light" wire:click="publish">
<i class="bi bi-cloud-fill me-2"></i>Save and Publish
</button>
</div>
</div>

</section>
Expand Down Expand Up @@ -109,4 +113,7 @@
</section>
</div>
</div>

@include('manage.livewire.modals.preview')

</form>
2 changes: 1 addition & 1 deletion resources/views/manage/partials/forms/note.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
<div class="mb-3">
<label for="body" class="form-label">Body</label>
<textarea class="form-control" id="body" aria-describedby="bodyHelp" rows="10" wire:model="body"></textarea>
<div id="bodyHelp" class="form-text"></div>
<div id="bodyHelp" class="small text-muted form-text">Markdown Supported</div>
</div>
2 changes: 1 addition & 1 deletion resources/views/manage/partials/forms/page.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
<div class="mb-3">
<label for="body" class="form-label">Page Body</label>
<textarea class="form-control" id="body" aria-describedby="bodyHelp" rows="10" wire:model="body"></textarea>
<div id="bodyHelp" class="form-text"></div>
<div id="bodyHelp" class="small text-muted form-text">Markdown Supported</div>
</div>
8 changes: 4 additions & 4 deletions resources/views/manage/partials/forms/post.blade.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<div class="mb-3">
<label for="subject" class="form-label required">Subject</label>
<input type="text" class="form-control @error('subject') border border-danger @enderror" id="subject" aria-describedby="subjectHelp" wire:model="subject">
<input type="text" class="form-control @error('subject') border border-danger @enderror" id="story-subject" aria-describedby="subjectHelp" wire:model="subject">
<div id="subjectHelp" class="form-text"></div>
</div>

<div class="mb-3">
<label for="summary" class="form-label">Summary</label>
@error('summary') <span class="text-danger">{{ $message }}</span> @enderror
<textarea class="form-control @error('summary') border border-danger @enderror" id="summary" aria-describedby="subjectHelp" rows="2" wire:model="summary"></textarea>
<textarea class="form-control @error('summary') border border-danger @enderror" id="story-summary" aria-describedby="subjectHelp" rows="2" wire:model="summary"></textarea>
<div id="summaryHelp" class="form-text"></div>
</div>

<div class="mb-3">
<label for="body" class="form-label">Blog Post</label>
@error('body') <span class="text-danger">{{ $message }}</span> @enderror
<textarea class="form-control @error('body') border border-danger @enderror" id="body" aria-describedby="bodyHelp" rows="10" wire:model="body"></textarea>
<div id="bodyHelp" class="form-text"></div>
<textarea class="form-control @error('body') border border-danger @enderror" id="story-body" aria-describedby="bodyHelp" rows="10" wire:model="body"></textarea>
<div id="bodyHelp" class="small text-muted form-text">Markdown Supported</div>
</div>

0 comments on commit 56be8ee

Please sign in to comment.