-
Notifications
You must be signed in to change notification settings - Fork 804
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature (viewerpage): rewrite of the viewers
- Loading branch information
1 parent
55671b3
commit 21bf973
Showing
17 changed files
with
461 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
.component_dropdown { | ||
position: relative; | ||
} | ||
.component_dropdown .dropdown_container { | ||
display: none; | ||
position: absolute; | ||
right: 0; | ||
} | ||
.component_dropdown .dropdown_button { | ||
border: 1px solid rgba(0, 0, 0, 0); | ||
border-radius: 4px; | ||
padding: 5px; | ||
min-width: 20px; | ||
text-align: center; | ||
} | ||
.component_dropdown .dropdown_container { | ||
padding-top: 5px; | ||
z-index: 3; | ||
} | ||
.component_dropdown .dropdown_container:before { | ||
content: ' '; | ||
position: absolute; | ||
right: 10px; | ||
top: 1px; | ||
width: 0; | ||
height: 0; | ||
border-left: 6px solid transparent; | ||
border-right: 6px solid transparent; | ||
border-bottom: 6px solid white; | ||
} | ||
.component_dropdown .dropdown_container ul { | ||
margin: 0; | ||
list-style-type: none; | ||
background: white; | ||
border: 1px solid var(--border); | ||
box-shadow: 1px 1px 2px var(--border); | ||
color: rgba(0,10,20,0.85); | ||
border-radius: 3px; | ||
padding: 3px 0px; | ||
font-size: 0.92em; | ||
} | ||
.component_dropdown .dropdown_container ul li { | ||
display: flex; | ||
} | ||
.component_dropdown .dropdown_container ul li > div { | ||
width: 160px; | ||
padding: 8px 5px 8px 10px; | ||
} | ||
|
||
.component_dropdown.active .dropdown_container { | ||
display: block; | ||
} | ||
.component_dropdown.active .dropdown_container li { | ||
background: white; | ||
transition: background 0.1s ease-out; | ||
} | ||
.component_dropdown.active .dropdown_container li:hover { | ||
background: rgba(0, 0, 0, 0.05); | ||
} | ||
|
||
.component_dropdown.active .dropdown_button { | ||
border-color: var(--bg-color); | ||
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1); | ||
} |
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,88 @@ | ||
import { createFragment } from "../lib/skeleton/index.js"; | ||
import { animate, slideYIn } from "../lib/animate.js"; | ||
import { loadCSS } from "../helpers/loader.js"; | ||
|
||
await loadCSS(import.meta.url, "./dropdown.css"); | ||
|
||
export default class ComponentDropdown extends HTMLDivElement { | ||
constructor() { | ||
super(); | ||
this.render(); | ||
} | ||
|
||
static get observedAttributes() { | ||
return ["options"]; | ||
} | ||
|
||
render() { | ||
this.classList.add("component_dropdown", "view", "sort") | ||
this.appendChild(createFragment(` | ||
<div class="dropdown_button"> | ||
<img class="component_icon" draggable="false" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzODQgNTEyIj4KICA8cGF0aCBmaWxsPSIjZjJmMmYyIiBkPSJNIDM2MCw0NjAgSCAyNCBDIDEwLjcsNDYwIDAsNDUzLjMgMCw0NDAgdiAtMTIgYyAwLC0xMy4zIDEwLjcsLTIwIDI0LC0yMCBoIDMzNiBjIDEzLjMsMCAyNCw2LjcgMjQsMjAgdiAxMiBjIDAsMTMuMyAtMTAuNywyMCAtMjQsMjAgeiIgLz4KICA8cGF0aCBmaWxsPSIjZjJmMmYyIiBkPSJNIDIyNi41NTM5LDIzNC44ODQyOCBWIDUyLjk0MzI4MyBjIDAsLTYuNjI3IC01LjM3MywtMTIgLTEyLC0xMiBoIC00NCBjIC02LjYyNywwIC0xMiw1LjM3MyAtMTIsMTIgViAyMzQuODg0MjggaCAtNTIuMDU5IGMgLTIxLjM4MiwwIC0zMi4wOSwyNS44NTEgLTE2Ljk3MSw0MC45NzEgbCA4Ni4wNTksODYuMDU5IGMgOS4zNzMsOS4zNzMgMjQuNTY5LDkuMzczIDMzLjk0MSwwIGwgODYuMDU5LC04Ni4wNTkgYyAxNS4xMTksLTE1LjExOSA0LjQxMSwtNDAuOTcxIC0xNi45NzEsLTQwLjk3MSB6IiAvPgo8L3N2Zz4K" alt="download_white"> | ||
</div>`)); | ||
|
||
this.appendChild(createFragment(` | ||
<div class="dropdown_container"> | ||
<ul> | ||
<li> | ||
<div> | ||
<a download="README.org" href="/api/files/cat?path=%2FREADME.org">Save current file</a> | ||
</div> | ||
</li> | ||
<li> | ||
<div> | ||
<a target="_blank" href="/api/export/private/text/html/README.org">Export as HTML</a> | ||
</div> | ||
</li> | ||
<li> | ||
<div> | ||
<a target="_blank" href="/api/export/private/application/pdf/README.org">Export as PDF</a> | ||
</div> | ||
</li> | ||
<li> | ||
<div> | ||
<a target="_blank" href="/api/export/private/text/markdown/README.org">Export as Markdown</a> | ||
</div> | ||
</li> | ||
<li> | ||
<div> | ||
<a target="_blank" href="/api/export/private/text/plain/README.org">Export as TXT</a> | ||
</div> | ||
</li> | ||
<li> | ||
<div> | ||
<a target="_blank" download="README.tex" href="/api/export/private/text/x-latex/README.org">Export as Latex</a> | ||
</div> | ||
</li> | ||
<li> | ||
<div> | ||
<a target="_blank" download="README.ics" href="/api/export/private/text/calendar/README.org">Export as ical</a> | ||
</div> | ||
</li> | ||
<li> | ||
<div> | ||
<a target="_blank" download="README.odt" href="/api/export/private/application/vnd.oasis.opendocument.text/README.org">Export as Open office</a> | ||
</div> | ||
</li> | ||
<li> | ||
<div> | ||
<a target="_blank" download="README.pdf" href="/api/export/private/application/pdf/README.org?mode=beamer">Export as Beamer</a> | ||
</div> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
`)); | ||
|
||
const setActive = () => this.classList.toggle("active"); | ||
this.querySelector(".dropdown_button").onclick = () => { | ||
setActive(); | ||
animate(this.querySelector(".dropdown_container"), { | ||
time: 100, | ||
keyframes: slideYIn(2), | ||
}); | ||
}; | ||
} | ||
} | ||
|
||
customElements.define("component-dropdown", ComponentDropdown, { extends: "div" }); |
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
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,15 +1,15 @@ | ||
export default class assert { | ||
static type(object, type) { | ||
static type(object, type, msg) { | ||
if (object instanceof type) return; | ||
throw new Error(`assertion failed - unexpected type for ${object.toString()}`); | ||
throw new Error(msg ? msg : `assertion failed - unexpected type for ${object.toString()}`); | ||
} | ||
|
||
static truthy(object) { | ||
static truthy(object, msg) { | ||
if (object) return; | ||
throw new Error(`assertion failed - object is not truthy`); | ||
throw new Error(msg ? msg : `assertion failed - object is not truthy`); | ||
} | ||
|
||
static fail(object) { | ||
throw new Error(`assertion failed - ${object}`); | ||
static fail(object, msg) { | ||
throw new Error(msg ? msg : `assertion failed - ${object}`); | ||
} | ||
} |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Oops, something went wrong.