mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
stuff icon
This commit is contained in:
1 parent
61d6d42742
commit
402d054b30
6 files changed
+59
-11
No files matched your search
@@ -46,6 +46,7 @@ export abstract class AbstractAPI {
|
|||||||
abstract backgrounds(): Promise<Backgrounds>;
|
abstract backgrounds(): Promise<Backgrounds>;
|
||||||
|
|
||||||
abstract currencyIcon(id: string): Promise<string>;
|
abstract currencyIcon(id: string): Promise<string>;
|
||||||
|
abstract stuffIcon(id: string): Promise<string>;
|
||||||
|
|
||||||
private assertLocale(locale: string) {
|
private assertLocale(locale: string) {
|
||||||
const supported = locales.supported.find(
|
const supported = locales.supported.find(
|
||||||
|
|||||||
@@ -116,6 +116,11 @@ export class ClientAPI extends AbstractAPI {
|
|||||||
currencyIcon() {
|
currencyIcon() {
|
||||||
return rejected();
|
return rejected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UnimplementedOnClient
|
||||||
|
stuffIcon() {
|
||||||
|
return rejected();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function UnimplementedOnClient(
|
function UnimplementedOnClient(
|
||||||
|
|||||||
@@ -388,9 +388,16 @@ export class ServerAPI extends AbstractAPI {
|
|||||||
|
|
||||||
@Cache()
|
@Cache()
|
||||||
async currencyIcon(id: string) {
|
async currencyIcon(id: string) {
|
||||||
const item = this.metadata.item(`CurrencyEntity.${id}`);
|
const item = this.metadata.item(id);
|
||||||
const stuffUI = item.StuffUI("UIComponent");
|
const stuffUI = item.StuffUI("UIComponent");
|
||||||
|
return this.mediaPrefix(stuffUI.icon!.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Cache()
|
||||||
|
async stuffIcon(id: string) {
|
||||||
|
const item = this.metadata.item(id);
|
||||||
|
console.log(id);
|
||||||
|
const stuffUI = item.StuffUI("UIComponent");
|
||||||
return this.mediaPrefix(stuffUI.icon!.value);
|
return this.mediaPrefix(stuffUI.icon!.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,23 +26,44 @@ interface PriceEntryProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function PriceEntry({ entry }: PriceEntryProps) {
|
function PriceEntry({ entry }: PriceEntryProps) {
|
||||||
const locale = useLocale();
|
if (entry.premium_time_price !== undefined) {
|
||||||
|
console.log(entry);
|
||||||
|
|
||||||
if (
|
|
||||||
entry.premium_time_price !== undefined ||
|
|
||||||
entry.stuff_price !== undefined ||
|
|
||||||
entry.currency_price === undefined
|
|
||||||
) {
|
|
||||||
throw new Error("Unsupported price type");
|
throw new Error("Unsupported price type");
|
||||||
}
|
}
|
||||||
|
|
||||||
const [, iconName] = entry.currency_price.currency_catalog_id.split(".");
|
return (
|
||||||
|
<>
|
||||||
|
{entry.currency_price && (
|
||||||
|
<PriceInternal
|
||||||
|
icon={`/api/currencies/${entry.currency_price.currency_catalog_id}.webp`}
|
||||||
|
value={entry.currency_price.amount}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{entry.stuff_price && (
|
||||||
|
<PriceInternal
|
||||||
|
icon={`/api/stuff/${entry.stuff_price.stuff_catalog_id}.webp`}
|
||||||
|
value={entry.stuff_price.amount}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PriceInternalProps {
|
||||||
|
icon: string;
|
||||||
|
value: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
function PriceInternal({ icon, value }: PriceInternalProps) {
|
||||||
|
const locale = useLocale();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Text weight="light" size="minor" lowContrast className={styles.entry}>
|
<Text weight="light" size="minor" lowContrast className={styles.entry}>
|
||||||
<div className={styles.wrapper}>
|
<div className={styles.wrapper}>
|
||||||
<img className={styles.icon} src={`/api/currencies/${iconName}.webp`} />
|
<img className={styles.icon} src={icon} />
|
||||||
{formatCompact(locale, entry.currency_price.amount)}
|
{formatCompact(locale, value)}
|
||||||
</div>
|
</div>
|
||||||
</Text>
|
</Text>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { getStaticPaths as _getStaticPaths } from "../_index";
|
|||||||
|
|
||||||
export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
|
export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
|
||||||
const group = api.metadata.group("CurrencyEntity");
|
const group = api.metadata.group("CurrencyEntity");
|
||||||
return group.map(({ name }) => ({ params: { id: name } }));
|
return group.map(({ id }) => ({ params: { id } }));
|
||||||
});
|
});
|
||||||
|
|
||||||
export async function GET({ params }: { params: { id: string } }) {
|
export async function GET({ params }: { params: { id: string } }) {
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { api } from "../../../api/dynamic";
|
||||||
|
import { imageProxy } from "../../../api/imageProxy";
|
||||||
|
import { mixStaticPaths } from "../../../astro/mixStaticPaths";
|
||||||
|
import { getStaticPaths as _getStaticPaths } from "../_index";
|
||||||
|
|
||||||
|
export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
|
||||||
|
const group = api.metadata.group("ProxyEntity");
|
||||||
|
return group.map(({ id }) => ({ params: { id } }));
|
||||||
|
});
|
||||||
|
|
||||||
|
export async function GET({ params }: { params: { id: string } }) {
|
||||||
|
const icon = await api.stuffIcon(params.id);
|
||||||
|
return await imageProxy(icon);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user