-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from adrianfish/master
More stories
- Loading branch information
Showing
10 changed files
with
9,981 additions
and
53 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { html, css, LitElement } from 'lit-element'; | ||
import { icon, library } from '@fortawesome/fontawesome-svg-core'; | ||
import { faStar, faEllipsisV, faBell, faComments, faBook, faFileAlt } from '@fortawesome/free-solid-svg-icons'; | ||
|
||
export class SakaiIcon extends LitElement { | ||
|
||
static get styles() { | ||
|
||
return css` | ||
.sakai-small-icon { width: var(--sakai-small-icon-width, 14px); height: var(--sakai-small-icon-height, 15px) } | ||
.sakai-medium-icon { width: var(--sakai-medium-icon-width, 24px); height: var(--sakai-medium-icon-height, 24px) } | ||
.sakai-large-icon { width: var(--sakai-large-icon-width, 32px); height: var(--sakai-large-icon-height, 32px) } | ||
.alert { | ||
background-color: var(--sakai-icon-alert-color, red); | ||
width: var(--sakai-icon-alert-width, 4px); | ||
height: var(--sakai-icon-alert-width, 4px); | ||
position: absolute; | ||
margin-top: -18px; | ||
margin-left: 15px; | ||
-webkit-border-radius: calc(var(--sakai-icon-alert-width, 4px) / 2); | ||
-moz-border-radius: calc(var(--sakai-icon-alert-width, 4px) / 2); | ||
border-radius: calc(var(--sakai-icon-alert-width, 4px) / 2); | ||
} | ||
`; | ||
} | ||
|
||
static get properties() { | ||
|
||
return { | ||
hasAlerts: { attribute: "has-alerts", type: Boolean }, | ||
type: String, | ||
size: String, | ||
}; | ||
} | ||
|
||
constructor() { | ||
|
||
super(); | ||
this.size = "medium"; | ||
} | ||
|
||
render() { | ||
return html`${icon(SakaiIcon.lookups.get(this.type), {classes: `sakai-${this.size}-icon`}).node}${this.hasAlerts ? html`<div class="alert"></div>` : ""}`; | ||
} | ||
} | ||
|
||
library.add(faEllipsisV); // Menu | ||
library.add(faStar); // Favourite | ||
library.add(faBell); // General alerts | ||
library.add(faComments); // Forums | ||
library.add(faBook); // Gradebook | ||
library.add(faFileAlt); // Assignments | ||
|
||
SakaiIcon.lookups = new Map(); | ||
SakaiIcon.lookups.set("favourite", faStar); | ||
SakaiIcon.lookups.set("alert", faBell); | ||
SakaiIcon.lookups.set("menu", faEllipsisV); | ||
SakaiIcon.lookups.set("forums", faComments); | ||
SakaiIcon.lookups.set("gradebook", faBook); | ||
SakaiIcon.lookups.set("assignments", faFileAlt); | ||
|
||
if (!customElements.get("sakai-icon")) { | ||
customElements.define("sakai-icon", SakaiIcon); | ||
} |
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 { html, css, LitElement } from "lit-element"; | ||
import { createPopper } from "@popperjs/core"; | ||
import './sakai-icon.js'; | ||
|
||
export class SakaiOptionsMenu extends LitElement { | ||
|
||
static get styles() { | ||
|
||
return css` | ||
::slotted(div) { | ||
display: none; | ||
background-color: var(--sakai-options-menu-background-color, white); | ||
border-width: var(--sakai-options-menu-border-width, 1px); | ||
border-style: var(--sakai-options-menu-border-style, solid); | ||
border-color: var(--sakai-options-menu-border-color, black); | ||
font-family: var(--sakai-options-menu-font-family, arial, sans-serif); | ||
padding: 5px; | ||
} | ||
#invoker { | ||
color: var(--sakai-options-menu-invoker-color, white); | ||
font-size: var(--sakai-options-menu-invoker-size, 24px); | ||
} | ||
`; | ||
} | ||
|
||
static get properties() { | ||
|
||
return { | ||
placement: String, | ||
}; | ||
} | ||
|
||
|
||
constructor() { | ||
|
||
super(); | ||
this.placement = "right"; | ||
} | ||
|
||
firstUpdated(changed) { | ||
|
||
this.content = this.shadowRoot.querySelector('slot[name="content"]').assignedNodes()[0]; | ||
this.content.addEventListener("keydown", (e) => this._handleEscape(e)); | ||
|
||
this.invoker = this.shadowRoot.querySelector("#invoker"); | ||
this.invoker.addEventListener("keydown", (e) => this._handleEscape(e)); | ||
|
||
createPopper(this.invoker, this.content, | ||
{ | ||
placement: this.placement, | ||
modifiers: [ | ||
{ name: 'offset', options: { offset: [0, 8] }}, | ||
] | ||
} | ||
); | ||
} | ||
|
||
_handleEscape(e) { | ||
|
||
if (this.showing && e.key === "Escape") { | ||
this.content.style.display = "none"; | ||
this.showing = false; | ||
this.invoker.focus(); | ||
} | ||
} | ||
|
||
_toggle() { | ||
|
||
if (this.showing) { | ||
this.content.style.display = "none"; | ||
} else { | ||
this.content.style.display = "block"; | ||
} | ||
this.showing = !this.showing; | ||
} | ||
|
||
render() { | ||
|
||
return html` | ||
<a id="invoker" href="javascript:;" @click=${this._toggle}><sakai-icon type="menu" size="small" /></a> | ||
<slot name="content"></slot> | ||
`; | ||
} | ||
} | ||
|
||
if (!customElements.get("sakai-options-menu")) { | ||
customElements.define("sakai-options-menu", SakaiOptionsMenu); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.