-
Notifications
You must be signed in to change notification settings - Fork 138
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
Add PreLoadImage class to substitute IdentityBackground #2434
Conversation
import { dapps } from "../constants"; | ||
import { displayManagePage } from "$src/flows/manage"; | ||
import { html } from "lit-html"; | ||
import identityCardBackground from "$src/assets/identityCardBackground.png"; |
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.
Importing it here we ensure that it doesn't get mixed with the application code and we don't need to cast types.
Ideally, we will move the showcase to its own library with its own package.json and then we will be able to separate import statements better.
|
||
export const identityBackground = IdentityBackground.getSingleton( | ||
// When running the build, this is also built but not in an Astro environment | ||
(backgroundImage as unknown as ImageMetadata).src |
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.
The way to remove this ugly line was to import the asset in the .astro
files directly.
@frederikrothenberger let me know what you think now. |
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.
Nice, lgtm!
Main motivation is to remove the IdentityBackground class because it increases more the complexity than the value it adds.
The problem is that importing an asset in the showcase (Astro) and the application means different types of the imported value.
Before, we had a workaround that another instance of the class was created for the showcase and for the application.
IdentityBackground had two functionalities:
This PR introduces a new class
PreLoadImage
that has only the preloading functionality and expects an image as input.This allows us to use the image differently in Astro and app environments.