Skip to content

Commit

Permalink
chore: run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
GODrums committed Nov 25, 2024
1 parent c891946 commit a43cbaf
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 55 deletions.
7 changes: 2 additions & 5 deletions src/lib/components/inventory/selected_item_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,9 @@ export class SelectedItemInfo extends FloatElement {
if (!this.itemInfo) {
return html``;
}

return html`
<float-bar
float=${this.itemInfo.floatvalue}
minFloat=${this.itemInfo.min}
maxFloat=${this.itemInfo.max}>
<float-bar float=${this.itemInfo.floatvalue} minFloat=${this.itemInfo.min} maxFloat=${this.itemInfo.max}>
</float-bar>
`;
}
Expand Down
12 changes: 4 additions & 8 deletions src/lib/components/market/item_row_wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ export class ItemRowWrapper extends FloatElement {

return html`
<div class="float-row-wrapper">
${this.renderFloatBar()}
Float: ${this.itemInfo.floatvalue.toFixed(14)} ${renderClickableRank(this.itemInfo)}<br />
${this.renderFloatBar()} Float: ${this.itemInfo.floatvalue.toFixed(14)}
${renderClickableRank(this.itemInfo)}<br />
Paint Seed:
${formatSeed(this.itemInfo)}${fadePercentage !== undefined
? html`<br />
Expand All @@ -182,17 +182,13 @@ export class ItemRowWrapper extends FloatElement {
}
}


renderFloatBar(): TemplateResult<1> {
if (!this.itemInfo) {
return html``;
}

return html`
<float-bar
float=${this.itemInfo.floatvalue}
minFloat=${this.itemInfo.min}
maxFloat=${this.itemInfo.max}>
<float-bar float=${this.itemInfo.floatvalue} minFloat=${this.itemInfo.min} maxFloat=${this.itemInfo.max}>
</float-bar>
`;
}
Expand Down
86 changes: 44 additions & 42 deletions src/lib/ui/floatbar.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
import { LitElement, html, css, TemplateResult } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import {LitElement, html, css, TemplateResult} from 'lit';
import {customElement, property} from 'lit/decorators.js';

@customElement('float-bar')
export class FloatBar extends LitElement {
@property({ type: Number }) float!: number;
@property({ type: Number }) minFloat = 0;
@property({ type: Number }) maxFloat = 1;
@property({type: Number}) float!: number;
@property({type: Number}) minFloat = 0;
@property({type: Number}) maxFloat = 1;

static styles = css`
.market-float-bar-container {
position: relative;
width: 100%;
height: 8px;
margin: 5px 0;
}
.market-float-bar-container {
position: relative;
width: 100%;
height: 8px;
margin: 5px 0;
}
.market-float-bar-marker {
position: absolute;
background-color: #d9d9d9;
width: 3px;
top: -3px;
height: 14px;
border-radius: 4px;
}
.market-float-bar-marker {
position: absolute;
background-color: #d9d9d9;
width: 3px;
top: -3px;
height: 14px;
border-radius: 4px;
}
.market-float-bar {
display: inline-block;
vertical-align: top;
height: 100%;
opacity: 0.8;
}
.market-float-bar {
display: inline-block;
vertical-align: top;
height: 100%;
opacity: 0.8;
}
.market-float-bar:not([style*='background-color: transparent']):first-of-type {
border-radius: 4px 0 0 4px;
}
.market-float-bar:not([style*='background-color: transparent']):last-of-type {
border-radius: 0 4px 4px 0;
}
.market-float-bar:not([style*='background-color: transparent']):first-of-type {
border-radius: 4px 0 0 4px;
}
.market-float-bar:not([style*='background-color: transparent']):last-of-type {
border-radius: 0 4px 4px 0;
}
`;

private readonly floatConditions = [
Expand All @@ -49,24 +49,26 @@ export class FloatBar extends LitElement {

render(): TemplateResult {
const left = (this.minFloat * 100).toFixed(0);
const markerLeft = ((this.float - this.minFloat) * 100 / (this.maxFloat - this.minFloat)).toFixed(3);
const markerLeft = (((this.float - this.minFloat) * 100) / (this.maxFloat - this.minFloat)).toFixed(3);
const dynamicWidth = (this.maxFloat - this.minFloat) * 100;

return html`
<div class="market-float-bar-container" style="left: ${left}%; width: ${dynamicWidth.toFixed(2)}%;">
<div style="height: 100%; border-radius: 4px; overflow: hidden; font-size: 0;">
${this.floatConditions.map((cond) => html`
<div
class="market-float-bar"
style="width: ${((Math.min(cond.max, this.maxFloat * 100) -
Math.max(cond.min, this.minFloat * 100)) *
100) /
dynamicWidth}%; background-color: ${cond.color};">
</div>
`)}
${this.floatConditions.map(
(cond) => html`
<div
class="market-float-bar"
style="width: ${((Math.min(cond.max, this.maxFloat * 100) -
Math.max(cond.min, this.minFloat * 100)) *
100) /
dynamicWidth}%; background-color: ${cond.color};"
></div>
`
)}
</div>
<div class="market-float-bar-marker" style="left: calc(${markerLeft}% - 2px);"></div>
</div>
`;
}
}
}

0 comments on commit a43cbaf

Please sign in to comment.