Skip to content
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

-#94 better visibility for the text in the popularity component #116

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion force-app/main/default/lwc/popularity/popularity.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
:host {
--slds-c-alert-color-background: var(--titleColor);
--slds-c-alert-color-background: var(--bannerColor);
}

.color {
color: var(--textColor);
font-size: medium;
font-weight: 500;
}
2 changes: 1 addition & 1 deletion force-app/main/default/lwc/popularity/popularity.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<template if:true={message}>
<div class="slds-notify slds-notify_alert" role="alert">
<span class="slds-assistive-text">{message}</span>
<p>{message}</p>
<p class="color">{message}</p>
</div>
</template>
</template>
12 changes: 6 additions & 6 deletions force-app/main/default/lwc/popularity/popularity.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@ import POPULARITY_FIELD from "@salesforce/schema/Track__c.Popularity__c";
export default class Popularity extends LightningElement {
@api recordId;
message;

@wire(getRecord, {
recordId: "$recordId",
fields: [POPULARITY_FIELD]
})
@wire(getRecord, { recordId: "$recordId", fields: [POPULARITY_FIELD] })
trackRecord({ data }) {
if (data) {
const popularity = getFieldValue(data, POPULARITY_FIELD);
let color = null;
let textColor = "#000000";

if (popularity == null) {
this.message = null;
} else if (popularity <= 30) {
color = "#d62023";
this.message = "this song is bad according to most people";
textColor = "#FDFEFE";
} else if (popularity <= 50) {
color = "#d1d62d";
this.message = "not the best song";
Expand All @@ -29,7 +28,8 @@ export default class Popularity extends LightningElement {
this.message = "this song is fire";
color = "#40f702";
}
document.documentElement.style.setProperty("--titleColor", color);
document.documentElement.style.setProperty("--bannerColor", color);
document.documentElement.style.setProperty("--textColor", textColor);
}
}
}