-
-
Notifications
You must be signed in to change notification settings - Fork 23
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 #4299 from dodona-edu/feature/teacher-course-cards
Show more relevant info for teachers on course cards
- Loading branch information
Showing
35 changed files
with
744 additions
and
169 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,39 @@ | ||
import { html, TemplateResult } from "lit"; | ||
import { customElement, property } from "lit/decorators.js"; | ||
import { ShadowlessLitElement } from "components/shadowless_lit_element"; | ||
import { searchQuery } from "search"; | ||
|
||
/** | ||
* This component represents a loading bar. | ||
* It will be triggered by search | ||
* | ||
* @element d-loading-bar | ||
*/ | ||
@customElement("d-loading-bar") | ||
export class LoadingBar extends ShadowlessLitElement { | ||
@property({ type: Boolean, state: true }) | ||
loading = false; | ||
|
||
constructor() { | ||
super(); | ||
searchQuery.loadingBars.push(this); | ||
} | ||
|
||
show(): void { | ||
this.loading = true; | ||
} | ||
|
||
hide(): void { | ||
this.loading = false; | ||
} | ||
|
||
render(): TemplateResult { | ||
return html` | ||
<div class="dodona-progress dodona-progress-indeterminate" style="visibility: ${this.loading ? "visible" : "hidden"};"> | ||
<div class="progressbar bar bar1" style="width: 0%;"></div> | ||
<div class="bufferbar bar bar2" style="width: 100%;"></div> | ||
<div class="auxbar bar bar3" style="width: 0%;"></div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { html, TemplateResult } from "lit"; | ||
import { customElement, property } from "lit/decorators.js"; | ||
import { ShadowlessLitElement } from "components/shadowless_lit_element"; | ||
import { initTooltips, ready } from "util.js"; | ||
|
||
/** | ||
* This component displays a progress bar consisting of consecutive divs | ||
* The divs are scaled according to the given values | ||
* The divs have an opacity according to their index | ||
* | ||
* @element d-progress-bar | ||
* | ||
* @prop {number[]} values - Pass the data as an array. | ||
* @prop {string} titleKey - The key of the title to be displayed in the tooltip. | ||
*/ | ||
@customElement("d-progress-bar") | ||
export class ProgressBar extends ShadowlessLitElement { | ||
@property({ type: Array }) | ||
values: Array<number>; | ||
|
||
@property({ type: String, attribute: "title-key" }) | ||
titleKey: string; | ||
|
||
get valuesSum(): number { | ||
return Object.values(this.values).reduce((a, b) => a + b, 0); | ||
} | ||
|
||
private getWidth(value: number): number { | ||
return 100 * value / this.valuesSum; | ||
} | ||
|
||
private getOpacity(key: number): number { | ||
return (key / (this.values.length - 1)) * 0.8 + 0.2; | ||
} | ||
|
||
private getTitle(value: number, index: number): string { | ||
return I18n.t(this.titleKey + I18n.t(this.titleKey + ".key", index), { index: index, smart_count: value }); | ||
} | ||
|
||
updated(changedProperties: Map<string, any>): void { | ||
initTooltips(this); | ||
super.updated(changedProperties); | ||
} | ||
|
||
constructor() { | ||
super(); | ||
// Reload when I18n is available | ||
ready.then(() => this.requestUpdate()); | ||
} | ||
|
||
private renderBar(value: number, index: number): TemplateResult { | ||
return html`<div | ||
class="bar" | ||
style="width: ${this.getWidth(value)}%; opacity: ${this.getOpacity(index)}; " | ||
title=${this.getTitle(value, index)} | ||
data-bs-toggle='tooltip'> | ||
</div>`; | ||
} | ||
|
||
render(): TemplateResult[] { | ||
return this.values.map( (v, i) => this.renderBar(v, i)).reverse(); | ||
} | ||
} |
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
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
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,9 @@ | ||
d-progress-bar { | ||
display: block; | ||
|
||
.bar { | ||
height: 8px; | ||
display: inline-block; | ||
background-color: $success; | ||
} | ||
} |
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.