Merge remote-tracking branch 'origin/unstable' into unstable

This commit is contained in:
KingRainbow44 2023-05-15 03:57:13 -04:00
commit c07c7701dd
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
2 changed files with 15 additions and 8 deletions

View File

@ -163,7 +163,12 @@ class ItemCard extends React.Component<IProps, IState> {
</div> </div>
<button className={"ObjectCard_Submit"} onClick={this.addToInventory.bind(this)}> <button className={"ObjectCard_Submit"} onClick={this.addToInventory.bind(this)}>
<TextState initial={connected} event={"connected"} text1={"Copy Command"} text2={"Add to Inventory"} /> <TextState
initial={connected}
event={"connected"}
text1={"Copy Command"}
text2={"Add to Inventory"}
/>
</button> </button>
</div> </div>
</div> </div>

View File

@ -19,7 +19,7 @@ interface IState {
class MiniCard extends React.Component<IProps, IState> { class MiniCard extends React.Component<IProps, IState> {
loading: number | any; loading: number | any;
containerRef: React.RefObject<HTMLDivElement>; containerRef: React.RefObject<HTMLDivElement>;
textRef: React.RefObject<HTMLDivElement>; textRef: React.RefObject<HTMLDivElement>;
@ -55,21 +55,21 @@ class MiniCard extends React.Component<IProps, IState> {
private adjustFontSize() { private adjustFontSize() {
const container = this.containerRef.current; const container = this.containerRef.current;
const text = this.textRef.current; const text = this.textRef.current;
if (!container || !text) { if (!container || !text) {
return; return;
} }
const containerWidth = container.offsetWidth; const containerWidth = container.offsetWidth;
const textWidth = text.scrollWidth; const textWidth = text.scrollWidth;
const fontSize = parseFloat(window.getComputedStyle(text).fontSize); const fontSize = parseFloat(window.getComputedStyle(text).fontSize);
const availableWidth = containerWidth - 10; const availableWidth = containerWidth - 10;
const scaleFactor = availableWidth / textWidth; const scaleFactor = availableWidth / textWidth;
if (scaleFactor < 1) { if (scaleFactor < 1) {
const newFontSize = fontSize * scaleFactor; const newFontSize = fontSize * scaleFactor;
text.style.fontSize = newFontSize + 'px'; text.style.fontSize = newFontSize + "px";
} }
} }
@ -98,7 +98,9 @@ class MiniCard extends React.Component<IProps, IState> {
)} )}
{(!this.state.loaded || !this.state.icon) && ( {(!this.state.loaded || !this.state.icon) && (
<p className={"MiniCard_Label"} ref={this.textRef}>{this.props.data.name}</p> <p className={"MiniCard_Label"} ref={this.textRef}>
{this.props.data.name}
</p>
)} )}
</div> </div>
</div> </div>