generated from ViBiOh/goweb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adding delete icon on UI (#12)
- Loading branch information
Showing
8 changed files
with
197 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{ define "form_buttons" }} | ||
<p class="padding no-margin center"> | ||
<a href="#" class="button white">Cancel</a> | ||
<button type="submit" class="button bg-primary">{{ . }}</button> | ||
</p> | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,93 @@ | ||
{{ define "delete-modal" }} | ||
<div id="delete-modal-{{ .ID }}" class="modal"> | ||
<div class="modal-content"> | ||
<h2 class="header">Confirmation</h2> | ||
|
||
<form method="delete" action="/api/targets/{{ .ID }}"> | ||
<p class="padding no-margin center"> | ||
Are you sure you want to delete <strong>{{ .Repository }}</strong>? | ||
</p> | ||
|
||
{{ template "form_buttons" "Confirm" }} | ||
</form> | ||
</div> | ||
</div> | ||
{{ end }} | ||
|
||
|
||
{{ define "targets" }} | ||
<style> | ||
{{ range . }} | ||
#delete-modal-{{ .ID }}:target, | ||
#edit-modal-{{ .ID }}:target, | ||
{{ end }} | ||
#action-modal:target { | ||
display: flex; | ||
z-index: 5; | ||
} | ||
|
||
{{ range . }} | ||
#delete-modal-{{ .ID }}:target ~ .content, | ||
#edit-modal-{{ .ID }}:target ~ .content, | ||
{{ end }} | ||
#action-modal:target ~ .content { | ||
display: flex; | ||
z-index: 5; | ||
} | ||
|
||
.target { | ||
display: flex; | ||
} | ||
</style> | ||
|
||
<div> | ||
<script> | ||
/** | ||
* Go back from state. | ||
*/ | ||
function goBack() { | ||
const previousHash = document.location.hash; | ||
document.location.hash = ''; | ||
|
||
if (/success$/gim.test(previousHash)) { | ||
window.location.reload(true); | ||
} | ||
} | ||
|
||
/** | ||
* Handle Previous/next. | ||
*/ | ||
window.onkeyup = e => { | ||
switch(e.key) { | ||
case 'Escape': | ||
goBack(); | ||
break; | ||
} | ||
}; | ||
</script> | ||
|
||
<article> | ||
{{ range $index, $target := . }} | ||
<p> | ||
<div>{{ $target.Repository }}</div> | ||
{{ template "delete-modal" $target }} | ||
|
||
<span class="{{ if ne $target.CurrentVersion $target.LatestVersion }}danger{{ else }}success{{ end }}"> | ||
{{ $target.CurrentVersion }} | ||
</span> | ||
<div class="padding target"> | ||
<span> | ||
<p class="no-margin">{{ $target.Repository }}</p> | ||
|
||
{{ if ne $target.CurrentVersion $target.LatestVersion }} | ||
<span> | ||
-> <a class="success" href="https://github.com/{{ $target.Repository }}/releases/tag/{{ $target.LatestVersion }}" rel="noopener noreferrer" target="_blank">{{ $target.LatestVersion }}</a> | ||
<span class="{{ if ne $target.CurrentVersion $target.LatestVersion }}danger{{ else }}success{{ end }}"> | ||
{{ $target.CurrentVersion }} | ||
</span> | ||
{{ end }} | ||
</p> | ||
|
||
{{ if ne $target.CurrentVersion $target.LatestVersion }} | ||
<span> | ||
-> <a class="success" href="https://github.com/{{ $target.Repository }}/releases/tag/{{ $target.LatestVersion }}" rel="noopener noreferrer" target="_blank">{{ $target.LatestVersion }}</a> | ||
</span> | ||
{{ end }} | ||
</span> | ||
|
||
<a href="#delete-modal-{{ .ID }}" class="button button-icon" alt="Delete"> | ||
<img class="icon" src="/svg/times?fill=silver" alt="Delete"> | ||
</a> | ||
</div> | ||
{{ end }} | ||
</div> | ||
</article> | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{{ define "style-icon" }} | ||
<style> | ||
:root { | ||
--icon-size: 2.4rem; | ||
--icon-large: 4.8rem; | ||
} | ||
|
||
.icon { | ||
background-position: center center; | ||
background-repeat: no-repeat; | ||
color: var(--white); | ||
display: inline-block; | ||
height: var(--icon-size); | ||
text-decoration: none; | ||
vertical-align: middle; | ||
width: var(--icon-size); | ||
} | ||
|
||
.icon-large { | ||
height: var(--icon-large); | ||
width: var(--icon-large); | ||
} | ||
|
||
.icon-overlay { | ||
height: var(--icon-large); | ||
left: calc((100% - var(--icon-large)) / 2); | ||
position: absolute; | ||
top: calc((100% - var(--icon-large)) / 2); | ||
width: var(--icon-large); | ||
pointer-events: none; | ||
} | ||
</style> | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{{ define "style-modal" }} | ||
{{ $root := . }} | ||
|
||
<style> | ||
.modal { | ||
align-items: center; | ||
background-color: rgba(84, 84, 84, 0.75); | ||
display: none; | ||
height: 100vh; | ||
justify-content: center; | ||
left: 0; | ||
pointer-events: none; | ||
position: fixed; | ||
top: 0; | ||
width: 100vw; | ||
} | ||
|
||
.modal-content { | ||
background-color: var(--dark); | ||
display: flex; | ||
flex-direction: column; | ||
max-height: 100%; | ||
max-width: 100%; | ||
pointer-events: auto; | ||
} | ||
</style> | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{{ define "svg-edit" }} | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path fill="{{ . }}" d="M402.6 83.2l90.2 90.2c3.8 3.8 3.8 10 0 13.8L274.4 405.6l-92.8 10.3c-12.4 1.4-22.9-9.1-21.5-21.5l10.3-92.8L388.8 83.2c3.8-3.8 10-3.8 13.8 0zm162-22.9l-48.8-48.8c-15.2-15.2-39.9-15.2-55.2 0l-35.4 35.4c-3.8 3.8-3.8 10 0 13.8l90.2 90.2c3.8 3.8 10 3.8 13.8 0l35.4-35.4c15.2-15.3 15.2-40 0-55.2zM384 346.2V448H64V128h229.8c3.2 0 6.2-1.3 8.5-3.5l40-40c7.6-7.6 2.2-20.5-8.5-20.5H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V306.2c0-10.7-12.9-16-20.5-8.5l-40 40c-2.2 2.3-3.5 5.3-3.5 8.5z"/></svg> | ||
{{ end }} | ||
|
||
{{ define "svg-times" }} | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path fill="{{ . }}" d="M323.1 441l53.9-53.9c9.4-9.4 9.4-24.5 0-33.9L279.8 256l97.2-97.2c9.4-9.4 9.4-24.5 0-33.9L323.1 71c-9.4-9.4-24.5-9.4-33.9 0L192 168.2 94.8 71c-9.4-9.4-24.5-9.4-33.9 0L7 124.9c-9.4 9.4-9.4 24.5 0 33.9l97.2 97.2L7 353.2c-9.4 9.4-9.4 24.5 0 33.9L60.9 441c9.4 9.4 24.5 9.4 33.9 0l97.2-97.2 97.2 97.2c9.3 9.3 24.5 9.3 33.9 0z"/></svg> | ||
{{ end }} |