-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Item Card component displays Critic|Community ratings from setting #6919
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
eea6dcf
a22a8a2
6cab06c
8073994
446f9bc
d824b23
dfb1d53
678c1d7
b4d8298
dbbade5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,8 @@ | |
resolveMixedShapeByAspectRatio | ||
} from './cardBuilderUtils'; | ||
|
||
import * as userSettings from 'scripts/settings/userSettings'; | ||
|
||
const enableFocusTransform = !browser.slow && !browser.edge; | ||
|
||
/** | ||
|
@@ -1127,12 +1129,37 @@ | |
let additionalCardContent = ''; | ||
|
||
if (layoutManager.desktop && !options.disableHoverMenu) { | ||
additionalCardContent += getRatingHtml(item); | ||
additionalCardContent += getHoverMenuHtml(item, action); | ||
} | ||
|
||
return '<' + tagName + ' data-index="' + index + '"' + timerAttributes + actionAttribute + ' data-isfolder="' + (item.IsFolder || false) + '" data-serverid="' + (item.ServerId || options.serverId) + '" data-id="' + (item.Id || item.ItemId) + '" data-type="' + item.Type + '"' + mediaTypeData + collectionTypeData + channelIdData + pathData + positionTicksData + collectionIdData + playlistIdData + contextData + parentIdData + startDate + endDate + ' data-prefix="' + escapeHtml(prefix) + '" class="' + className + '"' + ariaLabelAttribute + '>' + cardImageContainerOpen + innerCardFooter + cardImageContainerClose + overlayButtons + additionalCardContent + cardScalableClose + outerCardFooter + cardBoxClose + '</' + tagName + '>'; | ||
} | ||
|
||
/** | ||
* Generates HTML markup for card rating. | ||
* @param {object} item - Item used to generate the card rating. | ||
* @returns {string} HTML markup of the card rating. | ||
*/ | ||
function getRatingHtml(item) { | ||
viown marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const ratingsSetting = userSettings.cardRatings(); | ||
if (!ratingsSetting || ratingsSetting === 'none') { | ||
return ''; | ||
} | ||
|
||
let cardRatingHtml = ''; | ||
if (item.CriticRating && ['critic', 'all'].includes(ratingsSetting)) { | ||
const backgroundImageClass = item.CriticRating >= 60 ? 'cardRatingFresh' : 'cardRatingRotten'; | ||
cardRatingHtml += `<div class="cardCriticRating ${backgroundImageClass}">${item.CriticRating}</div>`; | ||
} | ||
if (item.CommunityRating && ['community', 'all'].includes(ratingsSetting)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can put community ratings first? Same order as in the item details page. |
||
const starIconHtml = '<span class="material-icons cardStarIcon star" aria-hidden="true"></span>' | ||
github-actions[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cardRatingHtml += `<div class="cardRating cardCommunityRating">${starIconHtml}${item.CommunityRating.toFixed(1)}</div>`; | ||
} | ||
|
||
return cardRatingHtml ? `<div class="cardRatingContainer">${cardRatingHtml}</div>` : ''; | ||
} | ||
|
||
/** | ||
* Generates HTML markup for the card overlay. | ||
* @param {object} item - Item used to generate the card overlay. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -296,6 +296,20 @@ <h2 class="sectionTitle"> | |
<div class="fieldDescription checkboxFieldDescription">${UseEpisodeImagesInNextUpHelp}</div> | ||
</div> | ||
|
||
<h2 class="sectionTitle"> | ||
${ItemCard} | ||
</h2> | ||
Comment on lines
+299
to
+301
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not think any of the other sections fit well enough. Seeing "Item Details" existed I thought "Item Card" was a consistently themed section. |
||
|
||
<div class="selectContainer"> | ||
<select id="selectCardRatings" is="emby-select" class="selectLayout" label="${LabelCardRatings}"> | ||
<option value="none">${None}</option> | ||
<option value="critic">${CriticRating}</option> | ||
<option value="community">${CommunityRating}</option> | ||
<option value="all">${All}</option> | ||
</select> | ||
<div class="fieldDescription">${CardRatingsHelp}</div> | ||
</div> | ||
|
||
<h2 class="sectionTitle"> | ||
${ItemDetails} | ||
</h2> | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -309,9 +309,9 @@ export class UserSettings { | |||||
} | ||||||
|
||||||
/** | ||||||
* Get or set customCss. | ||||||
* @param {string|undefined} [val] - Language. | ||||||
* @return {string} Language. | ||||||
* Get or set 'customCss'. | ||||||
* @param {string|undefined} [val] - 'customCss' state. | ||||||
* @return {string} 'customCss' state. | ||||||
*/ | ||||||
customCss(val) { | ||||||
if (val !== undefined) { | ||||||
|
@@ -321,6 +321,19 @@ export class UserSettings { | |||||
return this.get('customCss', false); | ||||||
} | ||||||
|
||||||
/** | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know I'm open to different approaches but I think its important to have a setting. Both to allow for default behavior of still not showing card ratings, and the extra options I added. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's adding new files that would be an issue, so it's fine. |
||||||
* Get or set 'cardRatings' state. | ||||||
* @param {string|undefined} [val] - 'cardRatings' state. | ||||||
* @return {string} 'cardRatings' state. | ||||||
*/ | ||||||
cardRatings(val) { | ||||||
if (val !== undefined) { | ||||||
return this.set('cardRatings', val.toString(), false); | ||||||
} | ||||||
|
||||||
return this.get('cardRatings', false); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
/** | ||||||
* Get or set 'Details Banner' state. | ||||||
* @param {boolean|undefined} [val] - Flag to enable 'Details Banner' or undefined. | ||||||
|
@@ -694,6 +707,7 @@ export const enableThemeVideos = currentSettings.enableThemeVideos.bind(currentS | |||||
export const enableFastFadein = currentSettings.enableFastFadein.bind(currentSettings); | ||||||
export const enableBlurhash = currentSettings.enableBlurhash.bind(currentSettings); | ||||||
export const enableBackdrops = currentSettings.enableBackdrops.bind(currentSettings); | ||||||
export const cardRatings = currentSettings.cardRatings.bind(currentSettings); | ||||||
export const detailsBanner = currentSettings.detailsBanner.bind(currentSettings); | ||||||
export const useEpisodeImagesInNextUpAndResume = currentSettings.useEpisodeImagesInNextUpAndResume.bind(currentSettings); | ||||||
export const language = currentSettings.language.bind(currentSettings); | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.