-
Notifications
You must be signed in to change notification settings - Fork 40
Restore Market Filter with Custom Expression Parser #403
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 all commits
47b0317
c62d824
53e505a
6736e91
d42d64c
86a7466
a7325b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import {css, html, nothing, HTMLTemplateResult} from 'lit'; | ||
| import {CustomElement, InjectBefore, InjectionMode} from '../../injectors'; | ||
| import {FloatElement} from '../../custom'; | ||
| import {isReactSteamMarket} from '../mode'; | ||
|
|
||
| import '../../filter/filter_container'; | ||
|
|
||
| /** | ||
| * Steam Market Beta equivalent of {@link UtilityBelt}. | ||
| */ | ||
| @CustomElement() | ||
| @InjectBefore( | ||
| 'div:has(> [style*="grid-columns:repeat(auto-fill, minmax(260px"])', | ||
| InjectionMode.CONTINUOUS, | ||
| isReactSteamMarket | ||
| ) | ||
| export class ReactFilterPanel extends FloatElement { | ||
| static styles = [ | ||
| ...FloatElement.styles, | ||
| css` | ||
| .panel { | ||
| margin-bottom: 16px; | ||
| padding: 16px; | ||
| background-color: rgba(0, 0, 0, 0.25); | ||
| border: 1px solid rgba(255, 255, 255, 0.06); | ||
| border-radius: 8px; | ||
| color: #c7d5e0; | ||
| font-family: 'Motiva Sans', sans-serif; | ||
| } | ||
|
|
||
| .panel-title { | ||
| font-family: 'Motiva Sans', sans-serif; | ||
| font-size: 14px; | ||
| font-weight: 600; | ||
| letter-spacing: 0.04em; | ||
| text-transform: uppercase; | ||
| color: #ebebeb; | ||
| margin: 0 0 12px; | ||
| } | ||
| `, | ||
| ]; | ||
|
|
||
| private get key(): string { | ||
| return getSteamMarketID() || ''; | ||
| } | ||
|
|
||
| protected render(): HTMLTemplateResult | typeof nothing { | ||
| if (!this.key) return nothing; | ||
| return html` | ||
| <div class="panel"> | ||
| <h3 class="panel-title">CSFloat Filters</h3> | ||
| <csfloat-filter-container .key="${this.key}"></csfloat-filter-container> | ||
| </div> | ||
| `; | ||
| } | ||
| } | ||
|
|
||
| /** Example: G18FD03209F033003 */ | ||
| function getSteamMarketID(): string | undefined { | ||
| return location.pathname.split('/').pop(); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import {nothing} from 'lit'; | ||
| import {property} from 'lit/decorators.js'; | ||
| import type {Subscription} from 'rxjs'; | ||
| import {CustomElement, InjectIntoScope} from '../../injectors'; | ||
| import {FloatElement} from '../../custom'; | ||
| import {gFilterService} from '../../../services/filter'; | ||
| import {pickTextColour} from '../../../utils/colours'; | ||
| import {ReactMarketListingScope, type ReactListingContext} from './listing'; | ||
|
|
||
| @CustomElement() | ||
| @InjectIntoScope(ReactMarketListingScope, { | ||
| anchor: ({scope}) => scope, | ||
| }) | ||
| export class ReactListingHighlight extends FloatElement { | ||
| @property({attribute: false}) injectionContext?: ReactListingContext; | ||
|
|
||
| private filterSubscription?: Subscription; | ||
|
|
||
| connectedCallback(): void { | ||
| super.connectedCallback(); | ||
| this.filterSubscription = gFilterService.onUpdate$.subscribe(() => this.applyColour()); | ||
| } | ||
|
|
||
| disconnectedCallback(): void { | ||
| super.disconnectedCallback(); | ||
| this.filterSubscription?.unsubscribe(); | ||
| this.filterSubscription = undefined; | ||
| } | ||
|
|
||
| private get convertedPrice(): number | undefined { | ||
| const listing = this.injectionContext?.listing; | ||
| if (!listing?.unPrice) return undefined; | ||
| return (listing.unPrice + listing.unFee) / 100; | ||
| } | ||
|
|
||
| private applyColour(): void { | ||
| const card = this.parentElement; | ||
| const context = this.injectionContext; | ||
| if (!card || !context) return; | ||
|
|
||
| const colour = gFilterService.matchColour(context.itemInfo, this.convertedPrice) || ''; | ||
|
Collaborator
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. nit: If we don't have a color to apply, we should skip applying a style below. Otherwise, there is risk that we reset a bg color that Valve applies in the future. |
||
| card.style.backgroundColor = colour; | ||
| card.style.color = colour ? pickTextColour(colour, '#8F98A0', '#484848') : ''; | ||
| } | ||
|
|
||
| protected render() { | ||
| return nothing; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.