-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always use svg series icon #5214
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
75ec662
Only use simplified icon when series is not yet loaded
jorg-vr 465558e
Fix homepage
jorg-vr 20591e1
Make series icon into webcomponent
jorg-vr 2accdd0
Fix loading of series
jorg-vr 93096ba
Fix tooltip positioning
jorg-vr d7f0a4c
Merge branch 'main' into fix/series-icon
jorg-vr 2f1b38c
Simplify arguments
jorg-vr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,76 @@ | ||
import { ShadowlessLitElement } from "components/meta/shadowless_lit_element"; | ||
import { html, svg, TemplateResult } from "lit"; | ||
import { customElement, property } from "lit/decorators.js"; | ||
|
||
/** | ||
* @element d-series-icon | ||
* | ||
* this icon visualizes the status of a series for a give user | ||
* | ||
* @cssprop --icon-color - the color of the icon | ||
* @cssprop --icon-background-color - the background color of the icon | ||
* @cssprop --deadline-icon-color - the color of the deadline icon | ||
* @cssprop --deadline-icon-background-color - the background color of the deadline icon | ||
* | ||
* @attr {string} deadline-class - a css class to apply related to the deadline if any | ||
* @attr {string} deadline-icon - the icon to show for the deadline if any | ||
* @attr {string} overlay-class - a css class to apply to the overlay if any | ||
* @attr {string} progress-class - a css class to apply that is related to the progress | ||
* @attr {string} progress-icon - the icon to show that indicates the progress, defaults to mdi-school | ||
* @attr {number} size - the size of the icon in pixels | ||
*/ | ||
@customElement("d-series-icon") | ||
export class SeriesIcon extends ShadowlessLitElement { | ||
jorg-vr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@property({ type: String, attribute: "deadline-class" }) | ||
deadline_class = ""; | ||
@property({ type: String, attribute: "deadline-icon" }) | ||
deadline_icon = ""; | ||
@property({ type: String, attribute: "overlay-class" }) | ||
overlay_class = ""; | ||
@property({ type: String, attribute: "progress-class" }) | ||
progress_class = ""; | ||
@property({ type: String, attribute: "progress-icon" }) | ||
progress_icon = "mdi-school"; | ||
@property({ type: Number }) | ||
size = 40; | ||
protected render(): TemplateResult { | ||
return html` | ||
<svg viewBox="0 0 40 40" | ||
style="width: ${this.size}px; height: ${this.size}px; " | ||
class="series-icon ${this.overlay_class} ${this.progress_class} ${this.deadline_class}" | ||
> | ||
<defs> | ||
<linearGradient id="rainbow" gradientTransform="rotate(135, 0.5, 0.5)" > | ||
<stop stop-color="var(--red)" offset="1%" /> | ||
<stop stop-color="var(--orange)" offset="25%" /> | ||
<stop stop-color="var(--yellow)" offset="40%" /> | ||
<stop stop-color="var(--green)" offset="60%" /> | ||
<stop stop-color="var(--blue)" offset="75%" /> | ||
<stop stop-color="var(--purple)" offset="99%" /> | ||
</linearGradient> | ||
</defs> | ||
jorg-vr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<g class="icon-base" > | ||
<circle cx="50%" cy="50%" r= "50%" fill="var(--icon-color)" class="outer-circle"></circle> | ||
<circle cx="50%" cy="50%" r= "42%" fill="var(--icon-background-color)"></circle> | ||
<foreignObject x="8" y="8" height="24" width="24" style="color: var(--icon-color)"> | ||
<i class="mdi ${this.progress_icon}"></i> | ||
</foreignObject> | ||
|
||
${this.deadline_icon ? svg` | ||
<circle cx="33" cy="34.5" r= "11" fill="var(--deadline-icon-background-color)"></circle> | ||
<foreignObject x="24" y="26" height="18" width="18" style="color: var(--deadline-icon-color)"> | ||
<i class="mdi mdi-18 ${this.deadline_icon}"></i> | ||
</foreignObject> | ||
` : ""} | ||
</g> | ||
|
||
${this.overlay_class ? svg` | ||
<foreignObject width="100%" height="100%" class="overlay"> | ||
<div></div> | ||
</foreignObject> | ||
` : ""} | ||
</svg> | ||
`; | ||
} | ||
} |
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,58 +1,20 @@ | ||
<% # arguments: loaded (bool), series (Series), user (User) %> | ||
<% size ||= 40 %> | ||
<% if defined?(loaded) && !loaded %> | ||
<div class="card-title-icon skeleton"> | ||
<i class="mdi mdi-school"></i> | ||
</div> | ||
<% elsif defined?(loaded) && loaded && user.present? %> | ||
<% if defined?(loaded) && loaded && user.present? %> | ||
<% deadline_class, deadline_icon = series_status_deadline(series, user) %> | ||
<% progress_class, progress_icon = series_status_progress(series, user) %> | ||
<% overlay_class = series_status_overlay %> | ||
<svg viewBox="0 0 40 40" | ||
style="width: <%= size %>px; height: <%= size %>px; " | ||
class="series-icon <%= overlay_class %> <%= progress_class %> <%= deadline_class %>" | ||
title="<%= series_status(series, user) %>" | ||
data-bs-toggle="tooltip" | ||
data-bs-placement="top" | ||
> | ||
<defs> | ||
<linearGradient id="rainbow" gradientTransform="rotate(135, 0.5, 0.5)" > | ||
<stop stop-color="var(--red)" offset="1%" /> | ||
<stop stop-color="var(--orange)" offset="25%" /> | ||
<stop stop-color="var(--yellow)" offset="40%" /> | ||
<stop stop-color="var(--green)" offset="60%" /> | ||
<stop stop-color="var(--blue)" offset="75%" /> | ||
<stop stop-color="var(--purple)" offset="99%" /> | ||
</linearGradient> | ||
</defs> | ||
|
||
<g class="icon-base" > | ||
<circle cx="50%" cy="50%" r= "50%" fill="var(--icon-color)" class="outer-circle"></circle> | ||
<circle cx="50%" cy="50%" r= "42%" fill="var(--icon-background-color)"></circle> | ||
<foreignObject x="8" y="8" height="24" width="24" style="color: var(--icon-color)"> | ||
<i class="mdi <%= progress_icon %>"></i> | ||
</foreignObject> | ||
|
||
<% if deadline_icon %> | ||
<circle cx="33" cy="34.5" r= "11" fill="var(--deadline-icon-background-color)"></circle> | ||
<foreignObject x="24" y="26" height="18" width="18" style="color: var(--deadline-icon-color)"> | ||
<i class="mdi mdi-18 <%= deadline_icon %>"></i> | ||
</foreignObject> | ||
<% end %> | ||
</g> | ||
|
||
<% if overlay_class %> | ||
<foreignObject width="100%" height="100%" class="overlay"> | ||
<div></div> | ||
</foreignObject> | ||
<% end %> | ||
</svg> | ||
<d-series-icon | ||
size="<%= size %>" | ||
overlay-class="<%= overlay_class %>" | ||
progress-class="<%= progress_class %>" | ||
progress-icon="<%= progress_icon %>" | ||
deadline-class="<%= deadline_class %>" | ||
deadline-icon="<%= deadline_icon %>" | ||
title="<%= series_status(series, user) %>" | ||
data-bs-toggle="tooltip" | ||
data-bs-placement="top" | ||
></d-series-icon> | ||
<% else %> | ||
<svg viewBox="0 0 40 40" style="width: <%= size %>px; height: <%= size %>px; " class="series-icon"> | ||
<circle cx="50%" cy="50%" r= "50%" fill="var(--icon-color)" class="outer-circle"></circle> | ||
<circle cx="50%" cy="50%" r= "42%" fill="var(--icon-background-color)"></circle> | ||
<foreignObject x="8" y="8" height="24" width="24" style="color: var(--icon-color)"> | ||
<i class="mdi mdi-school"></i> | ||
</foreignObject> | ||
</svg> | ||
<d-series-icon size="<%= size %>"></d-series-icon> | ||
<% end %> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these specified in a general css file? Why not add them here to make this component self contained?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now it is a shadowless lit component, which forces all style definitions to be in the global scope.
Changing it to use the shadow dom would not allow any use of globally defined classes. In this this would mean we had to redefine the material design icons used within this class. I do not think that is desired.
Sadly there is no way to 'partially' use the shadow dom. Which is why we also aren't using the shadow dom in most other components for now.