|
| 1 | +import { Perk, PerkValue } from './types/data'; |
| 2 | + |
| 3 | +/** |
| 4 | + * The values listed here are used as CSS classes. See source link for more |
| 5 | + * information. |
| 6 | + */ |
| 7 | +export const CLASSES = { |
| 8 | + /** |
| 9 | + * The element displayed while the grid is loading. |
| 10 | + * Only used in custom-element. |
| 11 | + */ |
| 12 | + loading: 'epg_loading' as const, |
| 13 | + /** |
| 14 | + * The element displayed if there is an error while loading the grid/ |
| 15 | + * Only used in custom-element. |
| 16 | + */ |
| 17 | + error: 'epg_error' as const, |
| 18 | + /** The parent grid element, once loaded with no error */ |
| 19 | + grid: 'epg_grid' as const, |
| 20 | + /** |
| 21 | + * If the grid element has this class, the element should be displayed as a |
| 22 | + * grid rather than as a list. |
| 23 | + */ |
| 24 | + displayAsGrid: 'epg_display-as-grid' as const, |
| 25 | + /** The grid header rowgroup element */ |
| 26 | + header: 'epg_header' as const, |
| 27 | + /** The grid body rowgroup element */ |
| 28 | + body: 'epg_body' as const, |
| 29 | + /** The grid footer rowgroup element */ |
| 30 | + footer: 'epg_footer' as const, |
| 31 | + /** All rowgroup elements */ |
| 32 | + rowgroup: 'epg_rowgroup' as const, |
| 33 | + /** All row elements */ |
| 34 | + row: 'epg_row' as const, |
| 35 | + /** All columnheader elements */ |
| 36 | + columnheader: 'epg_columnheader' as const, |
| 37 | + /** All rowheader elements */ |
| 38 | + rowheader: 'epg_rowheader' as const, |
| 39 | + /** All gridcell, columnheader, and rowheader elements */ |
| 40 | + cell: 'epg_cell' as const, |
| 41 | + /** All gridcell and columnheader elements related to a Package */ |
| 42 | + package: 'epg_package' as const, |
| 43 | + /** All gridcell and rowheader elements related to a Perk */ |
| 44 | + perk: 'epg_perk' as const, |
| 45 | + /** Lists of perks within the package header elements */ |
| 46 | + packagePerkList: 'epg_package-perk-list' as const, |
| 47 | + /** All Package Name or Perk Description elements */ |
| 48 | + descriptor: 'epg_descriptor' as const, |
| 49 | + attributes: { |
| 50 | + /** All Package/Park attribute elements */ |
| 51 | + container: 'epg_attributes' as const, |
| 52 | + /** All Package/Park "sold-out" attribute elements */ |
| 53 | + soldOut: 'epg_attributes-sold-out' as const, |
| 54 | + /** All Package/Park "limited" attribute elements */ |
| 55 | + limited: 'epg_attributes-limited' as const, |
| 56 | + }, |
| 57 | + /** |
| 58 | + * @param perk |
| 59 | + * @param value A {@link PerkValue} or undefined. If undefined, the value is falsy. |
| 60 | + * @returns A string of classes for selecting a perk value. |
| 61 | + * |
| 62 | + * @example |
| 63 | + * ```js |
| 64 | + * CLASSES.perkValue(mySimplePerk, false); |
| 65 | + * #=> 'epg_perk-value epg_perk-value-simple epg_perk-value-falsy' |
| 66 | + * |
| 67 | + * CLASSES.perkValue(myQuantityPerk, 1); |
| 68 | + * #=> 'epg_perk-value epg_perk-value-quantity epg_perk-value-truthy' |
| 69 | + * |
| 70 | + * CLASSES.perkValue(myFreeformPerk, undefined); |
| 71 | + * #=> 'epg_perk-value epg_perk-value-freeform epg_perk-value-falsy' |
| 72 | + * ``` |
| 73 | + */ |
| 74 | + perkValue(perk: Perk, value: PerkValue | undefined): string { |
| 75 | + return `epg_perk-value epg_perk-value-${perk.type} epg_perk-value-${ |
| 76 | + value ? 'truthy' : 'falsy' |
| 77 | + }`; |
| 78 | + }, |
| 79 | +}; |
0 commit comments