Skip to content

Commit dbba1dc

Browse files
authored
Display the name of the creator for flags & skins (#3510)
## Description: So artists get credit for the work they do. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: evan
1 parent 4bf18df commit dbba1dc

7 files changed

Lines changed: 69 additions & 15 deletions

File tree

resources/lang/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,9 @@
919919
"select_skin": "Select Skin",
920920
"selected": "selected"
921921
},
922+
"cosmetics": {
923+
"artist_label": "Artist:"
924+
},
922925
"flag_input": {
923926
"title": "Select Flag",
924927
"button_title": "Pick a flag!",

src/client/FlagInputModal.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ export class FlagInputModal extends BaseModal {
3939
.map(
4040
([key, flag]) => html`
4141
<flag-button
42-
.flag=${{ key: `flag:${key}`, name: flag.name, url: flag.url }}
42+
.flag=${{
43+
key: `flag:${key}`,
44+
name: flag.name,
45+
url: flag.url,
46+
artist: flag.artist,
47+
}}
4348
.selected=${selectedFlag === `flag:${key}`}
4449
.onSelect=${onSelect}
4550
></flag-button>

src/client/Store.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ export class StoreModal extends BaseModal {
188188
name: flag.name,
189189
url: flag.url,
190190
product: flag.product,
191+
artist: flag.artist,
191192
}}
192193
.selected=${selectedFlag === `flag:${key}`}
193194
.requiresPurchase=${rel === "purchasable"}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { html, LitElement, nothing } from "lit";
2+
import { customElement, property } from "lit/decorators.js";
3+
import { translateText } from "../Utils";
4+
5+
@customElement("artist-info")
6+
export class ArtistInfo extends LitElement {
7+
@property({ type: String })
8+
artist?: string;
9+
10+
createRenderRoot() {
11+
return this;
12+
}
13+
14+
render() {
15+
if (!this.artist) {
16+
return nothing;
17+
}
18+
19+
return html`
20+
<div
21+
class="absolute -top-1 -right-1 z-10 group/artist"
22+
@click=${(e: Event) => e.stopPropagation()}
23+
>
24+
<div
25+
class="w-6 h-6 rounded-full bg-white/20 hover:bg-white/40 flex items-center justify-center cursor-help transition-colors duration-150"
26+
>
27+
<span class="text-xs font-bold text-white/70">?</span>
28+
</div>
29+
<div
30+
class="hidden group-hover/artist:block absolute top-7 right-0 bg-zinc-800 text-white text-xs px-2.5 py-1.5 rounded shadow-lg whitespace-nowrap z-20 border border-white/10"
31+
>
32+
${translateText("cosmetics.artist_label")} ${this.artist}
33+
</div>
34+
</div>
35+
`;
36+
}
37+
}

src/client/components/FlagButton.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import { html, LitElement } from "lit";
22
import { customElement, property } from "lit/decorators.js";
33
import { Product } from "../../core/CosmeticSchemas";
44
import { translateCosmetic } from "../Cosmetics";
5+
import "./ArtistInfo";
56
import "./PurchaseButton";
67

78
export interface FlagItem {
89
key: string;
910
name: string;
1011
url: string;
1112
product?: Product | null;
13+
artist?: string;
1214
}
1315

1416
@customElement("flag-button")
@@ -39,7 +41,7 @@ export class FlagButton extends LitElement {
3941
render() {
4042
return html`
4143
<div
42-
class="flex flex-col items-center justify-between gap-1 p-2 bg-white/5 backdrop-blur-sm border rounded-lg w-36 h-full transition-all duration-200 ${this
44+
class="flex flex-col items-center justify-between gap-1 p-1.5 bg-white/5 backdrop-blur-sm border rounded-lg w-36 h-full transition-all duration-200 ${this
4345
.selected
4446
? "border-green-500 shadow-[0_0_15px_rgba(34,197,94,0.5)]"
4547
: "hover:bg-white/10 hover:border-white/20 hover:shadow-xl border-white/10"}"
@@ -50,17 +52,17 @@ export class FlagButton extends LitElement {
5052
?disabled=${this.requiresPurchase}
5153
@click=${this.handleClick}
5254
>
53-
<div class="flex flex-col items-center w-full">
54-
<div
55-
class="text-[10px] font-bold text-white uppercase tracking-wider mb-0.5 text-center truncate w-full ${this
56-
.requiresPurchase
57-
? "opacity-50"
58-
: ""}"
59-
title="${translateCosmetic("flags", this.flag.name)}"
60-
>
61-
${translateCosmetic("flags", this.flag.name)}
62-
</div>
63-
<div class="h-[14px] mb-1 w-full"></div>
55+
<artist-info .artist=${this.flag.artist}></artist-info>
56+
<div
57+
class="text-[10px] font-bold text-white uppercase tracking-wider mt-1 ${this
58+
.flag.artist
59+
? "pr-5"
60+
: ""} text-center truncate w-full ${this.requiresPurchase
61+
? "opacity-50"
62+
: ""}"
63+
title="${translateCosmetic("flags", this.flag.name)}"
64+
>
65+
${translateCosmetic("flags", this.flag.name)}
6466
</div>
6567
6668
<div

src/client/components/PatternButton.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { PatternDecoder } from "../../core/PatternDecoder";
1111
import { PlayerPattern } from "../../core/Schemas";
1212
import { translateCosmetic } from "../Cosmetics";
1313
import { translateText } from "../Utils";
14+
import "./ArtistInfo";
1415
import "./PurchaseButton";
1516

1617
export const BUTTON_WIDTH = 150;
@@ -72,10 +73,13 @@ export class PatternButton extends LitElement {
7273
?disabled=${this.requiresPurchase}
7374
@click=${this.handleClick}
7475
>
76+
<artist-info .artist=${this.pattern?.artist}></artist-info>
7577
<div class="flex flex-col items-center w-full">
7678
<div
77-
class="text-xs font-bold text-white uppercase tracking-wider mb-1 text-center truncate w-full ${this
78-
.requiresPurchase
79+
class="text-xs font-bold text-white uppercase tracking-wider mb-1 ${this
80+
.pattern?.artist
81+
? "pr-5"
82+
: ""} text-center truncate w-full ${this.requiresPurchase
7983
? "opacity-50"
8084
: ""}"
8185
title="${isDefaultPattern

src/core/CosmeticSchemas.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@ export const PatternSchema = z.object({
6363
.optional(),
6464
affiliateCode: z.string().nullable(),
6565
product: ProductSchema.nullable(),
66+
artist: z.string().optional(),
6667
});
6768

6869
export const FlagSchema = z.object({
6970
name: CosmeticNameSchema,
7071
url: z.string(),
7172
affiliateCode: z.string().nullable(),
7273
product: ProductSchema.nullable(),
74+
artist: z.string().optional(),
7375
});
7476

7577
// Schema for resources/cosmetics/cosmetics.json

0 commit comments

Comments
 (0)