Compare commits
10
Commits
0d7617e2d2
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5882585f69 | ||
|
|
2d8027cb16 | ||
|
|
fbf22284e8 | ||
|
|
6efbd50db7 | ||
|
|
3f68997b9a | ||
|
|
be4de61bb7 | ||
|
|
6c582ba3cf | ||
|
|
9064340584 | ||
|
|
cc358697d4 | ||
|
|
f6686bbf17 |
No files matched your search
@@ -26,6 +26,7 @@ website/LICENSE
|
|||||||
!design-qa.md
|
!design-qa.md
|
||||||
!docs/specs/home-banner-production.md
|
!docs/specs/home-banner-production.md
|
||||||
!docs/specs/match-status-and-result-presentation.md
|
!docs/specs/match-status-and-result-presentation.md
|
||||||
|
!docs/specs/information-visible-ui.md
|
||||||
!docs/ux-audit-2026-11-10/06-ui-improvement-review.md
|
!docs/ux-audit-2026-11-10/06-ui-improvement-review.md
|
||||||
!docs/ux-audit-2026-11-10/07-visual-design-review.md
|
!docs/ux-audit-2026-11-10/07-visual-design-review.md
|
||||||
/tmp/
|
/tmp/
|
||||||
|
|||||||
@@ -72,6 +72,19 @@ executable path. The runner starts an isolated replica set on a random loopback
|
|||||||
port, uses a temporary database directory, and removes it after the tests. It
|
port, uses a temporary database directory, and removes it after the tests. It
|
||||||
does not use the application's database connection settings.
|
does not use the application's database connection settings.
|
||||||
|
|
||||||
|
## Temporary auction role selection
|
||||||
|
|
||||||
|
Until captain accounts are issued, bids use the team selected in the auction UI.
|
||||||
|
By default, both WebSocket and HTTP bids accept guests and signed-in users without
|
||||||
|
checking whether the user is that team's captain. Team existence, bid amounts,
|
||||||
|
remaining points, roster limits, deadlines and round consistency are still checked.
|
||||||
|
Bid history continues to identify the selected team's captain, so it is not proof
|
||||||
|
of the account that submitted a bid in this temporary mode.
|
||||||
|
|
||||||
|
After issuing accounts, set `AUCTION_REQUIRE_CAPTAIN_AUTH=true` in the API
|
||||||
|
environment (or `project.env`) and restart the API to require a signed-in captain
|
||||||
|
for the selected team on all bid paths. Unset or `false` keeps temporary mode.
|
||||||
|
|
||||||
## Auction durability
|
## Auction durability
|
||||||
|
|
||||||
Accepted Redis bids now enter `auction:bidArchivePayloads` and
|
Accepted Redis bids now enter `auction:bidArchivePayloads` and
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
"class-transformer": "^0.5.1",
|
"class-transformer": "^0.5.1",
|
||||||
"class-validator": "^0.15.1",
|
"class-validator": "^0.15.1",
|
||||||
"jose": "^6.2.2",
|
"jose": "^6.2.2",
|
||||||
"mongoose": "9.4.1",
|
"mongoose": "9.11.4",
|
||||||
"nats": "^2.29.3",
|
"nats": "^2.29.3",
|
||||||
"newrelic": "^14.3.3",
|
"newrelic": "^14.3.3",
|
||||||
"redis": "^5.12.1",
|
"redis": "^5.12.1",
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
/**
|
||||||
|
* 계정 지급 전에는 화면에서 선택한 팀으로 입찰하는 임시 운영 모드가 기본이다.
|
||||||
|
* 계정 지급 후 AUCTION_REQUIRE_CAPTAIN_AUTH=true로 로그인·팀장 검증을 복구한다.
|
||||||
|
*/
|
||||||
|
export function isAuctionCaptainAuthRequired(): boolean {
|
||||||
|
return (
|
||||||
|
process.env.AUCTION_REQUIRE_CAPTAIN_AUTH?.trim().toLowerCase() === 'true'
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
import mongoose from 'mongoose';
|
||||||
|
import { BadRequestException } from '@nestjs/common';
|
||||||
|
jest.mock('../auth/jwt.service', () => ({ JwtService: class JwtService {} }));
|
||||||
|
import { AuctionGateway } from './auction.gateway';
|
||||||
|
|
||||||
|
function setup() {
|
||||||
|
const appendChatMessage = jest.fn();
|
||||||
|
const gateway = new AuctionGateway(
|
||||||
|
{ appendChatMessage } as never,
|
||||||
|
{} as never,
|
||||||
|
{} as never,
|
||||||
|
{} as never,
|
||||||
|
{} as never,
|
||||||
|
{} as never,
|
||||||
|
{} as never,
|
||||||
|
);
|
||||||
|
const broadcast = jest.fn();
|
||||||
|
const to = jest.fn().mockReturnValue({ emit: broadcast });
|
||||||
|
(gateway as unknown as { server: unknown }).server = {
|
||||||
|
to,
|
||||||
|
};
|
||||||
|
const socket = {
|
||||||
|
data: {
|
||||||
|
matchId: new mongoose.Types.ObjectId().toString(),
|
||||||
|
user: {
|
||||||
|
_id: new mongoose.Types.ObjectId(),
|
||||||
|
role: 'admin',
|
||||||
|
riotAccounts: [],
|
||||||
|
kakaoTalkNickname: '운영자',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
emit: jest.fn(),
|
||||||
|
};
|
||||||
|
return { gateway, appendChatMessage, broadcast, socket, to };
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('Auction chat delivery', () => {
|
||||||
|
const payload = {
|
||||||
|
message: '준비해 주세요',
|
||||||
|
clientMessageId: '0589e8a4-bccd-4ccd-a3ae-28f117401e79',
|
||||||
|
};
|
||||||
|
it('acknowledges only after saving and assigns the operator role from the socket user', async () => {
|
||||||
|
const { gateway, appendChatMessage, broadcast, socket } = setup();
|
||||||
|
const message = { id: 'saved', ...payload, sentAt: new Date() };
|
||||||
|
let finish!: (result: unknown) => void;
|
||||||
|
appendChatMessage.mockReturnValue(
|
||||||
|
new Promise((resolve) => {
|
||||||
|
finish = resolve;
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
const ack = jest.fn();
|
||||||
|
const pending = gateway.handleChatMessage(socket as never, payload, ack);
|
||||||
|
expect(ack).not.toHaveBeenCalled();
|
||||||
|
expect(broadcast).not.toHaveBeenCalled();
|
||||||
|
finish({ message, created: true });
|
||||||
|
await pending;
|
||||||
|
expect(appendChatMessage).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
clientMessageId: payload.clientMessageId,
|
||||||
|
senderRole: 'operator',
|
||||||
|
displayName: '운영자',
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
expect(ack).toHaveBeenCalledWith({
|
||||||
|
ok: true,
|
||||||
|
message: expect.objectContaining({ id: 'saved' }),
|
||||||
|
});
|
||||||
|
expect(broadcast).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('acknowledges a retry without broadcasting a duplicate', async () => {
|
||||||
|
const { gateway, appendChatMessage, broadcast, socket } = setup();
|
||||||
|
appendChatMessage.mockResolvedValue({
|
||||||
|
message: { id: 'saved' },
|
||||||
|
created: false,
|
||||||
|
});
|
||||||
|
const ack = jest.fn();
|
||||||
|
await gateway.handleChatMessage(socket as never, payload, ack);
|
||||||
|
expect(ack).toHaveBeenCalledWith({ ok: true, message: { id: 'saved' } });
|
||||||
|
expect(broadcast).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns rejection to the requesting composer without reporting success', async () => {
|
||||||
|
const { gateway, appendChatMessage, broadcast, socket } = setup();
|
||||||
|
appendChatMessage.mockRejectedValue(
|
||||||
|
new BadRequestException('Chat message is required.'),
|
||||||
|
);
|
||||||
|
const ack = jest.fn();
|
||||||
|
await gateway.handleChatMessage(socket as never, payload, ack);
|
||||||
|
expect(ack).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
ok: false,
|
||||||
|
message: 'Chat message is required.',
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
expect(broadcast).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Auction live reactions', () => {
|
||||||
|
it('broadcasts to the joined room with the server-resolved name, without saving a chat message', () => {
|
||||||
|
const { gateway, appendChatMessage, broadcast, socket, to } = setup();
|
||||||
|
const ack = jest.fn();
|
||||||
|
gateway.handleChatReaction(socket as never, { kind: 'clap' }, ack);
|
||||||
|
expect(to).toHaveBeenCalledWith(socket.data.matchId);
|
||||||
|
expect(broadcast).toHaveBeenCalledWith(
|
||||||
|
'chat-reaction',
|
||||||
|
expect.objectContaining({
|
||||||
|
id: expect.any(String),
|
||||||
|
kind: 'clap',
|
||||||
|
displayName: '운영자',
|
||||||
|
userId: socket.data.user._id.toString(),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
expect(ack).toHaveBeenCalledWith({
|
||||||
|
ok: true,
|
||||||
|
reaction: broadcast.mock.calls[0][1],
|
||||||
|
});
|
||||||
|
expect(appendChatMessage).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rejects unjoined clients and arbitrary reaction values', () => {
|
||||||
|
const { gateway, broadcast, socket } = setup();
|
||||||
|
const ack = jest.fn();
|
||||||
|
gateway.handleChatReaction({ data: {} } as never, { kind: 'heart' }, ack);
|
||||||
|
expect(ack).toHaveBeenLastCalledWith({ ok: false, code: 'NOT_JOINED' });
|
||||||
|
for (const kind of ['__proto__', 'not-supported', 1, null]) {
|
||||||
|
gateway.handleChatReaction(socket as never, { kind }, ack);
|
||||||
|
expect(ack).toHaveBeenLastCalledWith({
|
||||||
|
ok: false,
|
||||||
|
code: 'INVALID_REACTION',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect(broadcast).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('throttles bursts, then accepts the next reaction after the interval', () => {
|
||||||
|
const { gateway, broadcast, socket } = setup();
|
||||||
|
const clock = jest.spyOn(Date, 'now').mockReturnValue(1000);
|
||||||
|
const ack = jest.fn();
|
||||||
|
try {
|
||||||
|
gateway.handleChatReaction(socket as never, { kind: 'heart' }, ack);
|
||||||
|
gateway.handleChatReaction(socket as never, { kind: 'heart' }, ack);
|
||||||
|
expect(ack).toHaveBeenLastCalledWith({
|
||||||
|
ok: false,
|
||||||
|
code: 'REACTION_RATE_LIMITED',
|
||||||
|
});
|
||||||
|
expect(broadcast).toHaveBeenCalledTimes(1);
|
||||||
|
clock.mockReturnValue(1400);
|
||||||
|
gateway.handleChatReaction(socket as never, { kind: 'celebrate' }, ack);
|
||||||
|
expect(broadcast).toHaveBeenCalledTimes(2);
|
||||||
|
} finally {
|
||||||
|
clock.mockRestore();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
import 'reflect-metadata';
|
||||||
|
import mongoose from 'mongoose';
|
||||||
|
import { GUARDS_METADATA } from '@nestjs/common/constants';
|
||||||
|
import { METADATA_KEY_IS_PUBLIC_ACCESS_ALLOWED } from '../auth/allow-public-access.decorator';
|
||||||
|
import type { UserDocument } from '../global/database/schema';
|
||||||
|
|
||||||
|
jest.mock('../auth/jwt.service', () => ({
|
||||||
|
JwtService: class JwtService {},
|
||||||
|
}));
|
||||||
|
|
||||||
|
import { AuctionController } from './auction.controller';
|
||||||
|
|
||||||
|
describe('AuctionController bid authentication', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.replaceProperty(process, 'env', { ...process.env });
|
||||||
|
delete process.env.AUCTION_REQUIRE_CAPTAIN_AUTH;
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => jest.restoreAllMocks());
|
||||||
|
|
||||||
|
it('allows HTTP guests to reach the configurable bid checks', () => {
|
||||||
|
const handler = AuctionController.prototype.placeBid;
|
||||||
|
expect(
|
||||||
|
Reflect.getMetadata(METADATA_KEY_IS_PUBLIC_ACCESS_ALLOWED, handler),
|
||||||
|
).toBe(true);
|
||||||
|
expect(Reflect.getMetadata(GUARDS_METADATA, handler)).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([undefined, 'false', 'true'])(
|
||||||
|
'handles HTTP guests with captain auth=%s',
|
||||||
|
async (auth) => {
|
||||||
|
if (auth !== undefined) process.env.AUCTION_REQUIRE_CAPTAIN_AUTH = auth;
|
||||||
|
const placeBid = jest.fn().mockResolvedValue({ revision: 2 });
|
||||||
|
const controller = new AuctionController(
|
||||||
|
{ placeBid } as never,
|
||||||
|
{} as never,
|
||||||
|
{} as never,
|
||||||
|
);
|
||||||
|
const matchId = new mongoose.Types.ObjectId();
|
||||||
|
const result = controller.placeBid(
|
||||||
|
undefined,
|
||||||
|
new mongoose.Types.ObjectId(),
|
||||||
|
matchId,
|
||||||
|
{
|
||||||
|
bidderTeamIndex: 2,
|
||||||
|
bidPointAmount: 20,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (auth === 'true') {
|
||||||
|
await expect(result).rejects.toThrow(
|
||||||
|
'팀장 계정으로 로그인해야 입찰할 수 있습니다.',
|
||||||
|
);
|
||||||
|
expect(placeBid).not.toHaveBeenCalled();
|
||||||
|
} else {
|
||||||
|
await expect(result).resolves.toEqual({ revision: 2 });
|
||||||
|
expect(placeBid).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
matchId,
|
||||||
|
teamIndex: 2,
|
||||||
|
amount: 20,
|
||||||
|
bidderUserId: undefined,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
it('passes the signed-in user to service checks and restores community validation in strict mode', async () => {
|
||||||
|
const placeBid = jest.fn().mockResolvedValue({ revision: 2 });
|
||||||
|
const controller = new AuctionController(
|
||||||
|
{ placeBid } as never,
|
||||||
|
{} as never,
|
||||||
|
{} as never,
|
||||||
|
);
|
||||||
|
const user = {
|
||||||
|
_id: new mongoose.Types.ObjectId(),
|
||||||
|
communityId: new mongoose.Types.ObjectId(),
|
||||||
|
} as UserDocument;
|
||||||
|
const matchId = new mongoose.Types.ObjectId();
|
||||||
|
const body = { bidderTeamIndex: 2, bidPointAmount: 20 };
|
||||||
|
await controller.placeBid(
|
||||||
|
user,
|
||||||
|
new mongoose.Types.ObjectId(),
|
||||||
|
matchId,
|
||||||
|
body,
|
||||||
|
);
|
||||||
|
expect(placeBid).toHaveBeenLastCalledWith(
|
||||||
|
expect.objectContaining({ bidderUserId: user._id }),
|
||||||
|
);
|
||||||
|
|
||||||
|
process.env.AUCTION_REQUIRE_CAPTAIN_AUTH = 'true';
|
||||||
|
await expect(
|
||||||
|
controller.placeBid(user, new mongoose.Types.ObjectId(), matchId, body),
|
||||||
|
).rejects.toThrow('Different community.');
|
||||||
|
expect(placeBid).toHaveBeenCalledTimes(1);
|
||||||
|
await expect(
|
||||||
|
controller.placeBid(user, user.communityId, matchId, body),
|
||||||
|
).resolves.toEqual({ revision: 2 });
|
||||||
|
expect(placeBid).toHaveBeenCalledTimes(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
|
ForbiddenException,
|
||||||
Get,
|
Get,
|
||||||
HttpCode,
|
HttpCode,
|
||||||
HttpStatus,
|
HttpStatus,
|
||||||
@@ -19,6 +20,7 @@ import { RolesGuard } from '../auth/roles.guard';
|
|||||||
import { ParseObjectIdPipe } from '../common/parse-object-id.pipe';
|
import { ParseObjectIdPipe } from '../common/parse-object-id.pipe';
|
||||||
import type { UserDocument } from '../global/database/schema';
|
import type { UserDocument } from '../global/database/schema';
|
||||||
import { AuctionService } from './auction.service';
|
import { AuctionService } from './auction.service';
|
||||||
|
import { isAuctionCaptainAuthRequired } from './auction-bid-auth';
|
||||||
import { AuctionGateway } from './auction.gateway';
|
import { AuctionGateway } from './auction.gateway';
|
||||||
import { AuctionBidArchiveService } from './auction-bid-archive.service';
|
import { AuctionBidArchiveService } from './auction-bid-archive.service';
|
||||||
import {
|
import {
|
||||||
@@ -106,20 +108,26 @@ export class AuctionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Post('bids')
|
@Post('bids')
|
||||||
@Roles('admin', 'owner', 'member')
|
@AllowPublicAccess()
|
||||||
@UseGuards(RolesGuard)
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
public async placeBid(
|
public async placeBid(
|
||||||
@CurrentUser() currentUser: UserDocument,
|
@CurrentUser() currentUser: UserDocument | undefined,
|
||||||
@Param('communityId', ParseObjectIdPipe)
|
@Param('communityId', ParseObjectIdPipe)
|
||||||
communityId: mongoose.Types.ObjectId,
|
communityId: mongoose.Types.ObjectId,
|
||||||
@Param('matchId', ParseObjectIdPipe) matchId: mongoose.Types.ObjectId,
|
@Param('matchId', ParseObjectIdPipe) matchId: mongoose.Types.ObjectId,
|
||||||
@Body() body: PlaceBidDto,
|
@Body() body: PlaceBidDto,
|
||||||
) {
|
) {
|
||||||
|
if (isAuctionCaptainAuthRequired()) {
|
||||||
|
if (!currentUser) {
|
||||||
|
throw new ForbiddenException(
|
||||||
|
'팀장 계정으로 로그인해야 입찰할 수 있습니다.',
|
||||||
|
);
|
||||||
|
}
|
||||||
this.assertSameCommunity(currentUser, communityId);
|
this.assertSameCommunity(currentUser, communityId);
|
||||||
|
}
|
||||||
return this.auctionService.placeBid({
|
return this.auctionService.placeBid({
|
||||||
matchId,
|
matchId,
|
||||||
bidderUserId: currentUser._id,
|
bidderUserId: currentUser?._id,
|
||||||
teamIndex: body.bidderTeamIndex,
|
teamIndex: body.bidderTeamIndex,
|
||||||
amount: body.bidPointAmount,
|
amount: body.bidPointAmount,
|
||||||
bidRequestId: body.bidRequestId,
|
bidRequestId: body.bidRequestId,
|
||||||
|
|||||||
@@ -8,6 +8,15 @@ jest.mock('../auth/jwt.service', () => ({
|
|||||||
import { AuctionGateway } from './auction.gateway';
|
import { AuctionGateway } from './auction.gateway';
|
||||||
|
|
||||||
describe('AuctionGateway', () => {
|
describe('AuctionGateway', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.replaceProperty(process, 'env', { ...process.env });
|
||||||
|
delete process.env.AUCTION_REQUIRE_CAPTAIN_AUTH;
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
it('signals pending initial state so the client can retry privately after recovery', async () => {
|
it('signals pending initial state so the client can retry privately after recovery', async () => {
|
||||||
const matchId = new mongoose.Types.ObjectId().toString();
|
const matchId = new mongoose.Types.ObjectId().toString();
|
||||||
const gateway = new AuctionGateway(
|
const gateway = new AuctionGateway(
|
||||||
@@ -114,7 +123,8 @@ describe('AuctionGateway', () => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
it('requires an authenticated user before forwarding a bid', async () => {
|
it('requires an authenticated user when captain authentication is enabled', async () => {
|
||||||
|
process.env.AUCTION_REQUIRE_CAPTAIN_AUTH = 'true';
|
||||||
const matchId = new mongoose.Types.ObjectId().toString();
|
const matchId = new mongoose.Types.ObjectId().toString();
|
||||||
const { gateway, auctionService } = createGateway();
|
const { gateway, auctionService } = createGateway();
|
||||||
const ack = jest.fn();
|
const ack = jest.fn();
|
||||||
@@ -131,6 +141,49 @@ describe('AuctionGateway', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it.each([undefined, bidderUserId])(
|
||||||
|
'accepts the selected team in temporary mode for user %s',
|
||||||
|
async (userId) => {
|
||||||
|
const matchId = new mongoose.Types.ObjectId().toString();
|
||||||
|
const placeBidDelta = jest.fn().mockResolvedValue({
|
||||||
|
auctionBidHistoryEntry: {
|
||||||
|
bidderTeamIndex: 2,
|
||||||
|
bidderUserId: new mongoose.Types.ObjectId().toString(),
|
||||||
|
bidPointAmount: 120,
|
||||||
|
bidPlacedAtTimestampMS: 1780000000000,
|
||||||
|
},
|
||||||
|
currentHighestBidderTeamIndex: 2,
|
||||||
|
currentHighestBidPointAmount: 120,
|
||||||
|
currentServerTimestampMS: 1780000000000,
|
||||||
|
revision: 9,
|
||||||
|
});
|
||||||
|
const { gateway, emit } = createGateway({ placeBidDelta });
|
||||||
|
const ack = jest.fn();
|
||||||
|
|
||||||
|
await gateway.handleBid(
|
||||||
|
{
|
||||||
|
data: { matchId, user: userId ? { _id: userId } : undefined },
|
||||||
|
emit: jest.fn(),
|
||||||
|
} as never,
|
||||||
|
{ bidderTeamIndex: 2, bidPointAmount: 120 },
|
||||||
|
ack,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(placeBidDelta).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
teamIndex: 2,
|
||||||
|
amount: 120,
|
||||||
|
bidderUserId: userId,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
expect(ack).toHaveBeenCalledWith(expect.objectContaining({ ok: true }));
|
||||||
|
expect(emit).toHaveBeenCalledWith(
|
||||||
|
'bid',
|
||||||
|
expect.objectContaining({ currentHighestBidderTeamIndex: 2 }),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
it('broadcasts a bid delta and acknowledges the matching bid request', async () => {
|
it('broadcasts a bid delta and acknowledges the matching bid request', async () => {
|
||||||
const matchId = new mongoose.Types.ObjectId().toString();
|
const matchId = new mongoose.Types.ObjectId().toString();
|
||||||
const auctionBidHistoryEntry = {
|
const auctionBidHistoryEntry = {
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ import {
|
|||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import type { JWTPayload } from 'jose';
|
import type { JWTPayload } from 'jose';
|
||||||
import type { DefaultEventsMap, Namespace, Socket } from 'socket.io';
|
import type { DefaultEventsMap, Namespace, Socket } from 'socket.io';
|
||||||
|
import type {
|
||||||
|
AuctionReactionEvent,
|
||||||
|
AuctionReactionKind,
|
||||||
|
AuctionReactionReply,
|
||||||
|
} from '@lolympus/contracts';
|
||||||
import { AuthService } from '../auth/auth.service';
|
import { AuthService } from '../auth/auth.service';
|
||||||
import { IdentityService } from '../auth/identity.service';
|
import { IdentityService } from '../auth/identity.service';
|
||||||
import { JwtService } from '../auth/jwt.service';
|
import { JwtService } from '../auth/jwt.service';
|
||||||
@@ -31,6 +36,7 @@ import type {
|
|||||||
AuctionStateResponse,
|
AuctionStateResponse,
|
||||||
} from './auction.service';
|
} from './auction.service';
|
||||||
import { AuctionEventBusService } from './auction-event-bus.service';
|
import { AuctionEventBusService } from './auction-event-bus.service';
|
||||||
|
import { isAuctionCaptainAuthRequired } from './auction-bid-auth';
|
||||||
import {
|
import {
|
||||||
isAuctionResyncRecommended,
|
isAuctionResyncRecommended,
|
||||||
resolveAuctionRejectionReason,
|
resolveAuctionRejectionReason,
|
||||||
@@ -72,6 +78,7 @@ type AuctionActionPayload = Omit<SoldPayload, 'assignedPosition'>;
|
|||||||
interface ChatMessagePayload {
|
interface ChatMessagePayload {
|
||||||
message?: string;
|
message?: string;
|
||||||
displayName?: string;
|
displayName?: string;
|
||||||
|
clientMessageId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BidRateLimitState {
|
interface BidRateLimitState {
|
||||||
@@ -80,6 +87,7 @@ interface BidRateLimitState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface AuctionSocketData {
|
interface AuctionSocketData {
|
||||||
|
auctionReactionSentAt?: number;
|
||||||
auctionResyncAtTimestampMS?: number;
|
auctionResyncAtTimestampMS?: number;
|
||||||
auctionResyncInProgress?: boolean;
|
auctionResyncInProgress?: boolean;
|
||||||
auctionBidRateLimit?: BidRateLimitState;
|
auctionBidRateLimit?: BidRateLimitState;
|
||||||
@@ -97,6 +105,16 @@ type AuctionSocket = Socket<
|
|||||||
>;
|
>;
|
||||||
|
|
||||||
const BID_RATE_LIMIT_WINDOW_MS = 1000;
|
const BID_RATE_LIMIT_WINDOW_MS = 1000;
|
||||||
|
const REACTION_KINDS: Record<AuctionReactionKind, true> = {
|
||||||
|
'thumbs-up': true,
|
||||||
|
heart: true,
|
||||||
|
clap: true,
|
||||||
|
laugh: true,
|
||||||
|
wow: true,
|
||||||
|
sad: true,
|
||||||
|
fire: true,
|
||||||
|
celebrate: true,
|
||||||
|
};
|
||||||
const BID_RATE_LIMIT_MAX_REQUESTS_PER_WINDOW = 8;
|
const BID_RATE_LIMIT_MAX_REQUESTS_PER_WINDOW = 8;
|
||||||
const BID_RATE_LIMIT_REJECTION_CODE = 'BID_RATE_LIMITED';
|
const BID_RATE_LIMIT_REJECTION_CODE = 'BID_RATE_LIMITED';
|
||||||
const BID_RATE_LIMIT_REJECTION_MESSAGE =
|
const BID_RATE_LIMIT_REJECTION_MESSAGE =
|
||||||
@@ -250,7 +268,7 @@ export class AuctionGateway implements OnGatewayConnection, OnGatewayInit {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const bidderUserId = this.resolveSocketUserId(socket);
|
const bidderUserId = this.resolveSocketUserId(socket);
|
||||||
if (!bidderUserId)
|
if (isAuctionCaptainAuthRequired() && !bidderUserId)
|
||||||
throw new ForbiddenException(
|
throw new ForbiddenException(
|
||||||
'팀장 계정으로 로그인해야 입찰할 수 있습니다.',
|
'팀장 계정으로 로그인해야 입찰할 수 있습니다.',
|
||||||
);
|
);
|
||||||
@@ -466,30 +484,82 @@ export class AuctionGateway implements OnGatewayConnection, OnGatewayInit {
|
|||||||
public async handleChatMessage(
|
public async handleChatMessage(
|
||||||
@ConnectedSocket() socket: AuctionSocket,
|
@ConnectedSocket() socket: AuctionSocket,
|
||||||
@MessageBody() payload: ChatMessagePayload,
|
@MessageBody() payload: ChatMessagePayload,
|
||||||
|
@Ack() ack?: (response: Record<string, unknown>) => void,
|
||||||
) {
|
) {
|
||||||
const matchId = this.requireJoinedMatchId(socket);
|
const matchId = this.requireJoinedMatchId(socket);
|
||||||
if (!matchId) return;
|
if (!matchId) {
|
||||||
|
ack?.({ ok: false, message: 'Join a match room before sending events.' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof payload?.message !== 'string') {
|
if (typeof payload?.message !== 'string') {
|
||||||
this.emitError(socket, 'Chat message is required.');
|
this.emitError(socket, 'Chat message is required.');
|
||||||
|
ack?.({ ok: false, message: 'Chat message is required.' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { message } = await this.auctionService.appendChatMessage({
|
const { message, created } = await this.auctionService.appendChatMessage({
|
||||||
matchId: new mongoose.Types.ObjectId(matchId),
|
matchId: new mongoose.Types.ObjectId(matchId),
|
||||||
|
clientMessageId: payload.clientMessageId,
|
||||||
|
senderRole: ['owner', 'admin'].includes(socket.data.user?.role ?? '')
|
||||||
|
? 'operator'
|
||||||
|
: undefined,
|
||||||
userId: this.resolveSocketUserId(socket),
|
userId: this.resolveSocketUserId(socket),
|
||||||
displayName: this.resolveChatDisplayName(socket, payload.displayName),
|
displayName: this.resolveChatDisplayName(socket, payload.displayName),
|
||||||
message: payload.message,
|
message: payload.message,
|
||||||
});
|
});
|
||||||
this.server
|
const serialized = this.serializeChatMessage(message);
|
||||||
.to(matchId)
|
if (created) this.server.to(matchId).emit('chat-message', serialized);
|
||||||
.emit('chat-message', this.serializeChatMessage(message));
|
ack?.({ ok: true, message: serialized });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.emitKnownError(socket, error);
|
if (ack) ack({ ok: false, ...this.resolveErrorPayload(error) });
|
||||||
|
else this.emitKnownError(socket, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeMessage('chat-reaction')
|
||||||
|
public handleChatReaction(
|
||||||
|
@ConnectedSocket() socket: AuctionSocket,
|
||||||
|
@MessageBody() payload: { kind?: unknown },
|
||||||
|
@Ack() ack?: (response: AuctionReactionReply) => void,
|
||||||
|
) {
|
||||||
|
const matchId = this.getSocketMatchId(socket);
|
||||||
|
if (!matchId) {
|
||||||
|
ack?.({ ok: false, code: 'NOT_JOINED' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
typeof payload?.kind !== 'string' ||
|
||||||
|
!Object.hasOwn(REACTION_KINDS, payload.kind)
|
||||||
|
) {
|
||||||
|
ack?.({ ok: false, code: 'INVALID_REACTION' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const now = Date.now();
|
||||||
|
if (
|
||||||
|
socket.data.auctionReactionSentAt !== undefined &&
|
||||||
|
now - socket.data.auctionReactionSentAt < 400
|
||||||
|
) {
|
||||||
|
ack?.({ ok: false, code: 'REACTION_RATE_LIMITED' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
socket.data.auctionReactionSentAt = now;
|
||||||
|
const reaction: AuctionReactionEvent = {
|
||||||
|
id: randomUUID(),
|
||||||
|
kind: payload.kind as AuctionReactionKind,
|
||||||
|
displayName: Array.from(this.resolveChatDisplayName(socket))
|
||||||
|
.slice(0, 40)
|
||||||
|
.join(''),
|
||||||
|
userId: this.resolveSocketUserId(socket)?.toString(),
|
||||||
|
sentAt: now,
|
||||||
|
};
|
||||||
|
// The room adapter fans out to all viewers. Reactions never enter the
|
||||||
|
// persisted message history, so reconnects do not replay old animations.
|
||||||
|
this.server.to(matchId).emit('chat-reaction', reaction);
|
||||||
|
ack?.({ ok: true, reaction });
|
||||||
|
}
|
||||||
|
|
||||||
private requireJoinedMatchId(socket: AuctionSocket): string | null {
|
private requireJoinedMatchId(socket: AuctionSocket): string | null {
|
||||||
const matchId = this.getSocketMatchId(socket);
|
const matchId = this.getSocketMatchId(socket);
|
||||||
if (!matchId) {
|
if (!matchId) {
|
||||||
|
|||||||
@@ -156,6 +156,11 @@ describe('AuctionService', () => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.replaceProperty(process, 'env', { ...process.env });
|
||||||
|
delete process.env.AUCTION_REQUIRE_CAPTAIN_AUTH;
|
||||||
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.restoreAllMocks();
|
jest.restoreAllMocks();
|
||||||
jest.useRealTimers();
|
jest.useRealTimers();
|
||||||
@@ -1055,6 +1060,113 @@ describe('AuctionService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe.each(['realtime', 'redis-fallback', 'legacy'] as const)(
|
||||||
|
'%s bid authorization',
|
||||||
|
(path) => {
|
||||||
|
it.each([
|
||||||
|
[undefined, 'guest'],
|
||||||
|
[undefined, 'other-user'],
|
||||||
|
['false', 'other-user'],
|
||||||
|
['true', 'guest'],
|
||||||
|
['true', 'other-user'],
|
||||||
|
['true', 'captain'],
|
||||||
|
] as const)('checks auth=%s for %s', async (auth, actor) => {
|
||||||
|
if (auth !== undefined) process.env.AUCTION_REQUIRE_CAPTAIN_AUTH = auth;
|
||||||
|
const matchId = new mongoose.Types.ObjectId();
|
||||||
|
const captainUserId = new mongoose.Types.ObjectId();
|
||||||
|
const playerUserId = new mongoose.Types.ObjectId();
|
||||||
|
const bidderUserId =
|
||||||
|
actor === 'guest'
|
||||||
|
? undefined
|
||||||
|
: actor === 'captain'
|
||||||
|
? captainUserId
|
||||||
|
: new mongoose.Types.ObjectId();
|
||||||
|
const team = { teamIndex: 2, captainUserId, points: 1000, members: [] };
|
||||||
|
const auction = {
|
||||||
|
_id: new mongoose.Types.ObjectId(),
|
||||||
|
matchId,
|
||||||
|
auctionEngineVersion: path === 'legacy' ? undefined : 'redis-v1',
|
||||||
|
phase: 'bidding',
|
||||||
|
teams: [team],
|
||||||
|
currentBid: 0,
|
||||||
|
bidExtensionSeconds: 5,
|
||||||
|
bids: [],
|
||||||
|
save: jest.fn().mockResolvedValue(undefined),
|
||||||
|
toObject: () => ({ matchId, teams: [team], phase: 'bidding' }),
|
||||||
|
};
|
||||||
|
const {
|
||||||
|
service,
|
||||||
|
auctionRedisCommandService,
|
||||||
|
auctionRedisStateReaderService,
|
||||||
|
} = createService({
|
||||||
|
auction: { findOne: jest.fn().mockResolvedValue(auction) },
|
||||||
|
});
|
||||||
|
const state = {
|
||||||
|
auctionLifecycleId: 'life-1',
|
||||||
|
currentBidRoundPlayerUserId: playerUserId.toString(),
|
||||||
|
phase: 'bidding',
|
||||||
|
revision: 2,
|
||||||
|
auctionTeams: [
|
||||||
|
{
|
||||||
|
teamIndex: 2,
|
||||||
|
captainUserId: captainUserId.toString(),
|
||||||
|
remainingBidPointAmount: 1000,
|
||||||
|
members: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
auctionRedisStateReaderService.readAuctionStateView.mockResolvedValue(
|
||||||
|
state,
|
||||||
|
);
|
||||||
|
if (path === 'realtime') {
|
||||||
|
auctionRedisStateReaderService.readBidContext.mockResolvedValue({
|
||||||
|
...state,
|
||||||
|
bidderTeamCaptainUserId: captainUserId.toString(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = service.placeBidDelta({
|
||||||
|
matchId,
|
||||||
|
teamIndex: 2,
|
||||||
|
amount: 20,
|
||||||
|
bidderUserId,
|
||||||
|
bidRequestId: 'auth-mode-bid',
|
||||||
|
});
|
||||||
|
if (auth === 'true' && actor !== 'captain') {
|
||||||
|
await expect(result).rejects.toThrow(
|
||||||
|
actor === 'guest'
|
||||||
|
? '팀장 계정으로 로그인해야 입찰할 수 있습니다.'
|
||||||
|
: '해당 팀의 팀장만 입찰할 수 있습니다.',
|
||||||
|
);
|
||||||
|
expect(auctionRedisCommandService.placeBid).not.toHaveBeenCalled();
|
||||||
|
expect(auction.save).not.toHaveBeenCalled();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await expect(result).resolves.toBeDefined();
|
||||||
|
if (path === 'legacy') {
|
||||||
|
expect(auction.bids).toEqual([
|
||||||
|
expect.objectContaining({
|
||||||
|
teamIndex: 2,
|
||||||
|
amount: 20,
|
||||||
|
bidderUserId: captainUserId,
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
expect(auction.save).toHaveBeenCalledTimes(1);
|
||||||
|
} else {
|
||||||
|
expect(auctionRedisCommandService.placeBid).toHaveBeenCalledWith(
|
||||||
|
matchId.toString(),
|
||||||
|
expect.objectContaining({
|
||||||
|
bidderTeamIndex: 2,
|
||||||
|
bidPointAmount: 20,
|
||||||
|
bidderUserId: captainUserId.toString(),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
it('places bids through Redis for redis-v1 auctions', async () => {
|
it('places bids through Redis for redis-v1 auctions', async () => {
|
||||||
const matchId = new mongoose.Types.ObjectId();
|
const matchId = new mongoose.Types.ObjectId();
|
||||||
const captainUserId = new mongoose.Types.ObjectId();
|
const captainUserId = new mongoose.Types.ObjectId();
|
||||||
@@ -1747,9 +1859,17 @@ describe('AuctionService', () => {
|
|||||||
chatMessages: oldMessages,
|
chatMessages: oldMessages,
|
||||||
save: jest.fn().mockResolvedValue(undefined),
|
save: jest.fn().mockResolvedValue(undefined),
|
||||||
};
|
};
|
||||||
|
const findOneAndUpdate = jest.fn().mockImplementation((_filter, update) => {
|
||||||
|
auction.chatMessages = [
|
||||||
|
...auction.chatMessages,
|
||||||
|
...update.$push.chatMessages.$each,
|
||||||
|
].slice(-200);
|
||||||
|
return auction;
|
||||||
|
});
|
||||||
const { service } = createService({
|
const { service } = createService({
|
||||||
auction: {
|
auction: {
|
||||||
findOne: jest.fn().mockResolvedValue(auction),
|
findOne: jest.fn().mockResolvedValue(auction),
|
||||||
|
findOneAndUpdate,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1770,7 +1890,54 @@ describe('AuctionService', () => {
|
|||||||
expect(auction.chatMessages).toHaveLength(200);
|
expect(auction.chatMessages).toHaveLength(200);
|
||||||
expect(auction.chatMessages[0].id).toBe('old-1');
|
expect(auction.chatMessages[0].id).toBe('old-1');
|
||||||
expect(auction.chatMessages.at(-1)).toBe(appended.message);
|
expect(auction.chatMessages.at(-1)).toBe(appended.message);
|
||||||
expect(auction.save).toHaveBeenCalledTimes(1);
|
expect(auction.save).not.toHaveBeenCalled();
|
||||||
|
expect(appended.created).toBe(true);
|
||||||
|
expect(findOneAndUpdate).toHaveBeenCalledWith(
|
||||||
|
{ matchId, 'chatMessages.id': { $ne: appended.message.id } },
|
||||||
|
{ $push: { chatMessages: { $each: [appended.message], $slice: -200 } } },
|
||||||
|
{ new: true },
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns the saved message on retry without appending or broadcasting it again', async () => {
|
||||||
|
const matchId = new mongoose.Types.ObjectId();
|
||||||
|
const userId = new mongoose.Types.ObjectId();
|
||||||
|
const clientMessageId = '0589e8a4-bccd-4ccd-a3ae-28f117401e79';
|
||||||
|
const saved = {
|
||||||
|
id: `${userId.toString()}:${clientMessageId}`,
|
||||||
|
clientMessageId,
|
||||||
|
userId,
|
||||||
|
displayName: '팀장',
|
||||||
|
message: '확인했습니다',
|
||||||
|
sentAt: new Date(),
|
||||||
|
};
|
||||||
|
const findOneAndUpdate = jest.fn().mockResolvedValue(null);
|
||||||
|
const auction = { matchId, chatMessages: [saved] };
|
||||||
|
const { service } = createService({
|
||||||
|
auction: {
|
||||||
|
findOneAndUpdate,
|
||||||
|
findOne: jest.fn().mockResolvedValue(auction),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
await expect(
|
||||||
|
service.appendChatMessage({
|
||||||
|
matchId,
|
||||||
|
userId,
|
||||||
|
clientMessageId,
|
||||||
|
message: '확인했습니다',
|
||||||
|
}),
|
||||||
|
).resolves.toEqual({ auction, message: saved, created: false });
|
||||||
|
expect(findOneAndUpdate.mock.calls[0][0]['chatMessages.id']).toEqual({
|
||||||
|
$ne: saved.id,
|
||||||
|
});
|
||||||
|
await expect(
|
||||||
|
service.appendChatMessage({
|
||||||
|
matchId,
|
||||||
|
userId,
|
||||||
|
clientMessageId,
|
||||||
|
message: '다른 메시지',
|
||||||
|
}),
|
||||||
|
).rejects.toThrow('Chat message conflicts with an earlier request.');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects blank and overly long chat messages', async () => {
|
it('rejects blank and overly long chat messages', async () => {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
} from './auction-lifecycle-lock';
|
} from './auction-lifecycle-lock';
|
||||||
import { AUCTION_OPTIONAL_PROJECTION_FIELDS } from './auction-projection';
|
import { AUCTION_OPTIONAL_PROJECTION_FIELDS } from './auction-projection';
|
||||||
import { AuctionEventBusService } from './auction-event-bus.service';
|
import { AuctionEventBusService } from './auction-event-bus.service';
|
||||||
|
import { isAuctionCaptainAuthRequired } from './auction-bid-auth';
|
||||||
import { performance } from 'perf_hooks';
|
import { performance } from 'perf_hooks';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import { ConnectionService } from '../global/database/connection.service';
|
import { ConnectionService } from '../global/database/connection.service';
|
||||||
@@ -142,6 +143,8 @@ type RedisActionRequestContext =
|
|||||||
|
|
||||||
interface AppendChatMessageParams {
|
interface AppendChatMessageParams {
|
||||||
matchId: mongoose.Types.ObjectId;
|
matchId: mongoose.Types.ObjectId;
|
||||||
|
clientMessageId?: string;
|
||||||
|
senderRole?: 'operator';
|
||||||
userId?: mongoose.Types.ObjectId;
|
userId?: mongoose.Types.ObjectId;
|
||||||
displayName?: string;
|
displayName?: string;
|
||||||
message: string;
|
message: string;
|
||||||
@@ -666,26 +669,57 @@ export class AuctionService {
|
|||||||
public async appendChatMessage(params: AppendChatMessageParams): Promise<{
|
public async appendChatMessage(params: AppendChatMessageParams): Promise<{
|
||||||
auction: AuctionDocument;
|
auction: AuctionDocument;
|
||||||
message: AuctionChatMessage;
|
message: AuctionChatMessage;
|
||||||
|
created: boolean;
|
||||||
}> {
|
}> {
|
||||||
const auction = await this.getByMatchId(params.matchId);
|
|
||||||
const messageText = this.normalizeChatMessage(params.message);
|
const messageText = this.normalizeChatMessage(params.message);
|
||||||
|
if (
|
||||||
|
params.clientMessageId !== undefined &&
|
||||||
|
!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
|
||||||
|
params.clientMessageId,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
throw new BadRequestException('Invalid chat message id.');
|
||||||
|
}
|
||||||
|
// A retry keeps its ID. The conditional push is atomic, including when
|
||||||
|
// the first request is still saving after the client has timed out.
|
||||||
|
const id = params.clientMessageId
|
||||||
|
? `${params.userId?.toString() ?? 'guest'}:${params.clientMessageId}`
|
||||||
|
: randomUUID();
|
||||||
const message: AuctionChatMessage = {
|
const message: AuctionChatMessage = {
|
||||||
id: randomUUID(),
|
id,
|
||||||
|
clientMessageId: params.clientMessageId,
|
||||||
|
senderRole: params.senderRole,
|
||||||
userId: params.userId,
|
userId: params.userId,
|
||||||
displayName: this.normalizeChatDisplayName(params.displayName),
|
displayName: this.normalizeChatDisplayName(params.displayName),
|
||||||
message: messageText,
|
message: messageText,
|
||||||
sentAt: new Date(),
|
sentAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
auction.chatMessages ??= [];
|
const AuctionModel = await this.connectionService.getModel('auction');
|
||||||
auction.chatMessages.push(message);
|
const auction = await AuctionModel.findOneAndUpdate(
|
||||||
const overflow = auction.chatMessages.length - AUCTION_CHAT_MAX_MESSAGES;
|
{ matchId: params.matchId, 'chatMessages.id': { $ne: id } },
|
||||||
if (overflow > 0) {
|
{
|
||||||
auction.chatMessages.splice(0, overflow);
|
$push: {
|
||||||
}
|
chatMessages: {
|
||||||
|
$each: [message],
|
||||||
|
$slice: -AUCTION_CHAT_MAX_MESSAGES,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ new: true },
|
||||||
|
);
|
||||||
|
if (auction) return { auction, message, created: true };
|
||||||
|
|
||||||
await auction.save();
|
const existingAuction = await this.getByMatchId(params.matchId);
|
||||||
return { auction, message };
|
const existing = existingAuction.chatMessages.find(
|
||||||
|
(entry) => entry.id === id,
|
||||||
|
);
|
||||||
|
if (!existing || existing.message !== messageText) {
|
||||||
|
throw new BadRequestException(
|
||||||
|
'Chat message conflicts with an earlier request.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return { auction: existingAuction, message: existing, created: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
public async listHistory(params: {
|
public async listHistory(params: {
|
||||||
@@ -2921,7 +2955,13 @@ export class AuctionService {
|
|||||||
bidderUserId: mongoose.Types.ObjectId | undefined,
|
bidderUserId: mongoose.Types.ObjectId | undefined,
|
||||||
captainUserId: string,
|
captainUserId: string,
|
||||||
) {
|
) {
|
||||||
if (bidderUserId && bidderUserId.toString() !== captainUserId) {
|
if (!isAuctionCaptainAuthRequired()) return;
|
||||||
|
if (!bidderUserId) {
|
||||||
|
throw new ForbiddenException(
|
||||||
|
'팀장 계정으로 로그인해야 입찰할 수 있습니다.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (bidderUserId.toString() !== captainUserId) {
|
||||||
throw new ForbiddenException('해당 팀의 팀장만 입찰할 수 있습니다.');
|
throw new ForbiddenException('해당 팀의 팀장만 입찰할 수 있습니다.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,10 +86,11 @@ export class CommunityStatsController {
|
|||||||
@Query('to') to?: string,
|
@Query('to') to?: string,
|
||||||
@Query('championId') championId?: string,
|
@Query('championId') championId?: string,
|
||||||
@Query('q') query?: string,
|
@Query('q') query?: string,
|
||||||
|
@Query('lane') lane?: string,
|
||||||
) {
|
) {
|
||||||
return this.communityStatsService.getLeaderboard({
|
return this.communityStatsService.getLeaderboard({
|
||||||
communityId,
|
communityId,
|
||||||
filters: this.toFilters({ seasonId, from, to, championId, query }),
|
filters: this.toFilters({ seasonId, from, to, championId, query, lane }),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,18 +132,24 @@ export class CommunityStatsController {
|
|||||||
@Query('championId') championId?: string,
|
@Query('championId') championId?: string,
|
||||||
@Query('cursor') cursor?: string,
|
@Query('cursor') cursor?: string,
|
||||||
@Query('limit') limit?: string,
|
@Query('limit') limit?: string,
|
||||||
|
@Query('lane') lane?: string,
|
||||||
|
@Query('includePositionCounts') includePositionCounts?: string,
|
||||||
) {
|
) {
|
||||||
return this.communityStatsService.getUserInternalHistory({
|
return this.communityStatsService.getUserInternalHistory({
|
||||||
communityId,
|
communityId,
|
||||||
userId,
|
userId,
|
||||||
filters: this.toFilters({
|
filters: {
|
||||||
|
...this.toFilters({
|
||||||
seasonId,
|
seasonId,
|
||||||
from,
|
from,
|
||||||
to,
|
to,
|
||||||
championId,
|
championId,
|
||||||
cursor,
|
cursor,
|
||||||
limit,
|
limit,
|
||||||
|
lane,
|
||||||
}),
|
}),
|
||||||
|
includePositionCounts: includePositionCounts === 'true',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +164,14 @@ export class CommunityStatsController {
|
|||||||
format?: CommunityStatsFilters['format'];
|
format?: CommunityStatsFilters['format'];
|
||||||
playerId?: string;
|
playerId?: string;
|
||||||
cursorMatchId?: string;
|
cursorMatchId?: string;
|
||||||
|
lane?: string;
|
||||||
}): CommunityStatsFilters {
|
}): CommunityStatsFilters {
|
||||||
|
if (
|
||||||
|
params.lane !== undefined &&
|
||||||
|
!['TOP', 'JUNGLE', 'MIDDLE', 'BOTTOM', 'UTILITY'].includes(params.lane)
|
||||||
|
) {
|
||||||
|
throw new BadRequestException('Invalid lane.');
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
params.query !== undefined &&
|
params.query !== undefined &&
|
||||||
(typeof params.query !== 'string' || params.query.length > 100)
|
(typeof params.query !== 'string' || params.query.length > 100)
|
||||||
@@ -175,6 +189,7 @@ export class CommunityStatsController {
|
|||||||
format: params.format,
|
format: params.format,
|
||||||
playerId: params.playerId,
|
playerId: params.playerId,
|
||||||
cursorMatchId: params.cursorMatchId,
|
cursorMatchId: params.cursorMatchId,
|
||||||
|
lane: params.lane as CommunityStatsFilters['lane'],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -222,7 +222,9 @@ describe('CommunityStatsService', () => {
|
|||||||
const setDetail = jest.fn();
|
const setDetail = jest.fn();
|
||||||
const service = new CommunityStatsService(
|
const service = new CommunityStatsService(
|
||||||
{
|
{
|
||||||
getModel: async () => ({ exists: () => ({ exec: async () => null }) }),
|
getModel: async () => ({
|
||||||
|
exists: () => ({ exec: async () => null }),
|
||||||
|
}),
|
||||||
} as unknown as ConnectionService,
|
} as unknown as ConnectionService,
|
||||||
{
|
{
|
||||||
get: async () => null,
|
get: async () => null,
|
||||||
@@ -318,7 +320,7 @@ describe('CommunityStatsService', () => {
|
|||||||
expect(set).not.toHaveBeenCalled();
|
expect(set).not.toHaveBeenCalled();
|
||||||
expect(setDetail).toHaveBeenCalledTimes(2);
|
expect(setDetail).toHaveBeenCalledTimes(2);
|
||||||
expect(setDetail).toHaveBeenCalledWith(
|
expect(setDetail).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({ field: expect.stringContaining(':r8:') }),
|
expect.objectContaining({ field: expect.stringContaining(':r9:') }),
|
||||||
response,
|
response,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -528,7 +530,7 @@ describe('CommunityStatsService', () => {
|
|||||||
expect(setDetail).toHaveBeenCalledTimes(2);
|
expect(setDetail).toHaveBeenCalledTimes(2);
|
||||||
expect(setDetail).toHaveBeenNthCalledWith(
|
expect(setDetail).toHaveBeenNthCalledWith(
|
||||||
2,
|
2,
|
||||||
expect.objectContaining({ field: expect.stringContaining(':r8:') }),
|
expect.objectContaining({ field: expect.stringContaining(':r9:') }),
|
||||||
invalidCheckpointResponse,
|
invalidCheckpointResponse,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -635,7 +637,7 @@ describe('CommunityStatsService', () => {
|
|||||||
includeTimeline: true,
|
includeTimeline: true,
|
||||||
});
|
});
|
||||||
expect(set).toHaveBeenCalledWith(
|
expect(set).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({ field: expect.stringContaining(':r8:') }),
|
expect.objectContaining({ field: expect.stringContaining(':r9:') }),
|
||||||
fallback,
|
fallback,
|
||||||
60,
|
60,
|
||||||
);
|
);
|
||||||
@@ -647,7 +649,7 @@ describe('CommunityStatsService', () => {
|
|||||||
expect(buildAndUpsert).toHaveBeenCalledTimes(2);
|
expect(buildAndUpsert).toHaveBeenCalledTimes(2);
|
||||||
expect(setDetail).toHaveBeenCalledTimes(1);
|
expect(setDetail).toHaveBeenCalledTimes(1);
|
||||||
expect(setDetail).toHaveBeenCalledWith(
|
expect(setDetail).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({ field: expect.stringContaining(':r8:') }),
|
expect.objectContaining({ field: expect.stringContaining(':r9:') }),
|
||||||
recovered,
|
recovered,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -818,6 +820,73 @@ describe('CommunityStatsService', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns independent recent-20 lane windows and counts from records before pagination', async () => {
|
||||||
|
const communityId = new mongoose.Types.ObjectId();
|
||||||
|
const matchId = new mongoose.Types.ObjectId();
|
||||||
|
const userId = new mongoose.Types.ObjectId();
|
||||||
|
const records = Array.from({ length: 60 }, (_, index) => ({
|
||||||
|
...record(matchId),
|
||||||
|
userId: userId.toString(),
|
||||||
|
gameNumber: index + 1,
|
||||||
|
riotMatchId: `KR_${index}`,
|
||||||
|
gameCreation: index * 1000,
|
||||||
|
teamPosition: index < 25 ? 'MIDDLE' : 'TOP',
|
||||||
|
}));
|
||||||
|
const repository = {
|
||||||
|
findUserRecordFragments: jest
|
||||||
|
.fn()
|
||||||
|
.mockResolvedValue([
|
||||||
|
{ matchId, builderVersion: MATCH_STATS_BUILDER_VERSION, records },
|
||||||
|
]),
|
||||||
|
findDetailsByMatches: jest.fn().mockResolvedValue([]),
|
||||||
|
} as unknown as jest.Mocked<MatchStatsRepository>;
|
||||||
|
const cache = {
|
||||||
|
get: jest.fn().mockResolvedValue(null),
|
||||||
|
set: jest.fn().mockResolvedValue(undefined),
|
||||||
|
} as unknown as CommunityStatsCacheService;
|
||||||
|
const service = new CommunityStatsService(
|
||||||
|
{} as ConnectionService,
|
||||||
|
cache,
|
||||||
|
repository,
|
||||||
|
{} as MatchStatsService,
|
||||||
|
);
|
||||||
|
(service as unknown as { resolveContext: jest.Mock }).resolveContext = jest
|
||||||
|
.fn()
|
||||||
|
.mockResolvedValue({
|
||||||
|
community: {},
|
||||||
|
season: { id: 'all', label: '전체', startedAt: null, endedAt: null },
|
||||||
|
from: null,
|
||||||
|
to: null,
|
||||||
|
});
|
||||||
|
const mid = await service.getUserInternalHistory({
|
||||||
|
communityId,
|
||||||
|
userId,
|
||||||
|
filters: { limit: 20, lane: 'MIDDLE', includePositionCounts: true },
|
||||||
|
});
|
||||||
|
expect(mid.matches).toHaveLength(20);
|
||||||
|
expect(mid.matches[0].matchId).toBe('KR_24');
|
||||||
|
expect(mid.matches[19].matchId).toBe('KR_5');
|
||||||
|
expect(mid.matches[0].damageShare).toBe(30);
|
||||||
|
expect(mid.positionCounts).toEqual({
|
||||||
|
ALL: 20,
|
||||||
|
TOP: 20,
|
||||||
|
JUNGLE: 0,
|
||||||
|
MIDDLE: 20,
|
||||||
|
BOTTOM: 0,
|
||||||
|
UTILITY: 0,
|
||||||
|
});
|
||||||
|
expect(repository.findUserRecordFragments).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({ limit: 0 }),
|
||||||
|
);
|
||||||
|
const all = await service.getUserInternalHistory({
|
||||||
|
communityId,
|
||||||
|
userId,
|
||||||
|
filters: { limit: 20, includePositionCounts: true },
|
||||||
|
});
|
||||||
|
expect(all.matches.every((game) => game.teamPosition === 'TOP')).toBe(true);
|
||||||
|
expect(all.positionCounts).toEqual(mid.positionCounts);
|
||||||
|
});
|
||||||
|
|
||||||
it('coalesces concurrent user internal history cache misses', async () => {
|
it('coalesces concurrent user internal history cache misses', async () => {
|
||||||
const communityId = new mongoose.Types.ObjectId();
|
const communityId = new mongoose.Types.ObjectId();
|
||||||
const matchId = new mongoose.Types.ObjectId();
|
const matchId = new mongoose.Types.ObjectId();
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import {
|
|||||||
MatchStatsUserRecordFragment,
|
MatchStatsUserRecordFragment,
|
||||||
} from './match-stats.repository';
|
} from './match-stats.repository';
|
||||||
import { MatchStatsService } from './match-stats.service';
|
import { MatchStatsService } from './match-stats.service';
|
||||||
|
import { presentStatsCard, statsDate } from './internal-stats-presentation';
|
||||||
import {
|
import {
|
||||||
InternalGameDetail,
|
InternalGameDetail,
|
||||||
InternalRecord,
|
InternalRecord,
|
||||||
@@ -55,7 +56,7 @@ const DEFAULT_LIST_LIMIT = 20;
|
|||||||
const MAX_LIST_LIMIT = 50;
|
const MAX_LIST_LIMIT = 50;
|
||||||
const MAX_MATCH_SCAN = 300;
|
const MAX_MATCH_SCAN = 300;
|
||||||
const MIN_HIGHLIGHT_GAMES = 5;
|
const MIN_HIGHLIGHT_GAMES = 5;
|
||||||
const MATCH_DETAIL_RESPONSE_CACHE_VERSION = 8;
|
const MATCH_DETAIL_RESPONSE_CACHE_VERSION = 9;
|
||||||
const INCOMPLETE_MATCH_DETAIL_TTL_SECONDS = 60;
|
const INCOMPLETE_MATCH_DETAIL_TTL_SECONDS = 60;
|
||||||
|
|
||||||
interface CommunityStatsContext {
|
interface CommunityStatsContext {
|
||||||
@@ -139,6 +140,7 @@ export class CommunityStatsService {
|
|||||||
'projection.formatType': 1,
|
'projection.formatType': 1,
|
||||||
'projection.outcome': 1,
|
'projection.outcome': 1,
|
||||||
'projection.series': 1,
|
'projection.series': 1,
|
||||||
|
'projection.games': 1,
|
||||||
})
|
})
|
||||||
.lean()
|
.lean()
|
||||||
.exec();
|
.exec();
|
||||||
@@ -148,6 +150,9 @@ export class CommunityStatsService {
|
|||||||
this.presentOfficialResult(competition),
|
this.presentOfficialResult(competition),
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
const sources = new Map(
|
||||||
|
competitions.map((source) => [source.matchId.toString(), source]),
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
...pagination,
|
...pagination,
|
||||||
matches: cards.map(({ card, sourceCompetitionId, sourceRevision }) => {
|
matches: cards.map(({ card, sourceCompetitionId, sourceRevision }) => {
|
||||||
@@ -161,10 +166,20 @@ export class CommunityStatsService {
|
|||||||
(resultPresentation.type === 'official' &&
|
(resultPresentation.type === 'official' &&
|
||||||
sourceCompetitionId === resultPresentation.competitionId &&
|
sourceCompetitionId === resultPresentation.competitionId &&
|
||||||
sourceRevision === resultPresentation.sourceRevision);
|
sourceRevision === resultPresentation.sourceRevision);
|
||||||
return {
|
const presented = {
|
||||||
...(canUseGames ? card : this.adjustCardForRange(card, [])),
|
...(canUseGames ? card : this.adjustCardForRange(card, [])),
|
||||||
resultPresentation,
|
resultPresentation,
|
||||||
};
|
};
|
||||||
|
const source = sources.get(card.matchId);
|
||||||
|
return source && canUseGames
|
||||||
|
? presentStatsCard(
|
||||||
|
presented,
|
||||||
|
presentCompetitionDetail({
|
||||||
|
...source,
|
||||||
|
teams: source.teams.map((team) => ({ ...team, members: [] })),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
: presented;
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -192,7 +207,24 @@ export class CommunityStatsService {
|
|||||||
return {
|
return {
|
||||||
cards: visible.map((fragment) => ({
|
cards: visible.map((fragment) => ({
|
||||||
card: this.adjustCardForRange(
|
card: this.adjustCardForRange(
|
||||||
fragment.matchCard as unknown as InternalMatchCardView,
|
{
|
||||||
|
...(fragment.matchCard as unknown as InternalMatchCardView),
|
||||||
|
games: (
|
||||||
|
fragment.matchCard as unknown as InternalMatchCardView
|
||||||
|
).games.map((game) => {
|
||||||
|
const detail = fragment.gameDetails?.find(
|
||||||
|
(item) => item.gameNumber === game.gameNumber,
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
...game,
|
||||||
|
analysisAvailability: !detail
|
||||||
|
? ('pending' as const)
|
||||||
|
: detail.rawAvailable === false
|
||||||
|
? ('missing' as const)
|
||||||
|
: ('available' as const),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
},
|
||||||
(fragment.gameDetails ?? []).filter((game) =>
|
(fragment.gameDetails ?? []).filter((game) =>
|
||||||
this.isGameInRange(game.gameCreation, context),
|
this.isGameInRange(game.gameCreation, context),
|
||||||
),
|
),
|
||||||
@@ -226,6 +258,7 @@ export class CommunityStatsService {
|
|||||||
const records = this.applyChampionFilter(dataset.records, filters);
|
const records = this.applyChampionFilter(dataset.records, filters);
|
||||||
response = {
|
response = {
|
||||||
rows: this.buildLeaderboardRows(records),
|
rows: this.buildLeaderboardRows(records),
|
||||||
|
lane: filters.lane,
|
||||||
season: dataset.season,
|
season: dataset.season,
|
||||||
};
|
};
|
||||||
await this.cacheService.set(key, response);
|
await this.cacheService.set(key, response);
|
||||||
@@ -275,6 +308,7 @@ export class CommunityStatsService {
|
|||||||
|
|
||||||
const response: TeamInsightsResponse = {
|
const response: TeamInsightsResponse = {
|
||||||
season: dataset.season,
|
season: dataset.season,
|
||||||
|
totals: dataset.totals,
|
||||||
sideWinRate: {
|
sideWinRate: {
|
||||||
blue: this.percent(blueWins, blueGames),
|
blue: this.percent(blueWins, blueGames),
|
||||||
red: this.percent(redWins, redGames),
|
red: this.percent(redWins, redGames),
|
||||||
@@ -464,7 +498,18 @@ export class CommunityStatsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const response: InternalMatchDetailResponse = {
|
const response: InternalMatchDetailResponse = {
|
||||||
match,
|
match: presentStatsCard(
|
||||||
|
{
|
||||||
|
...match,
|
||||||
|
games: (match.games ?? []).map((game) => ({
|
||||||
|
...game,
|
||||||
|
analysisAvailability:
|
||||||
|
games.find((linked) => linked.game.gameNumber === game.gameNumber)
|
||||||
|
?.analysisAvailability ?? 'pending',
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
dataset.competition,
|
||||||
|
),
|
||||||
competition: dataset.competition,
|
competition: dataset.competition,
|
||||||
games: games.map(({ game, official, analysisAvailability }) => ({
|
games: games.map(({ game, official, analysisAvailability }) => ({
|
||||||
gameNumber: game.gameNumber,
|
gameNumber: game.gameNumber,
|
||||||
@@ -649,9 +694,8 @@ export class CommunityStatsService {
|
|||||||
if (retryAt <= now) this.rawRecoveryRetryAfter.delete(field);
|
if (retryAt <= now) this.rawRecoveryRetryAfter.delete(field);
|
||||||
}
|
}
|
||||||
if (this.rawRecoveryRetryAfter.size >= 1000) {
|
if (this.rawRecoveryRetryAfter.size >= 1000) {
|
||||||
this.rawRecoveryRetryAfter.delete(
|
const oldest = this.rawRecoveryRetryAfter.keys().next();
|
||||||
this.rawRecoveryRetryAfter.keys().next().value!,
|
if (!oldest.done) this.rawRecoveryRetryAfter.delete(oldest.value);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
this.rawRecoveryRetryAfter.set(
|
this.rawRecoveryRetryAfter.set(
|
||||||
key.field,
|
key.field,
|
||||||
@@ -709,11 +753,24 @@ export class CommunityStatsService {
|
|||||||
});
|
});
|
||||||
const gameDetails: Array<Pick<InternalGameDetail, 'winnerSide'>> = [];
|
const gameDetails: Array<Pick<InternalGameDetail, 'winnerSide'>> = [];
|
||||||
const records: InternalRecord[] = [];
|
const records: InternalRecord[] = [];
|
||||||
|
const participants = new Set<string>();
|
||||||
|
let matches = 0,
|
||||||
|
analyzedGames = 0;
|
||||||
for (const fragment of fragments) {
|
for (const fragment of fragments) {
|
||||||
const games = fragment.gameDetails.filter((game) =>
|
const games = fragment.gameDetails.filter((game) =>
|
||||||
this.isGameInRange(game.gameCreation, context),
|
this.isGameInRange(game.gameCreation, context),
|
||||||
);
|
);
|
||||||
const gameNumbers = new Set(games.map(({ gameNumber }) => gameNumber));
|
if (games.length) matches += 1;
|
||||||
|
const gameNumbers = new Set(
|
||||||
|
games
|
||||||
|
.filter((game) => game.rawAvailable !== false)
|
||||||
|
.map(({ gameNumber }) => gameNumber),
|
||||||
|
);
|
||||||
|
analyzedGames += gameNumbers.size;
|
||||||
|
const allNumbers = new Set(games.map((game) => game.gameNumber));
|
||||||
|
fragment.records
|
||||||
|
.filter((record) => allNumbers.has(record.gameNumber))
|
||||||
|
.forEach((record) => participants.add(record.userId));
|
||||||
gameDetails.push(...games);
|
gameDetails.push(...games);
|
||||||
records.push(
|
records.push(
|
||||||
...fragment.records.filter(({ gameNumber }) =>
|
...fragment.records.filter(({ gameNumber }) =>
|
||||||
@@ -721,7 +778,17 @@ export class CommunityStatsService {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return { season: context.season, records, gameDetails };
|
return {
|
||||||
|
season: context.season,
|
||||||
|
records,
|
||||||
|
gameDetails,
|
||||||
|
totals: {
|
||||||
|
matches,
|
||||||
|
games: gameDetails.length,
|
||||||
|
analyzedGames,
|
||||||
|
players: participants.size,
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private async buildBaseDataset(
|
private async buildBaseDataset(
|
||||||
@@ -851,7 +918,8 @@ export class CommunityStatsService {
|
|||||||
userId: params.userId,
|
userId: params.userId,
|
||||||
fromGameCreation: context.from?.getTime(),
|
fromGameCreation: context.from?.getTime(),
|
||||||
toGameCreation: context.to?.getTime(),
|
toGameCreation: context.to?.getTime(),
|
||||||
limit: MAX_MATCH_SCAN,
|
// The inspector needs the latest 20 of each lane, even in older events.
|
||||||
|
limit: params.filters.includePositionCounts ? 0 : MAX_MATCH_SCAN,
|
||||||
};
|
};
|
||||||
let fragments =
|
let fragments =
|
||||||
await this.matchStatsRepository.findUserRecordFragments(fragmentQuery);
|
await this.matchStatsRepository.findUserRecordFragments(fragmentQuery);
|
||||||
@@ -886,8 +954,31 @@ export class CommunityStatsService {
|
|||||||
};
|
};
|
||||||
const response: UserInternalHistoryResponse = {
|
const response: UserInternalHistoryResponse = {
|
||||||
season: context.season,
|
season: context.season,
|
||||||
|
...(params.filters.includePositionCounts
|
||||||
|
? {
|
||||||
|
positionCounts: Object.fromEntries(
|
||||||
|
['ALL', 'TOP', 'JUNGLE', 'MIDDLE', 'BOTTOM', 'UTILITY'].map(
|
||||||
|
(lane) => [
|
||||||
|
lane,
|
||||||
|
Math.min(
|
||||||
|
20,
|
||||||
|
this.applyChampionFilter(allUserRecords, {
|
||||||
|
championId: params.filters.championId,
|
||||||
|
}).filter(
|
||||||
|
(record) =>
|
||||||
|
lane === 'ALL' || record.teamPosition === lane,
|
||||||
|
).length,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
playerStats: records.length
|
||||||
|
? this.toLeaderboardRow(userId, records)
|
||||||
|
: null,
|
||||||
championStats: this.buildUserChampionStats(
|
championStats: this.buildUserChampionStats(
|
||||||
allUserRecords,
|
this.applyChampionFilter(allUserRecords, { lane: params.filters.lane }),
|
||||||
context.season,
|
context.season,
|
||||||
),
|
),
|
||||||
summary: this.buildUserSummary(records, visible.length || limit),
|
summary: this.buildUserSummary(records, visible.length || limit),
|
||||||
@@ -914,6 +1005,11 @@ export class CommunityStatsService {
|
|||||||
fragment.records.filter(
|
fragment.records.filter(
|
||||||
(record) =>
|
(record) =>
|
||||||
record.userId === userId &&
|
record.userId === userId &&
|
||||||
|
!fragment.gameDetails?.some(
|
||||||
|
(game) =>
|
||||||
|
game.gameNumber === record.gameNumber &&
|
||||||
|
game.rawAvailable === false,
|
||||||
|
) &&
|
||||||
this.isGameInRange(record.gameCreation, context),
|
this.isGameInRange(record.gameCreation, context),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -1130,13 +1226,13 @@ export class CommunityStatsService {
|
|||||||
const community = await CommunityModel.findById(communityId).exec();
|
const community = await CommunityModel.findById(communityId).exec();
|
||||||
if (!community) throw new NotFoundException('Community not found.');
|
if (!community) throw new NotFoundException('Community not found.');
|
||||||
const season = this.resolveSeason(community, filters.seasonId);
|
const season = this.resolveSeason(community, filters.seasonId);
|
||||||
const from = filters.from
|
let from = filters.from
|
||||||
? new Date(filters.from)
|
? statsDate(filters.from, false)
|
||||||
: season.startedAt
|
: season.startedAt
|
||||||
? new Date(season.startedAt)
|
? new Date(season.startedAt)
|
||||||
: null;
|
: null;
|
||||||
const to = filters.to
|
let to = filters.to
|
||||||
? new Date(filters.to)
|
? statsDate(filters.to, true)
|
||||||
: season.endedAt
|
: season.endedAt
|
||||||
? new Date(season.endedAt)
|
? new Date(season.endedAt)
|
||||||
: null;
|
: null;
|
||||||
@@ -1149,6 +1245,11 @@ export class CommunityStatsService {
|
|||||||
if (from && to && from.getTime() > to.getTime()) {
|
if (from && to && from.getTime() > to.getTime()) {
|
||||||
throw new BadRequestException('Invalid date range.');
|
throw new BadRequestException('Invalid date range.');
|
||||||
}
|
}
|
||||||
|
// A date filter narrows the selected season; it never escapes it.
|
||||||
|
if (season.startedAt && (!from || from < new Date(season.startedAt)))
|
||||||
|
from = new Date(season.startedAt);
|
||||||
|
if (season.endedAt && (!to || to > new Date(season.endedAt)))
|
||||||
|
to = new Date(season.endedAt);
|
||||||
return { community, season, from, to };
|
return { community, season, from, to };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1420,6 +1521,7 @@ export class CommunityStatsService {
|
|||||||
return {
|
return {
|
||||||
matchId: record.riotMatchId,
|
matchId: record.riotMatchId,
|
||||||
internalMatchId: record.matchId,
|
internalMatchId: record.matchId,
|
||||||
|
internalMatchTitle: record.title,
|
||||||
gameNumber: record.gameNumber,
|
gameNumber: record.gameNumber,
|
||||||
queueId: 0,
|
queueId: 0,
|
||||||
queueLabel: '내전',
|
queueLabel: '내전',
|
||||||
@@ -1444,6 +1546,7 @@ export class CommunityStatsService {
|
|||||||
wardsPlaced: record.wardsPlaced,
|
wardsPlaced: record.wardsPlaced,
|
||||||
wardsKilled: record.wardsKilled,
|
wardsKilled: record.wardsKilled,
|
||||||
damageDealtToChampions: record.damageDealtToChampions,
|
damageDealtToChampions: record.damageDealtToChampions,
|
||||||
|
damageShare: record.damageShare,
|
||||||
damageTaken: record.damageTaken,
|
damageTaken: record.damageTaken,
|
||||||
goldEarned: record.gold,
|
goldEarned: record.gold,
|
||||||
items: record.items,
|
items: record.items,
|
||||||
@@ -1494,8 +1597,11 @@ export class CommunityStatsService {
|
|||||||
records: InternalRecord[],
|
records: InternalRecord[],
|
||||||
filters: CommunityStatsFilters,
|
filters: CommunityStatsFilters,
|
||||||
): InternalRecord[] {
|
): InternalRecord[] {
|
||||||
if (!filters.championId) return records;
|
return records.filter(
|
||||||
return records.filter((record) => record.championId === filters.championId);
|
(record) =>
|
||||||
|
(!filters.championId || record.championId === filters.championId) &&
|
||||||
|
(!filters.lane || record.teamPosition === filters.lane),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private isGameInRange(
|
private isGameInRange(
|
||||||
@@ -1534,6 +1640,8 @@ export class CommunityStatsService {
|
|||||||
summonerName: record.summonerName,
|
summonerName: record.summonerName,
|
||||||
championId: record.championId,
|
championId: record.championId,
|
||||||
matchId: record.riotMatchId,
|
matchId: record.riotMatchId,
|
||||||
|
internalMatchId: record.matchId,
|
||||||
|
gameNumber: record.gameNumber,
|
||||||
isSingleGame: true,
|
isSingleGame: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1622,7 +1730,7 @@ export class CommunityStatsService {
|
|||||||
cacheScope,
|
cacheScope,
|
||||||
JSON.stringify([
|
JSON.stringify([
|
||||||
MATCH_STATS_BUILDER_VERSION,
|
MATCH_STATS_BUILDER_VERSION,
|
||||||
scope === 'matches' ? 'matches-page-v1' : scope,
|
`${scope}:presentation-v2`,
|
||||||
filters.seasonId ?? 'current',
|
filters.seasonId ?? 'current',
|
||||||
filters.from ?? '',
|
filters.from ?? '',
|
||||||
filters.to ?? '',
|
filters.to ?? '',
|
||||||
@@ -1633,6 +1741,8 @@ export class CommunityStatsService {
|
|||||||
filters.format ?? '',
|
filters.format ?? '',
|
||||||
filters.playerId ?? '',
|
filters.playerId ?? '',
|
||||||
filters.cursorMatchId ?? '',
|
filters.cursorMatchId ?? '',
|
||||||
|
filters.lane ?? '',
|
||||||
|
...(filters.includePositionCounts ? ['position-windows-v1'] : []),
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import type {
|
|||||||
InternalMatchCompetition,
|
InternalMatchCompetition,
|
||||||
InternalMatchResultPresentation,
|
InternalMatchResultPresentation,
|
||||||
SeriesId,
|
SeriesId,
|
||||||
|
SeriesProjection,
|
||||||
} from '@lolympus/contracts';
|
} from '@lolympus/contracts';
|
||||||
import type {
|
import type {
|
||||||
MatchStatsParticipantCheckpoints,
|
MatchStatsParticipantCheckpoints,
|
||||||
@@ -21,6 +22,7 @@ import type {
|
|||||||
} from '../match-history/match-history.types';
|
} from '../match-history/match-history.types';
|
||||||
|
|
||||||
export interface CommunityStatsFilters {
|
export interface CommunityStatsFilters {
|
||||||
|
includePositionCounts?: boolean;
|
||||||
seasonId?: string;
|
seasonId?: string;
|
||||||
from?: string;
|
from?: string;
|
||||||
to?: string;
|
to?: string;
|
||||||
@@ -31,6 +33,7 @@ export interface CommunityStatsFilters {
|
|||||||
format?: 'pair' | 'tournament';
|
format?: 'pair' | 'tournament';
|
||||||
playerId?: string;
|
playerId?: string;
|
||||||
cursorMatchId?: string;
|
cursorMatchId?: string;
|
||||||
|
lane?: RiotLane;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface InternalMatchListResponse {
|
export interface InternalMatchListResponse {
|
||||||
@@ -48,6 +51,8 @@ export interface InternalMatchCardView {
|
|||||||
gameCount: number;
|
gameCount: number;
|
||||||
winnerTeamIndex?: number;
|
winnerTeamIndex?: number;
|
||||||
resultPresentation?: InternalMatchResultPresentation;
|
resultPresentation?: InternalMatchResultPresentation;
|
||||||
|
/** Official series only. Historical opponent pairs are not inferred rounds. */
|
||||||
|
series?: SeriesProjection[];
|
||||||
seriesResults: Array<{
|
seriesResults: Array<{
|
||||||
teamAIndex: number;
|
teamAIndex: number;
|
||||||
teamBIndex: number;
|
teamBIndex: number;
|
||||||
@@ -57,6 +62,9 @@ export interface InternalMatchCardView {
|
|||||||
}>;
|
}>;
|
||||||
games: Array<{
|
games: Array<{
|
||||||
gameNumber: number;
|
gameNumber: number;
|
||||||
|
seriesId?: string;
|
||||||
|
ordinal?: number;
|
||||||
|
analysisAvailability?: GameAnalysisAvailability | 'pending';
|
||||||
riotMatchId: string | null;
|
riotMatchId: string | null;
|
||||||
blueTeamIndex: number;
|
blueTeamIndex: number;
|
||||||
redTeamIndex: number;
|
redTeamIndex: number;
|
||||||
@@ -66,6 +74,7 @@ export interface InternalMatchCardView {
|
|||||||
}>;
|
}>;
|
||||||
teams: Array<{
|
teams: Array<{
|
||||||
teamIndex: number;
|
teamIndex: number;
|
||||||
|
teamId?: string;
|
||||||
name: string;
|
name: string;
|
||||||
members: Array<{
|
members: Array<{
|
||||||
userId: string;
|
userId: string;
|
||||||
@@ -77,6 +86,7 @@ export interface InternalMatchCardView {
|
|||||||
|
|
||||||
export interface LeaderboardResponse {
|
export interface LeaderboardResponse {
|
||||||
rows: LeaderboardRow[];
|
rows: LeaderboardRow[];
|
||||||
|
lane?: RiotLane;
|
||||||
season: HistorySeasonDto;
|
season: HistorySeasonDto;
|
||||||
matchedUserIds?: string[];
|
matchedUserIds?: string[];
|
||||||
}
|
}
|
||||||
@@ -111,11 +121,19 @@ export interface LeaderHighlight {
|
|||||||
summonerName: string;
|
summonerName: string;
|
||||||
championId?: number;
|
championId?: number;
|
||||||
matchId?: string;
|
matchId?: string;
|
||||||
|
internalMatchId?: string;
|
||||||
|
gameNumber?: number;
|
||||||
isSingleGame: boolean;
|
isSingleGame: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TeamInsightsResponse {
|
export interface TeamInsightsResponse {
|
||||||
season: HistorySeasonDto;
|
season: HistorySeasonDto;
|
||||||
|
totals: {
|
||||||
|
matches: number;
|
||||||
|
games: number;
|
||||||
|
analyzedGames: number;
|
||||||
|
players: number;
|
||||||
|
};
|
||||||
sideWinRate: {
|
sideWinRate: {
|
||||||
blue: number;
|
blue: number;
|
||||||
red: number;
|
red: number;
|
||||||
@@ -214,7 +232,9 @@ export interface InternalMatchDetailResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface UserInternalHistoryResponse {
|
export interface UserInternalHistoryResponse {
|
||||||
|
positionCounts?: Record<string, number>;
|
||||||
season: HistorySeasonDto;
|
season: HistorySeasonDto;
|
||||||
|
playerStats?: LeaderboardRow | null;
|
||||||
championStats: LeaderboardChampionStats;
|
championStats: LeaderboardChampionStats;
|
||||||
summary: {
|
summary: {
|
||||||
windowSize: number;
|
windowSize: number;
|
||||||
|
|||||||
@@ -0,0 +1,378 @@
|
|||||||
|
import { BadRequestException } from '@nestjs/common';
|
||||||
|
import { Test } from '@nestjs/testing';
|
||||||
|
import request from 'supertest';
|
||||||
|
import type { Server } from 'node:http';
|
||||||
|
import mongoose from 'mongoose';
|
||||||
|
import { CommunityStatsService } from './community-stats.service';
|
||||||
|
import { CommunityStatsController } from './community-stats.controller';
|
||||||
|
import { ConnectionService } from '../global/database/connection.service';
|
||||||
|
import { CommunityStatsCacheService } from './community-stats-cache.service';
|
||||||
|
import { MatchStatsRepository } from './match-stats.repository';
|
||||||
|
import { MatchStatsService } from './match-stats.service';
|
||||||
|
import {
|
||||||
|
MATCH_STATS_BUILDER_VERSION,
|
||||||
|
type InternalRecord,
|
||||||
|
} from './match-stats.types';
|
||||||
|
import { presentStatsCard, statsDate } from './internal-stats-presentation';
|
||||||
|
|
||||||
|
const communityId = new mongoose.Types.ObjectId();
|
||||||
|
const matchId = new mongoose.Types.ObjectId();
|
||||||
|
const userId = new mongoose.Types.ObjectId();
|
||||||
|
const start = Date.parse('2026-06-18T12:00:00Z');
|
||||||
|
function record(
|
||||||
|
gameNumber: number,
|
||||||
|
values: Partial<InternalRecord> = {},
|
||||||
|
): InternalRecord {
|
||||||
|
return {
|
||||||
|
matchId: matchId.toString(),
|
||||||
|
title: '여름 내전',
|
||||||
|
scheduledAt: new Date(start),
|
||||||
|
gameNumber,
|
||||||
|
riotMatchId: `KR_${gameNumber}`,
|
||||||
|
gameCreation: start + gameNumber * 1800000,
|
||||||
|
gameDuration: 1800,
|
||||||
|
userId: userId.toString(),
|
||||||
|
summonerName: '선수',
|
||||||
|
tagLine: 'KR1',
|
||||||
|
profileIconId: 1,
|
||||||
|
teamIndex: 1,
|
||||||
|
side: 'blue',
|
||||||
|
championId: 1,
|
||||||
|
teamPosition: 'TOP',
|
||||||
|
kills: 8,
|
||||||
|
deaths: 2,
|
||||||
|
assists: 4,
|
||||||
|
win: true,
|
||||||
|
cs: 240,
|
||||||
|
csPerMin: 8,
|
||||||
|
gold: 12000,
|
||||||
|
gpm: 400,
|
||||||
|
killParticipation: 60,
|
||||||
|
damageShare: 30,
|
||||||
|
visionScore: 12,
|
||||||
|
damageDealtToChampions: 18000,
|
||||||
|
...values,
|
||||||
|
} as InternalRecord;
|
||||||
|
}
|
||||||
|
function fixture() {
|
||||||
|
const records = [
|
||||||
|
record(1),
|
||||||
|
record(2, {
|
||||||
|
teamPosition: 'JUNGLE',
|
||||||
|
championId: 2,
|
||||||
|
kills: 2,
|
||||||
|
deaths: 4,
|
||||||
|
assists: 6,
|
||||||
|
win: false,
|
||||||
|
csPerMin: 4,
|
||||||
|
gpm: 300,
|
||||||
|
killParticipation: 40,
|
||||||
|
}),
|
||||||
|
record(3, { kills: 99 }),
|
||||||
|
record(3, { userId: new mongoose.Types.ObjectId().toString() }),
|
||||||
|
];
|
||||||
|
const fragment = {
|
||||||
|
matchId,
|
||||||
|
builderVersion: MATCH_STATS_BUILDER_VERSION,
|
||||||
|
records,
|
||||||
|
gameDetails: [1, 2, 3].map((gameNumber) => ({
|
||||||
|
gameNumber,
|
||||||
|
gameCreation: start + gameNumber * 1800000,
|
||||||
|
winnerSide: gameNumber === 2 ? 'red' : 'blue',
|
||||||
|
rawAvailable: gameNumber !== 3,
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
const cache = new Map<string, unknown>();
|
||||||
|
const repository = {
|
||||||
|
findSeasonStats: jest.fn().mockResolvedValue([fragment]),
|
||||||
|
findUserRecordFragments: jest.fn().mockResolvedValue([fragment]),
|
||||||
|
findDetailsByMatches: jest.fn().mockResolvedValue([]),
|
||||||
|
};
|
||||||
|
const service = new CommunityStatsService(
|
||||||
|
{
|
||||||
|
getModel: async () => ({
|
||||||
|
findById: () => ({
|
||||||
|
exec: async () => ({
|
||||||
|
seasons: [
|
||||||
|
{
|
||||||
|
id: 'june',
|
||||||
|
label: '6월',
|
||||||
|
startedAt: new Date('2026-06-01T00:00:00+09:00'),
|
||||||
|
endedAt: new Date('2026-06-30T23:59:59.999+09:00'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
} as unknown as ConnectionService,
|
||||||
|
{
|
||||||
|
get: async (key: unknown) => cache.get(JSON.stringify(key)),
|
||||||
|
set: async (key: unknown, value: unknown) => {
|
||||||
|
cache.set(JSON.stringify(key), value);
|
||||||
|
},
|
||||||
|
} as unknown as CommunityStatsCacheService,
|
||||||
|
repository as unknown as MatchStatsRepository,
|
||||||
|
{} as MatchStatsService,
|
||||||
|
);
|
||||||
|
jest
|
||||||
|
.spyOn(
|
||||||
|
service as unknown as { repairCommunityFragments: () => Promise<number> },
|
||||||
|
'repairCommunityFragments',
|
||||||
|
)
|
||||||
|
.mockResolvedValue(0);
|
||||||
|
return { service, repository };
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('internal stats API contract', () => {
|
||||||
|
it('serves the scoped player and leaderboard contracts through the HTTP routes', async () => {
|
||||||
|
const { service } = fixture();
|
||||||
|
const module = await Test.createTestingModule({
|
||||||
|
controllers: [CommunityStatsController],
|
||||||
|
providers: [{ provide: CommunityStatsService, useValue: service }],
|
||||||
|
}).compile();
|
||||||
|
const app = module.createNestApplication();
|
||||||
|
await app.init();
|
||||||
|
const server: Server = app.getHttpServer();
|
||||||
|
try {
|
||||||
|
const base = `/communities/${communityId.toString()}`;
|
||||||
|
const leaderboard = await request(server)
|
||||||
|
.get(`${base}/internal-stats/leaderboard?seasonId=all&lane=TOP`)
|
||||||
|
.expect(200);
|
||||||
|
expect(leaderboard.body).toMatchObject({
|
||||||
|
lane: 'TOP',
|
||||||
|
rows: [{ games: 1, kda: 6 }],
|
||||||
|
});
|
||||||
|
const player = await request(server)
|
||||||
|
.get(
|
||||||
|
`${base}/users/${userId.toString()}/internal-history?seasonId=all&lane=JUNGLE`,
|
||||||
|
)
|
||||||
|
.expect(200);
|
||||||
|
expect(player.body).toMatchObject({
|
||||||
|
playerStats: { games: 1, kda: 2 },
|
||||||
|
matches: [{ gameNumber: 2 }],
|
||||||
|
});
|
||||||
|
await request(server)
|
||||||
|
.get(`${base}/internal-stats/leaderboard?lane=invalid`)
|
||||||
|
.expect(400);
|
||||||
|
await request(server)
|
||||||
|
.get(`${base}/internal-stats/leaderboard?from=2026-02-30`)
|
||||||
|
.expect(400);
|
||||||
|
await request(server)
|
||||||
|
.get('/communities/invalid/internal-stats/leaderboard')
|
||||||
|
.expect(400);
|
||||||
|
} finally {
|
||||||
|
await app.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
it('searches escaped text across title, team and player without losing date or cursor constraints', async () => {
|
||||||
|
const chain = {
|
||||||
|
select: jest.fn().mockReturnThis(),
|
||||||
|
sort: jest.fn().mockReturnThis(),
|
||||||
|
limit: jest.fn().mockReturnThis(),
|
||||||
|
lean: jest.fn().mockReturnThis(),
|
||||||
|
exec: jest.fn().mockResolvedValue([]),
|
||||||
|
};
|
||||||
|
const find = jest.fn().mockReturnValue(chain);
|
||||||
|
const repository = new MatchStatsRepository({
|
||||||
|
getModel: async () => ({ find }),
|
||||||
|
} as unknown as ConnectionService);
|
||||||
|
await repository.findMatchPage({
|
||||||
|
communityId,
|
||||||
|
query: '팀.*',
|
||||||
|
from: start,
|
||||||
|
cursor: start + 1000,
|
||||||
|
cursorMatchId: matchId.toString(),
|
||||||
|
limit: 4,
|
||||||
|
});
|
||||||
|
expect(find).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
communityId,
|
||||||
|
$and: expect.arrayContaining([
|
||||||
|
{
|
||||||
|
$or: [
|
||||||
|
'matchCard.title',
|
||||||
|
'matchCard.teams.name',
|
||||||
|
'matchCard.teams.members.summonerName',
|
||||||
|
].map((field) => ({
|
||||||
|
[field]: { $regex: '팀\\.\\*', $options: 'i' },
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
expect(chain.limit).toHaveBeenCalledWith(4);
|
||||||
|
expect(chain.select).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({ 'gameDetails.rawAvailable': 1 }),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('recalculates every metric per lane, isolates cached scopes and excludes missing raw data', async () => {
|
||||||
|
const { service } = fixture();
|
||||||
|
const all = await service.getLeaderboard({
|
||||||
|
communityId,
|
||||||
|
filters: { seasonId: 'all' },
|
||||||
|
});
|
||||||
|
const top = await service.getLeaderboard({
|
||||||
|
communityId,
|
||||||
|
filters: { seasonId: 'all', lane: 'TOP' },
|
||||||
|
});
|
||||||
|
const jungle = await service.getLeaderboard({
|
||||||
|
communityId,
|
||||||
|
filters: { seasonId: 'all', lane: 'JUNGLE' },
|
||||||
|
});
|
||||||
|
expect(all.rows).toHaveLength(1);
|
||||||
|
expect(all.rows[0]).toMatchObject({
|
||||||
|
games: 2,
|
||||||
|
totalKills: 10,
|
||||||
|
winRate: 50,
|
||||||
|
avgGoldPerMin: 350,
|
||||||
|
avgCsPerMin: 6,
|
||||||
|
avgKillParticipation: 50,
|
||||||
|
});
|
||||||
|
expect(top).toMatchObject({
|
||||||
|
lane: 'TOP',
|
||||||
|
rows: [
|
||||||
|
{
|
||||||
|
games: 1,
|
||||||
|
kda: 6,
|
||||||
|
winRate: 100,
|
||||||
|
avgGoldPerMin: 400,
|
||||||
|
avgCsPerMin: 8,
|
||||||
|
avgKillParticipation: 60,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
expect(jungle).toMatchObject({
|
||||||
|
lane: 'JUNGLE',
|
||||||
|
rows: [{ games: 1, kda: 2, winRate: 0, avgGoldPerMin: 300 }],
|
||||||
|
});
|
||||||
|
expect(
|
||||||
|
await service.getLeaderboard({
|
||||||
|
communityId,
|
||||||
|
filters: { seasonId: 'all' },
|
||||||
|
}),
|
||||||
|
).toEqual(all);
|
||||||
|
const insight = await service.getTeamInsights({
|
||||||
|
communityId,
|
||||||
|
filters: { seasonId: 'all' },
|
||||||
|
});
|
||||||
|
expect(insight.totals).toEqual({
|
||||||
|
matches: 1,
|
||||||
|
games: 3,
|
||||||
|
analyzedGames: 2,
|
||||||
|
players: 2,
|
||||||
|
});
|
||||||
|
expect(insight.topTeamGpm).toMatchObject({
|
||||||
|
internalMatchId: matchId.toString(),
|
||||||
|
gameNumber: 1,
|
||||||
|
metric: 400,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('keeps player summary and matches in the same scope while retaining champion choices', async () => {
|
||||||
|
const { service } = fixture();
|
||||||
|
const history = await service.getUserInternalHistory({
|
||||||
|
communityId,
|
||||||
|
userId,
|
||||||
|
filters: { seasonId: 'all', championId: 1 },
|
||||||
|
});
|
||||||
|
expect(history.playerStats).toMatchObject({ games: 1, kda: 6 });
|
||||||
|
expect(history.matches).toHaveLength(1);
|
||||||
|
expect(history.matches[0]).toMatchObject({
|
||||||
|
internalMatchId: matchId.toString(),
|
||||||
|
internalMatchTitle: '여름 내전',
|
||||||
|
gameNumber: 1,
|
||||||
|
});
|
||||||
|
expect(history.championStats.champions).toHaveLength(2);
|
||||||
|
});
|
||||||
|
it('intersects custom dates with the season and accepts inclusive KST calendar dates', async () => {
|
||||||
|
const { service, repository } = fixture();
|
||||||
|
await service.getLeaderboard({
|
||||||
|
communityId,
|
||||||
|
filters: { seasonId: 'june', from: '2026-05-01', to: '2026-07-31' },
|
||||||
|
});
|
||||||
|
expect(repository.findSeasonStats).toHaveBeenCalledWith({
|
||||||
|
communityId,
|
||||||
|
from: Date.parse('2026-05-31T15:00:00Z'),
|
||||||
|
to: Date.parse('2026-06-30T14:59:59.999Z'),
|
||||||
|
});
|
||||||
|
expect(statsDate('2026-06-18', false)?.toISOString()).toBe(
|
||||||
|
'2026-06-17T15:00:00.000Z',
|
||||||
|
);
|
||||||
|
expect(statsDate('2026-06-18', true)?.toISOString()).toBe(
|
||||||
|
'2026-06-18T14:59:59.999Z',
|
||||||
|
);
|
||||||
|
await expect(
|
||||||
|
service.getLeaderboard({ communityId, filters: { from: '2026-02-30' } }),
|
||||||
|
).rejects.toBeInstanceOf(BadRequestException);
|
||||||
|
await expect(
|
||||||
|
service.getLeaderboard({
|
||||||
|
communityId,
|
||||||
|
filters: { from: '2026-06-20', to: '2026-06-19' },
|
||||||
|
}),
|
||||||
|
).rejects.toBeInstanceOf(BadRequestException);
|
||||||
|
});
|
||||||
|
it('rejects unsupported lanes at the HTTP controller boundary', () => {
|
||||||
|
const controller = new CommunityStatsController(
|
||||||
|
{} as CommunityStatsService,
|
||||||
|
);
|
||||||
|
expect(() =>
|
||||||
|
(
|
||||||
|
controller as unknown as {
|
||||||
|
toFilters: (params: { lane: string }) => unknown;
|
||||||
|
}
|
||||||
|
).toFilters({ lane: 'SUPPORT' }),
|
||||||
|
).toThrow(BadRequestException);
|
||||||
|
});
|
||||||
|
it('uses official evidence to distinguish rematches and does not invent round identities', () => {
|
||||||
|
type Card = Parameters<typeof presentStatsCard>[0];
|
||||||
|
type Competition = NonNullable<Parameters<typeof presentStatsCard>[1]>;
|
||||||
|
const card = {
|
||||||
|
games: [
|
||||||
|
{ gameNumber: 1, riotMatchId: 'KR_1' },
|
||||||
|
{ gameNumber: 2, riotMatchId: 'KR_2' },
|
||||||
|
{ gameNumber: 3, riotMatchId: 'old' },
|
||||||
|
],
|
||||||
|
teams: [{ teamIndex: 1 }],
|
||||||
|
} as Card;
|
||||||
|
const competition = {
|
||||||
|
teams: [{ displayOrder: 1, teamId: 'a' }],
|
||||||
|
projection: {
|
||||||
|
games: [
|
||||||
|
{
|
||||||
|
displayNumber: 1,
|
||||||
|
ordinal: 1,
|
||||||
|
seriesId: 'upper',
|
||||||
|
evidence: { type: 'riot', riotMatchId: 'KR_1' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayNumber: 2,
|
||||||
|
ordinal: 1,
|
||||||
|
seriesId: 'final',
|
||||||
|
evidence: { type: 'riot', riotMatchId: 'KR_2' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayNumber: 3,
|
||||||
|
ordinal: 2,
|
||||||
|
seriesId: 'final',
|
||||||
|
evidence: { type: 'riot', riotMatchId: 'replacement' },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
series: [
|
||||||
|
{ seriesId: 'upper' },
|
||||||
|
{ seriesId: 'final' },
|
||||||
|
{ seriesId: 'other', status: 'scheduled' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
} as unknown as Competition;
|
||||||
|
const result = presentStatsCard(card, competition);
|
||||||
|
expect(result.games.map((game) => game.seriesId)).toEqual([
|
||||||
|
'upper',
|
||||||
|
'final',
|
||||||
|
undefined,
|
||||||
|
]);
|
||||||
|
expect(result.series?.map((series) => series.seriesId)).toEqual([
|
||||||
|
'upper',
|
||||||
|
'final',
|
||||||
|
]);
|
||||||
|
expect(result.teams[0].teamId).toBe('a');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import type { InternalMatchCompetition } from '@lolympus/contracts';
|
||||||
|
import type { InternalMatchCardView } from './community-stats.types';
|
||||||
|
|
||||||
|
/** Attach official identities without merging rematches between the same teams. */
|
||||||
|
export function presentStatsCard(
|
||||||
|
card: InternalMatchCardView,
|
||||||
|
competition?: Pick<InternalMatchCompetition, 'teams' | 'projection'>,
|
||||||
|
): InternalMatchCardView {
|
||||||
|
if (!competition) return card;
|
||||||
|
const officialGames = competition.projection.games ?? [];
|
||||||
|
const games = card.games.map((game) => {
|
||||||
|
const official = officialGames.find(
|
||||||
|
(candidate) =>
|
||||||
|
candidate.displayNumber === game.gameNumber &&
|
||||||
|
(candidate.evidence.type === 'riot'
|
||||||
|
? candidate.evidence.riotMatchId
|
||||||
|
: candidate.evidence.legacyReference) === game.riotMatchId,
|
||||||
|
);
|
||||||
|
return official
|
||||||
|
? { ...game, seriesId: official.seriesId, ordinal: official.ordinal }
|
||||||
|
: game;
|
||||||
|
});
|
||||||
|
const visible = new Set(games.map((game) => game.seriesId));
|
||||||
|
return {
|
||||||
|
...card,
|
||||||
|
games,
|
||||||
|
teams: card.teams?.map((team) => ({
|
||||||
|
...team,
|
||||||
|
teamId: competition.teams.find((t) => t.displayOrder === team.teamIndex)
|
||||||
|
?.teamId,
|
||||||
|
})),
|
||||||
|
series: (competition.projection.series ?? []).filter(
|
||||||
|
(series) =>
|
||||||
|
visible.has(series.seriesId) ||
|
||||||
|
(series.status === 'completed' && series.outcome.type !== 'played'),
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Date-only inputs are inclusive Korean calendar days; ISO timestamps remain supported. */
|
||||||
|
export function statsDate(
|
||||||
|
value: string | undefined,
|
||||||
|
end: boolean,
|
||||||
|
): Date | null {
|
||||||
|
if (!value) return null;
|
||||||
|
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
||||||
|
const date = new Date(
|
||||||
|
`${value}T${end ? '23:59:59.999' : '00:00:00.000'}+09:00`,
|
||||||
|
);
|
||||||
|
const midnight = new Date(`${value}T00:00:00.000Z`);
|
||||||
|
if (
|
||||||
|
!Number.isFinite(midnight.getTime()) ||
|
||||||
|
midnight.toISOString().slice(0, 10) !== value
|
||||||
|
)
|
||||||
|
return new Date(NaN);
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
return new Date(value);
|
||||||
|
}
|
||||||
@@ -6,7 +6,11 @@ import type { MatchStats, MatchStatsDocument } from '../global/database/schema';
|
|||||||
export type MatchStatsUserRecordFragment = Pick<
|
export type MatchStatsUserRecordFragment = Pick<
|
||||||
MatchStats,
|
MatchStats,
|
||||||
'matchId' | 'records' | 'builderVersion'
|
'matchId' | 'records' | 'builderVersion'
|
||||||
>;
|
> & {
|
||||||
|
gameDetails?: Array<
|
||||||
|
Pick<MatchStats['gameDetails'][number], 'gameNumber' | 'rawAvailable'>
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
|
||||||
export type MatchStatsDetailFragment = Pick<
|
export type MatchStatsDetailFragment = Pick<
|
||||||
MatchStats,
|
MatchStats,
|
||||||
@@ -209,10 +213,17 @@ export class MatchStatsRepository {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (params.query) {
|
if (params.query) {
|
||||||
filter['matchCard.title'] = {
|
const search = {
|
||||||
$regex: params.query.replace(/[.*+?^$\x7b\x7d()|[\]\\]/g, '\\$&'),
|
$regex: params.query.replace(/[.*+?^$\x7b\x7d()|[\]\\]/g, '\\$&'),
|
||||||
$options: 'i',
|
$options: 'i',
|
||||||
};
|
};
|
||||||
|
conditions.push({
|
||||||
|
$or: [
|
||||||
|
{ 'matchCard.title': search },
|
||||||
|
{ 'matchCard.teams.name': search },
|
||||||
|
{ 'matchCard.teams.members.summonerName': search },
|
||||||
|
],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (params.format) {
|
if (params.format) {
|
||||||
filter['matchCard.teams.1'] = { $exists: true };
|
filter['matchCard.teams.1'] = { $exists: true };
|
||||||
@@ -250,6 +261,7 @@ export class MatchStatsRepository {
|
|||||||
sourceRevision: 1,
|
sourceRevision: 1,
|
||||||
'gameDetails.gameNumber': 1,
|
'gameDetails.gameNumber': 1,
|
||||||
'gameDetails.gameCreation': 1,
|
'gameDetails.gameCreation': 1,
|
||||||
|
'gameDetails.rawAvailable': 1,
|
||||||
})
|
})
|
||||||
.sort({ scheduledAt: -1, matchId: -1 })
|
.sort({ scheduledAt: -1, matchId: -1 })
|
||||||
.limit(params.limit)
|
.limit(params.limit)
|
||||||
@@ -298,6 +310,8 @@ export class MatchStatsRepository {
|
|||||||
})
|
})
|
||||||
.select({
|
.select({
|
||||||
_id: 0,
|
_id: 0,
|
||||||
|
matchId: 1,
|
||||||
|
scheduledAt: 1,
|
||||||
'records.userId': 1,
|
'records.userId': 1,
|
||||||
'records.summonerName': 1,
|
'records.summonerName': 1,
|
||||||
'records.tagLine': 1,
|
'records.tagLine': 1,
|
||||||
@@ -319,6 +333,7 @@ export class MatchStatsRepository {
|
|||||||
'gameDetails.gameCreation': 1,
|
'gameDetails.gameCreation': 1,
|
||||||
'gameDetails.gameNumber': 1,
|
'gameDetails.gameNumber': 1,
|
||||||
'gameDetails.winnerSide': 1,
|
'gameDetails.winnerSide': 1,
|
||||||
|
'gameDetails.rawAvailable': 1,
|
||||||
})
|
})
|
||||||
.sort({ scheduledAt: -1 })
|
.sort({ scheduledAt: -1 })
|
||||||
.lean()
|
.lean()
|
||||||
@@ -352,7 +367,14 @@ export class MatchStatsRepository {
|
|||||||
return MatchStatsModel.find(filter)
|
return MatchStatsModel.find(filter)
|
||||||
.sort({ scheduledAt: -1 })
|
.sort({ scheduledAt: -1 })
|
||||||
.limit(params.limit ?? 300)
|
.limit(params.limit ?? 300)
|
||||||
.select({ _id: 0, matchId: 1, records: 1, builderVersion: 1 })
|
.select({
|
||||||
|
_id: 0,
|
||||||
|
matchId: 1,
|
||||||
|
records: 1,
|
||||||
|
builderVersion: 1,
|
||||||
|
'gameDetails.gameNumber': 1,
|
||||||
|
'gameDetails.rawAvailable': 1,
|
||||||
|
})
|
||||||
.lean<MatchStatsUserRecordFragment[]>()
|
.lean<MatchStatsUserRecordFragment[]>()
|
||||||
.exec();
|
.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { readFile } from 'node:fs/promises';
|
|||||||
import { resolve } from 'node:path';
|
import { resolve } from 'node:path';
|
||||||
import { ConnectionService, resolveMongoDbName } from '../connection.service';
|
import { ConnectionService, resolveMongoDbName } from '../connection.service';
|
||||||
import type {
|
import type {
|
||||||
|
Community,
|
||||||
MatchGameResult,
|
MatchGameResult,
|
||||||
MatchParticipant,
|
MatchParticipant,
|
||||||
MatchSeriesResult,
|
MatchSeriesResult,
|
||||||
@@ -250,16 +251,17 @@ async function main() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const match = await MatchModel.create(payload);
|
const matchId = new mongoose.Types.ObjectId();
|
||||||
console.log(`[temp result seed] created=${match._id.toString()}`);
|
await MatchModel.create({ ...payload, _id: matchId });
|
||||||
console.log(`[temp result seed] route=/match/${match._id.toString()}`);
|
console.log(`[temp result seed] created=${matchId.toString()}`);
|
||||||
|
console.log(`[temp result seed] route=/match/${matchId.toString()}`);
|
||||||
} finally {
|
} finally {
|
||||||
await app.close();
|
await app.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resolveCommunity(
|
async function resolveCommunity(
|
||||||
CommunityModel: mongoose.Model<unknown>,
|
CommunityModel: mongoose.Model<Community>,
|
||||||
communityId?: string,
|
communityId?: string,
|
||||||
): Promise<CommunityLean> {
|
): Promise<CommunityLean> {
|
||||||
const community = communityId
|
const community = communityId
|
||||||
@@ -316,11 +318,11 @@ function buildMatchPayload(
|
|||||||
description:
|
description:
|
||||||
'결과 페이지 검증용으로 생성된 30명, 6팀, 15경기 완료 임시 데이터입니다.',
|
'결과 페이지 검증용으로 생성된 30명, 6팀, 15경기 완료 임시 데이터입니다.',
|
||||||
mapId: 11,
|
mapId: 11,
|
||||||
status: 'finished',
|
status: 'finished' as const,
|
||||||
scheduledAt: options.scheduledAt,
|
scheduledAt: options.scheduledAt,
|
||||||
maxParticipants: TOTAL_PLAYERS,
|
maxParticipants: TOTAL_PLAYERS,
|
||||||
gameCount: GAME_COUNT_PER_SERIES_GROUP,
|
gameCount: GAME_COUNT_PER_SERIES_GROUP,
|
||||||
gameMode: 'round-robin',
|
gameMode: 'round-robin' as const,
|
||||||
tournamentCodeIds: [],
|
tournamentCodeIds: [],
|
||||||
teamBuiltAt: new Date(options.scheduledAt.getTime() - 30 * 60000),
|
teamBuiltAt: new Date(options.scheduledAt.getTime() - 30 * 60000),
|
||||||
participants,
|
participants,
|
||||||
@@ -335,10 +337,10 @@ function buildMatchPayload(
|
|||||||
resultPollState: {
|
resultPollState: {
|
||||||
startedAt: new Date(options.scheduledAt.getTime() + 2 * 60 * 60 * 1000),
|
startedAt: new Date(options.scheduledAt.getTime() + 2 * 60 * 60 * 1000),
|
||||||
lastPolledAt: now,
|
lastPolledAt: now,
|
||||||
lastPollOutcome: 'matched',
|
lastPollOutcome: 'matched' as const,
|
||||||
matchedCount: games.length,
|
matchedCount: games.length,
|
||||||
expandedToAllPuuids: true,
|
expandedToAllPuuids: true,
|
||||||
state: 'complete',
|
state: 'complete' as const,
|
||||||
},
|
},
|
||||||
legacyImported: true,
|
legacyImported: true,
|
||||||
legacyImportSource: {
|
legacyImportSource: {
|
||||||
|
|||||||
@@ -40,7 +40,10 @@ export const MATCH_STATUSES: MatchStatus[] = [
|
|||||||
'finished',
|
'finished',
|
||||||
];
|
];
|
||||||
|
|
||||||
export const MATCH_EVENT_TYPES = ['inhouse', 'tournament'] as const satisfies readonly MatchEventType[];
|
export const MATCH_EVENT_TYPES = [
|
||||||
|
'inhouse',
|
||||||
|
'tournament',
|
||||||
|
] as const satisfies readonly MatchEventType[];
|
||||||
|
|
||||||
export type TeamSide = 'blue' | 'red';
|
export type TeamSide = 'blue' | 'red';
|
||||||
export const TEAM_SIDES: TeamSide[] = ['blue', 'red'];
|
export const TEAM_SIDES: TeamSide[] = ['blue', 'red'];
|
||||||
@@ -854,6 +857,8 @@ export const AuctionBidRecordSchema = new Schema<AuctionBidRecord>(
|
|||||||
|
|
||||||
export interface AuctionChatMessage {
|
export interface AuctionChatMessage {
|
||||||
id: string;
|
id: string;
|
||||||
|
clientMessageId?: string;
|
||||||
|
senderRole?: 'operator';
|
||||||
userId?: mongoose.Types.ObjectId;
|
userId?: mongoose.Types.ObjectId;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
message: string;
|
message: string;
|
||||||
@@ -2252,6 +2257,8 @@ const AuctionBidHistoryEntrySubSchema = new Schema<AuctionBidHistoryEntry>(
|
|||||||
const AuctionChatMessageSubSchema = new Schema<AuctionChatMessage>(
|
const AuctionChatMessageSubSchema = new Schema<AuctionChatMessage>(
|
||||||
{
|
{
|
||||||
id: { type: String, required: true },
|
id: { type: String, required: true },
|
||||||
|
clientMessageId: { type: String, required: false },
|
||||||
|
senderRole: { type: String, enum: ['operator'], required: false },
|
||||||
userId: { type: Schema.Types.ObjectId, ref: 'user', required: false },
|
userId: { type: Schema.Types.ObjectId, ref: 'user', required: false },
|
||||||
displayName: { type: String, required: true },
|
displayName: { type: String, required: true },
|
||||||
message: { type: String, required: true },
|
message: { type: String, required: true },
|
||||||
@@ -2554,7 +2561,10 @@ MatchStatsSchema.index({
|
|||||||
MatchStatsSchema.index({ communityId: 1, userIds: 1 });
|
MatchStatsSchema.index({ communityId: 1, userIds: 1 });
|
||||||
MatchStatsSchema.index({ communityId: 1, userIds: 1, scheduledAt: -1 });
|
MatchStatsSchema.index({ communityId: 1, userIds: 1, scheduledAt: -1 });
|
||||||
MatchStatsSchema.index({ communityId: 1, championIds: 1 });
|
MatchStatsSchema.index({ communityId: 1, championIds: 1 });
|
||||||
MatchStatsSchema.index(MATCH_STATS_RIOT_MATCH_INDEX.key, MATCH_STATS_RIOT_MATCH_INDEX.options);
|
MatchStatsSchema.index(
|
||||||
|
MATCH_STATS_RIOT_MATCH_INDEX.key,
|
||||||
|
MATCH_STATS_RIOT_MATCH_INDEX.options,
|
||||||
|
);
|
||||||
|
|
||||||
export const tournamentModelDefinitions: Array<
|
export const tournamentModelDefinitions: Array<
|
||||||
ModelDefinition & { name: keyof TournamentModelTypes }
|
ModelDefinition & { name: keyof TournamentModelTypes }
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ export class MatchHistoryController {
|
|||||||
@Query('seasonId') seasonId?: string,
|
@Query('seasonId') seasonId?: string,
|
||||||
@Query('championId') championId?: string,
|
@Query('championId') championId?: string,
|
||||||
@Query('limit') limit?: string,
|
@Query('limit') limit?: string,
|
||||||
|
@Query('lane') lane?: string,
|
||||||
) {
|
) {
|
||||||
return this.matchHistoryService.getRecentSummary({
|
return this.matchHistoryService.getRecentSummary({
|
||||||
communityId,
|
communityId,
|
||||||
@@ -66,6 +67,7 @@ export class MatchHistoryController {
|
|||||||
seasonId,
|
seasonId,
|
||||||
championId: this.toNumber(championId),
|
championId: this.toNumber(championId),
|
||||||
limit: this.toNumber(limit),
|
limit: this.toNumber(limit),
|
||||||
|
lane,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -82,6 +84,8 @@ export class MatchHistoryController {
|
|||||||
@Query('championId') championId?: string,
|
@Query('championId') championId?: string,
|
||||||
@Query('limit') limit?: string,
|
@Query('limit') limit?: string,
|
||||||
@Query('cursor') cursor?: string,
|
@Query('cursor') cursor?: string,
|
||||||
|
@Query('lane') lane?: string,
|
||||||
|
@Query('includePositionCounts') includePositionCounts?: string,
|
||||||
) {
|
) {
|
||||||
return this.matchHistoryService.getRecentMatches({
|
return this.matchHistoryService.getRecentMatches({
|
||||||
communityId,
|
communityId,
|
||||||
@@ -93,6 +97,8 @@ export class MatchHistoryController {
|
|||||||
championId: this.toNumber(championId),
|
championId: this.toNumber(championId),
|
||||||
limit: this.toNumber(limit),
|
limit: this.toNumber(limit),
|
||||||
cursor: this.toNumber(cursor),
|
cursor: this.toNumber(cursor),
|
||||||
|
lane,
|
||||||
|
includePositionCounts: includePositionCounts === 'true',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,72 @@ import { MatchHistoryService } from './match-history.service';
|
|||||||
const SEASON_START = Date.parse('2026-01-01T00:00:00Z');
|
const SEASON_START = Date.parse('2026-01-01T00:00:00Z');
|
||||||
|
|
||||||
describe('MatchHistoryService champion filtering', () => {
|
describe('MatchHistoryService champion filtering', () => {
|
||||||
|
it('selects a lane before limiting and uses only the requested participant, including legacy individualPosition', async () => {
|
||||||
|
const { service, scope, find } = createHarness();
|
||||||
|
const result = await service.getRecentMatches({
|
||||||
|
...scope,
|
||||||
|
filters: { rank: 'solo', lane: 'MIDDLE', limit: 20 },
|
||||||
|
});
|
||||||
|
expect(result.matches.map((game) => game.matchId)).toEqual([
|
||||||
|
'KR_3',
|
||||||
|
'KR_2',
|
||||||
|
'KR_1',
|
||||||
|
]);
|
||||||
|
expect(result.matches.every((game) => game.teamPosition === 'MIDDLE')).toBe(
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
expect(result.matches[0].damageShare).toBe(100);
|
||||||
|
expect(find.mock.calls[0][0]['raw.info.participants']?.$elemMatch).toEqual({
|
||||||
|
puuid: 'player',
|
||||||
|
$or: [
|
||||||
|
{ teamPosition: 'MIDDLE' },
|
||||||
|
{ teamPosition: { $in: ['', null] }, individualPosition: 'MIDDLE' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('combines champion and lane filtering and rejects invalid lanes', async () => {
|
||||||
|
const { service, scope } = createHarness();
|
||||||
|
const result = await service.getRecentMatches({
|
||||||
|
...scope,
|
||||||
|
filters: { rank: 'solo', championId: 1, lane: 'MIDDLE', limit: 20 },
|
||||||
|
});
|
||||||
|
expect(result.matches).toEqual([]);
|
||||||
|
await expect(
|
||||||
|
service.getRecentMatches({ ...scope, filters: { lane: 'unknown' } }),
|
||||||
|
).rejects.toThrow('Invalid lane');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('counts independent lane windows across the season and caps each at twenty', async () => {
|
||||||
|
const { service, scope, aggregate } = createHarness();
|
||||||
|
const result = await service.getRecentMatches({
|
||||||
|
...scope,
|
||||||
|
filters: {
|
||||||
|
rank: 'solo',
|
||||||
|
lane: 'MIDDLE',
|
||||||
|
limit: 20,
|
||||||
|
includePositionCounts: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(result.positionCounts).toEqual({
|
||||||
|
ALL: 20,
|
||||||
|
TOP: 20,
|
||||||
|
JUNGLE: 0,
|
||||||
|
MIDDLE: 3,
|
||||||
|
BOTTOM: 0,
|
||||||
|
UTILITY: 0,
|
||||||
|
});
|
||||||
|
expect(aggregate.mock.calls[0][0][0]).toEqual({
|
||||||
|
$match: {
|
||||||
|
participantPuuids: 'player',
|
||||||
|
queueId: { $in: [420] },
|
||||||
|
gameCreation: { $gte: SEASON_START },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(JSON.stringify(aggregate.mock.calls[0][0])).toContain('$$p.puuid');
|
||||||
|
expect(JSON.stringify(aggregate.mock.calls[0][0])).not.toContain('$limit');
|
||||||
|
});
|
||||||
|
|
||||||
it('paginates matching games beyond 120 newer games and excludes opponents using the champion', async () => {
|
it('paginates matching games beyond 120 newer games and excludes opponents using the champion', async () => {
|
||||||
const harness = createHarness();
|
const harness = createHarness();
|
||||||
const filters = { championId: 99, rank: 'solo', limit: 2 };
|
const filters = { championId: 99, rank: 'solo', limit: 2 };
|
||||||
@@ -77,7 +143,14 @@ interface HistoryQuery {
|
|||||||
queueId: { $in: number[] };
|
queueId: { $in: number[] };
|
||||||
gameCreation?: { $gte?: number; $lt?: number };
|
gameCreation?: { $gte?: number; $lt?: number };
|
||||||
'raw.info.participants'?: {
|
'raw.info.participants'?: {
|
||||||
$elemMatch: { puuid: string; championId: number };
|
$elemMatch: {
|
||||||
|
puuid: string;
|
||||||
|
championId?: number;
|
||||||
|
$or?: Array<{
|
||||||
|
teamPosition: string | { $in: (string | null)[] };
|
||||||
|
individualPosition?: string;
|
||||||
|
}>;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +195,18 @@ function createHarness() {
|
|||||||
row.raw.info.participants.some(
|
row.raw.info.participants.some(
|
||||||
(entry) =>
|
(entry) =>
|
||||||
entry.puuid === participant.puuid &&
|
entry.puuid === participant.puuid &&
|
||||||
entry.championId === participant.championId,
|
(participant.championId === undefined ||
|
||||||
|
entry.championId === participant.championId) &&
|
||||||
|
(!participant.$or ||
|
||||||
|
participant.$or.some((condition) =>
|
||||||
|
typeof condition.teamPosition === 'string'
|
||||||
|
? entry.teamPosition === condition.teamPosition
|
||||||
|
: condition.teamPosition.$in.includes(
|
||||||
|
entry.teamPosition ?? null,
|
||||||
|
) &&
|
||||||
|
entry.individualPosition ===
|
||||||
|
condition.individualPosition,
|
||||||
|
)),
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
.sort((a, b) => b.gameCreation - a.gameCreation)
|
.sort((a, b) => b.gameCreation - a.gameCreation)
|
||||||
@@ -133,6 +217,15 @@ function createHarness() {
|
|||||||
};
|
};
|
||||||
return query;
|
return query;
|
||||||
});
|
});
|
||||||
|
const aggregate = jest.fn<
|
||||||
|
{ exec: () => Promise<Array<{ _id: string; count: number }>> },
|
||||||
|
[unknown[]]
|
||||||
|
>(() => ({
|
||||||
|
exec: async () => [
|
||||||
|
{ _id: 'TOP', count: 127 },
|
||||||
|
{ _id: 'MIDDLE', count: 3 },
|
||||||
|
],
|
||||||
|
}));
|
||||||
const models = {
|
const models = {
|
||||||
user: {
|
user: {
|
||||||
find: () => ({
|
find: () => ({
|
||||||
@@ -179,7 +272,7 @@ function createHarness() {
|
|||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
riotMatch: { find },
|
riotMatch: { find, aggregate },
|
||||||
};
|
};
|
||||||
const connection = {
|
const connection = {
|
||||||
getModel: async (name: keyof typeof models) => models[name],
|
getModel: async (name: keyof typeof models) => models[name],
|
||||||
@@ -190,6 +283,7 @@ function createHarness() {
|
|||||||
find,
|
find,
|
||||||
select,
|
select,
|
||||||
returnedCounts,
|
returnedCounts,
|
||||||
|
aggregate,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,6 +292,9 @@ function storedMatch(sequence: number, championId: number, queueId = 420) {
|
|||||||
const participant = {
|
const participant = {
|
||||||
puuid: 'player',
|
puuid: 'player',
|
||||||
championId,
|
championId,
|
||||||
|
teamPosition:
|
||||||
|
sequence === 2 ? undefined : championId === 99 ? 'MIDDLE' : 'TOP',
|
||||||
|
individualPosition: championId === 99 ? 'MIDDLE' : 'TOP',
|
||||||
teamId: 100,
|
teamId: 100,
|
||||||
win: true,
|
win: true,
|
||||||
kills: 5,
|
kills: 5,
|
||||||
@@ -229,6 +326,7 @@ function storedMatch(sequence: number, championId: number, queueId = 420) {
|
|||||||
puuid: 'opponent',
|
puuid: 'opponent',
|
||||||
teamId: 200,
|
teamId: 200,
|
||||||
championId: 99,
|
championId: 99,
|
||||||
|
teamPosition: 'MIDDLE',
|
||||||
win: false,
|
win: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ interface MatchFilters {
|
|||||||
championId?: number;
|
championId?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
cursor?: number;
|
cursor?: number;
|
||||||
|
lane?: string;
|
||||||
|
includePositionCounts?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AggregatedChampion {
|
interface AggregatedChampion {
|
||||||
@@ -183,6 +185,7 @@ export class MatchHistoryService {
|
|||||||
context,
|
context,
|
||||||
queueIds,
|
queueIds,
|
||||||
championId: params.filters.championId,
|
championId: params.filters.championId,
|
||||||
|
lane: params.filters.lane,
|
||||||
limit,
|
limit,
|
||||||
});
|
});
|
||||||
const views = docs
|
const views = docs
|
||||||
@@ -212,6 +215,7 @@ export class MatchHistoryService {
|
|||||||
context,
|
context,
|
||||||
queueIds,
|
queueIds,
|
||||||
championId: params.filters.championId,
|
championId: params.filters.championId,
|
||||||
|
lane: params.filters.lane,
|
||||||
limit: limit + 1,
|
limit: limit + 1,
|
||||||
cursor: params.filters.cursor,
|
cursor: params.filters.cursor,
|
||||||
});
|
});
|
||||||
@@ -223,6 +227,15 @@ export class MatchHistoryService {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
matches: page,
|
matches: page,
|
||||||
|
...(params.filters.includePositionCounts
|
||||||
|
? {
|
||||||
|
positionCounts: await this.getPositionCounts(
|
||||||
|
context,
|
||||||
|
queueIds,
|
||||||
|
params.filters.championId,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
nextCursor:
|
nextCursor:
|
||||||
views.length > limit
|
views.length > limit
|
||||||
? (page[page.length - 1]?.gameCreation ?? null)
|
? (page[page.length - 1]?.gameCreation ?? null)
|
||||||
@@ -394,7 +407,14 @@ export class MatchHistoryService {
|
|||||||
limit: number;
|
limit: number;
|
||||||
cursor?: number;
|
cursor?: number;
|
||||||
championId?: number;
|
championId?: number;
|
||||||
|
lane?: string;
|
||||||
}): Promise<RiotMatchDocument[]> {
|
}): Promise<RiotMatchDocument[]> {
|
||||||
|
if (
|
||||||
|
params.lane &&
|
||||||
|
!['TOP', 'JUNGLE', 'MIDDLE', 'BOTTOM', 'UTILITY'].includes(params.lane)
|
||||||
|
) {
|
||||||
|
throw new BadRequestException('Invalid lane.');
|
||||||
|
}
|
||||||
if (params.queueIds.length === 0) return [];
|
if (params.queueIds.length === 0) return [];
|
||||||
const RiotMatchModel = await this.connectionService.getModel('riotMatch');
|
const RiotMatchModel = await this.connectionService.getModel('riotMatch');
|
||||||
const gameCreation: Record<string, number> = {};
|
const gameCreation: Record<string, number> = {};
|
||||||
@@ -408,12 +428,25 @@ export class MatchHistoryService {
|
|||||||
queueId: { $in: params.queueIds },
|
queueId: { $in: params.queueIds },
|
||||||
};
|
};
|
||||||
if (Object.keys(gameCreation).length > 0) query.gameCreation = gameCreation;
|
if (Object.keys(gameCreation).length > 0) query.gameCreation = gameCreation;
|
||||||
if (params.championId !== undefined) {
|
if (params.championId !== undefined || params.lane) {
|
||||||
// Both conditions must match the same participant, before pagination.
|
// Both conditions must match the same participant, before pagination.
|
||||||
query['raw.info.participants'] = {
|
query['raw.info.participants'] = {
|
||||||
$elemMatch: {
|
$elemMatch: {
|
||||||
puuid: params.context.account.puuid,
|
puuid: params.context.account.puuid,
|
||||||
championId: params.championId,
|
...(params.championId !== undefined
|
||||||
|
? { championId: params.championId }
|
||||||
|
: {}),
|
||||||
|
...(params.lane
|
||||||
|
? {
|
||||||
|
$or: [
|
||||||
|
{ teamPosition: params.lane },
|
||||||
|
{
|
||||||
|
teamPosition: { $in: ['', null] },
|
||||||
|
individualPosition: params.lane,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -425,6 +458,74 @@ export class MatchHistoryService {
|
|||||||
.exec();
|
.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Counts independent position windows, without transferring full match payloads. */
|
||||||
|
private async getPositionCounts(
|
||||||
|
context: HistoryContext,
|
||||||
|
queueIds: number[],
|
||||||
|
championId?: number,
|
||||||
|
): Promise<Record<string, number>> {
|
||||||
|
const model = await this.connectionService.getModel('riotMatch');
|
||||||
|
const rows = await model
|
||||||
|
.aggregate<{ _id: string; count: number }>([
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
participantPuuids: context.account.puuid,
|
||||||
|
queueId: { $in: queueIds },
|
||||||
|
...(context.seasonStartedAt
|
||||||
|
? { gameCreation: { $gte: context.seasonStartedAt.getTime() } }
|
||||||
|
: {}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$project: {
|
||||||
|
participant: {
|
||||||
|
$first: {
|
||||||
|
$filter: {
|
||||||
|
input: '$raw.info.participants',
|
||||||
|
as: 'p',
|
||||||
|
cond: { $eq: ['$$p.puuid', context.account.puuid] },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
participant: { $ne: null },
|
||||||
|
...(championId !== undefined
|
||||||
|
? { 'participant.championId': championId }
|
||||||
|
: {}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$group: {
|
||||||
|
_id: {
|
||||||
|
$cond: [
|
||||||
|
{ $in: [{ $ifNull: ['$participant.teamPosition', ''] }, ['']] },
|
||||||
|
'$participant.individualPosition',
|
||||||
|
'$participant.teamPosition',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
count: { $sum: 1 },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
])
|
||||||
|
.exec();
|
||||||
|
const counts: Record<string, number> = {
|
||||||
|
ALL: Math.min(
|
||||||
|
20,
|
||||||
|
rows.reduce((sum, row) => sum + row.count, 0),
|
||||||
|
),
|
||||||
|
};
|
||||||
|
for (const lane of ['TOP', 'JUNGLE', 'MIDDLE', 'BOTTOM', 'UTILITY']) {
|
||||||
|
counts[lane] = Math.min(
|
||||||
|
20,
|
||||||
|
rows.find((row) => row._id === lane)?.count ?? 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return counts;
|
||||||
|
}
|
||||||
|
|
||||||
private async aggregateChampionStats(params: {
|
private async aggregateChampionStats(params: {
|
||||||
context: HistoryContext;
|
context: HistoryContext;
|
||||||
queueIds: number[];
|
queueIds: number[];
|
||||||
@@ -676,6 +777,7 @@ export class MatchHistoryService {
|
|||||||
wardsPlaced: participant.wardsPlaced,
|
wardsPlaced: participant.wardsPlaced,
|
||||||
wardsKilled: participant.wardsKilled,
|
wardsKilled: participant.wardsKilled,
|
||||||
damageDealtToChampions: participant.totalDamageDealtToChampions,
|
damageDealtToChampions: participant.totalDamageDealtToChampions,
|
||||||
|
damageShare: damageShare * 100,
|
||||||
damageTaken: participant.totalDamageTaken,
|
damageTaken: participant.totalDamageTaken,
|
||||||
goldEarned: participant.goldEarned,
|
goldEarned: participant.goldEarned,
|
||||||
items: [
|
items: [
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ export interface RecentSummaryResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface RecentMatchesResponse {
|
export interface RecentMatchesResponse {
|
||||||
|
/** Available games in each independent recent-20 window. */
|
||||||
|
positionCounts?: Record<string, number>;
|
||||||
matches: RecentMatchView[];
|
matches: RecentMatchView[];
|
||||||
nextCursor: number | null;
|
nextCursor: number | null;
|
||||||
lastFetchedAt: string | null;
|
lastFetchedAt: string | null;
|
||||||
@@ -136,8 +138,11 @@ export interface RecentMatchTeamParticipantView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface RecentMatchView {
|
export interface RecentMatchView {
|
||||||
|
/** Player champion damage / team champion damage, as a percentage. */
|
||||||
|
damageShare?: number;
|
||||||
matchId: string;
|
matchId: string;
|
||||||
internalMatchId?: string;
|
internalMatchId?: string;
|
||||||
|
internalMatchTitle?: string;
|
||||||
gameNumber?: number;
|
gameNumber?: number;
|
||||||
queueId: number;
|
queueId: number;
|
||||||
queueLabel: string;
|
queueLabel: string;
|
||||||
|
|||||||
@@ -3,7 +3,11 @@ import { BadRequestException, ValidationPipe } from '@nestjs/common';
|
|||||||
import { plainToInstance } from 'class-transformer';
|
import { plainToInstance } from 'class-transformer';
|
||||||
import { validateSync } from 'class-validator';
|
import { validateSync } from 'class-validator';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import { CreateMatchDto, JoinMatchDto, UpdateMatchDto } from './create-match.dto';
|
import {
|
||||||
|
CreateMatchDto,
|
||||||
|
JoinMatchDto,
|
||||||
|
UpdateMatchDto,
|
||||||
|
} from './create-match.dto';
|
||||||
|
|
||||||
describe('CreateMatchDto game mode cutover', () => {
|
describe('CreateMatchDto game mode cutover', () => {
|
||||||
it('rejects the removed live bracket mode', () => {
|
it('rejects the removed live bracket mode', () => {
|
||||||
@@ -75,7 +79,9 @@ describe('Grand final format validation', () => {
|
|||||||
doubleEliminationGrandFinalGameCount: 2,
|
doubleEliminationGrandFinalGameCount: 2,
|
||||||
});
|
});
|
||||||
expect(validateSync(update)).toEqual([
|
expect(validateSync(update)).toEqual([
|
||||||
expect.objectContaining({ property: 'doubleEliminationGrandFinalGameCount' }),
|
expect.objectContaining({
|
||||||
|
property: 'doubleEliminationGrandFinalGameCount',
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -93,16 +99,19 @@ describe('Match event type validation', () => {
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
).toEqual([]);
|
).toEqual([]);
|
||||||
expect(validateSync(plainToInstance(UpdateMatchDto, { eventType }))).toEqual(
|
expect(
|
||||||
[],
|
validateSync(plainToInstance(UpdateMatchDto, { eventType })),
|
||||||
);
|
).toEqual([]);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
it.each(['double-elimination', null])('rejects %s as an event type', (eventType) => {
|
it.each(['double-elimination', null])(
|
||||||
|
'rejects %s as an event type',
|
||||||
|
(eventType) => {
|
||||||
const dto = plainToInstance(UpdateMatchDto, { eventType });
|
const dto = plainToInstance(UpdateMatchDto, { eventType });
|
||||||
expect(validateSync(dto)).toEqual([
|
expect(validateSync(dto)).toEqual([
|
||||||
expect.objectContaining({ property: 'eventType' }),
|
expect.objectContaining({ property: 'eventType' }),
|
||||||
]);
|
]);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
@@ -26,7 +26,10 @@ interface PublicMatchSource {
|
|||||||
gameCount: number;
|
gameCount: number;
|
||||||
gameMode: MatchGameMode;
|
gameMode: MatchGameMode;
|
||||||
roundRobinMaxRounds?: number;
|
roundRobinMaxRounds?: number;
|
||||||
doubleElimination?: { resetFinalEnabled?: boolean; grandFinalGameCount?: 1 | 3 | 5 };
|
doubleElimination?: {
|
||||||
|
resetFinalEnabled?: boolean;
|
||||||
|
grandFinalGameCount?: 1 | 3 | 5;
|
||||||
|
};
|
||||||
hostUserId?: IdLike;
|
hostUserId?: IdLike;
|
||||||
participants: Array<{
|
participants: Array<{
|
||||||
userId: IdLike;
|
userId: IdLike;
|
||||||
|
|||||||
@@ -69,7 +69,12 @@ describe('MatchController partial updates', () => {
|
|||||||
const controller = new MatchController(matchService as never);
|
const controller = new MatchController(matchService as never);
|
||||||
const body = plainToInstance(UpdateMatchDto, { eventType: 'tournament' });
|
const body = plainToInstance(UpdateMatchDto, { eventType: 'tournament' });
|
||||||
|
|
||||||
await controller.updateMatch(user as UserDocument, communityId, matchId, body);
|
await controller.updateMatch(
|
||||||
|
user as UserDocument,
|
||||||
|
communityId,
|
||||||
|
matchId,
|
||||||
|
body,
|
||||||
|
);
|
||||||
|
|
||||||
expect(matchService.update).toHaveBeenCalledWith({
|
expect(matchService.update).toHaveBeenCalledWith({
|
||||||
communityId,
|
communityId,
|
||||||
|
|||||||
@@ -540,7 +540,7 @@ export class TournamentCodeService {
|
|||||||
): Promise<MatchDocument[]> {
|
): Promise<MatchDocument[]> {
|
||||||
const MatchModel = await this.connectionService.getModel('match');
|
const MatchModel = await this.connectionService.getModel('match');
|
||||||
const filter: {
|
const filter: {
|
||||||
status: { $in: string[] };
|
status: { $in: MatchDocument['status'][] };
|
||||||
communityId?: mongoose.Types.ObjectId;
|
communityId?: mongoose.Types.ObjectId;
|
||||||
} = {
|
} = {
|
||||||
status: { $in: ['team-built', 'in-progress'] },
|
status: { $in: ['team-built', 'in-progress'] },
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ export class CompetitionOutboxProcessor
|
|||||||
function leaseFilter(event: ClaimedOutboxEvent) {
|
function leaseFilter(event: ClaimedOutboxEvent) {
|
||||||
return {
|
return {
|
||||||
_id: event._id,
|
_id: event._id,
|
||||||
state: 'pending',
|
state: 'pending' as const,
|
||||||
attemptCount: event.attemptCount,
|
attemptCount: event.attemptCount,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="ko">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>내전 전적 개선 시안 · LOLYMPUS</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="/src/design-previews/internal-stats/main.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="ko">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>선수 정보 시안 02 · LOLYMPUS</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="/src/design-previews/player-information-v2/main.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="ko">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>선수 정보 개선 시안 · LOLYMPUS</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="/src/design-previews/player-information/main.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -19,5 +19,15 @@ export default defineConfig([
|
|||||||
ecmaVersion: 2020,
|
ecmaVersion: 2020,
|
||||||
globals: globals.browser,
|
globals: globals.browser,
|
||||||
},
|
},
|
||||||
|
rules: {
|
||||||
|
// Product policy: information stays visible; use sections, links and pagination.
|
||||||
|
'no-restricted-syntax': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
selector: 'JSXOpeningElement[name.name="details"], JSXOpeningElement[name.name="summary"]',
|
||||||
|
message: 'LOLYMPUS does not use disclosure/accordion UI. Keep content visible in a section, or use a dedicated route for a separate task.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
+38
-88
@@ -6,11 +6,10 @@ import {
|
|||||||
Route,
|
Route,
|
||||||
Routes,
|
Routes,
|
||||||
useLocation,
|
useLocation,
|
||||||
useNavigate,
|
|
||||||
} from "react-router";
|
} from "react-router";
|
||||||
import { useState, type FormEvent, type ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
import { useMsal } from "@azure/msal-react";
|
import { useMsal } from "@azure/msal-react";
|
||||||
import { LogOut, Moon, Search, Sun } from "lucide-react";
|
import { LogOut, Moon, Sun } from "lucide-react";
|
||||||
import DevAuthSwitcher from "./components/DevAuthSwitcher";
|
import DevAuthSwitcher from "./components/DevAuthSwitcher";
|
||||||
import { DEFAULT_COMMUNITY_ID, setTheme, useTheme } from "./config";
|
import { DEFAULT_COMMUNITY_ID, setTheme, useTheme } from "./config";
|
||||||
import { useCommunity, useMatch, useMe } from "./api/hooks";
|
import { useCommunity, useMatch, useMe } from "./api/hooks";
|
||||||
@@ -24,16 +23,18 @@ import MatchTeamProgressPage from "./pages/MatchTeamProgressPage";
|
|||||||
import AuctionPage from "./pages/AuctionPage";
|
import AuctionPage from "./pages/AuctionPage";
|
||||||
import UserHistoryPage from "./pages/UserHistoryPage";
|
import UserHistoryPage from "./pages/UserHistoryPage";
|
||||||
import CommunityInternalStatsPage from "./pages/CommunityInternalStatsPage";
|
import CommunityInternalStatsPage from "./pages/CommunityInternalStatsPage";
|
||||||
|
import CommunityInternalPlayerPage from "./pages/CommunityInternalPlayerPage";
|
||||||
import InternalMatchDetailPage from "./pages/InternalMatchDetailPage";
|
import InternalMatchDetailPage from "./pages/InternalMatchDetailPage";
|
||||||
import LegacyImportPage from "./pages/admin/LegacyImportPage";
|
import LegacyImportPage from "./pages/admin/LegacyImportPage";
|
||||||
import LegacyMatchesPage from "./pages/admin/LegacyMatchesPage";
|
import LegacyMatchesPage from "./pages/admin/LegacyMatchesPage";
|
||||||
import MatchAdminPage from "./pages/admin/MatchAdminPage";
|
import MatchAdminPage from "./pages/admin/MatchAdminPage";
|
||||||
import TournamentCodesPage from "./pages/admin/TournamentCodesPage";
|
import TournamentCodesPage from "./pages/admin/TournamentCodesPage";
|
||||||
import { PlainPage, Tooltip, pageWidthClass } from "./ui";
|
import { PlainPage, Tooltip, pageWidthClass } from "./ui";
|
||||||
|
import "./components/app-header.css";
|
||||||
|
|
||||||
|
|
||||||
const NAV_ICON_BUTTON_CLASS =
|
const NAV_ICON_BUTTON_CLASS =
|
||||||
"grid size-10 shrink-0 place-items-center rounded-field text-content-muted transition-colors hover:bg-sunken-strong hover:text-content md:size-11";
|
"lts-header-icon-button";
|
||||||
|
|
||||||
function MsalHeaderActions() {
|
function MsalHeaderActions() {
|
||||||
const { accounts, instance } = useMsal();
|
const { accounts, instance } = useMsal();
|
||||||
@@ -42,7 +43,7 @@ function MsalHeaderActions() {
|
|||||||
if (!account) {
|
if (!account) {
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
className="inline-flex h-10 items-center whitespace-nowrap rounded-full border border-line-strong px-3.5 text-sm font-semibold text-content transition-colors hover:bg-sunken md:h-11 md:px-4 md:text-[15px]"
|
className="inline-flex h-8 items-center whitespace-nowrap rounded-full border border-line px-3 text-[13px] font-medium text-content-muted transition-colors hover:bg-sunken hover:text-content"
|
||||||
to="/login"
|
to="/login"
|
||||||
>
|
>
|
||||||
로그인
|
로그인
|
||||||
@@ -64,7 +65,7 @@ function MsalHeaderActions() {
|
|||||||
aria-label={`${name} 로그아웃`}
|
aria-label={`${name} 로그아웃`}
|
||||||
onClick={() => void instance.logoutRedirect()}
|
onClick={() => void instance.logoutRedirect()}
|
||||||
>
|
>
|
||||||
<LogOut className="size-[18px] md:size-5" aria-hidden="true" />
|
<LogOut className="size-[18px]" aria-hidden="true" />
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
@@ -82,11 +83,11 @@ function ThemeToggle() {
|
|||||||
<Tooltip content={label} placement="below">
|
<Tooltip content={label} placement="below">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={NAV_ICON_BUTTON_CLASS}
|
className={`${NAV_ICON_BUTTON_CLASS} lts-header-theme-toggle`}
|
||||||
aria-label={label}
|
aria-label={label}
|
||||||
onClick={() => setTheme(nextTheme)}
|
onClick={() => setTheme(nextTheme)}
|
||||||
>
|
>
|
||||||
<Icon className="size-[18px] md:size-5" aria-hidden="true" />
|
<Icon className="size-[18px]" aria-hidden="true" />
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
@@ -112,55 +113,13 @@ function PrimaryNavLink({
|
|||||||
<Link
|
<Link
|
||||||
to={to}
|
to={to}
|
||||||
aria-current={current}
|
aria-current={current}
|
||||||
className={`relative inline-flex h-full items-center whitespace-nowrap px-2.5 text-base font-semibold transition-colors focus-visible:-outline-offset-2 sm:px-4 md:px-7 md:text-xl ${
|
className="lts-primary-nav-link"
|
||||||
current
|
|
||||||
? "text-content-strong after:absolute after:inset-x-2.5 after:bottom-0 after:h-[3px] after:rounded-t-full after:bg-primary sm:after:inset-x-4 md:after:inset-x-7"
|
|
||||||
: "text-content-subtle hover:text-content-strong"
|
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 선수 이름으로 전적 순위표를 바로 찾는 머리글 검색. */
|
|
||||||
function HeaderPlayerSearch() {
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const [value, setValue] = useState("");
|
|
||||||
|
|
||||||
function handleSubmit(event: FormEvent<HTMLFormElement>) {
|
|
||||||
event.preventDefault();
|
|
||||||
const query = value.trim();
|
|
||||||
if (!query) return;
|
|
||||||
const params = new URLSearchParams({ view: "ranking", q: query });
|
|
||||||
void navigate(
|
|
||||||
`/communities/${DEFAULT_COMMUNITY_ID}/internal-stats?${params.toString()}`,
|
|
||||||
);
|
|
||||||
setValue("");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<form
|
|
||||||
role="search"
|
|
||||||
onSubmit={handleSubmit}
|
|
||||||
className="relative hidden w-56 min-w-0 md:block lg:w-72"
|
|
||||||
>
|
|
||||||
<Search
|
|
||||||
className="pointer-events-none absolute left-3.5 top-1/2 size-[18px] -translate-y-1/2 text-content-subtle"
|
|
||||||
aria-hidden="true"
|
|
||||||
/>
|
|
||||||
<input
|
|
||||||
type="search"
|
|
||||||
value={value}
|
|
||||||
onChange={(event) => setValue(event.target.value)}
|
|
||||||
placeholder="선수 이름 검색"
|
|
||||||
aria-label="선수 이름으로 전적 검색"
|
|
||||||
className="h-11 w-full rounded-full border border-line-strong bg-sunken pr-4 pl-10 text-[15px] text-content placeholder:text-content-muted focus-visible:bg-card focus-visible:placeholder:text-content-subtle"
|
|
||||||
/>
|
|
||||||
</form>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function AppHeader() {
|
function AppHeader() {
|
||||||
const { pathname } = useLocation();
|
const { pathname } = useLocation();
|
||||||
const matchId = matchPath("/match/:id/*", pathname)?.params.id;
|
const matchId = matchPath("/match/:id/*", pathname)?.params.id;
|
||||||
@@ -177,38 +136,20 @@ function AppHeader() {
|
|||||||
const adminPath = `/admin/communities/${DEFAULT_COMMUNITY_ID}`;
|
const adminPath = `/admin/communities/${DEFAULT_COMMUNITY_ID}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<header
|
||||||
<header className="h-(--app-header-row-height) shrink-0 border-b border-line bg-card dark:bg-ink">
|
className={`lts-app-header${DEFAULT_COMMUNITY_ID ? "" : " lts-app-header--without-nav"}`}
|
||||||
<div
|
|
||||||
className={`${pageWidthClass("xl")} grid h-full grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center sm:gap-x-3`}
|
|
||||||
>
|
>
|
||||||
|
<div className="lts-app-header-inner">
|
||||||
<Link
|
<Link
|
||||||
className="col-start-2 row-start-1 flex h-full items-center text-content-strong"
|
className="lts-header-brand"
|
||||||
to="/"
|
to="/"
|
||||||
aria-label={`${communityLabel} 홈`}
|
aria-label={`${communityLabel} 홈`}
|
||||||
>
|
>
|
||||||
<span className="max-w-32 truncate text-xl font-extrabold tracking-[-0.02em] md:max-w-48 md:text-[22px]">
|
<span className="lts-header-brand-name">{communityLabel}</span>
|
||||||
{communityLabel}
|
<span className="lts-header-brand-tagline">TOURNAMENT</span>
|
||||||
</span>
|
|
||||||
</Link>
|
</Link>
|
||||||
<div className="contents sm:col-start-3 sm:row-start-1 sm:flex sm:min-w-0 sm:items-center sm:justify-end sm:gap-1 lg:gap-2">
|
|
||||||
{DEFAULT_COMMUNITY_ID && <HeaderPlayerSearch />}
|
|
||||||
<div className="col-start-1 row-start-1 justify-self-start sm:shrink-0">
|
|
||||||
<ThemeToggle />
|
|
||||||
</div>
|
|
||||||
{isMsalConfigured && (
|
|
||||||
<div className="col-start-3 row-start-1 min-w-0 justify-self-end sm:shrink-0">
|
|
||||||
<MsalHeaderActions />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
{DEFAULT_COMMUNITY_ID && (
|
{DEFAULT_COMMUNITY_ID && (
|
||||||
<nav
|
<nav aria-label="주 메뉴" className="lts-primary-nav">
|
||||||
aria-label="주 메뉴"
|
|
||||||
className="sticky top-0 z-50 flex h-(--app-header-nav-height) shrink-0 justify-center gap-0.5 border-b border-line bg-card sm:gap-2 md:gap-5 dark:bg-ink"
|
|
||||||
>
|
|
||||||
<PrimaryNavLink to="/">홈</PrimaryNavLink>
|
<PrimaryNavLink to="/">홈</PrimaryNavLink>
|
||||||
<PrimaryNavLink
|
<PrimaryNavLink
|
||||||
to="/inhouse"
|
to="/inhouse"
|
||||||
@@ -238,7 +179,12 @@ function AppHeader() {
|
|||||||
)}
|
)}
|
||||||
</nav>
|
</nav>
|
||||||
)}
|
)}
|
||||||
</>
|
<div className="lts-header-actions">
|
||||||
|
<ThemeToggle />
|
||||||
|
{isMsalConfigured && <MsalHeaderActions />}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,26 +192,29 @@ function AppFooter() {
|
|||||||
return (
|
return (
|
||||||
<footer className="border-t border-line">
|
<footer className="border-t border-line">
|
||||||
<div
|
<div
|
||||||
className={`${pageWidthClass("xl")} flex flex-col gap-3 py-8 text-xs text-content-subtle`}
|
className={`${pageWidthClass("xl")} flex flex-col items-center gap-4 py-10 text-center text-xs text-content-subtle sm:py-12`}
|
||||||
>
|
>
|
||||||
<nav
|
<nav
|
||||||
aria-label="정책"
|
aria-label="정책"
|
||||||
className="flex items-center gap-4 font-semibold text-content-muted"
|
className="flex flex-wrap items-center justify-center gap-x-6 gap-y-2 font-semibold text-content-muted"
|
||||||
>
|
>
|
||||||
<Link to="/terms" className="hover:text-content">
|
<Link to="/terms" className="inline-flex min-h-8 items-center hover:text-content">
|
||||||
서비스 이용약관
|
서비스 이용약관
|
||||||
</Link>
|
</Link>
|
||||||
<Link to="/privacy" className="hover:text-content">
|
<Link to="/privacy" className="inline-flex min-h-8 items-center font-bold hover:text-content">
|
||||||
개인정보처리방침
|
개인정보처리방침
|
||||||
</Link>
|
</Link>
|
||||||
</nav>
|
</nav>
|
||||||
<p className="max-w-4xl leading-relaxed">
|
<div className="w-full max-w-4xl space-y-1 leading-relaxed">
|
||||||
© 2026 LOLYMPUS. LOLYMPUS is not endorsed by Riot Games and does not
|
<p className="text-balance">
|
||||||
reflect the views or opinions of Riot Games or anyone officially
|
LOLYMPUS is not endorsed by Riot Games and does not reflect the views
|
||||||
involved in producing or managing League of Legends. League of Legends
|
or opinions of Riot Games or anyone officially involved in producing
|
||||||
and Riot Games are trademarks or registered trademarks of Riot Games,
|
or managing League of Legends. League of Legends and Riot Games are
|
||||||
Inc. League of Legends © Riot Games, Inc.
|
trademarks or registered trademarks of Riot Games, Inc. League of
|
||||||
|
Legends © Riot Games, Inc.
|
||||||
</p>
|
</p>
|
||||||
|
<p>© 2026 LOLYMPUS.</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
);
|
);
|
||||||
@@ -329,7 +278,7 @@ function App() {
|
|||||||
return (
|
return (
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<div
|
<div
|
||||||
className={`lts-app-shell flex min-h-screen flex-col bg-body ${DEFAULT_COMMUNITY_ID ? "" : "[--app-header-nav-height:0px]"}`}
|
className={`lts-app-shell flex min-h-screen flex-col bg-body ${DEFAULT_COMMUNITY_ID ? "" : "lts-app-shell--without-nav"}`}
|
||||||
>
|
>
|
||||||
<AppHeader />
|
<AppHeader />
|
||||||
|
|
||||||
@@ -361,6 +310,7 @@ function App() {
|
|||||||
path="/communities/:cid/internal-stats"
|
path="/communities/:cid/internal-stats"
|
||||||
element={<CommunityInternalStatsPage />}
|
element={<CommunityInternalStatsPage />}
|
||||||
/>
|
/>
|
||||||
|
<Route path="/communities/:cid/internal-stats/players/:userId" element={<CommunityInternalPlayerPage />} />
|
||||||
<Route
|
<Route
|
||||||
path="/communities/:cid/internal-stats/match/:matchId"
|
path="/communities/:cid/internal-stats/match/:matchId"
|
||||||
element={<InternalMatchDetailPage />}
|
element={<InternalMatchDetailPage />}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import type { ApiAuctionChatMessage } from "./types.ts";
|
||||||
|
|
||||||
|
export interface ChatMessagePayload {
|
||||||
|
displayName?: string;
|
||||||
|
message: string;
|
||||||
|
clientMessageId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ChatMessageReply {
|
||||||
|
ok?: boolean;
|
||||||
|
message?: ApiAuctionChatMessage | string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function sendAuctionChatMessage(
|
||||||
|
send: (() => Promise<ChatMessageReply>) | undefined,
|
||||||
|
): Promise<ApiAuctionChatMessage> {
|
||||||
|
if (!send) throw new Error("연결이 끊겼습니다. 연결 후 다시 보내 주세요.");
|
||||||
|
let reply: ChatMessageReply;
|
||||||
|
try {
|
||||||
|
reply = await send();
|
||||||
|
} catch {
|
||||||
|
throw new Error("전송을 확인하지 못했습니다. 다시 보내 주세요.");
|
||||||
|
}
|
||||||
|
if (reply?.ok && typeof reply.message === "object" && reply.message?.id) {
|
||||||
|
return reply.message;
|
||||||
|
}
|
||||||
|
if (reply?.message === "Chat message must be 300 characters or less.") {
|
||||||
|
throw new Error("메시지는 300자까지 보낼 수 있습니다.");
|
||||||
|
}
|
||||||
|
throw new Error("메시지를 보내지 못했습니다. 다시 보내 주세요.");
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import type {
|
||||||
|
AuctionReactionEvent,
|
||||||
|
AuctionReactionKind,
|
||||||
|
AuctionReactionReply,
|
||||||
|
} from "@lolympus/contracts";
|
||||||
|
|
||||||
|
export const AUCTION_REACTIONS: Record<
|
||||||
|
AuctionReactionKind,
|
||||||
|
{ emoji: string; label: string }
|
||||||
|
> = {
|
||||||
|
"thumbs-up": { emoji: "👍", label: "좋아요" },
|
||||||
|
heart: { emoji: "❤️", label: "하트" },
|
||||||
|
clap: { emoji: "👏", label: "박수" },
|
||||||
|
laugh: { emoji: "😂", label: "웃음" },
|
||||||
|
wow: { emoji: "😮", label: "놀람" },
|
||||||
|
sad: { emoji: "😢", label: "아쉬움" },
|
||||||
|
fire: { emoji: "🔥", label: "불꽃" },
|
||||||
|
celebrate: { emoji: "🎉", label: "축하" },
|
||||||
|
};
|
||||||
|
|
||||||
|
export const REACTION_LIFETIME_MS = 3200;
|
||||||
|
export const MAX_VISIBLE_REACTIONS = 12;
|
||||||
|
export type ActiveAuctionReaction = AuctionReactionEvent & {
|
||||||
|
receivedAt: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function isAuctionReaction(
|
||||||
|
value: unknown,
|
||||||
|
): value is AuctionReactionEvent {
|
||||||
|
if (!value || typeof value !== "object") return false;
|
||||||
|
const reaction = value as Partial<AuctionReactionEvent>;
|
||||||
|
return (
|
||||||
|
typeof reaction.id === "string" &&
|
||||||
|
reaction.id.length > 0 &&
|
||||||
|
reaction.id.length <= 100 &&
|
||||||
|
typeof reaction.kind === "string" &&
|
||||||
|
Object.hasOwn(AUCTION_REACTIONS, reaction.kind) &&
|
||||||
|
typeof reaction.displayName === "string" &&
|
||||||
|
reaction.displayName.length <= 160 &&
|
||||||
|
typeof reaction.sentAt === "number" &&
|
||||||
|
Number.isFinite(reaction.sentAt)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function appendAuctionReaction(
|
||||||
|
current: ActiveAuctionReaction[],
|
||||||
|
incoming: AuctionReactionEvent,
|
||||||
|
now = Date.now(),
|
||||||
|
): ActiveAuctionReaction[] {
|
||||||
|
const active = current.filter(
|
||||||
|
(reaction) => now - reaction.receivedAt < REACTION_LIFETIME_MS,
|
||||||
|
);
|
||||||
|
if (active.some((reaction) => reaction.id === incoming.id)) return active;
|
||||||
|
return [...active, { ...incoming, receivedAt: now }].slice(
|
||||||
|
-MAX_VISIBLE_REACTIONS,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function sendAuctionReaction(
|
||||||
|
send: (() => Promise<AuctionReactionReply>) | undefined,
|
||||||
|
): Promise<AuctionReactionEvent> {
|
||||||
|
if (!send) throw new Error("연결되면 반응을 보낼 수 있습니다.");
|
||||||
|
let reply: AuctionReactionReply;
|
||||||
|
try {
|
||||||
|
reply = await send();
|
||||||
|
} catch {
|
||||||
|
throw new Error("반응을 보내지 못했습니다. 잠시 후 다시 눌러 주세요.");
|
||||||
|
}
|
||||||
|
if (reply?.ok && isAuctionReaction(reply.reaction)) return reply.reaction;
|
||||||
|
if (reply?.code === "REACTION_RATE_LIMITED")
|
||||||
|
throw new Error("조금만 기다렸다가 다시 눌러 주세요.");
|
||||||
|
throw new Error("반응을 보내지 못했습니다. 잠시 후 다시 눌러 주세요.");
|
||||||
|
}
|
||||||
@@ -56,6 +56,7 @@ import type {
|
|||||||
MeResponse,
|
MeResponse,
|
||||||
RiotQueueGroup,
|
RiotQueueGroup,
|
||||||
RiotRankFilter,
|
RiotRankFilter,
|
||||||
|
RiotLane,
|
||||||
RebuildLegacyMatchesResponse,
|
RebuildLegacyMatchesResponse,
|
||||||
TournamentCodeBulkUploadResponse,
|
TournamentCodeBulkUploadResponse,
|
||||||
TournamentCodeListResponse,
|
TournamentCodeListResponse,
|
||||||
@@ -84,6 +85,7 @@ interface MatchesPageQueryOptions extends MatchesQueryOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface UserHistoryFilters {
|
export interface UserHistoryFilters {
|
||||||
|
lane?: RiotLane;
|
||||||
queueGroup?: RiotQueueGroup;
|
queueGroup?: RiotQueueGroup;
|
||||||
rank?: RiotRankFilter;
|
rank?: RiotRankFilter;
|
||||||
seasonId?: string;
|
seasonId?: string;
|
||||||
@@ -91,6 +93,7 @@ export interface UserHistoryFilters {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface CommunityInternalStatsFilters {
|
export interface CommunityInternalStatsFilters {
|
||||||
|
lane?: RiotLane;
|
||||||
seasonId?: string;
|
seasonId?: string;
|
||||||
from?: string;
|
from?: string;
|
||||||
to?: string;
|
to?: string;
|
||||||
@@ -559,6 +562,7 @@ function createUserHistoryPath(
|
|||||||
const searchParams = new URLSearchParams();
|
const searchParams = new URLSearchParams();
|
||||||
if (filters.queueGroup) searchParams.set('queueGroup', filters.queueGroup);
|
if (filters.queueGroup) searchParams.set('queueGroup', filters.queueGroup);
|
||||||
if (filters.rank) searchParams.set('rank', filters.rank);
|
if (filters.rank) searchParams.set('rank', filters.rank);
|
||||||
|
if (filters.lane) searchParams.set('lane', filters.lane);
|
||||||
if (filters.seasonId) searchParams.set('seasonId', filters.seasonId);
|
if (filters.seasonId) searchParams.set('seasonId', filters.seasonId);
|
||||||
if (filters.championId)
|
if (filters.championId)
|
||||||
searchParams.set('championId', String(filters.championId));
|
searchParams.set('championId', String(filters.championId));
|
||||||
@@ -569,7 +573,8 @@ function createUserHistoryPath(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const queryString = searchParams.toString();
|
const queryString = searchParams.toString();
|
||||||
return `/communities/${communityId}/users/${userId}/${resource}${queryString ? `?${queryString}` : ''}`;
|
const path = `/communities/${communityId}/users/${userId}/${resource}${queryString ? `?${queryString}` : ''}`;
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useUserHistoryProfile(
|
export function useUserHistoryProfile(
|
||||||
@@ -695,6 +700,7 @@ function createCommunityInternalStatsPath(
|
|||||||
extra: Record<string, string | number | null | undefined> = {},
|
extra: Record<string, string | number | null | undefined> = {},
|
||||||
) {
|
) {
|
||||||
const searchParams = new URLSearchParams();
|
const searchParams = new URLSearchParams();
|
||||||
|
if (filters.lane) searchParams.set('lane', filters.lane);
|
||||||
if (filters.seasonId) searchParams.set('seasonId', filters.seasonId);
|
if (filters.seasonId) searchParams.set('seasonId', filters.seasonId);
|
||||||
if (filters.from) searchParams.set('from', filters.from);
|
if (filters.from) searchParams.set('from', filters.from);
|
||||||
if (filters.to) searchParams.set('to', filters.to);
|
if (filters.to) searchParams.set('to', filters.to);
|
||||||
@@ -757,6 +763,7 @@ export function useCommunityLeaderboard(
|
|||||||
queryKey: [
|
queryKey: [
|
||||||
'community-internal-stats-leaderboard',
|
'community-internal-stats-leaderboard',
|
||||||
communityId,
|
communityId,
|
||||||
|
filters.lane ?? null,
|
||||||
filters.seasonId ?? null,
|
filters.seasonId ?? null,
|
||||||
filters.from ?? null,
|
filters.from ?? null,
|
||||||
filters.to ?? null,
|
filters.to ?? null,
|
||||||
@@ -838,6 +845,7 @@ export function useUserInternalHistory(
|
|||||||
queryKey: [
|
queryKey: [
|
||||||
'user-internal-history',
|
'user-internal-history',
|
||||||
communityId,
|
communityId,
|
||||||
|
filters.lane ?? null,
|
||||||
userId ?? null,
|
userId ?? null,
|
||||||
filters.seasonId ?? null,
|
filters.seasonId ?? null,
|
||||||
filters.championId ?? null,
|
filters.championId ?? null,
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ export interface AuctionTeamView {
|
|||||||
name: string;
|
name: string;
|
||||||
captainUserId: string;
|
captainUserId: string;
|
||||||
captainName: string;
|
captainName: string;
|
||||||
|
captain?: ParticipantView;
|
||||||
points: number;
|
points: number;
|
||||||
members: (AuctionPlayerView & {
|
members: (AuctionPlayerView & {
|
||||||
assignedPosition: Position;
|
assignedPosition: Position;
|
||||||
@@ -253,13 +254,16 @@ function mapAuctionTeamToView(
|
|||||||
playerLookup: Map<string, AuctionPlayerView>,
|
playerLookup: Map<string, AuctionPlayerView>,
|
||||||
participantLookup: Map<string, ParticipantView>,
|
participantLookup: Map<string, ParticipantView>,
|
||||||
): AuctionTeamView {
|
): AuctionTeamView {
|
||||||
|
const captain =
|
||||||
|
participantLookup.get(team.captainUserId) ??
|
||||||
|
playerLookup.get(team.captainUserId);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
teamIndex: team.teamIndex,
|
teamIndex: team.teamIndex,
|
||||||
name: teamIndexLabel(team.teamIndex),
|
name: teamIndexLabel(team.teamIndex),
|
||||||
captainUserId: team.captainUserId,
|
captainUserId: team.captainUserId,
|
||||||
captainName:
|
captainName: captain?.summonerName ?? `User ${team.captainUserId.slice(-4)}`,
|
||||||
participantLookup.get(team.captainUserId)?.summonerName ??
|
captain,
|
||||||
`User ${team.captainUserId.slice(-4)}`,
|
|
||||||
points: team.points,
|
points: team.points,
|
||||||
members: team.members.map((member) => {
|
members: team.members.map((member) => {
|
||||||
const participant = participantLookup.get(member.userId);
|
const participant = participantLookup.get(member.userId);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import type {
|
|||||||
InternalMatchCompetition,
|
InternalMatchCompetition,
|
||||||
InternalMatchResultPresentation,
|
InternalMatchResultPresentation,
|
||||||
SeriesId,
|
SeriesId,
|
||||||
|
SeriesProjection,
|
||||||
MatchEventType,
|
MatchEventType,
|
||||||
RecentMatchParticipantRank,
|
RecentMatchParticipantRank,
|
||||||
MatchGameMode,
|
MatchGameMode,
|
||||||
@@ -184,6 +185,8 @@ export interface ApiAuctionBid {
|
|||||||
|
|
||||||
export interface ApiAuctionChatMessage {
|
export interface ApiAuctionChatMessage {
|
||||||
id: string;
|
id: string;
|
||||||
|
clientMessageId?: string;
|
||||||
|
senderRole?: 'operator';
|
||||||
userId?: string;
|
userId?: string;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
message: string;
|
message: string;
|
||||||
@@ -564,8 +567,11 @@ export interface ApiRecentMatchTeam {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiRecentMatchView {
|
export interface ApiRecentMatchView {
|
||||||
|
/** Champion damage as a percentage of team champion damage. */
|
||||||
|
damageShare?: number;
|
||||||
matchId: string;
|
matchId: string;
|
||||||
internalMatchId?: string;
|
internalMatchId?: string;
|
||||||
|
internalMatchTitle?: string;
|
||||||
gameNumber?: number;
|
gameNumber?: number;
|
||||||
queueId: number;
|
queueId: number;
|
||||||
queueLabel: string;
|
queueLabel: string;
|
||||||
@@ -601,6 +607,7 @@ export interface ApiRecentMatchView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiRecentMatchesResponse {
|
export interface ApiRecentMatchesResponse {
|
||||||
|
positionCounts?: Record<string, number>;
|
||||||
matches: ApiRecentMatchView[];
|
matches: ApiRecentMatchView[];
|
||||||
nextCursor: number | null;
|
nextCursor: number | null;
|
||||||
lastFetchedAt: string | null;
|
lastFetchedAt: string | null;
|
||||||
@@ -615,6 +622,7 @@ export interface ApiInternalMatchCard {
|
|||||||
gameCount: number;
|
gameCount: number;
|
||||||
winnerTeamIndex?: number;
|
winnerTeamIndex?: number;
|
||||||
resultPresentation?: InternalMatchResultPresentation;
|
resultPresentation?: InternalMatchResultPresentation;
|
||||||
|
series?: SeriesProjection[];
|
||||||
seriesResults: Array<{
|
seriesResults: Array<{
|
||||||
teamAIndex: number;
|
teamAIndex: number;
|
||||||
teamBIndex: number;
|
teamBIndex: number;
|
||||||
@@ -624,6 +632,9 @@ export interface ApiInternalMatchCard {
|
|||||||
}>;
|
}>;
|
||||||
games: Array<{
|
games: Array<{
|
||||||
gameNumber: number;
|
gameNumber: number;
|
||||||
|
seriesId?: string;
|
||||||
|
ordinal?: number;
|
||||||
|
analysisAvailability?: GameAnalysisAvailability | 'pending';
|
||||||
riotMatchId: string | null;
|
riotMatchId: string | null;
|
||||||
blueTeamIndex: number;
|
blueTeamIndex: number;
|
||||||
redTeamIndex: number;
|
redTeamIndex: number;
|
||||||
@@ -633,6 +644,7 @@ export interface ApiInternalMatchCard {
|
|||||||
}>;
|
}>;
|
||||||
teams: Array<{
|
teams: Array<{
|
||||||
teamIndex: number;
|
teamIndex: number;
|
||||||
|
teamId?: string;
|
||||||
name: string;
|
name: string;
|
||||||
members: Array<{
|
members: Array<{
|
||||||
userId: string;
|
userId: string;
|
||||||
@@ -652,6 +664,7 @@ export interface ApiInternalMatchListResponse {
|
|||||||
export interface ApiLeaderboardRow {
|
export interface ApiLeaderboardRow {
|
||||||
userId: string;
|
userId: string;
|
||||||
summonerName: string;
|
summonerName: string;
|
||||||
|
tagLine?: string;
|
||||||
profileIconId: number;
|
profileIconId: number;
|
||||||
games: number;
|
games: number;
|
||||||
wins: number;
|
wins: number;
|
||||||
@@ -672,6 +685,7 @@ export interface ApiLeaderboardRow {
|
|||||||
|
|
||||||
export interface ApiLeaderboardResponse {
|
export interface ApiLeaderboardResponse {
|
||||||
rows: ApiLeaderboardRow[];
|
rows: ApiLeaderboardRow[];
|
||||||
|
lane?: RiotLane;
|
||||||
season: ApiHistorySeason;
|
season: ApiHistorySeason;
|
||||||
matchedUserIds?: string[];
|
matchedUserIds?: string[];
|
||||||
}
|
}
|
||||||
@@ -682,11 +696,14 @@ export interface ApiLeaderHighlight {
|
|||||||
summonerName: string;
|
summonerName: string;
|
||||||
championId?: number;
|
championId?: number;
|
||||||
matchId?: string;
|
matchId?: string;
|
||||||
|
internalMatchId?: string;
|
||||||
|
gameNumber?: number;
|
||||||
isSingleGame: boolean;
|
isSingleGame: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiTeamInsightsResponse {
|
export interface ApiTeamInsightsResponse {
|
||||||
season: ApiHistorySeason;
|
season: ApiHistorySeason;
|
||||||
|
totals?: { matches: number; games: number; analyzedGames: number; players: number };
|
||||||
sideWinRate: {
|
sideWinRate: {
|
||||||
blue: number;
|
blue: number;
|
||||||
red: number;
|
red: number;
|
||||||
@@ -821,6 +838,8 @@ export interface ApiInternalMatchDetailResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiUserInternalHistoryResponse {
|
export interface ApiUserInternalHistoryResponse {
|
||||||
|
positionCounts?: Record<string, number>;
|
||||||
|
playerStats?: ApiLeaderboardRow | null;
|
||||||
season: ApiHistorySeason;
|
season: ApiHistorySeason;
|
||||||
championStats: ApiChampionStatsResponse;
|
championStats: ApiChampionStatsResponse;
|
||||||
summary: ApiRecentSummaryResponse;
|
summary: ApiRecentSummaryResponse;
|
||||||
|
|||||||
@@ -2,10 +2,13 @@ import { InteractionStatus } from '@azure/msal-browser';
|
|||||||
import { useMsal } from '@azure/msal-react';
|
import { useMsal } from '@azure/msal-react';
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { io, type Socket } from 'socket.io-client';
|
import { io, type Socket } from 'socket.io-client';
|
||||||
|
import type { AuctionReactionKind, AuctionReactionReply } from '@lolympus/contracts';
|
||||||
|
import { appendAuctionReaction, isAuctionReaction, REACTION_LIFETIME_MS, sendAuctionReaction, type ActiveAuctionReaction } from './auction-reactions';
|
||||||
import { API_BASE_URL, useAuthUserId } from '../config';
|
import { API_BASE_URL, useAuthUserId } from '../config';
|
||||||
import { acquireAccessToken } from '../lib/auth/token-provider';
|
import { acquireAccessToken } from '../lib/auth/token-provider';
|
||||||
import { isMsalConfigured } from '../lib/auth/msal.config';
|
import { isMsalConfigured } from '../lib/auth/msal.config';
|
||||||
import type { ApiAuction, ApiAuctionChatMessage, Position } from './types';
|
import type { ApiAuction, ApiAuctionChatMessage, Position } from './types';
|
||||||
|
import { sendAuctionChatMessage, type ChatMessagePayload, type ChatMessageReply } from './auction-chat';
|
||||||
import {
|
import {
|
||||||
createAuctionResyncRequester,
|
createAuctionResyncRequester,
|
||||||
type AuctionResyncReply,
|
type AuctionResyncReply,
|
||||||
@@ -44,11 +47,6 @@ interface BidPayload {
|
|||||||
clientObservedCurrentBidRoundPlayerUserId?: string;
|
clientObservedCurrentBidRoundPlayerUserId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ChatMessagePayload {
|
|
||||||
displayName?: string;
|
|
||||||
message: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface AuctionActionPayload {
|
interface AuctionActionPayload {
|
||||||
auctionActionRequestId?: string;
|
auctionActionRequestId?: string;
|
||||||
clientObservedAuctionLifecycleId?: string;
|
clientObservedAuctionLifecycleId?: string;
|
||||||
@@ -175,6 +173,29 @@ export function useAuctionSocket(matchId: string | undefined) {
|
|||||||
const latestConfirmedBidPointAmountRef = useRef(0);
|
const latestConfirmedBidPointAmountRef = useRef(0);
|
||||||
const [auction, setAuction] = useState<ApiAuction | null>(null);
|
const [auction, setAuction] = useState<ApiAuction | null>(null);
|
||||||
const [chatMessages, setChatMessages] = useState<ApiAuctionChatMessage[]>([]);
|
const [chatMessages, setChatMessages] = useState<ApiAuctionChatMessage[]>([]);
|
||||||
|
const [reactionState, setReactionState] = useState<{ key: string; items: ActiveAuctionReaction[] }>({ key: '', items: [] });
|
||||||
|
const seenReactionsRef = useRef(new Set<string>());
|
||||||
|
const receiveReaction = useCallback((value: unknown, key: string) => {
|
||||||
|
if (!isAuctionReaction(value) || seenReactionsRef.current.has(value.id)) return;
|
||||||
|
seenReactionsRef.current.add(value.id);
|
||||||
|
if (seenReactionsRef.current.size > 128) {
|
||||||
|
seenReactionsRef.current.delete(seenReactionsRef.current.values().next().value!);
|
||||||
|
}
|
||||||
|
setReactionState((current) => ({
|
||||||
|
key, items: appendAuctionReaction(current.key === key ? current.items : [], value),
|
||||||
|
}));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (reactionState.items.length === 0) return;
|
||||||
|
const expiresAt = reactionState.items[0].receivedAt + REACTION_LIFETIME_MS;
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
setReactionState((current) => ({ ...current, items: current.items.filter(
|
||||||
|
(reaction) => Date.now() - reaction.receivedAt < REACTION_LIFETIME_MS,
|
||||||
|
) }));
|
||||||
|
}, Math.max(0, expiresAt - Date.now()) + 16);
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, [reactionState]);
|
||||||
const [pendingBidRequests, setPendingBidRequests] = useState<
|
const [pendingBidRequests, setPendingBidRequests] = useState<
|
||||||
Record<string, { amount: number; teamIndex: number }>
|
Record<string, { amount: number; teamIndex: number }>
|
||||||
>({});
|
>({});
|
||||||
@@ -515,6 +536,7 @@ export function useAuctionSocket(matchId: string | undefined) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on('disconnect', () => {
|
socket.on('disconnect', () => {
|
||||||
|
setReactionState({ key: activeConnectionKey, items: [] });
|
||||||
resyncRequester.cancel();
|
resyncRequester.cancel();
|
||||||
clearTimeSyncTimers();
|
clearTimeSyncTimers();
|
||||||
setConnectionState({
|
setConnectionState({
|
||||||
@@ -538,6 +560,9 @@ export function useAuctionSocket(matchId: string | undefined) {
|
|||||||
socket.on('chat-message', (message: ApiAuctionChatMessage) => {
|
socket.on('chat-message', (message: ApiAuctionChatMessage) => {
|
||||||
setChatMessages((current) => mergeChatMessages(current, [message]));
|
setChatMessages((current) => mergeChatMessages(current, [message]));
|
||||||
});
|
});
|
||||||
|
socket.on('chat-reaction', (reaction: unknown) => {
|
||||||
|
receiveReaction(reaction, activeConnectionKey);
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('bid', (payload: BidDeltaPayload) => {
|
socket.on('bid', (payload: BidDeltaPayload) => {
|
||||||
applyFallbackServerTimestamp(payload?.currentServerTimestampMS);
|
applyFallbackServerTimestamp(payload?.currentServerTimestampMS);
|
||||||
@@ -681,26 +706,10 @@ export function useAuctionSocket(matchId: string | undefined) {
|
|||||||
commitBidDelta,
|
commitBidDelta,
|
||||||
connectionKey,
|
connectionKey,
|
||||||
matchId,
|
matchId,
|
||||||
|
receiveReaction,
|
||||||
setError,
|
setError,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function emit(eventName: string, payload?: unknown) {
|
|
||||||
const socket = socketRef.current;
|
|
||||||
if (!socket || !socket.connected) {
|
|
||||||
setError('소켓이 아직 연결되지 않았습니다.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setError(null);
|
|
||||||
|
|
||||||
if (payload === undefined) {
|
|
||||||
socket.emit(eventName);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
socket.emit(eventName, payload);
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildAuctionActionPayload(): AuctionActionPayload {
|
function buildAuctionActionPayload(): AuctionActionPayload {
|
||||||
const currentAuction = latestAuctionRef.current ?? auction;
|
const currentAuction = latestAuctionRef.current ?? auction;
|
||||||
return {
|
return {
|
||||||
@@ -889,6 +898,8 @@ export function useAuctionSocket(matchId: string | undefined) {
|
|||||||
return {
|
return {
|
||||||
auction: visibleAuction,
|
auction: visibleAuction,
|
||||||
chatMessages: visibleAuction ? chatMessages : [],
|
chatMessages: visibleAuction ? chatMessages : [],
|
||||||
|
reactions: visibleAuction && visibleConnectionStatus === 'connected' && reactionState.key === connectionKey
|
||||||
|
? reactionState.items : [],
|
||||||
isAuctionActionPending: Object.keys(pendingActionRequests).length > 0,
|
isAuctionActionPending: Object.keys(pendingActionRequests).length > 0,
|
||||||
isBidPending: Object.keys(pendingBidRequests).length > 0,
|
isBidPending: Object.keys(pendingBidRequests).length > 0,
|
||||||
pendingActionRequests,
|
pendingActionRequests,
|
||||||
@@ -989,8 +1000,22 @@ export function useAuctionSocket(matchId: string | undefined) {
|
|||||||
next() {
|
next() {
|
||||||
emitAuctionAction('next', buildAuctionActionPayload());
|
emitAuctionAction('next', buildAuctionActionPayload());
|
||||||
},
|
},
|
||||||
sendChatMessage(payload: ChatMessagePayload) {
|
async sendReaction(kind: AuctionReactionKind) {
|
||||||
emit('chat-message', payload);
|
const socket = socketRef.current;
|
||||||
|
const reaction = await sendAuctionReaction(socket?.connected
|
||||||
|
? () => socket.volatile.timeout(3000).emitWithAck('chat-reaction', { kind }) as Promise<AuctionReactionReply>
|
||||||
|
: undefined);
|
||||||
|
if (socketRef.current === socket && connectionKey) receiveReaction(reaction, connectionKey);
|
||||||
|
},
|
||||||
|
async sendChatMessage(payload: ChatMessagePayload) {
|
||||||
|
const socket = socketRef.current;
|
||||||
|
const message = await sendAuctionChatMessage(socket?.connected
|
||||||
|
? () => socket.timeout(8000).emitWithAck('chat-message', payload) as Promise<ChatMessageReply>
|
||||||
|
: undefined);
|
||||||
|
if (socketRef.current === socket) {
|
||||||
|
setChatMessages((current) => mergeChatMessages(current, [message]));
|
||||||
|
}
|
||||||
|
return message;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" shape-rendering="crispEdges">
|
||||||
|
<path fill="#2b1b12" d="M0 0h5v1h-5zM8 0h5v1h-5zM0 1h1v1h-1zM4 1h1v1h-1zM8 1h1v1h-1zM12 1h1v1h-1zM1 2h1v1h-1zM5 2h1v1h-1zM7 2h1v1h-1zM11 2h1v1h-1zM2 3h1v1h-1zM6 3h1v1h-1zM10 3h1v1h-1zM4 4h5v1h-5zM2 5h2v1h-2zM9 5h2v1h-2zM1 6h1v1h-1zM6 6h1v1h-1zM11 6h1v1h-1zM1 7h1v1h-1zM5 7h2v1h-2zM11 7h1v1h-1zM1 8h1v1h-1zM6 8h1v1h-1zM11 8h1v1h-1zM1 9h1v1h-1zM6 9h1v1h-1zM11 9h1v1h-1zM1 10h1v1h-1zM5 10h3v1h-3zM11 10h1v1h-1zM2 11h2v1h-2zM9 11h2v1h-2zM4 12h5v1h-5z"/>
|
||||||
|
<path fill="#fff4a8" d="M4 5h1v1h-1zM2 6h1v1h-1zM2 7h1v1h-1z"/>
|
||||||
|
<path fill="#ffd91a" d="M5 5h3v1h-3zM3 6h3v1h-3zM7 6h3v1h-3zM3 7h2v1h-2zM7 7h3v1h-3zM2 8h4v1h-4zM7 8h3v1h-3zM2 9h4v1h-4zM7 9h3v1h-3zM2 10h3v1h-3zM8 10h2v1h-2zM4 11h4v1h-4z"/>
|
||||||
|
<path fill="#f08a24" d="M8 5h1v1h-1zM10 6h1v1h-1zM10 7h1v1h-1zM10 8h1v1h-1zM10 9h1v1h-1zM10 10h1v1h-1zM8 11h1v1h-1z"/>
|
||||||
|
<path fill="#e5372b" d="M3 1h1v1h-1zM9 1h1v1h-1zM4 2h1v1h-1zM8 2h1v1h-1zM5 3h1v1h-1zM7 3h1v1h-1z"/>
|
||||||
|
<path fill="#3b6fe0" d="M1 1h2v1h-2zM10 1h2v1h-2zM2 2h2v1h-2zM9 2h2v1h-2zM3 3h2v1h-2zM8 3h2v1h-2z"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,6 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 15" shape-rendering="crispEdges">
|
||||||
|
<path fill="#2b1b12" d="M2 0h11v1h-11zM0 1h3v1h-3zM12 1h3v1h-3zM0 2h1v1h-1zM2 2h1v1h-1zM7 2h1v1h-1zM12 2h1v1h-1zM14 2h1v1h-1zM0 3h1v1h-1zM2 3h1v1h-1zM6 3h2v1h-2zM12 3h1v1h-1zM14 3h1v1h-1zM0 4h1v1h-1zM2 4h1v1h-1zM7 4h1v1h-1zM12 4h1v1h-1zM14 4h1v1h-1zM0 5h3v1h-3zM7 5h1v1h-1zM12 5h3v1h-3zM2 6h1v1h-1zM6 6h3v1h-3zM12 6h1v1h-1zM3 7h1v1h-1zM11 7h1v1h-1zM4 8h1v1h-1zM10 8h1v1h-1zM5 9h1v1h-1zM9 9h1v1h-1zM6 10h1v1h-1zM8 10h1v1h-1zM6 11h1v1h-1zM8 11h1v1h-1zM4 12h2v1h-2zM9 12h2v1h-2zM3 13h1v1h-1zM11 13h1v1h-1zM3 14h9v1h-9z"/>
|
||||||
|
<path fill="#fff4a8" d="M3 1h1v1h-1zM3 2h1v1h-1zM3 3h1v1h-1zM3 4h1v1h-1zM3 5h1v1h-1zM3 6h1v1h-1zM4 13h1v1h-1z"/>
|
||||||
|
<path fill="#ffd91a" d="M4 1h7v1h-7zM4 2h3v1h-3zM8 2h3v1h-3zM4 3h2v1h-2zM8 3h3v1h-3zM4 4h3v1h-3zM8 4h3v1h-3zM4 5h3v1h-3zM8 5h3v1h-3zM4 6h2v1h-2zM9 6h2v1h-2zM4 7h6v1h-6zM5 8h4v1h-4zM6 9h2v1h-2zM7 10h1v1h-1zM6 12h2v1h-2zM5 13h5v1h-5z"/>
|
||||||
|
<path fill="#f08a24" d="M11 1h1v1h-1zM11 2h1v1h-1zM11 3h1v1h-1zM11 4h1v1h-1zM11 5h1v1h-1zM11 6h1v1h-1zM10 7h1v1h-1zM9 8h1v1h-1zM8 9h1v1h-1zM7 11h1v1h-1zM8 12h1v1h-1zM10 13h1v1h-1z"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,8 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 15" shape-rendering="crispEdges">
|
||||||
|
<path fill="#2b1b12" d="M2 0h11v1h-11zM0 1h3v1h-3zM12 1h3v1h-3zM0 2h1v1h-1zM2 2h1v1h-1zM12 2h1v1h-1zM14 2h1v1h-1zM0 3h1v1h-1zM2 3h1v1h-1zM12 3h1v1h-1zM14 3h1v1h-1zM0 4h1v1h-1zM2 4h1v1h-1zM12 4h1v1h-1zM14 4h1v1h-1zM0 5h3v1h-3zM12 5h3v1h-3zM2 6h1v1h-1zM12 6h1v1h-1zM3 7h1v1h-1zM11 7h1v1h-1zM4 8h1v1h-1zM10 8h1v1h-1zM5 9h1v1h-1zM9 9h1v1h-1zM6 10h1v1h-1zM8 10h1v1h-1zM6 11h1v1h-1zM8 11h1v1h-1zM4 12h2v1h-2zM9 12h2v1h-2zM3 13h1v1h-1zM11 13h1v1h-1zM3 14h9v1h-9z"/>
|
||||||
|
<path fill="#fff4a8" d="M3 1h1v1h-1zM3 2h1v1h-1zM3 3h1v1h-1zM3 4h1v1h-1zM3 5h1v1h-1zM3 6h1v1h-1z"/>
|
||||||
|
<path fill="#ffd91a" d="M4 1h7v1h-7zM4 2h3v1h-3zM8 2h3v1h-3zM4 3h2v1h-2zM9 3h2v1h-2zM4 4h3v1h-3zM8 4h3v1h-3zM4 5h7v1h-7zM4 6h7v1h-7zM4 7h6v1h-6zM5 8h4v1h-4zM6 9h2v1h-2zM7 10h1v1h-1zM6 12h2v1h-2z"/>
|
||||||
|
<path fill="#f08a24" d="M11 1h1v1h-1zM11 2h1v1h-1zM11 3h1v1h-1zM11 4h1v1h-1zM11 5h1v1h-1zM11 6h1v1h-1zM10 7h1v1h-1zM9 8h1v1h-1zM8 9h1v1h-1zM7 11h1v1h-1zM8 12h1v1h-1z"/>
|
||||||
|
<path fill="#e5372b" d="M4 13h7v1h-7z"/>
|
||||||
|
<path fill="#ffffff" d="M7 2h1v1h-1zM6 3h3v1h-3zM7 4h1v1h-1z"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,497 @@
|
|||||||
|
import { useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
||||||
|
import { Badge } from "@astryxdesign/core/Badge";
|
||||||
|
import { Button } from "@astryxdesign/core/Button";
|
||||||
|
import {
|
||||||
|
ChatComposer,
|
||||||
|
ChatMessage,
|
||||||
|
ChatMessageBubble,
|
||||||
|
ChatMessageList,
|
||||||
|
ChatMessageMetadata,
|
||||||
|
} from "@astryxdesign/core/Chat";
|
||||||
|
import { StatusDot } from "@astryxdesign/core/StatusDot";
|
||||||
|
import { ArrowDown, RotateCcw, SendHorizontal } from "lucide-react";
|
||||||
|
import type { ApiAuctionChatMessage } from "../api/types";
|
||||||
|
import type { useAuctionSocket } from "../api/useAuctionSocket";
|
||||||
|
import type { AuctionReactionKind } from '@lolympus/contracts';
|
||||||
|
import { AuctionReactionPicker } from './AuctionReactionPicker';
|
||||||
|
import './auction-reactions.css';
|
||||||
|
import "./auction-chat.css";
|
||||||
|
|
||||||
|
type OutgoingMessage = ApiAuctionChatMessage & {
|
||||||
|
clientMessageId: string;
|
||||||
|
status: "sending" | "error";
|
||||||
|
error?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
messages: ApiAuctionChatMessage[];
|
||||||
|
connectionStatus: ReturnType<typeof useAuctionSocket>["connectionStatus"];
|
||||||
|
senderLabel: string;
|
||||||
|
currentUserId?: string;
|
||||||
|
isOperator?: boolean;
|
||||||
|
teams: readonly { captainUserId: string; teamIndex: number }[];
|
||||||
|
onSend: (
|
||||||
|
message: string,
|
||||||
|
clientMessageId: string,
|
||||||
|
) => Promise<ApiAuctionChatMessage>;
|
||||||
|
onReact: (kind: AuctionReactionKind) => Promise<void>;
|
||||||
|
className?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const timeFormatter = new Intl.DateTimeFormat("ko-KR", {
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
hour12: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
function resizeInput(input: HTMLTextAreaElement) {
|
||||||
|
input.style.height = "auto";
|
||||||
|
const maxHeight = Number.parseFloat(getComputedStyle(input).maxHeight);
|
||||||
|
input.style.height = `${Math.min(input.scrollHeight, maxHeight)}px`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AuctionChatPanel({
|
||||||
|
messages,
|
||||||
|
connectionStatus,
|
||||||
|
senderLabel,
|
||||||
|
currentUserId,
|
||||||
|
isOperator,
|
||||||
|
teams,
|
||||||
|
onSend,
|
||||||
|
onReact,
|
||||||
|
className = "",
|
||||||
|
}: Props) {
|
||||||
|
const titleId = useId();
|
||||||
|
const hintId = useId();
|
||||||
|
const [draft, setDraft] = useState("");
|
||||||
|
const [outbox, setOutbox] = useState<OutgoingMessage[]>([]);
|
||||||
|
const [hasNewMessages, setHasNewMessages] = useState(false);
|
||||||
|
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
||||||
|
const scrollRef = useRef<HTMLDivElement>(null);
|
||||||
|
const contentRef = useRef<HTMLDivElement>(null);
|
||||||
|
const pinnedRef = useRef(true);
|
||||||
|
const lastMessageIdRef = useRef<string | undefined>(undefined);
|
||||||
|
const anchorRef = useRef<{ id: string; offset: number } | null>(null);
|
||||||
|
const sendingRef = useRef(new Set<string>());
|
||||||
|
const [ownRequestIds, setOwnRequestIds] = useState(new Set<string>());
|
||||||
|
const connected = connectionStatus === "connected";
|
||||||
|
const canSend = connected && draft.trim().length > 0 && draft.length <= 300;
|
||||||
|
const status = connected
|
||||||
|
? "연결됨"
|
||||||
|
: connectionStatus === "connecting" || connectionStatus === "idle"
|
||||||
|
? "연결 중"
|
||||||
|
: "연결 끊김";
|
||||||
|
const captainTeams = useMemo(
|
||||||
|
() => new Map(teams.map((team) => [team.captainUserId, team.teamIndex])),
|
||||||
|
[teams],
|
||||||
|
);
|
||||||
|
const ownTeam = currentUserId ? captainTeams.get(currentUserId) : undefined;
|
||||||
|
const ownRole = isOperator
|
||||||
|
? "운영진"
|
||||||
|
: ownTeam !== undefined
|
||||||
|
? `${ownTeam}팀 팀장`
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
const confirmedRequests = new Set(
|
||||||
|
messages.map((message) => message.clientMessageId),
|
||||||
|
);
|
||||||
|
const visibleMessages = [
|
||||||
|
...messages,
|
||||||
|
...outbox.filter(
|
||||||
|
(message) => !confirmedRequests.has(message.clientMessageId),
|
||||||
|
),
|
||||||
|
].sort((a, b) => Date.parse(a.sentAt) - Date.parse(b.sentAt));
|
||||||
|
const groups: (ApiAuctionChatMessage | OutgoingMessage)[][] = [];
|
||||||
|
for (const message of visibleMessages) {
|
||||||
|
const previousGroup = groups.at(-1);
|
||||||
|
const previous = previousGroup?.at(-1);
|
||||||
|
const sameAuthor =
|
||||||
|
previous &&
|
||||||
|
(message.userId
|
||||||
|
? previous.userId === message.userId
|
||||||
|
: !previous.userId && previous.displayName === message.displayName);
|
||||||
|
if (
|
||||||
|
previous &&
|
||||||
|
sameAuthor &&
|
||||||
|
previous.senderRole === message.senderRole &&
|
||||||
|
!("status" in previous) &&
|
||||||
|
!("status" in message) &&
|
||||||
|
Date.parse(message.sentAt) - Date.parse(previous.sentAt) < 5 * 60_000 &&
|
||||||
|
new Date(message.sentAt).toDateString() ===
|
||||||
|
new Date(previous.sentAt).toDateString()
|
||||||
|
) {
|
||||||
|
previousGroup!.push(message);
|
||||||
|
} else groups.push([message]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function rememberScroll() {
|
||||||
|
const container = scrollRef.current;
|
||||||
|
if (!container) return;
|
||||||
|
pinnedRef.current =
|
||||||
|
container.scrollHeight - container.scrollTop - container.clientHeight <
|
||||||
|
40;
|
||||||
|
if (pinnedRef.current) setHasNewMessages(false);
|
||||||
|
const top = container.getBoundingClientRect().top;
|
||||||
|
const anchor = Array.from(
|
||||||
|
container.querySelectorAll<HTMLElement>("[data-chat-message-id]"),
|
||||||
|
).find((element) => element.getBoundingClientRect().bottom > top);
|
||||||
|
anchorRef.current = anchor
|
||||||
|
? {
|
||||||
|
id: anchor.dataset.chatMessageId!,
|
||||||
|
offset: anchor.getBoundingClientRect().top - top,
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function scrollToLatest() {
|
||||||
|
const container = scrollRef.current;
|
||||||
|
if (container) container.scrollTop = container.scrollHeight;
|
||||||
|
pinnedRef.current = true;
|
||||||
|
setHasNewMessages(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Track actual message IDs, including when the server's 200-message window
|
||||||
|
// rolls over without changing the list length. Preserve the visible anchor.
|
||||||
|
const latestId = visibleMessages.at(-1)?.id;
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
const container = scrollRef.current;
|
||||||
|
if (!container) return;
|
||||||
|
const isNew = latestId !== lastMessageIdRef.current;
|
||||||
|
lastMessageIdRef.current = latestId;
|
||||||
|
if (pinnedRef.current) container.scrollTop = container.scrollHeight;
|
||||||
|
else if (anchorRef.current) {
|
||||||
|
const anchor = Array.from(
|
||||||
|
container.querySelectorAll<HTMLElement>("[data-chat-message-id]"),
|
||||||
|
).find(
|
||||||
|
(element) => element.dataset.chatMessageId === anchorRef.current?.id,
|
||||||
|
);
|
||||||
|
if (anchor)
|
||||||
|
container.scrollTop +=
|
||||||
|
anchor.getBoundingClientRect().top -
|
||||||
|
container.getBoundingClientRect().top -
|
||||||
|
anchorRef.current.offset;
|
||||||
|
}
|
||||||
|
const frame = requestAnimationFrame(() => {
|
||||||
|
if (pinnedRef.current) setHasNewMessages(false);
|
||||||
|
else if (isNew) setHasNewMessages(true);
|
||||||
|
// A broadcast can arrive even if its acknowledgement is lost. Retire
|
||||||
|
// confirmed drafts now so they cannot reappear after history rolls over.
|
||||||
|
const confirmed = new Set(
|
||||||
|
messages.map((message) => message.clientMessageId),
|
||||||
|
);
|
||||||
|
setOutbox((current) => {
|
||||||
|
const remaining = current.filter(
|
||||||
|
(message) => !confirmed.has(message.clientMessageId),
|
||||||
|
);
|
||||||
|
return remaining.length === current.length ? current : remaining;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return () => cancelAnimationFrame(frame);
|
||||||
|
}, [messages, outbox, latestId]);
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
const input = textareaRef.current;
|
||||||
|
if (!input) return;
|
||||||
|
resizeInput(input);
|
||||||
|
}, [draft]);
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
let inputWidth = 0;
|
||||||
|
let frame = 0;
|
||||||
|
const observer = new ResizeObserver(() => {
|
||||||
|
// Defer writes to the next frame: resizing an observed input inside
|
||||||
|
// the observer callback causes ResizeObserver loop notifications.
|
||||||
|
cancelAnimationFrame(frame);
|
||||||
|
frame = requestAnimationFrame(() => {
|
||||||
|
const input = textareaRef.current;
|
||||||
|
if (input && input.clientWidth !== inputWidth) {
|
||||||
|
inputWidth = input.clientWidth;
|
||||||
|
resizeInput(input);
|
||||||
|
}
|
||||||
|
const container = scrollRef.current;
|
||||||
|
if (container && pinnedRef.current)
|
||||||
|
container.scrollTop = container.scrollHeight;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
if (scrollRef.current) observer.observe(scrollRef.current);
|
||||||
|
if (contentRef.current) observer.observe(contentRef.current);
|
||||||
|
if (textareaRef.current) observer.observe(textareaRef.current);
|
||||||
|
return () => {
|
||||||
|
observer.disconnect();
|
||||||
|
cancelAnimationFrame(frame);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function deliver(message: OutgoingMessage) {
|
||||||
|
if (sendingRef.current.has(message.clientMessageId)) return;
|
||||||
|
sendingRef.current.add(message.clientMessageId);
|
||||||
|
setOutbox((current) =>
|
||||||
|
current.map((entry) =>
|
||||||
|
entry.id === message.id
|
||||||
|
? { ...entry, status: "sending", error: undefined }
|
||||||
|
: entry,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
await onSend(message.message, message.clientMessageId);
|
||||||
|
setOutbox((current) =>
|
||||||
|
current.filter((entry) => entry.id !== message.id),
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
setOutbox((current) =>
|
||||||
|
current.map((entry) =>
|
||||||
|
entry.id === message.id
|
||||||
|
? {
|
||||||
|
...entry,
|
||||||
|
status: "error",
|
||||||
|
error:
|
||||||
|
error instanceof Error
|
||||||
|
? error.message
|
||||||
|
: "전송하지 못했습니다.",
|
||||||
|
}
|
||||||
|
: entry,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
sendingRef.current.delete(message.clientMessageId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function submit(value = draft) {
|
||||||
|
if (!connected || !value.trim() || value.length > 300) return;
|
||||||
|
const clientMessageId = crypto.randomUUID();
|
||||||
|
const message: OutgoingMessage = {
|
||||||
|
id: clientMessageId,
|
||||||
|
clientMessageId,
|
||||||
|
userId: currentUserId,
|
||||||
|
displayName: senderLabel,
|
||||||
|
senderRole: isOperator ? "operator" : undefined,
|
||||||
|
message: value.trim(),
|
||||||
|
sentAt: new Date().toISOString(),
|
||||||
|
status: "sending",
|
||||||
|
};
|
||||||
|
setOwnRequestIds((current) => new Set([...current, clientMessageId]));
|
||||||
|
setOutbox((current) => [...current, message]);
|
||||||
|
setDraft("");
|
||||||
|
pinnedRef.current = true;
|
||||||
|
void deliver(message);
|
||||||
|
textareaRef.current?.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section
|
||||||
|
className={`auction-chat-panel ${className}`}
|
||||||
|
aria-labelledby={titleId}
|
||||||
|
>
|
||||||
|
<header className="auction-chat-header">
|
||||||
|
<h2 id={titleId}>경매 채팅</h2>
|
||||||
|
<span className="auction-chat-connection" role="status">
|
||||||
|
<StatusDot
|
||||||
|
variant={connected ? "success" : "neutral"}
|
||||||
|
label={status}
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
{status}
|
||||||
|
</span>
|
||||||
|
</header>
|
||||||
|
<div className="auction-chat-conversation">
|
||||||
|
<div
|
||||||
|
className="auction-chat-scroll"
|
||||||
|
ref={scrollRef}
|
||||||
|
onScroll={rememberScroll}
|
||||||
|
tabIndex={0}
|
||||||
|
aria-label="경매 대화 내역"
|
||||||
|
>
|
||||||
|
<ChatMessageList
|
||||||
|
ref={contentRef}
|
||||||
|
density="compact"
|
||||||
|
gap={3}
|
||||||
|
aria-label="경매 채팅 메시지"
|
||||||
|
emptyState={
|
||||||
|
<div className="auction-chat-empty">
|
||||||
|
아직 대화가 없습니다.
|
||||||
|
<br />
|
||||||
|
팀장과 운영진에게 메시지를 남겨 보세요.
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{groups.map((group) => {
|
||||||
|
const first = group[0];
|
||||||
|
const last = group[group.length - 1];
|
||||||
|
const own = Boolean(
|
||||||
|
(currentUserId && first.userId === currentUserId) ||
|
||||||
|
(first.clientMessageId &&
|
||||||
|
ownRequestIds.has(first.clientMessageId)),
|
||||||
|
);
|
||||||
|
const team = first.userId
|
||||||
|
? captainTeams.get(first.userId)
|
||||||
|
: undefined;
|
||||||
|
const role =
|
||||||
|
first.senderRole === "operator"
|
||||||
|
? "운영진"
|
||||||
|
: team !== undefined
|
||||||
|
? `${team}팀 팀장`
|
||||||
|
: undefined;
|
||||||
|
const outgoing = "status" in last ? last : undefined;
|
||||||
|
return (
|
||||||
|
<ChatMessage
|
||||||
|
key={first.id}
|
||||||
|
sender={own ? "user" : "assistant"}
|
||||||
|
name={
|
||||||
|
<span className="auction-chat-author">
|
||||||
|
<span
|
||||||
|
className="auction-chat-name"
|
||||||
|
title={first.displayName}
|
||||||
|
>
|
||||||
|
{first.displayName}
|
||||||
|
</span>
|
||||||
|
{role && (
|
||||||
|
<Badge
|
||||||
|
variant={
|
||||||
|
first.senderRole === "operator"
|
||||||
|
? "purple"
|
||||||
|
: "neutral"
|
||||||
|
}
|
||||||
|
label={role}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{own && <span className="auction-chat-self">나</span>}
|
||||||
|
<time
|
||||||
|
dateTime={last.sentAt}
|
||||||
|
title={new Date(last.sentAt).toLocaleString("ko-KR")}
|
||||||
|
>
|
||||||
|
{timeFormatter.format(new Date(last.sentAt))}
|
||||||
|
</time>
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
metadata={
|
||||||
|
outgoing && (
|
||||||
|
<ChatMessageMetadata
|
||||||
|
timestamp={
|
||||||
|
<span
|
||||||
|
className="auction-chat-delivery"
|
||||||
|
data-failed={outgoing.status === "error"}
|
||||||
|
>
|
||||||
|
{outgoing.status === "sending" ? (
|
||||||
|
<span role="status">전송 중…</span>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<span role="alert">{outgoing.error}</span>
|
||||||
|
<Button
|
||||||
|
label="다시 보내기"
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
isDisabled={!connected}
|
||||||
|
icon={
|
||||||
|
<RotateCcw size={14} aria-hidden="true" />
|
||||||
|
}
|
||||||
|
onClick={() => void deliver(outgoing)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{group.map((message, index) => (
|
||||||
|
<ChatMessageBubble
|
||||||
|
key={message.id}
|
||||||
|
data-chat-message-id={message.id}
|
||||||
|
group={
|
||||||
|
group.length === 1
|
||||||
|
? undefined
|
||||||
|
: index === 0
|
||||||
|
? "first"
|
||||||
|
: index === group.length - 1
|
||||||
|
? "last"
|
||||||
|
: "middle"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{message.message}
|
||||||
|
</ChatMessageBubble>
|
||||||
|
))}
|
||||||
|
</ChatMessage>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ChatMessageList>
|
||||||
|
</div>
|
||||||
|
{hasNewMessages && (
|
||||||
|
<div className="auction-chat-new-messages">
|
||||||
|
<Button
|
||||||
|
label="새 메시지"
|
||||||
|
variant="secondary"
|
||||||
|
size="sm"
|
||||||
|
icon={<ArrowDown size={14} aria-hidden="true" />}
|
||||||
|
onClick={scrollToLatest}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="auction-chat-compose-area">
|
||||||
|
<div className="auction-chat-sender">
|
||||||
|
<span title={senderLabel}>
|
||||||
|
{ownRole ? `${ownRole} · ` : ""}
|
||||||
|
{senderLabel}
|
||||||
|
</span>
|
||||||
|
{draft.length >= 240 && (
|
||||||
|
<span
|
||||||
|
className="auction-chat-count"
|
||||||
|
data-limit={draft.length === 300}
|
||||||
|
>
|
||||||
|
{draft.length}/300
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<ChatComposer
|
||||||
|
className="auction-chat-composer"
|
||||||
|
density="compact"
|
||||||
|
elevation="none"
|
||||||
|
value={draft}
|
||||||
|
onChange={setDraft}
|
||||||
|
onSubmit={submit}
|
||||||
|
input={
|
||||||
|
<textarea
|
||||||
|
ref={textareaRef}
|
||||||
|
value={draft}
|
||||||
|
rows={1}
|
||||||
|
maxLength={300}
|
||||||
|
aria-label="경매 채팅 메시지"
|
||||||
|
aria-describedby={hintId}
|
||||||
|
placeholder="메시지 입력"
|
||||||
|
enterKeyHint="send"
|
||||||
|
onChange={(event) => setDraft(event.target.value)}
|
||||||
|
onKeyDown={(event) => {
|
||||||
|
// Product choice: Enter always sends, including during composition.
|
||||||
|
// Shift+Enter retains the existing newline shortcut.
|
||||||
|
if (event.key === "Enter" && !event.shiftKey) {
|
||||||
|
event.preventDefault();
|
||||||
|
submit(event.currentTarget.value);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
sendActions={<AuctionReactionPicker connected={connected} onReact={onReact} />}
|
||||||
|
sendButton={
|
||||||
|
<Button
|
||||||
|
className="auction-chat-send"
|
||||||
|
label="메시지 전송"
|
||||||
|
variant="primary"
|
||||||
|
size="md"
|
||||||
|
isIconOnly
|
||||||
|
isDisabled={!canSend}
|
||||||
|
onClick={() => submit()}
|
||||||
|
icon={<SendHorizontal size={18} aria-hidden="true" />}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<p className="auction-chat-hint" id={hintId}>
|
||||||
|
{connected
|
||||||
|
? "Enter 전송 · Shift+Enter 줄바꿈"
|
||||||
|
: "연결되면 전송할 수 있습니다. 작성 내용은 유지됩니다."}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import type { CSSProperties } from "react";
|
||||||
|
import { createPortal } from "react-dom";
|
||||||
|
import {
|
||||||
|
AUCTION_REACTIONS,
|
||||||
|
type ActiveAuctionReaction,
|
||||||
|
} from "../api/auction-reactions";
|
||||||
|
import "./auction-reactions.css";
|
||||||
|
|
||||||
|
function reactionStyle(id: string): CSSProperties {
|
||||||
|
let hash = 0;
|
||||||
|
for (const character of id)
|
||||||
|
hash = (hash * 31 + character.charCodeAt(0)) >>> 0;
|
||||||
|
return {
|
||||||
|
"--reaction-left": `${8 + (hash % 78)}%`,
|
||||||
|
"--reaction-drift": `${(hash % 65) - 32}px`,
|
||||||
|
"--reaction-tilt": `${(hash % 21) - 10}deg`,
|
||||||
|
} as CSSProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AuctionReactionLayer({
|
||||||
|
reactions,
|
||||||
|
}: {
|
||||||
|
reactions: ActiveAuctionReaction[];
|
||||||
|
}) {
|
||||||
|
if (typeof document === "undefined") return null;
|
||||||
|
const latest = reactions.at(-1);
|
||||||
|
return createPortal(
|
||||||
|
<>
|
||||||
|
<div className="auction-reaction-layer" aria-hidden="true">
|
||||||
|
{reactions.map((reaction) => (
|
||||||
|
<div
|
||||||
|
key={reaction.id}
|
||||||
|
className="auction-floating-reaction"
|
||||||
|
data-reaction-id={reaction.id}
|
||||||
|
style={reactionStyle(reaction.id)}
|
||||||
|
>
|
||||||
|
<span className="auction-floating-emoji">
|
||||||
|
{AUCTION_REACTIONS[reaction.kind].emoji}
|
||||||
|
</span>
|
||||||
|
<span className="auction-floating-name">
|
||||||
|
{reaction.displayName}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<span
|
||||||
|
className="sr-only"
|
||||||
|
role="status"
|
||||||
|
aria-live="polite"
|
||||||
|
aria-atomic="true"
|
||||||
|
>
|
||||||
|
{latest
|
||||||
|
? `${latest.displayName}님의 ${AUCTION_REACTIONS[latest.kind].label} 반응`
|
||||||
|
: ""}
|
||||||
|
</span>
|
||||||
|
</>,
|
||||||
|
document.body,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
|
import { Button } from "@astryxdesign/core/Button";
|
||||||
|
import { Popover } from "@astryxdesign/core/Popover";
|
||||||
|
import { Smile } from "lucide-react";
|
||||||
|
import type { AuctionReactionKind } from "@lolympus/contracts";
|
||||||
|
import { AUCTION_REACTIONS } from "../api/auction-reactions";
|
||||||
|
|
||||||
|
export function AuctionReactionPicker({
|
||||||
|
connected,
|
||||||
|
onReact,
|
||||||
|
}: {
|
||||||
|
connected: boolean;
|
||||||
|
onReact: (kind: AuctionReactionKind) => Promise<void>;
|
||||||
|
}) {
|
||||||
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
const [coolingDown, setCoolingDown] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const coolingDownRef = useRef(false);
|
||||||
|
const requestSequence = useRef(0);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!coolingDown) return;
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
coolingDownRef.current = false;
|
||||||
|
setCoolingDown(false);
|
||||||
|
}, 450);
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, [coolingDown]);
|
||||||
|
|
||||||
|
const handleReaction = useCallback(
|
||||||
|
async (kind: AuctionReactionKind) => {
|
||||||
|
if (!connected || coolingDownRef.current) return;
|
||||||
|
coolingDownRef.current = true;
|
||||||
|
const sequence = ++requestSequence.current;
|
||||||
|
setCoolingDown(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
await onReact(kind);
|
||||||
|
} catch (cause) {
|
||||||
|
if (sequence === requestSequence.current) {
|
||||||
|
setError(
|
||||||
|
cause instanceof Error
|
||||||
|
? cause.message
|
||||||
|
: "반응을 보내지 못했습니다.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[connected, onReact],
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Popover
|
||||||
|
label="이모지 반응"
|
||||||
|
closeButtonLabel="반응 선택 닫기"
|
||||||
|
placement="above"
|
||||||
|
alignment="end"
|
||||||
|
width={260}
|
||||||
|
isOpen={isOpen}
|
||||||
|
onOpenChange={setIsOpen}
|
||||||
|
content={
|
||||||
|
<div className="auction-reaction-picker">
|
||||||
|
<p className="auction-reaction-picker-title">이모지 반응</p>
|
||||||
|
<p className="auction-reaction-picker-description">
|
||||||
|
선택하면 모두에게 보여요
|
||||||
|
</p>
|
||||||
|
<div
|
||||||
|
className="auction-reaction-options"
|
||||||
|
role="group"
|
||||||
|
aria-label="반응 선택"
|
||||||
|
>
|
||||||
|
{(
|
||||||
|
Object.entries(AUCTION_REACTIONS) as [
|
||||||
|
AuctionReactionKind,
|
||||||
|
{ emoji: string; label: string },
|
||||||
|
][]
|
||||||
|
).map(([kind, { emoji, label }]) => (
|
||||||
|
<Button
|
||||||
|
key={kind}
|
||||||
|
label={`${label} 반응 보내기`}
|
||||||
|
variant="ghost"
|
||||||
|
size="lg"
|
||||||
|
isIconOnly
|
||||||
|
isDisabled={!connected || coolingDown}
|
||||||
|
className="auction-reaction-option"
|
||||||
|
onClick={() => void handleReaction(kind)}
|
||||||
|
icon={<span aria-hidden="true">{emoji}</span>}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
{(!connected || error) && (
|
||||||
|
<p className="auction-reaction-error" role="status">
|
||||||
|
{!connected ? "연결되면 반응을 보낼 수 있습니다." : error}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
label="이모지 반응"
|
||||||
|
variant="ghost"
|
||||||
|
size="md"
|
||||||
|
isIconOnly
|
||||||
|
className="auction-chat-reaction-trigger"
|
||||||
|
icon={<Smile size={20} aria-hidden="true" />}
|
||||||
|
/>
|
||||||
|
</Popover>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -11,11 +11,77 @@
|
|||||||
border-radius: 1.25rem;
|
border-radius: 1.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.lts-hall-player,
|
.lts-hall-team-name {
|
||||||
.lts-hall-portrait {
|
position: relative;
|
||||||
|
width: fit-content;
|
||||||
|
max-width: 100%;
|
||||||
|
color: var(--lts-gold);
|
||||||
|
filter: drop-shadow(0 0.5px 0 color-mix(in srgb, var(--lts-gold) 20%, transparent));
|
||||||
|
}
|
||||||
|
|
||||||
|
@supports (background-clip: text) or (-webkit-background-clip: text) {
|
||||||
|
.lts-hall-team-name {
|
||||||
|
background-image:
|
||||||
|
linear-gradient(
|
||||||
|
115deg,
|
||||||
|
transparent calc(50% - 9px),
|
||||||
|
color-mix(in srgb, var(--color-brand-gold) 45%, transparent) calc(50% - 5px),
|
||||||
|
color-mix(in srgb, var(--color-brand-gold) 18%, var(--color-palette-white)) 50%,
|
||||||
|
color-mix(in srgb, var(--color-brand-gold) 45%, transparent) calc(50% + 5px),
|
||||||
|
transparent calc(50% + 9px)
|
||||||
|
),
|
||||||
|
linear-gradient(
|
||||||
|
175deg,
|
||||||
|
var(--lts-gold) 0%,
|
||||||
|
color-mix(in srgb, var(--lts-gold) 45%, var(--color-brand-gold)) 28%,
|
||||||
|
var(--color-brand-gold) 39%,
|
||||||
|
color-mix(in srgb, var(--color-brand-gold) 65%, var(--color-palette-white)) 44%,
|
||||||
|
var(--lts-gold) 53%,
|
||||||
|
color-mix(in srgb, var(--lts-gold) 70%, var(--color-brand-gold)) 72%,
|
||||||
|
var(--color-brand-gold) 100%
|
||||||
|
);
|
||||||
|
background-size: 250% 100%, 100% 100%;
|
||||||
|
background-position: 100% 0, 0 0;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
-webkit-background-clip: text;
|
||||||
|
background-clip: text;
|
||||||
|
color: transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-hall-team-name::before,
|
||||||
|
.lts-hall-team-name::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
pointer-events: none;
|
||||||
|
width: 7px;
|
||||||
|
height: 7px;
|
||||||
|
background: var(--color-brand-gold);
|
||||||
|
clip-path: polygon(50% 0, 62% 37%, 100% 50%, 62% 63%, 50% 100%, 38% 63%, 0 50%, 38% 37%);
|
||||||
|
opacity: 0;
|
||||||
|
transform: scale(0.4) rotate(-15deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-hall-team-name::before {
|
||||||
|
top: -3px;
|
||||||
|
right: 22%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-hall-team-name::after {
|
||||||
|
top: 45%;
|
||||||
|
right: -5px;
|
||||||
|
width: 5px;
|
||||||
|
height: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-hall-player {
|
||||||
border-radius: 0.75rem;
|
border-radius: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.lts-hall-portrait {
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
.lts-hall-pixel {
|
.lts-hall-pixel {
|
||||||
image-rendering: pixelated;
|
image-rendering: pixelated;
|
||||||
}
|
}
|
||||||
@@ -25,9 +91,69 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-reduced-motion: no-preference) {
|
@media (prefers-reduced-motion: no-preference) {
|
||||||
|
.lts-hall[data-intro] .lts-hall-team-name {
|
||||||
|
animation: lts-hall-gold-shine 4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-hall[data-intro] .lts-hall-team-name::before,
|
||||||
|
.lts-hall[data-intro] .lts-hall-team-name::after {
|
||||||
|
animation: lts-hall-gold-sparkle 4s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-hall[data-intro] .lts-hall-team-name::after {
|
||||||
|
animation-delay: 120ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-hall:not([data-motion-active]) .lts-hall-team-name,
|
||||||
|
.lts-hall:not([data-motion-active]) .lts-hall-team-name::before,
|
||||||
|
.lts-hall:not([data-motion-active]) .lts-hall-team-name::after {
|
||||||
|
animation-play-state: paused;
|
||||||
|
}
|
||||||
|
|
||||||
.lts-hall[data-intro] .lts-hall-portrait img {
|
.lts-hall[data-intro] .lts-hall-portrait img {
|
||||||
animation: lts-hall-reveal 110ms linear
|
animation: lts-hall-reveal 6s linear
|
||||||
calc(180ms + var(--lts-hall-order) * 48ms) backwards;
|
calc(180ms + var(--lts-hall-order) * 48ms) infinite backwards;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (forced-colors: active) {
|
||||||
|
.lts-hall-team-name {
|
||||||
|
background: none;
|
||||||
|
color: CanvasText;
|
||||||
|
filter: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-hall-team-name::before,
|
||||||
|
.lts-hall-team-name::after {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes lts-hall-gold-shine {
|
||||||
|
0%,
|
||||||
|
5% {
|
||||||
|
background-position: 100% 0, 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sweep from 0.2s to 0.85s, then leave the gold finish at rest. */
|
||||||
|
21.25%,
|
||||||
|
100% {
|
||||||
|
background-position: 0 0, 0 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes lts-hall-gold-sparkle {
|
||||||
|
0%,
|
||||||
|
16.25%,
|
||||||
|
23.25%,
|
||||||
|
100% {
|
||||||
|
opacity: 0;
|
||||||
|
transform: scale(0.4) rotate(-15deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
19.5% {
|
||||||
|
opacity: 0.9;
|
||||||
|
transform: scale(1) rotate(15deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +167,9 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
/* Reveal for 110ms, then stay visible for the rest of the six-second cycle. */
|
||||||
|
1.833333%,
|
||||||
|
100% {
|
||||||
clip-path: polygon(
|
clip-path: polygon(
|
||||||
0 0,
|
0 0,
|
||||||
calc(100% + var(--lts-hall-slant)) 0,
|
calc(100% + var(--lts-hall-slant)) 0,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import captainCrown from '../assets/captain-crown.svg';
|
|||||||
import pixelTrophy from '../assets/pixel-trophy.svg';
|
import pixelTrophy from '../assets/pixel-trophy.svg';
|
||||||
import { profileIconUrl } from '../lib/ddragon';
|
import { profileIconUrl } from '../lib/ddragon';
|
||||||
import { positionLabel } from '../lib/league';
|
import { positionLabel } from '../lib/league';
|
||||||
import { pageWidthClass } from '../ui/layout';
|
import { pageWidthClass, Skeleton } from '../ui';
|
||||||
import './HomeHallOfFame.css';
|
import './HomeHallOfFame.css';
|
||||||
|
|
||||||
const POSITION_ORDER: MatchPosition[] = ['TOP', 'JGL', 'MID', 'ADC', 'SUP'];
|
const POSITION_ORDER: MatchPosition[] = ['TOP', 'JGL', 'MID', 'ADC', 'SUP'];
|
||||||
@@ -20,11 +20,13 @@ export default function HomeHallOfFame({
|
|||||||
const hallOfFame = useHallOfFame();
|
const hallOfFame = useHallOfFame();
|
||||||
const sectionRef = useRef<HTMLElement>(null);
|
const sectionRef = useRef<HTMLElement>(null);
|
||||||
const [playIntro, setPlayIntro] = useState(false);
|
const [playIntro, setPlayIntro] = useState(false);
|
||||||
|
const [isMotionActive, setIsMotionActive] = useState(false);
|
||||||
|
const isContentReady = introReady && hallOfFame.isSuccess;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const section = sectionRef.current;
|
const section = sectionRef.current;
|
||||||
if (
|
if (
|
||||||
!introReady ||
|
!isContentReady ||
|
||||||
!section ||
|
!section ||
|
||||||
typeof IntersectionObserver === 'undefined' ||
|
typeof IntersectionObserver === 'undefined' ||
|
||||||
window.matchMedia('(prefers-reduced-motion: reduce)').matches
|
window.matchMedia('(prefers-reduced-motion: reduce)').matches
|
||||||
@@ -32,15 +34,23 @@ export default function HomeHallOfFame({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let isInView = false;
|
||||||
|
const updateMotion = () => setIsMotionActive(isInView && !document.hidden);
|
||||||
const observer = new IntersectionObserver(
|
const observer = new IntersectionObserver(
|
||||||
([entry]) => {
|
([entry]) => {
|
||||||
if (entry?.isIntersecting) setPlayIntro(true);
|
isInView = entry?.isIntersecting ?? false;
|
||||||
|
if (isInView) setPlayIntro(true);
|
||||||
|
updateMotion();
|
||||||
},
|
},
|
||||||
{ threshold: 0.5 },
|
{ threshold: 0.5 },
|
||||||
);
|
);
|
||||||
observer.observe(section);
|
observer.observe(section);
|
||||||
return () => observer.disconnect();
|
document.addEventListener('visibilitychange', updateMotion);
|
||||||
}, [introReady]);
|
return () => {
|
||||||
|
observer.disconnect();
|
||||||
|
document.removeEventListener('visibilitychange', updateMotion);
|
||||||
|
};
|
||||||
|
}, [isContentReady]);
|
||||||
|
|
||||||
const featuredMatch = hallOfFame.data?.match;
|
const featuredMatch = hallOfFame.data?.match;
|
||||||
|
|
||||||
@@ -50,11 +60,16 @@ export default function HomeHallOfFame({
|
|||||||
<section
|
<section
|
||||||
ref={sectionRef}
|
ref={sectionRef}
|
||||||
aria-label="명예의 전당"
|
aria-label="명예의 전당"
|
||||||
|
aria-busy={hallOfFame.isPending}
|
||||||
className={`${pageWidthClass()} lts-hall grid gap-8 py-6 md:py-8 lg:grid-cols-[minmax(0,1fr)_20rem]`}
|
className={`${pageWidthClass()} lts-hall grid gap-8 py-6 md:py-8 lg:grid-cols-[minmax(0,1fr)_20rem]`}
|
||||||
data-intro={playIntro ? '' : undefined}
|
data-intro={playIntro ? '' : undefined}
|
||||||
|
data-motion-active={isMotionActive ? '' : undefined}
|
||||||
>
|
>
|
||||||
{hallOfFame.isPending ? (
|
{hallOfFame.isPending ? (
|
||||||
<p role="status">명예의 전당을 불러오는 중</p>
|
<>
|
||||||
|
<span role="status" className="sr-only">명예의 전당을 불러오는 중</span>
|
||||||
|
<FeaturedTeamSkeleton />
|
||||||
|
</>
|
||||||
) : hallOfFame.isError ? (
|
) : hallOfFame.isError ? (
|
||||||
<p role="status">
|
<p role="status">
|
||||||
명예의 전당을 불러오지 못했습니다.{' '}
|
명예의 전당을 불러오지 못했습니다.{' '}
|
||||||
@@ -75,6 +90,37 @@ export default function HomeHallOfFame({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function FeaturedTeamSkeleton() {
|
||||||
|
return (
|
||||||
|
<div className="lts-hall-card flex min-w-0 flex-col gap-4 bg-card p-5 sm:flex-row sm:gap-5">
|
||||||
|
<div className="min-w-0 sm:w-36 sm:shrink-0">
|
||||||
|
<h2 className="text-sm font-semibold text-content-muted">명예의 전당</h2>
|
||||||
|
<div className="mt-2">
|
||||||
|
<Skeleton width="80%" height={30} />
|
||||||
|
</div>
|
||||||
|
<div className="mt-1">
|
||||||
|
<Skeleton width="90%" height={16} index={1} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="h-px bg-line sm:h-auto sm:w-px" aria-hidden="true" />
|
||||||
|
<div className="grid min-w-0 flex-1 gap-1 sm:grid-cols-5 sm:content-center sm:items-start" aria-hidden="true">
|
||||||
|
{POSITION_ORDER.map((position, index) => (
|
||||||
|
<div key={position} className="flex min-w-0 items-center gap-2.5 px-2 py-2 sm:flex-col sm:gap-2 sm:py-3">
|
||||||
|
<div className="size-10 shrink-0 sm:size-13">
|
||||||
|
<Skeleton radius="rounded" index={index} />
|
||||||
|
</div>
|
||||||
|
<div className="min-w-0 flex-1 space-y-1 sm:w-full sm:flex-none sm:[&>div]:mx-auto">
|
||||||
|
<Skeleton width={24} height={16} index={index} />
|
||||||
|
<Skeleton width="80%" height={16} index={index} />
|
||||||
|
<Skeleton width="50%" height={12} index={index} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function FeaturedTeam({
|
function FeaturedTeam({
|
||||||
team,
|
team,
|
||||||
match,
|
match,
|
||||||
@@ -96,7 +142,7 @@ function FeaturedTeam({
|
|||||||
>
|
>
|
||||||
명예의 전당
|
명예의 전당
|
||||||
</span>
|
</span>
|
||||||
<span className="mt-2 block text-2xl leading-tight font-extrabold tracking-tight [overflow-wrap:anywhere]">
|
<span className="lts-hall-team-name mt-2 block text-2xl leading-tight font-extrabold tracking-tight [overflow-wrap:anywhere]">
|
||||||
{team.name}
|
{team.name}
|
||||||
</span>
|
</span>
|
||||||
<span className="mt-1 flex items-center gap-1 text-xs font-semibold text-content-muted">
|
<span className="mt-1 flex items-center gap-1 text-xs font-semibold text-content-muted">
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import { UserRound } from "lucide-react";
|
||||||
|
import { useDdragonManifest } from "../api/hooks";
|
||||||
|
import captainCrown from "../assets/captain-crown.svg";
|
||||||
|
import { profileIconUrl } from "../lib/ddragon";
|
||||||
|
|
||||||
|
const AVATAR_SIZE = {
|
||||||
|
sm: "size-7",
|
||||||
|
md: "size-10",
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
const CROWN_SIZE = {
|
||||||
|
sm: "-right-1 -top-1.5 w-4",
|
||||||
|
md: "-right-1.5 -top-2 w-5",
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
/** The adjacent player name labels the portrait; only the captain role is read. */
|
||||||
|
export function SummonerAvatar({
|
||||||
|
profileIconId,
|
||||||
|
isCaptain = false,
|
||||||
|
size = "md",
|
||||||
|
shape = "rounded",
|
||||||
|
}: {
|
||||||
|
profileIconId?: number;
|
||||||
|
isCaptain?: boolean;
|
||||||
|
size?: keyof typeof AVATAR_SIZE;
|
||||||
|
shape?: "circle" | "rounded";
|
||||||
|
}) {
|
||||||
|
const { data: manifest } = useDdragonManifest();
|
||||||
|
const icon = profileIconUrl(manifest, profileIconId ?? 0);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className={`relative inline-flex shrink-0 ${AVATAR_SIZE[size]} ${isCaptain ? "z-10" : ""}`}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className={`relative grid size-full place-items-center overflow-hidden bg-sunken-strong text-content-muted ring-2 ring-card ${shape === "circle" ? "rounded-full" : "rounded-[0.625rem]"}`}
|
||||||
|
>
|
||||||
|
<UserRound className={size === "sm" ? "size-4" : "size-5"} aria-hidden="true" />
|
||||||
|
<img
|
||||||
|
key={icon}
|
||||||
|
src={icon}
|
||||||
|
alt=""
|
||||||
|
className="absolute inset-0 size-full object-cover"
|
||||||
|
loading="lazy"
|
||||||
|
onError={(event) => {
|
||||||
|
event.currentTarget.hidden = true;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
{isCaptain && (
|
||||||
|
<img
|
||||||
|
src={captainCrown}
|
||||||
|
alt="팀장"
|
||||||
|
className={`pointer-events-none absolute z-10 rotate-[14deg] [image-rendering:pixelated] ${CROWN_SIZE[size]}`}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
.lts-app-header {
|
||||||
|
position: sticky;
|
||||||
|
top: calc(0px - var(--app-header-row-height));
|
||||||
|
z-index: 50;
|
||||||
|
flex-shrink: 0;
|
||||||
|
background: var(--color-background-body);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-app-header-inner {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) auto;
|
||||||
|
grid-template-rows: var(--app-header-row-height) minmax(0, 1fr);
|
||||||
|
height: var(--app-header-height);
|
||||||
|
align-items: center;
|
||||||
|
column-gap: 16px;
|
||||||
|
max-width: 1320px;
|
||||||
|
margin-inline: auto;
|
||||||
|
padding-inline: 16px;
|
||||||
|
border-bottom: 1px solid var(--color-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-header-brand {
|
||||||
|
grid-column: 1;
|
||||||
|
grid-row: 1;
|
||||||
|
display: flex;
|
||||||
|
min-width: 0;
|
||||||
|
width: fit-content;
|
||||||
|
max-width: 100%;
|
||||||
|
flex-direction: column;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-header-brand-name {
|
||||||
|
overflow: hidden;
|
||||||
|
font-size: 19px;
|
||||||
|
font-weight: 850;
|
||||||
|
line-height: 1.1;
|
||||||
|
letter-spacing: -0.7px;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-header-brand-tagline {
|
||||||
|
margin-top: 5px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
font-size: 7px;
|
||||||
|
font-weight: 750;
|
||||||
|
line-height: 1.1;
|
||||||
|
letter-spacing: 2.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-header-actions {
|
||||||
|
grid-column: 2;
|
||||||
|
grid-row: 1;
|
||||||
|
display: flex;
|
||||||
|
min-width: 0;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-header-icon-button {
|
||||||
|
display: grid;
|
||||||
|
width: 38px;
|
||||||
|
height: 38px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
place-items: center;
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
border-radius: 9px;
|
||||||
|
background: var(--color-background-card);
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
transition: background-color 150ms, color 150ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-header-theme-toggle {
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-header-icon-button:hover {
|
||||||
|
background: var(--lts-sunken);
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-primary-nav {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
grid-row: 2;
|
||||||
|
display: flex;
|
||||||
|
height: 100%;
|
||||||
|
align-items: stretch;
|
||||||
|
justify-content: center;
|
||||||
|
gap: clamp(20px, 5vw, 36px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-primary-nav-link {
|
||||||
|
position: relative;
|
||||||
|
display: inline-flex;
|
||||||
|
min-width: 36px;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 650;
|
||||||
|
white-space: nowrap;
|
||||||
|
transition: color 150ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-primary-nav-link:hover,
|
||||||
|
.lts-primary-nav-link[aria-current] {
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-primary-nav-link[aria-current]::after {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
bottom: -1px;
|
||||||
|
left: 0;
|
||||||
|
height: 3px;
|
||||||
|
border-radius: 3px 3px 0 0;
|
||||||
|
background: var(--color-brand-coral);
|
||||||
|
content: "";
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-app-header :focus-visible {
|
||||||
|
outline: 2px solid var(--color-win);
|
||||||
|
outline-offset: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-primary-nav-link:focus-visible {
|
||||||
|
outline-offset: -2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-app-shell--without-nav {
|
||||||
|
--app-header-nav-height: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-app-header--without-nav {
|
||||||
|
position: static;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-app-header--without-nav .lts-app-header-inner {
|
||||||
|
height: 60px;
|
||||||
|
grid-template-rows: minmax(0, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (width >= 48rem) {
|
||||||
|
.lts-app-header-inner {
|
||||||
|
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
|
||||||
|
grid-template-rows: minmax(0, 1fr);
|
||||||
|
column-gap: 24px;
|
||||||
|
padding-inline: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-header-brand-name {
|
||||||
|
font-size: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-header-brand-tagline {
|
||||||
|
margin-top: 6px;
|
||||||
|
font-size: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-header-actions {
|
||||||
|
grid-column: 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-primary-nav {
|
||||||
|
grid-column: 2;
|
||||||
|
grid-row: 1;
|
||||||
|
gap: 36px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-primary-nav-link {
|
||||||
|
min-width: 0;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lts-app-header--without-nav .lts-app-header-inner {
|
||||||
|
height: 74px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (width >= 80rem) {
|
||||||
|
.lts-app-header-inner {
|
||||||
|
padding-inline: 40px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,227 @@
|
|||||||
|
.auction-chat-panel {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-width: 0;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
background: var(--color-background-card);
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
border-radius: var(--radius-container);
|
||||||
|
}
|
||||||
|
|
||||||
|
.auction-chat-panel .auction-chat-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
flex-shrink: 0;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 12px 14px;
|
||||||
|
border-bottom: 1px solid var(--color-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.auction-chat-header h2 {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 700;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.auction-chat-connection {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
}
|
||||||
|
.auction-chat-conversation {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
.auction-chat-scroll {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
overflow-y: auto;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
padding: 16px 12px;
|
||||||
|
scrollbar-gutter: stable;
|
||||||
|
}
|
||||||
|
.auction-chat-scroll > .astryx-chat-message-list {
|
||||||
|
min-height: 100%;
|
||||||
|
}
|
||||||
|
.auction-chat-empty {
|
||||||
|
margin: auto;
|
||||||
|
padding: 24px 8px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.7;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
}
|
||||||
|
.auction-chat-author {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px 6px;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
.auction-chat-name {
|
||||||
|
max-width: 150px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
.auction-chat-author time,
|
||||||
|
.auction-chat-self {
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 400;
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
}
|
||||||
|
.auction-chat-author .astryx-badge {
|
||||||
|
font-size: 10px;
|
||||||
|
padding-inline: 5px;
|
||||||
|
height: 18px;
|
||||||
|
}
|
||||||
|
.auction-chat-panel
|
||||||
|
.astryx-chat-message[data-sender="user"]
|
||||||
|
.auction-chat-author {
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
.auction-chat-panel .astryx-chat-message-bubble {
|
||||||
|
padding: 8px 10px;
|
||||||
|
max-width: 100%;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.6;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
.auction-chat-panel
|
||||||
|
.astryx-chat-message[data-sender="assistant"]
|
||||||
|
.astryx-chat-message-bubble {
|
||||||
|
background: var(--color-background-muted);
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
}
|
||||||
|
.auction-chat-panel
|
||||||
|
.astryx-chat-message[data-sender="user"]
|
||||||
|
.astryx-chat-message-bubble {
|
||||||
|
background: var(--color-accent-muted);
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
}
|
||||||
|
.auction-chat-panel .astryx-chat-message > div {
|
||||||
|
max-width: 92%;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
.auction-chat-delivery {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 4px;
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
.auction-chat-delivery[data-failed="true"] {
|
||||||
|
color: var(--color-text-error);
|
||||||
|
}
|
||||||
|
.auction-chat-new-messages {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
inset-inline: 0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
.auction-chat-new-messages button {
|
||||||
|
pointer-events: auto;
|
||||||
|
box-shadow: 0 2px 8px var(--color-palette-shadow-light);
|
||||||
|
}
|
||||||
|
.auction-chat-compose-area {
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-top: 1px solid var(--color-border);
|
||||||
|
}
|
||||||
|
.auction-chat-sender {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 6px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
.auction-chat-sender > span:first-child {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.auction-chat-count {
|
||||||
|
flex-shrink: 0;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
.auction-chat-count[data-limit="true"] {
|
||||||
|
color: var(--color-text-error);
|
||||||
|
}
|
||||||
|
/* The Astryx composer keeps its focus/disabled shell; its input and footer
|
||||||
|
slots form one compact row for this sidebar's plain-text editor. */
|
||||||
|
.auction-chat-panel .auction-chat-composer > div {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) auto;
|
||||||
|
align-items: end;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 5px;
|
||||||
|
border-radius: var(--radius-element);
|
||||||
|
background: var(--color-background-card);
|
||||||
|
}
|
||||||
|
.auction-chat-composer textarea {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 36px;
|
||||||
|
max-height: calc(4lh + 14px);
|
||||||
|
resize: none;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 7px;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
font: inherit;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 22px;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
.auction-chat-composer textarea::placeholder {
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
}
|
||||||
|
.auction-chat-panel .auction-chat-send {
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
min-width: 36px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
.auction-chat-panel .auction-chat-send:disabled {
|
||||||
|
opacity: 1;
|
||||||
|
background: var(--color-background-muted);
|
||||||
|
color: var(--color-text-disabled);
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
.auction-chat-hint {
|
||||||
|
margin: 6px 0 0;
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
font-size: 10px;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (pointer: coarse), (max-width: 639px) {
|
||||||
|
.auction-chat-panel .auction-chat-send {
|
||||||
|
width: 44px;
|
||||||
|
height: 44px;
|
||||||
|
min-width: 44px;
|
||||||
|
}
|
||||||
|
.auction-chat-composer textarea {
|
||||||
|
min-height: 44px;
|
||||||
|
max-height: calc(4lh + 22px);
|
||||||
|
padding-block: 11px;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,598 @@
|
|||||||
|
import { useId, useState, type KeyboardEvent, type ReactNode } from "react";
|
||||||
|
import { Link } from "react-router";
|
||||||
|
import { ArrowUpRight } from "lucide-react";
|
||||||
|
import { Tooltip } from "@astryxdesign/core/Tooltip";
|
||||||
|
import type { AuctionPlayerView } from "../../api/mappers";
|
||||||
|
import type {
|
||||||
|
ApiRecentMatchView,
|
||||||
|
ApiTierInfo,
|
||||||
|
DdragonManifest,
|
||||||
|
} from "../../api/types";
|
||||||
|
import { DEFAULT_COMMUNITY_ID } from "../../config";
|
||||||
|
import {
|
||||||
|
championDisplayName,
|
||||||
|
championIconUrl,
|
||||||
|
profileIconUrl,
|
||||||
|
} from "../../lib/ddragon";
|
||||||
|
import { POSITION_ORDER, positionIcon, positionLabel } from "../../lib/league";
|
||||||
|
import { LANE_LABELS } from "../../lib/riot-history";
|
||||||
|
import { internalMatchGamePath } from "../../lib/internal-match-routes";
|
||||||
|
import { RankBadge } from "../RankBadge";
|
||||||
|
import { formatRankDetail } from "../rankBadgeUtils";
|
||||||
|
import {
|
||||||
|
metricLabel,
|
||||||
|
POSITION_LANES,
|
||||||
|
selectProfileGames,
|
||||||
|
summarizeProfileGames,
|
||||||
|
type PositionFilter,
|
||||||
|
type ProfileQueue,
|
||||||
|
} from "./stats";
|
||||||
|
import { useProfileHistory } from "./useProfileHistory";
|
||||||
|
import { useProfileManifest } from "./useProfileManifest";
|
||||||
|
import "./profile.css";
|
||||||
|
|
||||||
|
const POSITIONS: PositionFilter[] = ["ALL", ...POSITION_ORDER];
|
||||||
|
const QUEUES: ProfileQueue[] = ["internal", "solo"];
|
||||||
|
const queueName = (queue: ProfileQueue) =>
|
||||||
|
queue === "internal" ? "내전" : "솔로랭크";
|
||||||
|
const positionName = (position: PositionFilter) =>
|
||||||
|
position === "ALL" ? "전체" : positionLabel[position];
|
||||||
|
const dateLabel = (timestamp: number) =>
|
||||||
|
new Intl.DateTimeFormat("ko-KR", { month: "2-digit", day: "2-digit" })
|
||||||
|
.format(timestamp)
|
||||||
|
.replace(/\.$/, "");
|
||||||
|
type Summary = ReturnType<typeof summarizeProfileGames>;
|
||||||
|
type Manifest = DdragonManifest | undefined;
|
||||||
|
|
||||||
|
function moveTab<T extends string>(
|
||||||
|
event: KeyboardEvent<HTMLButtonElement>,
|
||||||
|
values: T[],
|
||||||
|
current: T,
|
||||||
|
select: (value: T) => void,
|
||||||
|
prefix: string,
|
||||||
|
) {
|
||||||
|
if (
|
||||||
|
event.altKey ||
|
||||||
|
event.ctrlKey ||
|
||||||
|
event.metaKey ||
|
||||||
|
!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
event.preventDefault();
|
||||||
|
const index = values.indexOf(current);
|
||||||
|
const next =
|
||||||
|
event.key === "Home"
|
||||||
|
? values[0]
|
||||||
|
: event.key === "End"
|
||||||
|
? values[values.length - 1]
|
||||||
|
: values[
|
||||||
|
(index + (event.key === "ArrowRight" ? 1 : -1) + values.length) %
|
||||||
|
values.length
|
||||||
|
];
|
||||||
|
select(next);
|
||||||
|
document.getElementById(`${prefix}-${next}`)?.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
function Portrait({
|
||||||
|
championId,
|
||||||
|
manifest,
|
||||||
|
}: {
|
||||||
|
championId: number;
|
||||||
|
manifest: Manifest;
|
||||||
|
}) {
|
||||||
|
const src = championIconUrl(manifest, championId);
|
||||||
|
return (
|
||||||
|
<span className="ap-champion-portrait">
|
||||||
|
{src && <img src={src} alt="" loading="lazy" />}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ChampionGroup({
|
||||||
|
summary,
|
||||||
|
manifest,
|
||||||
|
}: {
|
||||||
|
summary: NonNullable<Summary>;
|
||||||
|
manifest: Manifest;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div className="ap-champions">
|
||||||
|
<h3>최근 챔피언</h3>
|
||||||
|
<div className="ap-avatar-group" aria-label="최근 사용 챔피언">
|
||||||
|
{summary.champions.slice(0, 10).map((champion) => {
|
||||||
|
const name =
|
||||||
|
championDisplayName(manifest, champion.championId) ??
|
||||||
|
`챔피언 ${champion.championId}`;
|
||||||
|
const description = `${name} · ${champion.games}경기 · ${champion.wins}승 ${champion.games - champion.wins}패 · 승률 ${Math.round((champion.wins / champion.games) * 100)}%`;
|
||||||
|
return (
|
||||||
|
<Tooltip
|
||||||
|
content={description}
|
||||||
|
placement="below"
|
||||||
|
key={champion.championId}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="ap-avatar"
|
||||||
|
role="img"
|
||||||
|
tabIndex={0}
|
||||||
|
aria-label={description}
|
||||||
|
>
|
||||||
|
<Portrait
|
||||||
|
championId={champion.championId}
|
||||||
|
manifest={manifest}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Metrics({ summary }: { summary: Summary }) {
|
||||||
|
return (
|
||||||
|
<div className="ap-metrics" aria-label="선택한 포지션의 요약">
|
||||||
|
<div>
|
||||||
|
<span>승률</span>
|
||||||
|
<strong>
|
||||||
|
{summary ? (
|
||||||
|
<>
|
||||||
|
{summary.winRate}
|
||||||
|
<small>%</small>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
"—"
|
||||||
|
)}
|
||||||
|
</strong>
|
||||||
|
<p>
|
||||||
|
{summary
|
||||||
|
? `${summary.wins}승 ${summary.losses}패 · ${summary.games}경기`
|
||||||
|
: "기록 없음"}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span>KDA</span>
|
||||||
|
<strong data-perfect={summary?.kda === "Perfect"}>
|
||||||
|
{summary?.kda ?? "—"}
|
||||||
|
</strong>
|
||||||
|
<p>{summary?.averageKda ?? "기록 없음"}</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span>평균 킬 관여율</span>
|
||||||
|
<strong>
|
||||||
|
{summary?.killParticipation != null ? (
|
||||||
|
<>
|
||||||
|
{Math.round(summary.killParticipation)}
|
||||||
|
<small>%</small>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
"—"
|
||||||
|
)}
|
||||||
|
</strong>
|
||||||
|
<p>팀 처치 참여 비율</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function PlayMetrics({
|
||||||
|
summary,
|
||||||
|
position,
|
||||||
|
}: {
|
||||||
|
summary: NonNullable<Summary>;
|
||||||
|
position: PositionFilter;
|
||||||
|
}) {
|
||||||
|
const values = [
|
||||||
|
{ key: "cs", label: "분당 CS", value: metricLabel(summary.csPerMinute, 1) },
|
||||||
|
{
|
||||||
|
key: "damage",
|
||||||
|
label: "팀 내 피해량 비중",
|
||||||
|
value: metricLabel(summary.damageShare, 0, "%"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "vision",
|
||||||
|
label: "분당 시야 점수",
|
||||||
|
value: metricLabel(summary.visionPerMinute, 2),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
if (position === "SUP") values.unshift(values.splice(2, 1)[0]);
|
||||||
|
return (
|
||||||
|
<section
|
||||||
|
className="ap-play-metrics"
|
||||||
|
aria-label={`${positionName(position)} ${summary.games}경기 평균 플레이 지표`}
|
||||||
|
>
|
||||||
|
<dl>
|
||||||
|
{values.map((metric) => (
|
||||||
|
<div key={metric.key}>
|
||||||
|
<dt>{metric.label}</dt>
|
||||||
|
<dd>{metric.value}</dd>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</dl>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function RecentGames({
|
||||||
|
games,
|
||||||
|
queue,
|
||||||
|
manifest,
|
||||||
|
historyBackTo,
|
||||||
|
}: {
|
||||||
|
games: ApiRecentMatchView[];
|
||||||
|
queue: ProfileQueue;
|
||||||
|
manifest: Manifest;
|
||||||
|
historyBackTo: string;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<section className="ap-recent">
|
||||||
|
<div className="ap-section-heading">
|
||||||
|
<h3>최근 {queueName(queue)}</h3>
|
||||||
|
<span>{games.length}경기 · 최신순</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="ap-game-scroll"
|
||||||
|
tabIndex={0}
|
||||||
|
role="region"
|
||||||
|
aria-label={`${queueName(queue)} 최근 ${games.length}경기 목록`}
|
||||||
|
>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">경기</th>
|
||||||
|
<th scope="col">K / D / A</th>
|
||||||
|
<th scope="col">CS/분</th>
|
||||||
|
<th scope="col">킬 관여</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{games.map((game) => {
|
||||||
|
const name =
|
||||||
|
championDisplayName(manifest, game.championId) ??
|
||||||
|
`챔피언 ${game.championId}`;
|
||||||
|
const result = game.remake
|
||||||
|
? "다시하기"
|
||||||
|
: game.win
|
||||||
|
? "승리"
|
||||||
|
: "패배";
|
||||||
|
const content = (
|
||||||
|
<>
|
||||||
|
<Portrait championId={game.championId} manifest={manifest} />
|
||||||
|
<div>
|
||||||
|
<strong>
|
||||||
|
<b
|
||||||
|
data-result={
|
||||||
|
game.remake ? "remake" : game.win ? "win" : "loss"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{result}
|
||||||
|
</b>{" "}
|
||||||
|
{name}
|
||||||
|
</strong>
|
||||||
|
<p>
|
||||||
|
{dateLabel(game.gameCreation)} ·{" "}
|
||||||
|
{LANE_LABELS[game.teamPosition] ?? "포지션 미상"} ·{" "}
|
||||||
|
{Math.floor(game.gameDuration / 60)}분
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
const detailPath =
|
||||||
|
game.internalMatchId && game.gameNumber
|
||||||
|
? internalMatchGamePath(
|
||||||
|
DEFAULT_COMMUNITY_ID,
|
||||||
|
game.internalMatchId,
|
||||||
|
game.gameNumber,
|
||||||
|
)
|
||||||
|
: null;
|
||||||
|
return (
|
||||||
|
<tr key={`${game.matchId}-${game.gameNumber ?? ""}`}>
|
||||||
|
<td>
|
||||||
|
{detailPath ? (
|
||||||
|
<Link
|
||||||
|
to={detailPath}
|
||||||
|
state={{
|
||||||
|
backTo: historyBackTo,
|
||||||
|
backLabel: "경매로 돌아가기",
|
||||||
|
}}
|
||||||
|
className="ap-game-identity"
|
||||||
|
aria-label={`${name} ${result} 내전 상세 보기`}
|
||||||
|
>
|
||||||
|
{content}
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<div className="ap-game-identity">{content}</div>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{game.kills}/{game.deaths}/{game.assists}
|
||||||
|
</td>
|
||||||
|
<td>{metricLabel(game.csPerMin, 1)}</td>
|
||||||
|
<td>{metricLabel(game.killParticipation, 0, "%")}</td>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Masteries({
|
||||||
|
player,
|
||||||
|
manifest,
|
||||||
|
}: {
|
||||||
|
player: AuctionPlayerView;
|
||||||
|
manifest: Manifest;
|
||||||
|
}) {
|
||||||
|
if (!player.masteries.length) return null;
|
||||||
|
return (
|
||||||
|
<div className="ap-masteries">
|
||||||
|
<span>누적 숙련도</span>
|
||||||
|
<div className="ap-mastery-icons">
|
||||||
|
{player.masteries.slice(0, 5).map((champion) => {
|
||||||
|
const label = `${championDisplayName(manifest, champion.championId) ?? champion.championId} · Lv.${champion.level} · ${(champion.points / 1000).toFixed(0)}K`;
|
||||||
|
return (
|
||||||
|
<Tooltip
|
||||||
|
content={label}
|
||||||
|
placement="below"
|
||||||
|
key={champion.championId}
|
||||||
|
>
|
||||||
|
<span role="img" aria-label={label} tabIndex={0}>
|
||||||
|
<Portrait
|
||||||
|
championId={champion.championId}
|
||||||
|
manifest={manifest}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
<small>포지션 무관</small>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AuctionPlayerProfile({
|
||||||
|
player,
|
||||||
|
peakTier,
|
||||||
|
historyBackTo,
|
||||||
|
bidStatus,
|
||||||
|
}: {
|
||||||
|
player: AuctionPlayerView;
|
||||||
|
peakTier?: ApiTierInfo;
|
||||||
|
historyBackTo: string;
|
||||||
|
bidStatus?: ReactNode;
|
||||||
|
}) {
|
||||||
|
const prefix = useId();
|
||||||
|
const manifest = useProfileManifest();
|
||||||
|
// The parent keys this component by player, so a new player starts at their preference.
|
||||||
|
const [queue, setQueue] = useState<ProfileQueue>("internal");
|
||||||
|
const [position, setPosition] = useState<PositionFilter>(
|
||||||
|
player.mainPosition ?? "ALL",
|
||||||
|
);
|
||||||
|
const history = useProfileHistory(player.userId, queue, position);
|
||||||
|
const games = selectProfileGames(history.data?.matches ?? [], position);
|
||||||
|
const summary = summarizeProfileGames(games);
|
||||||
|
const preferences = [player.mainPosition, player.subPosition].filter(
|
||||||
|
(value, index, values) => value && values.indexOf(value) === index,
|
||||||
|
);
|
||||||
|
const historyParams = new URLSearchParams({
|
||||||
|
queueGroup: queue === "internal" ? "internal" : "summoners-rift",
|
||||||
|
});
|
||||||
|
if (queue === "solo") historyParams.set("rank", "solo");
|
||||||
|
const historyHref = `/users/${player.userId}/history?${historyParams}`;
|
||||||
|
const loading = !history.data && history.isPending;
|
||||||
|
const unavailable = !history.data && history.isError;
|
||||||
|
const showAll = () => {
|
||||||
|
setPosition("ALL");
|
||||||
|
document.getElementById(`${prefix}-position-ALL`)?.focus();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section
|
||||||
|
className="auction-player-profile"
|
||||||
|
aria-label={`${player.summonerName} 선수 정보`}
|
||||||
|
>
|
||||||
|
<header className="ap-identity">
|
||||||
|
<Link
|
||||||
|
to={`/users/${player.userId}/history`}
|
||||||
|
state={{ backTo: historyBackTo }}
|
||||||
|
aria-label={`${player.summonerName} 전체 전적`}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
className="ap-player-avatar"
|
||||||
|
src={profileIconUrl(manifest, player.profileIconId)}
|
||||||
|
alt=""
|
||||||
|
/>
|
||||||
|
</Link>
|
||||||
|
<div className="ap-player-info">
|
||||||
|
<div className="ap-player-name">
|
||||||
|
<h2>
|
||||||
|
<Link
|
||||||
|
to={`/users/${player.userId}/history`}
|
||||||
|
state={{ backTo: historyBackTo }}
|
||||||
|
>
|
||||||
|
{player.summonerName}
|
||||||
|
</Link>
|
||||||
|
</h2>
|
||||||
|
<span>#{player.tag}</span>
|
||||||
|
</div>
|
||||||
|
<div className="ap-rank">
|
||||||
|
<RankBadge tier={player.tier} />
|
||||||
|
<span>{formatRankDetail(player.tier)}</span>
|
||||||
|
<span className="ap-secondary">현재</span>
|
||||||
|
</div>
|
||||||
|
<p className="ap-peak">
|
||||||
|
기록된 최고 <strong>{formatRankDetail(peakTier)}</strong>
|
||||||
|
</p>
|
||||||
|
<div className="ap-preferences">
|
||||||
|
<span>신청 포지션</span>
|
||||||
|
{preferences.map((preference, index) => (
|
||||||
|
<span
|
||||||
|
className="ap-role-chip"
|
||||||
|
data-primary={index === 0}
|
||||||
|
key={preference}
|
||||||
|
>
|
||||||
|
<img src={positionIcon[preference]} alt="" />
|
||||||
|
{positionLabel[preference]}
|
||||||
|
<small>{index + 1}순위</small>
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
{bidStatus}
|
||||||
|
<div className="ap-tabs" role="tablist" aria-label="선수 전적 종류">
|
||||||
|
{QUEUES.map((value) => (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
role="tab"
|
||||||
|
key={value}
|
||||||
|
id={`${prefix}-queue-${value}`}
|
||||||
|
aria-selected={queue === value}
|
||||||
|
aria-controls={`${prefix}-queue-panel`}
|
||||||
|
tabIndex={queue === value ? 0 : -1}
|
||||||
|
onClick={() => setQueue(value)}
|
||||||
|
onKeyDown={(event) =>
|
||||||
|
moveTab(event, QUEUES, queue, setQueue, `${prefix}-queue`)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{queueName(value)}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="ap-card-body"
|
||||||
|
role="tabpanel"
|
||||||
|
id={`${prefix}-queue-panel`}
|
||||||
|
aria-labelledby={`${prefix}-queue-${queue}`}
|
||||||
|
>
|
||||||
|
<div className="ap-summary-heading">
|
||||||
|
<h3>최근 {queueName(queue)}</h3>
|
||||||
|
<Link to={historyHref} state={{ backTo: historyBackTo }}>
|
||||||
|
전체 전적
|
||||||
|
<ArrowUpRight size={13} aria-hidden="true" />
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="ap-position-tabs"
|
||||||
|
role="tablist"
|
||||||
|
aria-label="플레이 포지션"
|
||||||
|
>
|
||||||
|
{POSITIONS.map((value) => {
|
||||||
|
const count =
|
||||||
|
history.data?.positionCounts?.[
|
||||||
|
value === "ALL" ? "ALL" : POSITION_LANES[value]
|
||||||
|
] ??
|
||||||
|
(value === position && history.data ? games.length : undefined);
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
role="tab"
|
||||||
|
id={`${prefix}-position-${value}`}
|
||||||
|
aria-controls={`${prefix}-position-panel`}
|
||||||
|
aria-selected={position === value}
|
||||||
|
aria-label={`${positionName(value)}${count === undefined ? "" : ` ${count}경기`}`}
|
||||||
|
tabIndex={position === value ? 0 : -1}
|
||||||
|
key={value}
|
||||||
|
onClick={() => setPosition(value)}
|
||||||
|
onKeyDown={(event) =>
|
||||||
|
moveTab(
|
||||||
|
event,
|
||||||
|
POSITIONS,
|
||||||
|
position,
|
||||||
|
setPosition,
|
||||||
|
`${prefix}-position`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
{value !== "ALL" && <img src={positionIcon[value]} alt="" />}
|
||||||
|
{positionName(value)}
|
||||||
|
</span>
|
||||||
|
<small>{count ?? "—"}</small>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
role="tabpanel"
|
||||||
|
id={`${prefix}-position-panel`}
|
||||||
|
aria-labelledby={`${prefix}-position-${position}`}
|
||||||
|
aria-busy={loading}
|
||||||
|
>
|
||||||
|
{loading ? (
|
||||||
|
<div className="ap-loading" role="status">
|
||||||
|
<span />
|
||||||
|
전적을 불러오는 중입니다.
|
||||||
|
</div>
|
||||||
|
) : unavailable ? (
|
||||||
|
<div className="ap-empty" role="alert">
|
||||||
|
<strong>전적을 불러오지 못했습니다.</strong>
|
||||||
|
<p>잠시 후 다시 시도해 주세요.</p>
|
||||||
|
<button type="button" onClick={() => void history.refetch()}>
|
||||||
|
다시 시도
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<p className="ap-sample-context" aria-live="polite">
|
||||||
|
{position === "ALL" ? "전체 포지션" : positionName(position)}{" "}
|
||||||
|
최근 {games.length}경기
|
||||||
|
{games[0] && (
|
||||||
|
<span>
|
||||||
|
{dateLabel(games[games.length - 1].gameCreation)} –{" "}
|
||||||
|
{dateLabel(games[0].gameCreation)}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
<Metrics summary={summary} />
|
||||||
|
{summary && (
|
||||||
|
<>
|
||||||
|
<ChampionGroup summary={summary} manifest={manifest} />
|
||||||
|
<PlayMetrics summary={summary} position={position} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{games.length ? (
|
||||||
|
<RecentGames
|
||||||
|
key={`${queue}-${position}`}
|
||||||
|
games={games}
|
||||||
|
queue={queue}
|
||||||
|
manifest={manifest}
|
||||||
|
historyBackTo={historyBackTo}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="ap-empty">
|
||||||
|
<strong>
|
||||||
|
{positionName(position)} 플레이 기록이 없습니다.
|
||||||
|
</strong>
|
||||||
|
<p>포지션별로 최근 20경기까지 집계합니다.</p>
|
||||||
|
{position !== "ALL" && (
|
||||||
|
<button type="button" onClick={showAll}>
|
||||||
|
전체 전적 보기
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{queue === "solo" && <Masteries player={player} manifest={manifest} />}
|
||||||
|
{history.data && (
|
||||||
|
<p className="ap-data-note">
|
||||||
|
{history.data.season.label} · 지표는 선택한 경기 기준
|
||||||
|
{games.some((game) => game.remake) ? " · 다시하기 제외" : ""}
|
||||||
|
{summary?.games === 1 ? " · 1경기 표본" : ""}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{history.isError && history.data && (
|
||||||
|
<p className="ap-data-note" role="status">
|
||||||
|
전적 갱신이 지연되어 마지막으로 불러온 기록을 표시합니다.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
# Auction player information — applied v2
|
||||||
|
|
||||||
|
Verified 2026-11-11 on the actual auction route:
|
||||||
|
`http://localhost:5173/match/6a3b94bccb8a54219653f457/auction`.
|
||||||
|
|
||||||
|
## Approved source and implementation
|
||||||
|
|
||||||
|
The selected reference is `src/design-previews/player-information-v2/Preview.tsx`
|
||||||
|
and its CSS. Production uses the separate `AuctionPlayerProfile.tsx`, `profile.css`,
|
||||||
|
and history/statistics helpers; it imports no prototype fixtures.
|
||||||
|
|
||||||
|
The identity header, queue tabs, six position tabs, three summary metrics,
|
||||||
|
overlapping champion avatars, three performance metrics and scrolling game table
|
||||||
|
follow the approved reference. Container queries adapt the card at its actual
|
||||||
|
440 px desktop / 311 px mobile widths. The existing auction bid/status rendering,
|
||||||
|
team cards and chat are preserved.
|
||||||
|
|
||||||
|
## Browser results
|
||||||
|
|
||||||
|
- Initial player is 붕어베이글. Requested first position is 미드 and the selected
|
||||||
|
history position starts at 미드. Internal history: seven actual games, 57% wins,
|
||||||
|
2.96 aggregate KDA, 57% mean kill participation. All portraits loaded.
|
||||||
|
- Solo overall window has 20 games dated October 30–November 7. The independent
|
||||||
|
mid window includes the older October 26 game even though it is outside those
|
||||||
|
overall 20 games. Support independently has 20 games; top/ADC have one each;
|
||||||
|
jungle has zero. No missing games are invented or padded.
|
||||||
|
- Remakes remain in the game list; summary performance excludes them and states
|
||||||
|
that exclusion. The observed overall solo window has 19 completed games plus
|
||||||
|
one remake, so summary wins/losses differ intentionally from the list count.
|
||||||
|
- Support puts vision/minute first. Empty jungle shows dashes and an explicit
|
||||||
|
empty state. Queue/position changes update the sample, metrics and champions
|
||||||
|
together. No champion-count text or disclosure controls were introduced.
|
||||||
|
- The table has all 20 rows, a 228 px viewport and sticky headings. End reaches
|
||||||
|
the final row (scrollTop 565.3 of a 566 px range); changing position resets to 0.
|
||||||
|
- ArrowRight and Home move selection and focus between position tabs. Internal
|
||||||
|
game links retain the match/game route and return-to-auction state.
|
||||||
|
- At 360 px viewport, page scrollWidth is 345 px and card scrollWidth is 311 px:
|
||||||
|
no horizontal overflow. Desktop 1280 px also has no horizontal overflow.
|
||||||
|
Browser viewport override was reset; final state is 내전 / 미드.
|
||||||
|
|
||||||
|
## Evidence
|
||||||
|
|
||||||
|
- Approved source: `src/design-previews/player-information-v2/Preview.tsx`.
|
||||||
|
- Full mobile card: `C:/Users/park/.codex/visualizations/2026/11/11/01a1c930-2c9b-7531-a709-2ebb87701e9a/player-information-applied/mobile.jpg`.
|
||||||
|
- Desktop context: same directory, `desktop.jpg`.
|
||||||
|
- Desktop identity, tabs and metrics: same directory, `auction-player-card.jpg`.
|
||||||
|
|
||||||
|
## Data and validation
|
||||||
|
|
||||||
|
Both API and web TypeScript checks passed. Targeted ESLint passed. Eleven web
|
||||||
|
tests (including the five existing prototype tests) and seventeen backend tests
|
||||||
|
passed. Tests cover filtering before limiting, older position records, legacy
|
||||||
|
pagination, stalled cursors, independently capped counts, participant-scoped
|
||||||
|
Mongo predicates, averages, missing metrics and remake exclusion.
|
||||||
|
|
||||||
|
The connected staging API predates lane filtering and returns no positionCounts.
|
||||||
|
The UI therefore uses a cached compatibility collector over its paginated public
|
||||||
|
history API. It retains only the independent recent-20 windows. Once the new
|
||||||
|
backend response is deployed, the UI requests the selected position directly.
|
||||||
|
The new backend code was type/unit tested, not deployed or verified against a
|
||||||
|
live database in this task (local bootstrap credentials were unavailable).
|
||||||
|
Current history APIs use their configured season scope, shown below the card.
|
||||||
|
|
||||||
|
The staging DDragon manifest endpoint returned HTTP 500. A separate card-only
|
||||||
|
query obtains champion metadata from Riot's official CDN when that endpoint
|
||||||
|
fails. Its partial manifest does not replace the application's full manifest
|
||||||
|
cache used by item/rune views.
|
||||||
|
|
||||||
|
## Size and stable-height follow-up
|
||||||
|
|
||||||
|
- Desktop inspector width now matches the approved two-column reference:
|
||||||
|
`(1104 - 24) / 2 = 540px`. The page maximum width increases by the same 100px,
|
||||||
|
retaining the existing 484px team grid at the maximum desktop layout width.
|
||||||
|
The four-column layout starts at 1440px with minimum widths for adjacent areas.
|
||||||
|
- The passed-status footer uses the reference's 12px type and 10px vertical
|
||||||
|
padding. Before the fixed-height request, the complete internal card matched
|
||||||
|
the reference's approximately 826px height.
|
||||||
|
- The history body now reserves 656px on desktop, including the maximum solo
|
||||||
|
view, ten champion portraits, the mastery row and the 228px match list. It
|
||||||
|
reserves 720px at container widths up to 480px. Short/empty results retain the
|
||||||
|
space, and flex layout keeps the data note at the bottom. Overflow remains
|
||||||
|
available as an accessibility fallback; it is not needed in the tested states.
|
||||||
|
- Browser measurements: the full desktop card is 877.60px for internal seven
|
||||||
|
games, empty support, solo loading and solo support twenty games. On mobile,
|
||||||
|
both twenty games and empty jungle measure 957.55px. History clientHeight and
|
||||||
|
scrollHeight are equal (656 / 720 respectively); no extra body scroll appears.
|
||||||
|
- Web TypeScript and AuctionPage/profile ESLint checks passed. This CSS change
|
||||||
|
adds no new unit tests; verification exercises the real tab interactions.
|
||||||
|
- During follow-up, another local Vite process replaced port 5173's staging
|
||||||
|
configuration with development. Live-data verification continued on the
|
||||||
|
isolated port 5174 staging proxy (`tmp/auction-profile-qa.mjs`, ignored), with a
|
||||||
|
separate Vite dependency cache. No auction actions were performed.
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
import type {
|
||||||
|
ApiRecentMatchesResponse,
|
||||||
|
ApiRecentMatchView,
|
||||||
|
} from "../../api/types";
|
||||||
|
import {
|
||||||
|
POSITION_LANES,
|
||||||
|
RECENT_GAME_LIMIT,
|
||||||
|
selectProfileGames,
|
||||||
|
type PositionFilter,
|
||||||
|
} from "./stats.ts";
|
||||||
|
|
||||||
|
/** Compatibility for older APIs: collect independent windows, never filter just the overall twenty. */
|
||||||
|
export async function collectProfileWindows(
|
||||||
|
fetchPage: (cursor?: number) => Promise<ApiRecentMatchesResponse>,
|
||||||
|
) {
|
||||||
|
const positions: PositionFilter[] = [
|
||||||
|
"ALL",
|
||||||
|
"TOP",
|
||||||
|
"JGL",
|
||||||
|
"MID",
|
||||||
|
"ADC",
|
||||||
|
"SUP",
|
||||||
|
];
|
||||||
|
const windows = new Map<PositionFilter, ApiRecentMatchView[]>(
|
||||||
|
positions.map((position) => [position, []]),
|
||||||
|
);
|
||||||
|
const seen = new Set<string>();
|
||||||
|
let cursor: number | undefined;
|
||||||
|
let first: ApiRecentMatchesResponse | undefined;
|
||||||
|
while (true) {
|
||||||
|
const page = await fetchPage(cursor);
|
||||||
|
first ??= page;
|
||||||
|
for (const game of [...page.matches].sort(
|
||||||
|
(a, b) => b.gameCreation - a.gameCreation,
|
||||||
|
)) {
|
||||||
|
const key = `${game.matchId}:${game.gameNumber ?? ""}`;
|
||||||
|
if (seen.has(key)) continue;
|
||||||
|
seen.add(key);
|
||||||
|
for (const position of positions) {
|
||||||
|
const window = windows.get(position)!;
|
||||||
|
if (
|
||||||
|
window.length < RECENT_GAME_LIMIT &&
|
||||||
|
(position === "ALL" || game.teamPosition === POSITION_LANES[position])
|
||||||
|
)
|
||||||
|
window.push(game);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
page.nextCursor === null ||
|
||||||
|
positions.every(
|
||||||
|
(position) => windows.get(position)!.length === RECENT_GAME_LIMIT,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
break;
|
||||||
|
if (
|
||||||
|
!Number.isFinite(page.nextCursor) ||
|
||||||
|
(cursor !== undefined && page.nextCursor >= cursor)
|
||||||
|
)
|
||||||
|
throw new Error("전적 페이지를 이어 불러오지 못했습니다.");
|
||||||
|
cursor = page.nextCursor;
|
||||||
|
}
|
||||||
|
const uniqueGames = new Map<string, ApiRecentMatchView>();
|
||||||
|
for (const window of windows.values())
|
||||||
|
for (const game of window)
|
||||||
|
uniqueGames.set(`${game.matchId}:${game.gameNumber ?? ""}`, game);
|
||||||
|
return {
|
||||||
|
...first,
|
||||||
|
matches: [...uniqueGames.values()],
|
||||||
|
positionCounts: Object.fromEntries(
|
||||||
|
positions.map((position) => [
|
||||||
|
position === "ALL" ? "ALL" : POSITION_LANES[position],
|
||||||
|
windows.get(position)!.length,
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
nextCursor: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function profileWindow(
|
||||||
|
history: ApiRecentMatchesResponse,
|
||||||
|
position: PositionFilter,
|
||||||
|
): ApiRecentMatchesResponse {
|
||||||
|
return { ...history, matches: selectProfileGames(history.matches, position) };
|
||||||
|
}
|
||||||
@@ -0,0 +1,653 @@
|
|||||||
|
.auction-player-profile {
|
||||||
|
container: auction-profile / inline-size;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.45;
|
||||||
|
}
|
||||||
|
.ap-identity {
|
||||||
|
padding: 20px;
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
.ap-player-avatar {
|
||||||
|
width: 64px;
|
||||||
|
height: 64px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
object-fit: cover;
|
||||||
|
border-radius: var(--radius-inner);
|
||||||
|
}
|
||||||
|
.ap-player-info {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
.ap-player-name {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 8px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
.ap-player-name h2 {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 750;
|
||||||
|
line-height: 1.2;
|
||||||
|
letter-spacing: -0.02em;
|
||||||
|
}
|
||||||
|
.ap-player-name > span,
|
||||||
|
.ap-secondary {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
}
|
||||||
|
.ap-rank {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.ap-peak {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
.ap-peak strong {
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
margin-left: 4px;
|
||||||
|
}
|
||||||
|
.ap-preferences {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
.ap-preferences > span:first-child {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
margin-right: 2px;
|
||||||
|
}
|
||||||
|
.ap-role-chip {
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
border-radius: 7px;
|
||||||
|
padding: 2px 6px;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
.ap-role-chip[data-primary="true"] {
|
||||||
|
color: var(--color-text-accent);
|
||||||
|
border-color: color-mix(in srgb, var(--color-text-accent) 22%, transparent);
|
||||||
|
background: color-mix(in srgb, var(--color-text-accent) 4%, transparent);
|
||||||
|
}
|
||||||
|
.ap-role-chip img {
|
||||||
|
width: 13px;
|
||||||
|
height: 13px;
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
.ap-role-chip small {
|
||||||
|
font-size: 10px;
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
.ap-tabs {
|
||||||
|
display: flex;
|
||||||
|
border-block: 1px solid var(--color-border);
|
||||||
|
padding-inline: 12px;
|
||||||
|
gap: 5px;
|
||||||
|
}
|
||||||
|
.ap-tabs button {
|
||||||
|
position: relative;
|
||||||
|
padding: 12px 11px;
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 650;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
.ap-tabs button[aria-selected="true"] {
|
||||||
|
color: var(--color-text-accent);
|
||||||
|
}
|
||||||
|
.ap-tabs button[aria-selected="true"]::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
height: 2px;
|
||||||
|
background: currentColor;
|
||||||
|
bottom: -1px;
|
||||||
|
left: 11px;
|
||||||
|
right: 11px;
|
||||||
|
}
|
||||||
|
.ap-tabs button:hover {
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
}
|
||||||
|
.ap-tabs button:focus-visible,
|
||||||
|
.ap-recent-game:focus-visible,
|
||||||
|
.ap-summary-heading a:focus-visible {
|
||||||
|
outline: 2px solid var(--color-text-accent);
|
||||||
|
outline-offset: -2px;
|
||||||
|
}
|
||||||
|
.ap-card-body {
|
||||||
|
padding: 16px 18px 12px;
|
||||||
|
}
|
||||||
|
.ap-summary-heading {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
.ap-summary-heading h3 {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
.ap-summary-heading a {
|
||||||
|
color: var(--color-text-accent);
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 3px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
.ap-champion-portrait {
|
||||||
|
display: inline-block;
|
||||||
|
height: 32px;
|
||||||
|
width: 32px;
|
||||||
|
flex: 0 0 32px;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: var(--radius-inner);
|
||||||
|
background: var(--color-background-muted);
|
||||||
|
}
|
||||||
|
.ap-champion-portrait img {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
transform: scale(1.18);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ap-card-body {
|
||||||
|
padding: 14px 18px 10px;
|
||||||
|
/* Reserve the full solo-rank view: 20 games, ten portraits and mastery row. */
|
||||||
|
height: 656px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow-y: auto;
|
||||||
|
scrollbar-width: thin;
|
||||||
|
}
|
||||||
|
.ap-card-body > * {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.ap-card-body > [role="tabpanel"] {
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
.ap-identity {
|
||||||
|
padding: 18px;
|
||||||
|
}
|
||||||
|
.ap-position-tabs {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||||
|
gap: 3px;
|
||||||
|
margin-top: 13px;
|
||||||
|
border-bottom: 1px solid var(--color-border);
|
||||||
|
}
|
||||||
|
.ap-position-tabs button {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 5px;
|
||||||
|
min-height: 41px;
|
||||||
|
position: relative;
|
||||||
|
border-radius: 5px 5px 0 0;
|
||||||
|
font-size: 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
padding: 6px 2px;
|
||||||
|
}
|
||||||
|
.ap-position-tabs button > span {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 3px;
|
||||||
|
}
|
||||||
|
.ap-position-tabs img {
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
.ap-position-tabs small {
|
||||||
|
font-size: 11px;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
.ap-position-tabs button[data-empty="true"] {
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
}
|
||||||
|
.ap-position-tabs button[aria-selected="true"] {
|
||||||
|
background: color-mix(in srgb, var(--color-text-accent) 5%, transparent);
|
||||||
|
color: var(--color-text-accent);
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
.ap-position-tabs button[aria-selected="true"]::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
left: 7px;
|
||||||
|
right: 7px;
|
||||||
|
bottom: -1px;
|
||||||
|
height: 2px;
|
||||||
|
background: var(--color-text-accent);
|
||||||
|
}
|
||||||
|
.ap-position-tabs button:hover {
|
||||||
|
background: var(--color-background-muted);
|
||||||
|
}
|
||||||
|
.ap-position-tabs button:focus-visible,
|
||||||
|
.ap-avatar:focus-visible,
|
||||||
|
.ap-mastery-icons > span:focus-visible {
|
||||||
|
outline: 2px solid var(--color-text-accent);
|
||||||
|
outline-offset: 2px;
|
||||||
|
z-index: 5;
|
||||||
|
}
|
||||||
|
.ap-sample-context {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 6px;
|
||||||
|
margin-top: 9px;
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
}
|
||||||
|
.ap-metrics {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
margin: 13px 0 9px;
|
||||||
|
}
|
||||||
|
.ap-metrics > div {
|
||||||
|
min-width: 0;
|
||||||
|
padding-inline: 13px;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr auto;
|
||||||
|
align-items: center;
|
||||||
|
gap: 3px 5px;
|
||||||
|
}
|
||||||
|
.ap-metrics > div:first-child {
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
.ap-metrics > div:last-child {
|
||||||
|
padding-right: 0;
|
||||||
|
}
|
||||||
|
.ap-metrics > div + div {
|
||||||
|
border-left: 1px solid var(--color-border);
|
||||||
|
}
|
||||||
|
.ap-metrics > div > span {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
}
|
||||||
|
.ap-metrics strong {
|
||||||
|
display: block;
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 750;
|
||||||
|
line-height: 1.25;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
letter-spacing: -0.03em;
|
||||||
|
}
|
||||||
|
.ap-metrics strong[data-perfect="true"] {
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 1.875;
|
||||||
|
}
|
||||||
|
.ap-metrics small {
|
||||||
|
font-size: 14px;
|
||||||
|
margin-left: 1px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
.ap-metrics p {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.ap-champions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 4px 12px;
|
||||||
|
min-height: 49px;
|
||||||
|
padding-block: 6px;
|
||||||
|
}
|
||||||
|
.ap-champions h3 {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
font-weight: 500;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.ap-avatar-group {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
.ap-avatar {
|
||||||
|
display: inline-flex;
|
||||||
|
position: relative;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 2px solid var(--color-background-card);
|
||||||
|
margin-left: -10px;
|
||||||
|
background: var(--color-background-card);
|
||||||
|
cursor: help;
|
||||||
|
}
|
||||||
|
.ap-avatar:hover,
|
||||||
|
.ap-avatar:focus {
|
||||||
|
z-index: 4;
|
||||||
|
}
|
||||||
|
.ap-avatar .ap-champion-portrait {
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
flex-basis: 30px;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
.ap-play-metrics {
|
||||||
|
padding-block: 9px;
|
||||||
|
border-block: 1px solid var(--color-border);
|
||||||
|
margin: 2px 0 14px;
|
||||||
|
}
|
||||||
|
.ap-section-heading {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 9px;
|
||||||
|
}
|
||||||
|
.ap-section-heading h3 {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
.ap-section-heading > span {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
}
|
||||||
|
.ap-play-metrics dl {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
.ap-play-metrics dt {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
}
|
||||||
|
.ap-play-metrics dd {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 650;
|
||||||
|
margin-top: 2px;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
.ap-recent table {
|
||||||
|
width: 100%;
|
||||||
|
table-layout: fixed;
|
||||||
|
border-collapse: collapse;
|
||||||
|
font-size: 12px;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
.ap-game-scroll {
|
||||||
|
max-height: 228px;
|
||||||
|
overflow-y: auto;
|
||||||
|
overscroll-behavior-y: contain;
|
||||||
|
scrollbar-width: thin;
|
||||||
|
scrollbar-color: var(--color-border) transparent;
|
||||||
|
}
|
||||||
|
.ap-game-scroll:focus-visible {
|
||||||
|
outline: 2px solid var(--color-text-accent);
|
||||||
|
outline-offset: 3px;
|
||||||
|
}
|
||||||
|
.ap-recent thead {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 1;
|
||||||
|
background: var(--color-background-card);
|
||||||
|
}
|
||||||
|
.ap-recent th {
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 500;
|
||||||
|
text-align: right;
|
||||||
|
padding: 0 0 6px;
|
||||||
|
}
|
||||||
|
.ap-recent th:first-child {
|
||||||
|
width: auto;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.ap-recent th:nth-child(2) {
|
||||||
|
width: 78px;
|
||||||
|
}
|
||||||
|
.ap-recent th:nth-child(3) {
|
||||||
|
width: 58px;
|
||||||
|
}
|
||||||
|
.ap-recent th:nth-child(4) {
|
||||||
|
width: 62px;
|
||||||
|
}
|
||||||
|
.ap-recent td {
|
||||||
|
text-align: right;
|
||||||
|
padding: 5px 0;
|
||||||
|
border-top: 1px solid var(--color-border);
|
||||||
|
}
|
||||||
|
.ap-recent td:first-child {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.ap-game-identity {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 7px;
|
||||||
|
}
|
||||||
|
.ap-game-identity > div {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
.ap-game-identity .ap-champion-portrait {
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
flex-basis: 28px;
|
||||||
|
}
|
||||||
|
.ap-game-identity strong {
|
||||||
|
display: block;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.25;
|
||||||
|
font-weight: 550;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.ap-game-identity b {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
.ap-game-identity b[data-result="win"] {
|
||||||
|
color: var(--color-palette-win-text-light);
|
||||||
|
}
|
||||||
|
.ap-game-identity b[data-result="loss"] {
|
||||||
|
color: var(--color-palette-loss-text-light);
|
||||||
|
}
|
||||||
|
[data-theme="dark"] .ap-game-identity b[data-result="win"] {
|
||||||
|
color: var(--color-palette-win-text-dark);
|
||||||
|
}
|
||||||
|
[data-theme="dark"] .ap-game-identity b[data-result="loss"] {
|
||||||
|
color: var(--color-palette-loss-text-dark);
|
||||||
|
}
|
||||||
|
.ap-game-identity p {
|
||||||
|
font-size: 10px;
|
||||||
|
line-height: 1.2;
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
white-space: nowrap;
|
||||||
|
margin-top: 1px;
|
||||||
|
}
|
||||||
|
.ap-masteries {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding-top: 12px;
|
||||||
|
margin-top: 8px;
|
||||||
|
border-top: 1px solid var(--color-border);
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
.ap-mastery-icons {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 5px;
|
||||||
|
}
|
||||||
|
.ap-mastery-icons > span {
|
||||||
|
display: inline-flex;
|
||||||
|
border-radius: var(--radius-inner);
|
||||||
|
cursor: help;
|
||||||
|
}
|
||||||
|
.ap-masteries .ap-champion-portrait {
|
||||||
|
width: 22px;
|
||||||
|
height: 22px;
|
||||||
|
flex-basis: 22px;
|
||||||
|
}
|
||||||
|
.ap-masteries small {
|
||||||
|
margin-left: auto;
|
||||||
|
font-size: 10px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.ap-data-note {
|
||||||
|
font-size: 10px;
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
margin-top: 11px;
|
||||||
|
}
|
||||||
|
.ap-empty {
|
||||||
|
padding: 32px 8px 40px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.ap-empty strong {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
.ap-empty p {
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
font-size: 12px;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
.ap-empty button {
|
||||||
|
color: var(--color-text-accent);
|
||||||
|
font-size: 12px;
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
border-radius: var(--radius-element);
|
||||||
|
padding: 8px 12px;
|
||||||
|
margin-top: 16px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
@container auction-profile (max-width: 480px) {
|
||||||
|
.ap-card-body {
|
||||||
|
height: 720px;
|
||||||
|
}
|
||||||
|
.ap-card-body {
|
||||||
|
padding-inline: 12px;
|
||||||
|
}
|
||||||
|
.ap-position-tabs {
|
||||||
|
gap: 1px;
|
||||||
|
}
|
||||||
|
.ap-position-tabs button {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
font-size: 11px;
|
||||||
|
min-height: 48px;
|
||||||
|
}
|
||||||
|
.ap-position-tabs img {
|
||||||
|
width: 11px;
|
||||||
|
height: 11px;
|
||||||
|
}
|
||||||
|
.ap-metrics > div {
|
||||||
|
padding-inline: 9px;
|
||||||
|
}
|
||||||
|
.ap-metrics {
|
||||||
|
gap: 0;
|
||||||
|
}
|
||||||
|
.ap-metrics > div {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.ap-metrics > div > span {
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
.ap-metrics strong {
|
||||||
|
font-size: 23px;
|
||||||
|
}
|
||||||
|
.ap-metrics p {
|
||||||
|
font-size: 10px;
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
.ap-metrics strong[data-perfect="true"] {
|
||||||
|
font-size: 17px;
|
||||||
|
}
|
||||||
|
.ap-champions {
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
.ap-champions h3 {
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
.ap-avatar .ap-champion-portrait {
|
||||||
|
width: 27px;
|
||||||
|
height: 27px;
|
||||||
|
flex-basis: 27px;
|
||||||
|
}
|
||||||
|
.ap-recent th:nth-child(2) {
|
||||||
|
width: 58px;
|
||||||
|
}
|
||||||
|
.ap-recent th:nth-child(3) {
|
||||||
|
width: 43px;
|
||||||
|
}
|
||||||
|
.ap-recent th:nth-child(4) {
|
||||||
|
width: 46px;
|
||||||
|
}
|
||||||
|
.ap-recent table {
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
.ap-game-identity {
|
||||||
|
gap: 5px;
|
||||||
|
}
|
||||||
|
.ap-game-identity strong {
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
.ap-game-identity p {
|
||||||
|
font-size: 9px;
|
||||||
|
}
|
||||||
|
.ap-masteries {
|
||||||
|
gap: 7px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.ap-identity > a {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.ap-player-name h2 {
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
.ap-player-name a:hover,
|
||||||
|
.ap-game-identity:hover {
|
||||||
|
color: var(--color-text-accent);
|
||||||
|
}
|
||||||
|
.ap-game-identity:focus-visible,
|
||||||
|
.ap-identity a:focus-visible {
|
||||||
|
outline: 2px solid var(--color-text-accent);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
.ap-game-identity strong {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
.ap-game-identity b[data-result="remake"] {
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
}
|
||||||
|
.ap-loading {
|
||||||
|
min-height: 360px;
|
||||||
|
padding-top: 24px;
|
||||||
|
color: var(--lts-text-subtle);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
.ap-loading > span {
|
||||||
|
display: block;
|
||||||
|
height: 64px;
|
||||||
|
border-radius: var(--radius-element);
|
||||||
|
background: var(--color-background-muted);
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
@container auction-profile (max-width: 480px) {
|
||||||
|
.ap-identity {
|
||||||
|
padding: 16px;
|
||||||
|
gap: 11px;
|
||||||
|
}
|
||||||
|
.ap-player-avatar {
|
||||||
|
width: 52px;
|
||||||
|
height: 52px;
|
||||||
|
}
|
||||||
|
.ap-player-name h2 {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
.ap-preferences > span:first-child {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
import type { ApiRecentMatchView, Position, RiotLane } from "../../api/types";
|
||||||
|
|
||||||
|
export type ProfileQueue = "internal" | "solo";
|
||||||
|
export type PositionFilter = "ALL" | Position;
|
||||||
|
export const RECENT_GAME_LIMIT = 20;
|
||||||
|
export const POSITION_LANES: Record<Position, RiotLane> = {
|
||||||
|
TOP: "TOP",
|
||||||
|
JGL: "JUNGLE",
|
||||||
|
MID: "MIDDLE",
|
||||||
|
ADC: "BOTTOM",
|
||||||
|
SUP: "UTILITY",
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The server filters before limiting. Keep the display window bounded and sorted. */
|
||||||
|
export function selectProfileGames(
|
||||||
|
history: ApiRecentMatchView[],
|
||||||
|
position: PositionFilter,
|
||||||
|
) {
|
||||||
|
return history
|
||||||
|
.filter(
|
||||||
|
(game) =>
|
||||||
|
position === "ALL" || game.teamPosition === POSITION_LANES[position],
|
||||||
|
)
|
||||||
|
.sort((a, b) => b.gameCreation - a.gameCreation)
|
||||||
|
.slice(0, RECENT_GAME_LIMIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
const mean = (values: (number | undefined)[]) => {
|
||||||
|
const known = values.filter(
|
||||||
|
(value): value is number =>
|
||||||
|
typeof value === "number" && Number.isFinite(value),
|
||||||
|
);
|
||||||
|
return known.length
|
||||||
|
? known.reduce((sum, value) => sum + value, 0) / known.length
|
||||||
|
: null;
|
||||||
|
};
|
||||||
|
|
||||||
|
function damageShare(game: ApiRecentMatchView) {
|
||||||
|
if (game.damageShare !== undefined) return game.damageShare;
|
||||||
|
// Older responses expose team totals rather than the computed percentage.
|
||||||
|
const team = game.teams?.find((team) => team.win === game.win);
|
||||||
|
if (!team?.participants.length) return undefined;
|
||||||
|
const total = team.participants.reduce(
|
||||||
|
(sum, participant) => sum + participant.damageDealtToChampions,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
return total > 0
|
||||||
|
? (game.damageDealtToChampions / total) * 100
|
||||||
|
: total === 0
|
||||||
|
? 0
|
||||||
|
: undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function summarizeProfileGames(games: ApiRecentMatchView[]) {
|
||||||
|
// Remakes remain visible in the list but do not distort win rate or performance.
|
||||||
|
const completed = games.filter((game) => !game.remake);
|
||||||
|
if (!completed.length) return null;
|
||||||
|
const kills = completed.reduce((sum, game) => sum + game.kills, 0);
|
||||||
|
const deaths = completed.reduce((sum, game) => sum + game.deaths, 0);
|
||||||
|
const assists = completed.reduce((sum, game) => sum + game.assists, 0);
|
||||||
|
const wins = completed.filter((game) => game.win).length;
|
||||||
|
const champions = new Map<
|
||||||
|
number,
|
||||||
|
{ championId: number; games: number; wins: number }
|
||||||
|
>();
|
||||||
|
for (const game of completed) {
|
||||||
|
const champion = champions.get(game.championId) ?? {
|
||||||
|
championId: game.championId,
|
||||||
|
games: 0,
|
||||||
|
wins: 0,
|
||||||
|
};
|
||||||
|
champion.games++;
|
||||||
|
champion.wins += Number(game.win);
|
||||||
|
champions.set(game.championId, champion);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
games: completed.length,
|
||||||
|
wins,
|
||||||
|
losses: completed.length - wins,
|
||||||
|
winRate: Math.round((wins / completed.length) * 100),
|
||||||
|
kda: deaths
|
||||||
|
? ((kills + assists) / deaths).toFixed(2)
|
||||||
|
: kills + assists > 0
|
||||||
|
? "Perfect"
|
||||||
|
: "0.00",
|
||||||
|
averageKda: [kills, deaths, assists]
|
||||||
|
.map((value) => (value / completed.length).toFixed(1))
|
||||||
|
.join("/"),
|
||||||
|
killParticipation: mean(completed.map((game) => game.killParticipation)),
|
||||||
|
csPerMinute: mean(completed.map((game) => game.csPerMin)),
|
||||||
|
damageShare: mean(completed.map(damageShare)),
|
||||||
|
visionPerMinute: mean(
|
||||||
|
completed.map((game) =>
|
||||||
|
game.gameDuration > 0 && Number.isFinite(game.visionScore)
|
||||||
|
? game.visionScore / (game.gameDuration / 60)
|
||||||
|
: undefined,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
champions: [...champions.values()].sort(
|
||||||
|
(a, b) => b.games - a.games || b.wins - a.wins,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function metricLabel(
|
||||||
|
value: number | null | undefined,
|
||||||
|
digits = 0,
|
||||||
|
suffix = "",
|
||||||
|
) {
|
||||||
|
return typeof value === "number" && Number.isFinite(value)
|
||||||
|
? `${value.toFixed(digits)}${suffix}`
|
||||||
|
: "—";
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import type { ApiRecentMatchesResponse } from "../../api/types";
|
||||||
|
import { DEFAULT_COMMUNITY_ID } from "../../config";
|
||||||
|
import { apiFetch } from "../../lib/api";
|
||||||
|
import {
|
||||||
|
POSITION_LANES,
|
||||||
|
RECENT_GAME_LIMIT,
|
||||||
|
type PositionFilter,
|
||||||
|
type ProfileQueue,
|
||||||
|
} from "./stats";
|
||||||
|
import { collectProfileWindows, profileWindow } from "./history";
|
||||||
|
|
||||||
|
export function useProfileHistory(
|
||||||
|
userId: string,
|
||||||
|
queue: ProfileQueue,
|
||||||
|
position: PositionFilter,
|
||||||
|
) {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const legacyKey = [
|
||||||
|
"auction-player-history-windows",
|
||||||
|
DEFAULT_COMMUNITY_ID,
|
||||||
|
userId,
|
||||||
|
queue,
|
||||||
|
];
|
||||||
|
return useQuery({
|
||||||
|
queryKey: [
|
||||||
|
"auction-player-history",
|
||||||
|
DEFAULT_COMMUNITY_ID,
|
||||||
|
userId,
|
||||||
|
queue,
|
||||||
|
position,
|
||||||
|
],
|
||||||
|
queryFn: async ({ signal }) => {
|
||||||
|
const params = new URLSearchParams({
|
||||||
|
limit: String(RECENT_GAME_LIMIT),
|
||||||
|
includePositionCounts: "true",
|
||||||
|
});
|
||||||
|
if (position !== "ALL") params.set("lane", POSITION_LANES[position]);
|
||||||
|
if (queue === "solo") {
|
||||||
|
params.set("queueGroup", "summoners-rift");
|
||||||
|
params.set("rank", "solo");
|
||||||
|
}
|
||||||
|
const resource =
|
||||||
|
queue === "internal" ? "internal-history" : "recent-matches";
|
||||||
|
const path = `/communities/${DEFAULT_COMMUNITY_ID}/users/${userId}/${resource}`;
|
||||||
|
const loadWindows = () =>
|
||||||
|
queryClient.fetchQuery({
|
||||||
|
queryKey: legacyKey,
|
||||||
|
staleTime: 60_000,
|
||||||
|
retry: false,
|
||||||
|
queryFn: ({ signal: windowSignal }) =>
|
||||||
|
collectProfileWindows((cursor) => {
|
||||||
|
const pageParams = new URLSearchParams(params);
|
||||||
|
pageParams.delete("lane");
|
||||||
|
pageParams.delete("includePositionCounts");
|
||||||
|
pageParams.set("limit", "30");
|
||||||
|
if (cursor !== undefined)
|
||||||
|
pageParams.set("cursor", String(cursor));
|
||||||
|
return apiFetch<ApiRecentMatchesResponse>(
|
||||||
|
`${path}?${pageParams}`,
|
||||||
|
{ auth: "none", signal: windowSignal },
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
if (queryClient.getQueryData(legacyKey))
|
||||||
|
return profileWindow(await loadWindows(), position);
|
||||||
|
const response = await apiFetch<ApiRecentMatchesResponse>(
|
||||||
|
`${path}?${params}`,
|
||||||
|
{ auth: "none", signal },
|
||||||
|
);
|
||||||
|
return response.positionCounts
|
||||||
|
? response
|
||||||
|
: profileWindow(await loadWindows(), position);
|
||||||
|
},
|
||||||
|
enabled: Boolean(DEFAULT_COMMUNITY_ID && userId),
|
||||||
|
staleTime: 60_000,
|
||||||
|
retry: 1,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { useDdragonManifest } from "../../api/hooks";
|
||||||
|
import type { DdragonManifest } from "../../api/types";
|
||||||
|
|
||||||
|
/** Keep player portraits available if the application's manifest endpoint is down. */
|
||||||
|
export function useProfileManifest() {
|
||||||
|
const manifest = useDdragonManifest();
|
||||||
|
const champions = useQuery({
|
||||||
|
queryKey: ["auction-profile-champion-manifest", "ko_KR"],
|
||||||
|
enabled: !manifest.data && manifest.failureCount > 0,
|
||||||
|
staleTime: 24 * 60 * 60 * 1000,
|
||||||
|
retry: 1,
|
||||||
|
queryFn: async ({ signal }): Promise<DdragonManifest> => {
|
||||||
|
const cdn = "https://ddragon.leagueoflegends.com/cdn";
|
||||||
|
const versionResponse = await fetch(
|
||||||
|
"https://ddragon.leagueoflegends.com/api/versions.json",
|
||||||
|
{ signal },
|
||||||
|
);
|
||||||
|
if (!versionResponse.ok)
|
||||||
|
throw new Error("챔피언 버전을 불러오지 못했습니다.");
|
||||||
|
const versions: string[] = await versionResponse.json();
|
||||||
|
const version = versions[0];
|
||||||
|
if (!version || !/^\d+\.\d+\.\d+$/.test(version))
|
||||||
|
throw new Error("챔피언 버전 정보가 올바르지 않습니다.");
|
||||||
|
const response = await fetch(
|
||||||
|
`${cdn}/${version}/data/ko_KR/champion.json`,
|
||||||
|
{ signal },
|
||||||
|
);
|
||||||
|
if (!response.ok) throw new Error("챔피언 정보를 불러오지 못했습니다.");
|
||||||
|
const payload: {
|
||||||
|
data: Record<string, { key: string; id: string; name: string }>;
|
||||||
|
} = await response.json();
|
||||||
|
// This separate cache supplies only this card's champion and profile portraits.
|
||||||
|
return {
|
||||||
|
version,
|
||||||
|
cdn,
|
||||||
|
locale: "ko_KR",
|
||||||
|
fetchedAt: new Date().toISOString(),
|
||||||
|
champions: Object.fromEntries(
|
||||||
|
Object.values(payload.data).map((champion) => [
|
||||||
|
champion.key,
|
||||||
|
{ key: champion.id, name: champion.name },
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
items: {},
|
||||||
|
summonerSpells: {},
|
||||||
|
runesReforged: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return manifest.data ?? champions.data;
|
||||||
|
}
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
.auction-reaction-picker-title {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
.auction-reaction-picker-description {
|
||||||
|
margin: 3px 0 12px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
.auction-reaction-options {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, minmax(44px, 1fr));
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
.auction-reaction-options .auction-reaction-option {
|
||||||
|
width: 100%;
|
||||||
|
height: 46px;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
.auction-reaction-option span[aria-hidden] {
|
||||||
|
font-size: 27px;
|
||||||
|
line-height: 1;
|
||||||
|
font-family:
|
||||||
|
"Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
|
||||||
|
}
|
||||||
|
.auction-reaction-options .auction-reaction-option:disabled {
|
||||||
|
opacity: 0.55;
|
||||||
|
}
|
||||||
|
.auction-reaction-error {
|
||||||
|
margin: 10px 0 0;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
}
|
||||||
|
.auction-chat-panel .auction-chat-reaction-trigger {
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
min-width: 36px;
|
||||||
|
border-radius: 8px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.auction-reaction-layer {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 60;
|
||||||
|
overflow: hidden;
|
||||||
|
pointer-events: none;
|
||||||
|
user-select: none;
|
||||||
|
contain: strict;
|
||||||
|
}
|
||||||
|
.auction-floating-reaction {
|
||||||
|
position: absolute;
|
||||||
|
bottom: max(20px, env(safe-area-inset-bottom));
|
||||||
|
left: clamp(54px, var(--reaction-left), calc(100% - 54px));
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 5px;
|
||||||
|
width: 100px;
|
||||||
|
margin-left: -50px;
|
||||||
|
animation: auction-reaction-rise 2.8s cubic-bezier(0.18, 0.6, 0.25, 1) both;
|
||||||
|
will-change: transform, opacity;
|
||||||
|
}
|
||||||
|
.auction-floating-emoji {
|
||||||
|
font-family:
|
||||||
|
"Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
|
||||||
|
font-size: 48px;
|
||||||
|
line-height: 1.15;
|
||||||
|
filter: drop-shadow(0 3px 5px #0002);
|
||||||
|
}
|
||||||
|
.auction-floating-name {
|
||||||
|
max-width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
border-radius: 999px;
|
||||||
|
padding: 3px 8px;
|
||||||
|
background: #22252ee6;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes auction-reaction-rise {
|
||||||
|
0% {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translate3d(0, 32px, 0) scale(0.65) rotate(0);
|
||||||
|
}
|
||||||
|
12% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
40% {
|
||||||
|
transform: translate3d(var(--reaction-drift), -18vh, 0) scale(1.08)
|
||||||
|
rotate(var(--reaction-tilt));
|
||||||
|
}
|
||||||
|
70% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translate3d(0, -48vh, 0) scale(0.9) rotate(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes auction-reaction-fade {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
15%,
|
||||||
|
75% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.auction-floating-reaction {
|
||||||
|
animation: auction-reaction-fade 2.8s linear both;
|
||||||
|
transform: none;
|
||||||
|
will-change: opacity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (pointer: coarse), (max-width: 639px) {
|
||||||
|
.auction-chat-panel .auction-chat-reaction-trigger {
|
||||||
|
width: 44px;
|
||||||
|
height: 44px;
|
||||||
|
min-width: 44px;
|
||||||
|
}
|
||||||
|
.auction-floating-emoji {
|
||||||
|
font-size: 40px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,8 +4,6 @@ import type {
|
|||||||
MatchId,
|
MatchId,
|
||||||
TeamId,
|
TeamId,
|
||||||
} from "@lolympus/contracts";
|
} from "@lolympus/contracts";
|
||||||
import { ChevronDown } from "lucide-react";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { useLocation } from "react-router";
|
import { useLocation } from "react-router";
|
||||||
import {
|
import {
|
||||||
formatCompetitionHistoryDate,
|
formatCompetitionHistoryDate,
|
||||||
@@ -73,10 +71,7 @@ export function CompetitionSeriesHistory({
|
|||||||
className="inline-flex min-h-11 shrink-0 items-center gap-1 px-2 text-xs font-bold text-content-muted transition-colors hover:bg-base-content/[0.03] hover:text-base-content focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary"
|
className="inline-flex min-h-11 shrink-0 items-center gap-1 px-2 text-xs font-bold text-content-muted transition-colors hover:bg-base-content/[0.03] hover:text-base-content focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary"
|
||||||
>
|
>
|
||||||
{jumpLabel}
|
{jumpLabel}
|
||||||
<ChevronDown
|
<span aria-hidden="true">↓</span>
|
||||||
className="h-4 w-4 text-primary"
|
|
||||||
aria-hidden="true"
|
|
||||||
/>
|
|
||||||
</a>
|
</a>
|
||||||
)}
|
)}
|
||||||
</header>
|
</header>
|
||||||
@@ -121,7 +116,6 @@ export function CompetitionSeriesHistory({
|
|||||||
communityId={communityId}
|
communityId={communityId}
|
||||||
matchId={matchId}
|
matchId={matchId}
|
||||||
historyPath={historyPath}
|
historyPath={historyPath}
|
||||||
currentHash={location.hash}
|
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
@@ -140,18 +134,15 @@ function SeriesHistoryRow({
|
|||||||
communityId,
|
communityId,
|
||||||
matchId,
|
matchId,
|
||||||
historyPath,
|
historyPath,
|
||||||
currentHash,
|
|
||||||
}: {
|
}: {
|
||||||
row: CompetitionSeriesHistoryRow;
|
row: CompetitionSeriesHistoryRow;
|
||||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
||||||
communityId: CommunityId;
|
communityId: CommunityId;
|
||||||
matchId: MatchId;
|
matchId: MatchId;
|
||||||
historyPath: string;
|
historyPath: string;
|
||||||
currentHash: string;
|
|
||||||
}) {
|
}) {
|
||||||
const detailsId = seriesHistoryDetailsId(row.series.seriesId);
|
const detailsId = seriesHistoryDetailsId(row.series.seriesId);
|
||||||
const seriesHash = `#${detailsId}`;
|
const seriesHash = `#${detailsId}`;
|
||||||
const [expanded, setExpanded] = useState(currentHash === seriesHash);
|
|
||||||
|
|
||||||
if (row.games.length === 0) {
|
if (row.games.length === 0) {
|
||||||
return (
|
return (
|
||||||
@@ -164,19 +155,14 @@ function SeriesHistoryRow({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<details
|
<section id={detailsId} className="group scroll-mt-24">
|
||||||
id={detailsId}
|
<header>
|
||||||
className="group scroll-mt-24"
|
|
||||||
open={expanded}
|
|
||||||
onToggle={(event) => setExpanded(event.currentTarget.open)}
|
|
||||||
>
|
|
||||||
<summary className="list-none cursor-pointer transition-colors hover:bg-base-content/[0.04] active:bg-base-content/[0.06] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary group-open:bg-base-content/[0.025] [&::-webkit-details-marker]:hidden">
|
|
||||||
<SeriesSummary
|
<SeriesSummary
|
||||||
row={row}
|
row={row}
|
||||||
teamById={teamById}
|
teamById={teamById}
|
||||||
hasGameDetails
|
hasGameDetails
|
||||||
/>
|
/>
|
||||||
</summary>
|
</header>
|
||||||
<CompetitionGameHistory
|
<CompetitionGameHistory
|
||||||
games={row.games}
|
games={row.games}
|
||||||
teamById={teamById}
|
teamById={teamById}
|
||||||
@@ -184,7 +170,7 @@ function SeriesHistoryRow({
|
|||||||
matchId={matchId}
|
matchId={matchId}
|
||||||
historyBackTo={`${historyPath}${seriesHash}`}
|
historyBackTo={`${historyPath}${seriesHash}`}
|
||||||
/>
|
/>
|
||||||
</details>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,10 +189,9 @@ function SeriesSummary({
|
|||||||
series.stage.type,
|
series.stage.type,
|
||||||
series.stage.roundNumber,
|
series.stage.roundNumber,
|
||||||
);
|
);
|
||||||
const closedRecordLabel = getSeriesHistoryRecordLabel(
|
const recordLabel = getSeriesHistoryRecordLabel(
|
||||||
series,
|
series,
|
||||||
row.games.length,
|
row.games.length,
|
||||||
false,
|
|
||||||
);
|
);
|
||||||
const showRecordLabel = hasGameDetails || !isFutureSeries(series);
|
const showRecordLabel = hasGameDetails || !isFutureSeries(series);
|
||||||
|
|
||||||
@@ -228,20 +213,7 @@ function SeriesSummary({
|
|||||||
|
|
||||||
{showRecordLabel && (
|
{showRecordLabel && (
|
||||||
<span className="mt-2 flex min-h-6 items-center justify-end text-xs font-bold text-content-muted lg:col-start-3 lg:row-start-1 lg:mt-0">
|
<span className="mt-2 flex min-h-6 items-center justify-end text-xs font-bold text-content-muted lg:col-start-3 lg:row-start-1 lg:mt-0">
|
||||||
{hasGameDetails ? (
|
<span>{recordLabel}</span>
|
||||||
<>
|
|
||||||
<span className="group-open:hidden">{closedRecordLabel}</span>
|
|
||||||
<span className="hidden group-open:inline">
|
|
||||||
{getSeriesHistoryRecordLabel(series, row.games.length, true)}
|
|
||||||
</span>
|
|
||||||
<ChevronDown
|
|
||||||
className="ml-1 h-4 w-4 text-primary transition-transform group-open:rotate-180 motion-reduce:transition-none"
|
|
||||||
aria-hidden="true"
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<span>{closedRecordLabel}</span>
|
|
||||||
)}
|
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -23,10 +23,6 @@ export function DoubleEliminationMobileBracket({
|
|||||||
projection.series.map((series) => [series.seriesId, series]),
|
projection.series.map((series) => [series.seriesId, series]),
|
||||||
);
|
);
|
||||||
const nodeById = new Map(layout.nodes.map((node) => [node.seriesId, node]));
|
const nodeById = new Map(layout.nodes.map((node) => [node.seriesId, node]));
|
||||||
const isCurrentRound = (seriesIds: readonly SeriesId[]) => seriesIds.some((seriesId) => {
|
|
||||||
const status = seriesById.get(seriesId)?.status;
|
|
||||||
return status === "ready" || status === "in-progress";
|
|
||||||
});
|
|
||||||
const sections = [
|
const sections = [
|
||||||
{
|
{
|
||||||
key: "upper",
|
key: "upper",
|
||||||
@@ -77,17 +73,11 @@ export function DoubleEliminationMobileBracket({
|
|||||||
</div>
|
</div>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{groups.map((group) => (
|
{groups.map((group) => (
|
||||||
<details
|
<section key={`${group.stage}:${group.roundNumber}`} className="group lts-panel">
|
||||||
key={`${group.stage}:${group.roundNumber}`}
|
<h4 className="px-3 py-3 text-sm font-semibold ">
|
||||||
open={groups.length === 1 || isCurrentRound(group.seriesIds)}
|
|
||||||
className="group lts-panel"
|
|
||||||
>
|
|
||||||
<summary
|
|
||||||
className="cursor-pointer px-3 py-3 text-sm font-semibold hover:bg-sunken"
|
|
||||||
>
|
|
||||||
{group.accessibleLabel}
|
{group.accessibleLabel}
|
||||||
<span className="ml-2 text-xs font-medium text-content-muted">{group.seriesIds.length}경기</span>
|
<span className="ml-2 text-xs font-medium text-content-muted">{group.seriesIds.length}경기</span>
|
||||||
</summary>
|
</h4>
|
||||||
<div className="space-y-3 border-t border-line p-3">
|
<div className="space-y-3 border-t border-line p-3">
|
||||||
{group.seriesIds.map((seriesId) => {
|
{group.seriesIds.map((seriesId) => {
|
||||||
const series = seriesById.get(seriesId);
|
const series = seriesById.get(seriesId);
|
||||||
@@ -117,7 +107,7 @@ export function DoubleEliminationMobileBracket({
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</section>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import type { CompetitionTeamView } from "@lolympus/contracts";
|
||||||
|
import { sortTeamMembersForRoster } from "../../pages/match-team-progress-view";
|
||||||
|
import { SummonerAvatar } from "../SummonerAvatar";
|
||||||
|
|
||||||
|
export function TeamMemberSummary({ team }: { team: CompetitionTeamView }) {
|
||||||
|
const members = sortTeamMembersForRoster(team.members);
|
||||||
|
if (members.length === 0) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5">
|
||||||
|
<span className="flex shrink-0 -space-x-1.5 py-1.5 pr-1" aria-hidden="true">
|
||||||
|
{members.map((member) => (
|
||||||
|
<SummonerAvatar
|
||||||
|
key={member.userId}
|
||||||
|
profileIconId={member.profileIconId}
|
||||||
|
isCaptain={member.userId === team.captainUserId}
|
||||||
|
size="sm"
|
||||||
|
shape="circle"
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</span>
|
||||||
|
<p className="min-w-0 basis-48 grow text-[13px] leading-5 text-content-muted">
|
||||||
|
{members.map((member, index) => (
|
||||||
|
<span key={member.userId}>
|
||||||
|
{index > 0 && <span aria-hidden="true"> · </span>}
|
||||||
|
{index > 0 && <span className="sr-only">, </span>}
|
||||||
|
<span className="inline-block max-w-full align-top [overflow-wrap:anywhere]">{member.displayName}</span>
|
||||||
|
{member.userId === team.captainUserId && <span className="sr-only"> (팀장)</span>}
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import type { CompetitionTeamView } from "@lolympus/contracts";
|
||||||
|
import { Link } from "react-router";
|
||||||
|
import { positionLabel } from "../../lib/league";
|
||||||
|
import { sortTeamMembersForRoster } from "../../pages/match-team-progress-view";
|
||||||
|
import { SummonerAvatar } from "../SummonerAvatar";
|
||||||
|
|
||||||
|
export function TeamRoster({ team }: { team: CompetitionTeamView }) {
|
||||||
|
return (
|
||||||
|
<ul className="lts-panel divide-y divide-line">
|
||||||
|
{sortTeamMembersForRoster(team.members).map((member) => (
|
||||||
|
<li key={member.userId}>
|
||||||
|
<Link
|
||||||
|
to={`/users/${member.userId}/history?queueGroup=internal`}
|
||||||
|
className="group grid min-h-16 grid-cols-[2.5rem_2.5rem_minmax(0,1fr)] items-center gap-3 px-4 py-3 transition-colors hover:bg-sunken focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary sm:px-5"
|
||||||
|
>
|
||||||
|
<span className="text-xs font-semibold text-content-muted">
|
||||||
|
{member.assignedPosition ? positionLabel[member.assignedPosition] : "미정"}
|
||||||
|
</span>
|
||||||
|
<SummonerAvatar
|
||||||
|
profileIconId={member.profileIconId}
|
||||||
|
isCaptain={member.userId === team.captainUserId}
|
||||||
|
/>
|
||||||
|
<span className="min-w-0 text-sm font-bold text-base-content [overflow-wrap:anywhere] group-hover:underline">
|
||||||
|
{member.displayName}
|
||||||
|
<span className="sr-only"> 전적 보기</span>
|
||||||
|
</span>
|
||||||
|
</Link>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
type TeamSeriesTone,
|
type TeamSeriesTone,
|
||||||
} from "../../pages/match-team-progress-view";
|
} from "../../pages/match-team-progress-view";
|
||||||
import { isSeriesEntryWinner } from "./series-score-card-model";
|
import { isSeriesEntryWinner } from "./series-score-card-model";
|
||||||
|
import { TeamMemberSummary } from "./TeamMemberSummary";
|
||||||
|
|
||||||
const STATUS_TONE_CLASS: Record<TeamSeriesTone, string> = {
|
const STATUS_TONE_CLASS: Record<TeamSeriesTone, string> = {
|
||||||
muted: "border-base-content/15 bg-base-200 text-base-content",
|
muted: "border-base-content/15 bg-base-200 text-base-content",
|
||||||
@@ -38,7 +39,7 @@ export function TeamSeriesCard({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<article
|
<article
|
||||||
className={`overflow-hidden border bg-base-100 ${
|
className={`overflow-hidden rounded-box border bg-base-100 ${
|
||||||
emphasized ? "border-primary/30" : "border-base-content/10"
|
emphasized ? "border-primary/30" : "border-base-content/10"
|
||||||
}`}
|
}`}
|
||||||
aria-labelledby={headingId}
|
aria-labelledby={headingId}
|
||||||
@@ -50,19 +51,19 @@ export function TeamSeriesCard({
|
|||||||
: "border-base-content/10 bg-base-200/40"
|
: "border-base-content/10 bg-base-200/40"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<div className="min-w-0">
|
<div className="flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 self-center">
|
||||||
<h3
|
<h3
|
||||||
id={headingId}
|
id={headingId}
|
||||||
className="break-words text-base font-black text-base-content"
|
className="break-words text-xs font-bold text-content-muted"
|
||||||
>
|
>
|
||||||
{displayLabel}
|
{displayLabel}
|
||||||
</h3>
|
</h3>
|
||||||
<div className="mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-content-muted">
|
<div className="text-xs text-content-muted">
|
||||||
<span>{seriesRuleLabel(series)}</span>
|
<span>{seriesRuleLabel(series)}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span
|
<span
|
||||||
className={`shrink-0 border-l-2 px-2 py-1 text-xs font-bold ${STATUS_TONE_CLASS[presentation.tone]}`}
|
className={`inline-flex shrink-0 items-center rounded-full border px-2 py-1 text-xs font-bold ${STATUS_TONE_CLASS[presentation.tone]}`}
|
||||||
>
|
>
|
||||||
{presentation.label}
|
{presentation.label}
|
||||||
</span>
|
</span>
|
||||||
@@ -81,32 +82,33 @@ export function TeamSeriesCard({
|
|||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
key={entry.slot}
|
key={entry.slot}
|
||||||
className={`grid min-h-12 grid-cols-[minmax(0,1fr)_3rem] items-center gap-3 px-4 py-2.5 sm:px-5 ${
|
className="grid grid-cols-[minmax(0,1fr)_2.5rem] items-center gap-3 px-4 py-3 sm:px-5"
|
||||||
isHighlightedTeam ? "bg-base-200/35" : ""
|
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
|
<div className="min-w-0 space-y-1.5">
|
||||||
<div className="flex min-w-0 flex-wrap items-center gap-2">
|
<div className="flex min-w-0 flex-wrap items-center gap-2">
|
||||||
<span
|
<span
|
||||||
className={`min-w-0 break-words text-sm ${
|
className={`min-w-0 break-words text-base text-base-content ${
|
||||||
isWinner || isHighlightedTeam
|
isWinner || isHighlightedTeam
|
||||||
? "font-bold text-base-content"
|
? "font-bold"
|
||||||
: "text-content-subtle"
|
: "font-semibold"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<span className="sr-only">{entry.slot} 슬롯: </span>
|
<span className="sr-only">{entry.slot} 슬롯: </span>
|
||||||
{teamName}
|
{teamName}
|
||||||
</span>
|
</span>
|
||||||
{isHighlightedTeam && (
|
{isHighlightedTeam && (
|
||||||
<span className="border border-base-content/15 bg-base-100 px-1.5 py-0.5 text-[11px] font-bold text-base-content">
|
<span className="inline-flex items-center rounded-full border border-base-content/15 bg-base-100 px-1.5 py-0.5 text-[11px] font-bold text-base-content">
|
||||||
이 팀
|
우리 팀
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{isWinner && (
|
{isWinner && (
|
||||||
<span className="border-l-2 border-success bg-success/10 px-1.5 py-0.5 text-[11px] font-bold text-base-content">
|
<span className="inline-flex items-center rounded-full border border-success bg-success/10 px-1.5 py-0.5 text-[11px] font-bold text-base-content">
|
||||||
승리
|
승리
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
{team && <TeamMemberSummary team={team} />}
|
||||||
|
</div>
|
||||||
<span className="text-right font-mono text-base font-bold tabular-nums text-base-content">
|
<span className="text-right font-mono text-base font-bold tabular-nums text-base-content">
|
||||||
<span className="sr-only">
|
<span className="sr-only">
|
||||||
{presentation.showScore ? "게임 승수: " : "점수 없음"}
|
{presentation.showScore ? "게임 승수: " : "점수 없음"}
|
||||||
@@ -129,7 +131,7 @@ export function TeamSeriesCard({
|
|||||||
|
|
||||||
function seriesRuleLabel(series: SeriesProjection): string {
|
function seriesRuleLabel(series: SeriesProjection): string {
|
||||||
if (series.rule.type === "fixed-games") {
|
if (series.rule.type === "fixed-games") {
|
||||||
return `${series.rule.gameCount}게임`;
|
return `총 ${series.rule.gameCount}경기`;
|
||||||
}
|
}
|
||||||
return `${series.rule.maxGames}전 ${series.rule.winsRequired}선승`;
|
return `${series.rule.maxGames}전 ${series.rule.winsRequired}선승`;
|
||||||
}
|
}
|
||||||
@@ -99,9 +99,6 @@ export function TeamTournamentCodes({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const nextAssignment = assignments.find((assignment) => assignment.state !== "used") ?? assignments[0];
|
|
||||||
const otherAssignments = assignments.filter((assignment) => assignment !== nextAssignment);
|
|
||||||
|
|
||||||
function renderAssignment(assignment: TeamTournamentCodeView) {
|
function renderAssignment(assignment: TeamTournamentCodeView) {
|
||||||
const slotId = String(assignment.gameSlotId);
|
const slotId = String(assignment.gameSlotId);
|
||||||
const presentation = getTournamentCodePresentation(assignment, now);
|
const presentation = getTournamentCodePresentation(assignment, now);
|
||||||
@@ -111,16 +108,26 @@ export function TeamTournamentCodes({
|
|||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
key={slotId}
|
key={slotId}
|
||||||
className="grid gap-3 px-4 py-3 sm:px-5 md:grid-cols-[5.5rem_minmax(0,1fr)_auto] md:items-center"
|
className="grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-2 px-4 py-3 sm:grid-cols-[5.5rem_minmax(0,1fr)_auto] sm:px-5"
|
||||||
>
|
>
|
||||||
|
<div className="col-span-2 flex flex-wrap items-center gap-x-3 gap-y-1 sm:col-span-1 sm:block">
|
||||||
<div>
|
<div>
|
||||||
<p className="text-sm font-bold text-base-content">
|
<p className="text-sm font-bold text-base-content">
|
||||||
{assignment.ordinal}세트
|
{assignment.ordinal}세트
|
||||||
</p>
|
</p>
|
||||||
<p className="mt-0.5 text-xs text-content-muted">
|
<p className="mt-0.5 text-xs text-content-muted">
|
||||||
전체 {assignment.displayNumber}경기
|
대회 경기 #{assignment.displayNumber}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<span
|
||||||
|
className={`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[11px] font-semibold sm:mt-1.5 ${CODE_TONE_CLASS[presentation.tone]}`}
|
||||||
|
role="status"
|
||||||
|
aria-live="polite"
|
||||||
|
aria-atomic="true"
|
||||||
|
>
|
||||||
|
{presentation.label}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
{assignment.code ? (
|
{assignment.code ? (
|
||||||
@@ -147,19 +154,11 @@ export function TeamTournamentCodes({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-wrap items-center gap-2 md:justify-end">
|
<div className="flex min-w-20 justify-end">
|
||||||
<span
|
|
||||||
className={`border-l-2 px-2 py-1 text-xs font-bold ${CODE_TONE_CLASS[presentation.tone]}`}
|
|
||||||
role="status"
|
|
||||||
aria-live="polite"
|
|
||||||
aria-atomic="true"
|
|
||||||
>
|
|
||||||
{presentation.label}
|
|
||||||
</span>
|
|
||||||
{assignment.code && assignment.state === "reserved" && (
|
{assignment.code && assignment.state === "reserved" && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="inline-flex min-h-11 items-center justify-center gap-1.5 border border-base-content/20 bg-base-100 px-3 text-sm font-bold text-base-content hover:border-primary/50 hover:bg-primary/5 focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-70"
|
className="inline-flex min-h-11 min-w-20 items-center justify-center gap-1.5 rounded-field border border-base-content/20 bg-base-100 px-3 text-sm font-bold text-base-content hover:border-primary/50 hover:bg-primary/5 focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-70"
|
||||||
aria-label={
|
aria-label={
|
||||||
presentation.canCopy
|
presentation.canCopy
|
||||||
? getTournamentCodeCopyLabel(assignment, seriesLabel)
|
? getTournamentCodeCopyLabel(assignment, seriesLabel)
|
||||||
@@ -197,22 +196,13 @@ export function TeamTournamentCodes({
|
|||||||
className="border-t border-base-content/10 bg-sunken/50"
|
className="border-t border-base-content/10 bg-sunken/50"
|
||||||
aria-label={`${seriesLabel} 토너먼트 코드`}
|
aria-label={`${seriesLabel} 토너먼트 코드`}
|
||||||
>
|
>
|
||||||
<div className="px-4 pt-3 sm:px-5">
|
<div className="flex items-center justify-between gap-3 border-b border-line px-4 py-3 sm:px-5">
|
||||||
<h4 className="text-sm font-bold">토너먼트 코드</h4>
|
<h4 className="text-sm font-bold">토너먼트 코드</h4>
|
||||||
|
<span className="text-xs text-content-muted">{assignments.length}세트</span>
|
||||||
</div>
|
</div>
|
||||||
<ol>
|
<ol className="divide-y divide-line">
|
||||||
{renderAssignment(nextAssignment)}
|
{assignments.map(renderAssignment)}
|
||||||
</ol>
|
</ol>
|
||||||
{otherAssignments.length > 0 && (
|
|
||||||
<details className="border-t border-line">
|
|
||||||
<summary className="cursor-pointer px-4 py-3 text-sm font-semibold hover:bg-sunken sm:px-5">
|
|
||||||
다른 세트 코드 · {otherAssignments.length}개
|
|
||||||
</summary>
|
|
||||||
<ol className="divide-y divide-line border-t border-line">
|
|
||||||
{otherAssignments.map(renderAssignment)}
|
|
||||||
</ol>
|
|
||||||
</details>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{feedback && (
|
{feedback && (
|
||||||
<p
|
<p
|
||||||
|
|||||||
@@ -193,10 +193,9 @@ export function getSeriesHistoryResultLabel(
|
|||||||
export function getSeriesHistoryRecordLabel(
|
export function getSeriesHistoryRecordLabel(
|
||||||
series: CompetitionSeriesHistorySeries,
|
series: CompetitionSeriesHistorySeries,
|
||||||
gameCount: number,
|
gameCount: number,
|
||||||
expanded: boolean,
|
|
||||||
): string {
|
): string {
|
||||||
if (gameCount > 0) {
|
if (gameCount > 0) {
|
||||||
return expanded ? "게임 상세 접기" : `게임 상세 (${gameCount})`;
|
return `게임 기록 ${gameCount}개`;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
series.status === "inactive" ||
|
series.status === "inactive" ||
|
||||||
|
|||||||
@@ -0,0 +1,288 @@
|
|||||||
|
import {
|
||||||
|
ArrowRight,
|
||||||
|
CalendarDays,
|
||||||
|
ChevronRight,
|
||||||
|
Clock3,
|
||||||
|
Info,
|
||||||
|
Users,
|
||||||
|
} from "lucide-react";
|
||||||
|
import type { SeriesProjection } from "@lolympus/contracts";
|
||||||
|
import type { ApiInternalMatchCard } from "../../api/types";
|
||||||
|
import pixelMedal from "../../assets/pixel-medal-first.svg";
|
||||||
|
import { formatOfficialMatchResult } from "../../lib/internal-stats-presentation";
|
||||||
|
import {
|
||||||
|
getSeriesHistoryResultLabel,
|
||||||
|
shouldDisplaySeriesHistoryScore,
|
||||||
|
} from "../competition/competition-series-history";
|
||||||
|
import { StatsLink } from "./StatsShared";
|
||||||
|
import { statsDate, statsDuration } from "./stats-navigation";
|
||||||
|
import { statsGroups } from "./stats-model";
|
||||||
|
|
||||||
|
function statsFormat(match: ApiInternalMatchCard) {
|
||||||
|
const result = match.resultPresentation;
|
||||||
|
if (result?.type !== "official")
|
||||||
|
return match.teams.length === 2 ? "두 팀 내전" : "내전 기록";
|
||||||
|
return {
|
||||||
|
"paired-series": "두 팀 내전",
|
||||||
|
"double-elimination": "더블 엘리미네이션",
|
||||||
|
"round-robin": "리그전",
|
||||||
|
}[result.formatType];
|
||||||
|
}
|
||||||
|
function seriesLabel(series: SeriesProjection | undefined) {
|
||||||
|
if (!series) return "공식 시리즈 정보 없음";
|
||||||
|
if (series.stage.type === "pair")
|
||||||
|
return series.rule.type === "first-to"
|
||||||
|
? `${series.rule.winsRequired}선승 시리즈`
|
||||||
|
: `${series.rule.gameCount}세트 시리즈`;
|
||||||
|
return `${{ upper: "승자조", lower: "패자조", "grand-final": "최종 결승", "reset-final": "결승 재경기", "round-robin": "리그" }[series.stage.type]}${series.stage.roundNumber ? ` ${series.stage.roundNumber}라운드` : ""}`;
|
||||||
|
}
|
||||||
|
export function StatsEventOverview({ match }: { match: ApiInternalMatchCard }) {
|
||||||
|
const analyzed = match.games.every(
|
||||||
|
(g) => g.analysisAvailability !== undefined,
|
||||||
|
)
|
||||||
|
? match.games.filter((g) => g.analysisAvailability === "available").length
|
||||||
|
: "—";
|
||||||
|
return (
|
||||||
|
<div className="is-event-overview">
|
||||||
|
<div className="is-event-meta">
|
||||||
|
<span>
|
||||||
|
<CalendarDays size={14} />
|
||||||
|
<time dateTime={match.scheduledAt}>
|
||||||
|
{statsDate(match.scheduledAt)}{" "}
|
||||||
|
{new Intl.DateTimeFormat("ko-KR", {
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
hour12: false,
|
||||||
|
timeZone: "Asia/Seoul",
|
||||||
|
}).format(new Date(match.scheduledAt))}
|
||||||
|
</time>
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<Users size={14} />
|
||||||
|
{match.teams.length}팀 ·{" "}
|
||||||
|
{match.teams.reduce((n, t) => n + t.members.length, 0)}명
|
||||||
|
</span>
|
||||||
|
<span>{match.games.length}세트 결과</span>
|
||||||
|
<span className="is-analysis-count">{analyzed}세트 분석 가능</span>
|
||||||
|
</div>
|
||||||
|
<span className="is-champion-label">
|
||||||
|
<img src={pixelMedal} alt="" className="size-4 shrink-0 [image-rendering:pixelated]" />
|
||||||
|
<strong>{formatOfficialMatchResult(match.resultPresentation)}</strong>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export function StatsSeries({
|
||||||
|
match,
|
||||||
|
gameHref,
|
||||||
|
}: {
|
||||||
|
match: ApiInternalMatchCard;
|
||||||
|
gameHref: (number: number) => string;
|
||||||
|
}) {
|
||||||
|
const team = (index: number) =>
|
||||||
|
match.teams.find((t) => t.teamIndex === index)?.name ?? `${index}팀`;
|
||||||
|
const officialTeam = (id: string | null) =>
|
||||||
|
match.teams.find((t) => t.teamId === id)?.name ??
|
||||||
|
(id ? "팀 미확인" : "상대 미정");
|
||||||
|
return (
|
||||||
|
<div className="is-series-grid">
|
||||||
|
{statsGroups(match).map(({ id, series, games }) => {
|
||||||
|
const first = games[0],
|
||||||
|
label = seriesLabel(series);
|
||||||
|
const [a, b] = series?.entries ?? [];
|
||||||
|
const score = series && shouldDisplaySeriesHistoryScore(series);
|
||||||
|
const winner =
|
||||||
|
series?.status === "completed" && series.outcome.type !== "draw"
|
||||||
|
? series.outcome.winnerTeamId
|
||||||
|
: null;
|
||||||
|
return (
|
||||||
|
<section className="is-series-group" key={id} aria-label={label}>
|
||||||
|
<header>
|
||||||
|
<span>{label}</span>
|
||||||
|
<span>
|
||||||
|
{games.length}세트
|
||||||
|
{series &&
|
||||||
|
score &&
|
||||||
|
games.length !== (a?.gameWins ?? 0) + (b?.gameWins ?? 0)
|
||||||
|
? " · 기간 내 기록"
|
||||||
|
: ""}
|
||||||
|
</span>
|
||||||
|
</header>
|
||||||
|
<div className="is-matchup">
|
||||||
|
<strong
|
||||||
|
className={winner && winner === a?.teamId ? "is-winner" : ""}
|
||||||
|
>
|
||||||
|
{a
|
||||||
|
? officialTeam(a.teamId)
|
||||||
|
: first
|
||||||
|
? team(first.blueTeamIndex)
|
||||||
|
: "팀 미확인"}
|
||||||
|
</strong>
|
||||||
|
<span className="is-score">
|
||||||
|
{score ? (
|
||||||
|
<>
|
||||||
|
<b>{a?.gameWins}</b>
|
||||||
|
<i>:</i>
|
||||||
|
<b>{b?.gameWins}</b>
|
||||||
|
</>
|
||||||
|
) : series ? (
|
||||||
|
(getSeriesHistoryResultLabel(series) ?? "VS")
|
||||||
|
) : (
|
||||||
|
"VS"
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
<strong
|
||||||
|
className={winner && winner === b?.teamId ? "is-winner" : ""}
|
||||||
|
>
|
||||||
|
{b
|
||||||
|
? officialTeam(b.teamId)
|
||||||
|
: first
|
||||||
|
? team(first.redTeamIndex)
|
||||||
|
: "팀 미확인"}
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
|
<ul>
|
||||||
|
{games.map((game) => (
|
||||||
|
<li key={game.gameNumber}>
|
||||||
|
<span className="is-set-number">
|
||||||
|
{game.ordinal ?? game.gameNumber}세트
|
||||||
|
<small>전체 #{game.gameNumber}</small>
|
||||||
|
</span>
|
||||||
|
<span className="is-set-winner">
|
||||||
|
{game.winnerTeamIndex !== null ? (
|
||||||
|
<>
|
||||||
|
<span className="is-win-badge">승</span>
|
||||||
|
{team(game.winnerTeamIndex)}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
"결과 미확정"
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
<span className="is-duration">
|
||||||
|
<Clock3 size={12} />
|
||||||
|
{statsDuration(game.gameDuration)}
|
||||||
|
</span>
|
||||||
|
<StatsLink
|
||||||
|
className={`is-analysis-link ${game.analysisAvailability !== "available" ? "is-unavailable" : ""}`}
|
||||||
|
to={gameHref(game.gameNumber)}
|
||||||
|
data-return-id={`set-${match.matchId}-${game.gameNumber}`}
|
||||||
|
aria-label={`${match.title} 전체 ${game.gameNumber}세트 ${game.analysisAvailability === "missing" ? "원본 상태 확인" : "상세 분석"}`}
|
||||||
|
>
|
||||||
|
{game.analysisAvailability === "missing"
|
||||||
|
? "원본 없음"
|
||||||
|
: game.analysisAvailability === "pending"
|
||||||
|
? "준비 중"
|
||||||
|
: "분석"}
|
||||||
|
{game.analysisAvailability === "missing" ? (
|
||||||
|
<Info size={12} />
|
||||||
|
) : (
|
||||||
|
<ChevronRight size={13} />
|
||||||
|
)}
|
||||||
|
</StatsLink>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
{games.length === 0 && (
|
||||||
|
<p className="is-muted">
|
||||||
|
{series && getSeriesHistoryResultLabel(series)} · 기록된 세트
|
||||||
|
없음
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export function StatsEvent({
|
||||||
|
match,
|
||||||
|
eventHref,
|
||||||
|
gameHref,
|
||||||
|
}: {
|
||||||
|
match: ApiInternalMatchCard;
|
||||||
|
eventHref: string;
|
||||||
|
gameHref: (number: number) => string;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<article className="is-event-section" id={`event-${match.matchId}`}>
|
||||||
|
<header>
|
||||||
|
<div>
|
||||||
|
<div className="is-event-kicker">
|
||||||
|
<span>{statsFormat(match)}</span>
|
||||||
|
{Boolean(match.series?.length) && (
|
||||||
|
<span>{match.series!.length}개 시리즈</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<h3>
|
||||||
|
<StatsLink to={eventHref} data-return-id={`event-${match.matchId}`}>
|
||||||
|
{match.title}
|
||||||
|
<ChevronRight size={18} />
|
||||||
|
</StatsLink>
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<StatsLink
|
||||||
|
className="is-text-link is-event-detail-link"
|
||||||
|
to={eventHref}
|
||||||
|
data-return-id={`event-detail-${match.matchId}`}
|
||||||
|
>
|
||||||
|
전체 기록
|
||||||
|
<ArrowRight size={15} />
|
||||||
|
</StatsLink>
|
||||||
|
</header>
|
||||||
|
<StatsEventOverview match={match} />
|
||||||
|
<StatsSeries match={match} gameHref={gameHref} />
|
||||||
|
{match.games.length === 0 && (
|
||||||
|
<p className="is-event-empty is-muted">
|
||||||
|
기록된 세트가 없습니다. 전체 기록에서 공식 결과를 확인할 수 있습니다.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</article>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export function StatsEventJump({
|
||||||
|
matches,
|
||||||
|
}: {
|
||||||
|
matches: ApiInternalMatchCard[];
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<nav className="is-event-jump" aria-label="내전 바로가기">
|
||||||
|
<div className="is-jump-desktop">
|
||||||
|
<p>
|
||||||
|
<CalendarDays size={15} /> 내전 바로가기
|
||||||
|
</p>
|
||||||
|
{matches.map((m) => (
|
||||||
|
<a href={`#event-${m.matchId}`} key={m.matchId}>
|
||||||
|
<span>{statsDate(m.scheduledAt)}</span>
|
||||||
|
<strong>{m.title}</strong>
|
||||||
|
<small>{statsFormat(m)}</small>
|
||||||
|
</a>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<label className="is-jump-mobile">
|
||||||
|
<CalendarDays size={16} />
|
||||||
|
<span>내전 이동</span>
|
||||||
|
<select
|
||||||
|
aria-label="내전 바로가기"
|
||||||
|
defaultValue=""
|
||||||
|
onChange={(e) =>
|
||||||
|
document.getElementById(`event-${e.target.value}`)?.scrollIntoView({
|
||||||
|
behavior: matchMedia("(prefers-reduced-motion: reduce)").matches
|
||||||
|
? "instant"
|
||||||
|
: "smooth",
|
||||||
|
block: "start",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<option value="" disabled>
|
||||||
|
날짜로 바로가기
|
||||||
|
</option>
|
||||||
|
{matches.map((m) => (
|
||||||
|
<option key={m.matchId} value={m.matchId}>
|
||||||
|
{statsDate(m.scheduledAt)} · {m.title}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,200 @@
|
|||||||
|
import { ArrowDown, ArrowDownUp, ArrowRight, Info } from "lucide-react";
|
||||||
|
import type {
|
||||||
|
ApiLeaderboardRow,
|
||||||
|
DdragonManifest,
|
||||||
|
RiotLane,
|
||||||
|
} from "../../api/types";
|
||||||
|
import { getMainLane } from "../../lib/internal-stats-presentation";
|
||||||
|
import { profileIconUrl } from "../../lib/ddragon";
|
||||||
|
import { LANE_LABELS } from "../../lib/riot-history";
|
||||||
|
import { StatsChampion, StatsLink } from "./StatsShared";
|
||||||
|
|
||||||
|
import { STATS_SORTS, type StatsSort } from "./stats-model";
|
||||||
|
export function StatsLeaderboard({
|
||||||
|
rows,
|
||||||
|
minimum,
|
||||||
|
lane,
|
||||||
|
sort,
|
||||||
|
direction,
|
||||||
|
onSort,
|
||||||
|
playerHref,
|
||||||
|
participationHref,
|
||||||
|
manifest,
|
||||||
|
}: {
|
||||||
|
rows: Array<ApiLeaderboardRow & { rank: number }>;
|
||||||
|
minimum: number;
|
||||||
|
lane?: RiotLane;
|
||||||
|
sort: StatsSort;
|
||||||
|
direction: "asc" | "desc";
|
||||||
|
onSort: (key: StatsSort) => void;
|
||||||
|
playerHref: (id: string) => string;
|
||||||
|
participationHref: (id: string) => string;
|
||||||
|
manifest?: DdragonManifest;
|
||||||
|
}) {
|
||||||
|
const metric = (key: StatsSort, label: string) => (
|
||||||
|
<th
|
||||||
|
scope="col"
|
||||||
|
aria-sort={
|
||||||
|
sort === key
|
||||||
|
? direction === "desc"
|
||||||
|
? "descending"
|
||||||
|
: "ascending"
|
||||||
|
: "none"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
className={sort === key ? "is-sorted" : ""}
|
||||||
|
onClick={() => onSort(key)}
|
||||||
|
>
|
||||||
|
{label}
|
||||||
|
{sort === key ? (
|
||||||
|
<ArrowDown
|
||||||
|
size={13}
|
||||||
|
className={direction === "asc" ? "is-arrow-up" : ""}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<ArrowDownUp size={12} />
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
</th>
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<p className="is-table-hint">
|
||||||
|
<ArrowRight size={14} />
|
||||||
|
옆으로 이동하면 모든 지표를 볼 수 있어요. 선수 이름은 고정됩니다.
|
||||||
|
</p>
|
||||||
|
<div
|
||||||
|
className="is-table-scroll"
|
||||||
|
role="region"
|
||||||
|
tabIndex={0}
|
||||||
|
aria-label="선수 순위표, 좌우 방향키로 지표 이동"
|
||||||
|
>
|
||||||
|
<table className="is-leaderboard">
|
||||||
|
<caption className="sr-only">
|
||||||
|
{lane ? LANE_LABELS[lane] : "전체 포지션"} · {STATS_SORTS[sort]}{" "}
|
||||||
|
{direction === "desc" ? "높은" : "낮은"} 순 · 최소 {minimum}판
|
||||||
|
</caption>
|
||||||
|
<colgroup>
|
||||||
|
<col className="is-col-rank" />
|
||||||
|
<col className="is-col-player" />
|
||||||
|
<col className="is-col-win" />
|
||||||
|
<col className="is-col-games" />
|
||||||
|
<col className="is-col-kda" />
|
||||||
|
<col className="is-col-champions" />
|
||||||
|
<col />
|
||||||
|
<col />
|
||||||
|
<col />
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col" className="is-sticky-rank">
|
||||||
|
순위
|
||||||
|
</th>
|
||||||
|
<th scope="col" className="is-sticky-player">
|
||||||
|
선수
|
||||||
|
</th>
|
||||||
|
{metric("winRate", "승률")}
|
||||||
|
{metric("games", "판수")}
|
||||||
|
{metric("kda", "KDA")}
|
||||||
|
<th scope="col">주 챔피언</th>
|
||||||
|
{metric("avgGoldPerMin", "GPM")}
|
||||||
|
{metric("avgKillParticipation", "킬 관여")}
|
||||||
|
{metric("avgCsPerMin", "CS/분")}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{rows.map((row) => (
|
||||||
|
<tr
|
||||||
|
key={row.userId}
|
||||||
|
className={row.games < minimum ? "is-under-qualified" : ""}
|
||||||
|
>
|
||||||
|
<td className="is-sticky-rank">
|
||||||
|
<span className="is-rank-number">{row.rank}</span>
|
||||||
|
</td>
|
||||||
|
<th scope="row" className="is-sticky-player">
|
||||||
|
<div className="is-player-identity">
|
||||||
|
<img
|
||||||
|
className="is-champion"
|
||||||
|
src={profileIconUrl(manifest, row.profileIconId)}
|
||||||
|
alt=""
|
||||||
|
loading="lazy"
|
||||||
|
/>
|
||||||
|
<div>
|
||||||
|
<StatsLink
|
||||||
|
to={playerHref(row.userId)}
|
||||||
|
data-return-id={`player-${row.userId}`}
|
||||||
|
>
|
||||||
|
{row.summonerName}
|
||||||
|
</StatsLink>
|
||||||
|
<small>
|
||||||
|
{LANE_LABELS[lane ?? getMainLane(row.byLane) ?? ""] ??
|
||||||
|
"포지션 미확인"}
|
||||||
|
<span>·</span>
|
||||||
|
<StatsLink
|
||||||
|
to={participationHref(row.userId)}
|
||||||
|
data-return-id={`participation-${row.userId}`}
|
||||||
|
>
|
||||||
|
참가 내전
|
||||||
|
</StatsLink>
|
||||||
|
</small>
|
||||||
|
{row.games < minimum && (
|
||||||
|
<span className="is-sample-badge">기준 미달</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<strong className={row.winRate >= 50 ? "is-blue" : ""}>
|
||||||
|
{row.winRate}
|
||||||
|
<small>%</small>
|
||||||
|
</strong>
|
||||||
|
<div className="is-win-track" aria-hidden="true">
|
||||||
|
<span style={{ width: `${row.winRate}%` }} />
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<strong>{row.games}</strong>
|
||||||
|
<small className="is-win-loss">
|
||||||
|
{row.wins}승 {row.losses}패
|
||||||
|
</small>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<strong className={row.kda >= 3 ? "is-green" : ""}>
|
||||||
|
{row.kda.toFixed(2)}
|
||||||
|
</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div className="is-champion-list">
|
||||||
|
{row.topChampions.map((c) => (
|
||||||
|
<span key={c.championId}>
|
||||||
|
<StatsChampion
|
||||||
|
id={c.championId}
|
||||||
|
manifest={manifest}
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
<small>{c.games}</small>
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>{row.avgGoldPerMin}</td>
|
||||||
|
<td>{row.avgKillParticipation}%</td>
|
||||||
|
<td>{row.avgCsPerMin}</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div className="is-table-footnote">
|
||||||
|
<Info size={14} />
|
||||||
|
<p>
|
||||||
|
KDA는 (킬 + 어시스트) ÷ 데스, GPM은 분당 골드입니다.{" "}
|
||||||
|
{lane &&
|
||||||
|
`${LANE_LABELS[lane]}로 플레이한 경기의 모든 지표를 다시 집계합니다. `}
|
||||||
|
검색해도 전체 순위는 유지됩니다.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,181 @@
|
|||||||
|
import {
|
||||||
|
useEffect,
|
||||||
|
useState,
|
||||||
|
type ComponentProps,
|
||||||
|
type ReactNode,
|
||||||
|
} from "react";
|
||||||
|
import { Link } from "react-router";
|
||||||
|
import {
|
||||||
|
ArrowLeft,
|
||||||
|
Check,
|
||||||
|
Copy,
|
||||||
|
LoaderCircle,
|
||||||
|
Search,
|
||||||
|
ShieldAlert,
|
||||||
|
} from "lucide-react";
|
||||||
|
import type {
|
||||||
|
ApiHistorySeason,
|
||||||
|
DdragonManifest,
|
||||||
|
RiotLane,
|
||||||
|
} from "../../api/types";
|
||||||
|
import { championDisplayName, championIconUrl } from "../../lib/ddragon";
|
||||||
|
import { LANE_LABELS } from "../../lib/riot-history";
|
||||||
|
import "./internal-stats.css";
|
||||||
|
import { STATS_LANES, rememberStatsVisit } from "./stats-navigation";
|
||||||
|
|
||||||
|
export function StatsLink(props: ComponentProps<typeof Link>) {
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
{...props}
|
||||||
|
onClick={(event) => {
|
||||||
|
rememberStatsVisit();
|
||||||
|
props.onClick?.(event);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export function StatsBack({
|
||||||
|
to,
|
||||||
|
children = "내전 전적으로 돌아가기",
|
||||||
|
}: {
|
||||||
|
to: string;
|
||||||
|
children?: ReactNode;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<StatsLink className="is-back-link" to={to}>
|
||||||
|
<ArrowLeft size={16} />
|
||||||
|
{children}
|
||||||
|
</StatsLink>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export function StatsFeedback({
|
||||||
|
type,
|
||||||
|
title,
|
||||||
|
children,
|
||||||
|
action,
|
||||||
|
}: {
|
||||||
|
type: "empty" | "error" | "loading";
|
||||||
|
title: string;
|
||||||
|
children?: ReactNode;
|
||||||
|
action?: ReactNode;
|
||||||
|
}) {
|
||||||
|
const Icon =
|
||||||
|
type === "loading" ? LoaderCircle : type === "error" ? ShieldAlert : Search;
|
||||||
|
return (
|
||||||
|
<section
|
||||||
|
className={`is-feedback is-feedback-${type}`}
|
||||||
|
role={type === "error" ? "alert" : "status"}
|
||||||
|
>
|
||||||
|
<Icon size={26} aria-hidden="true" />
|
||||||
|
<h2>{title}</h2>
|
||||||
|
{children && <p>{children}</p>}
|
||||||
|
{action && <div className="is-feedback-actions">{action}</div>}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export function StatsChampion({
|
||||||
|
id,
|
||||||
|
manifest,
|
||||||
|
size = "normal",
|
||||||
|
}: {
|
||||||
|
id: number;
|
||||||
|
manifest?: DdragonManifest;
|
||||||
|
size?: "small" | "normal" | "large";
|
||||||
|
}) {
|
||||||
|
const src = championIconUrl(manifest, id),
|
||||||
|
name = championDisplayName(manifest, id) ?? "챔피언";
|
||||||
|
return src ? (
|
||||||
|
<img
|
||||||
|
className={`is-champion is-champion-${size}`}
|
||||||
|
src={src}
|
||||||
|
alt={name}
|
||||||
|
title={name}
|
||||||
|
loading="lazy"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<span
|
||||||
|
className={`is-champion is-champion-${size}`}
|
||||||
|
aria-label="챔피언 이미지 없음"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export function StatsSeasonControls({
|
||||||
|
value,
|
||||||
|
seasons,
|
||||||
|
onChange,
|
||||||
|
label,
|
||||||
|
}: {
|
||||||
|
value: string;
|
||||||
|
seasons?: ApiHistorySeason[];
|
||||||
|
onChange: (value: string) => void;
|
||||||
|
label?: string;
|
||||||
|
}) {
|
||||||
|
const [notice, setNotice] = useState("");
|
||||||
|
useEffect(() => {
|
||||||
|
if (!notice) return;
|
||||||
|
const timer = setTimeout(() => setNotice(""), 3000);
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, [notice]);
|
||||||
|
return (
|
||||||
|
<div className="is-page-actions">
|
||||||
|
<button
|
||||||
|
className="is-icon-button"
|
||||||
|
aria-label="현재 전적 링크 복사"
|
||||||
|
onClick={() =>
|
||||||
|
void navigator.clipboard.writeText(location.href).then(
|
||||||
|
() => setNotice("현재 조건이 포함된 링크를 복사했습니다."),
|
||||||
|
() => setNotice("주소 표시줄의 링크를 복사해 주세요."),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{notice ? <Check size={17} /> : <Copy size={17} />}
|
||||||
|
</button>
|
||||||
|
<label className="is-season-select">
|
||||||
|
<span>집계 시즌</span>
|
||||||
|
<select value={value} onChange={(e) => onChange(e.target.value)}>
|
||||||
|
<option value="current">현재 시즌</option>
|
||||||
|
{seasons
|
||||||
|
?.filter((s) => !["current", "all"].includes(s.id))
|
||||||
|
.map((s) => (
|
||||||
|
<option key={s.id} value={s.id}>
|
||||||
|
{s.label}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
<option value="all">전체 시즌</option>
|
||||||
|
{!["current", "all"].includes(value) &&
|
||||||
|
!seasons?.some((s) => s.id === value) && (
|
||||||
|
<option value={value}>{label ?? value}</option>
|
||||||
|
)}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<div className="is-announcement" role="status">
|
||||||
|
{notice}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export function StatsLaneSelect({
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
}: {
|
||||||
|
value?: RiotLane;
|
||||||
|
onChange: (value: string) => void;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<label className="is-select">
|
||||||
|
<span className="sr-only">플레이 포지션</span>
|
||||||
|
<select
|
||||||
|
aria-label="플레이 포지션"
|
||||||
|
value={value ?? ""}
|
||||||
|
onChange={(e) => onChange(e.target.value)}
|
||||||
|
>
|
||||||
|
<option value="">전체 포지션</option>
|
||||||
|
{STATS_LANES.map((lane) => (
|
||||||
|
<option key={lane} value={lane}>
|
||||||
|
{LANE_LABELS[lane]}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
import { ChevronRight, Trophy } from "lucide-react";
|
||||||
|
import type {
|
||||||
|
ApiLeaderHighlight,
|
||||||
|
ApiTeamInsightsResponse,
|
||||||
|
} from "../../api/types";
|
||||||
|
import { StatsLink } from "./StatsShared";
|
||||||
|
import { statsPeriod } from "./stats-navigation";
|
||||||
|
export function StatsSummary({
|
||||||
|
data,
|
||||||
|
href,
|
||||||
|
}: {
|
||||||
|
data: ApiTeamInsightsResponse;
|
||||||
|
href: (highlight: ApiLeaderHighlight) => string;
|
||||||
|
}) {
|
||||||
|
const total = data.totals,
|
||||||
|
rate = data.sideWinRate.confirmed;
|
||||||
|
const records = [
|
||||||
|
{
|
||||||
|
label: "평균 KDA",
|
||||||
|
value: data.topKda,
|
||||||
|
scope: `시즌 최고 · 최소 ${data.minGamesThreshold}판`,
|
||||||
|
suffix: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "누적 킬",
|
||||||
|
value: data.mostKills,
|
||||||
|
scope: "시즌 누적",
|
||||||
|
suffix: "킬",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "분당 골드",
|
||||||
|
value: data.topTeamGpm,
|
||||||
|
scope: "단일 경기 최고",
|
||||||
|
suffix: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "평균 킬 관여",
|
||||||
|
value: data.topKillParticipation,
|
||||||
|
scope: `시즌 최고 · 최소 ${data.minGamesThreshold}판`,
|
||||||
|
suffix: "%",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "평균 분당 CS",
|
||||||
|
value: data.bestFarm,
|
||||||
|
scope: `시즌 최고 · 최소 ${data.minGamesThreshold}판`,
|
||||||
|
suffix: "",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
return (
|
||||||
|
<section className="is-season-summary" aria-label="커뮤니티 전체 시즌 요약">
|
||||||
|
<div className="is-summary-topline">
|
||||||
|
<span>
|
||||||
|
<span className="is-current-dot" />
|
||||||
|
{data.season.label} 요약
|
||||||
|
</span>
|
||||||
|
<span className="is-muted">
|
||||||
|
커뮤니티 전체 · {statsPeriod(data.season)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="is-summary-metrics">
|
||||||
|
<div>
|
||||||
|
<span>진행한 내전</span>
|
||||||
|
<strong>
|
||||||
|
{total?.matches ?? "—"}
|
||||||
|
<small>회</small>
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span>기록된 세트</span>
|
||||||
|
<strong>
|
||||||
|
{total?.games ?? "—"}
|
||||||
|
<small>판</small>
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span>참가 선수</span>
|
||||||
|
<strong>
|
||||||
|
{total?.players ?? "—"}
|
||||||
|
<small>명</small>
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
|
<div className="is-side-rate">
|
||||||
|
<span>
|
||||||
|
진영 승률<small>{rate?.sampleSize ?? 0}세트 기준</small>
|
||||||
|
</span>
|
||||||
|
<div>
|
||||||
|
<strong className="is-blue">
|
||||||
|
{rate?.sampleSize ? rate.blue : "—"}
|
||||||
|
<small>%</small>
|
||||||
|
</strong>
|
||||||
|
<span>BLUE / RED</span>
|
||||||
|
<strong className="is-red">
|
||||||
|
{rate?.sampleSize ? rate.red : "—"}
|
||||||
|
<small>%</small>
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
|
<div className="is-side-track" aria-hidden="true">
|
||||||
|
<span style={{ width: `${rate?.blue ?? 50}%` }} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="is-records-heading">
|
||||||
|
<Trophy size={14} />
|
||||||
|
<h2>시즌 기록</h2>
|
||||||
|
<span>
|
||||||
|
분석 가능한 {total?.analyzedGames ?? "—"}세트 기준 · 검색 조건과 별도
|
||||||
|
집계
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="is-records">
|
||||||
|
{records.map((record) => (
|
||||||
|
<div className="is-record" key={record.label}>
|
||||||
|
<p>
|
||||||
|
{record.label}
|
||||||
|
<span>{record.scope}</span>
|
||||||
|
</p>
|
||||||
|
<div>
|
||||||
|
<strong>
|
||||||
|
{record.value?.metric ?? "—"}
|
||||||
|
<small>{record.suffix}</small>
|
||||||
|
</strong>
|
||||||
|
{record.value ? (
|
||||||
|
<StatsLink
|
||||||
|
to={href(record.value)}
|
||||||
|
data-return-id={`record-${record.label}`}
|
||||||
|
aria-label={`${record.label} ${record.value.summonerName} ${record.value.isSingleGame ? "근거 경기" : "시즌 전적"}`}
|
||||||
|
>
|
||||||
|
{record.value.summonerName}
|
||||||
|
<ChevronRight size={13} />
|
||||||
|
</StatsLink>
|
||||||
|
) : (
|
||||||
|
<span className="is-muted">기록 없음</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
# 내전 전적 제품 반영 · 2026-11-11
|
||||||
|
|
||||||
|
승인된 `src/design-previews/internal-stats` 시안의 정보 구조와 스타일을 실제 라우트와 API에 반영했다. 시안의 fixture는 제품 코드에서 사용하지 않는다. 모든 세트는 표시하며 접기/아코디언을 추가하지 않았다.
|
||||||
|
|
||||||
|
## 반영 범위
|
||||||
|
|
||||||
|
- 시즌 전체 요약과 5개 기록, 최근 내전/선수 순위의 별도 검색, 날짜·유형·참가 선수 조건, 조건 초기화, 이전 내전 더 보기.
|
||||||
|
- 공식 `seriesId`와 세트 순번으로 대결을 묶는다. 같은 두 팀의 재대결을 합치거나 누락된 라운드를 추정하지 않는다. 공식 경기 결과와 원본 분석 가능 상태를 구분한다.
|
||||||
|
- 6개 지표 정렬, 최소 0/5/10/20판, 기준 충족 선수만 보기, 검색 후에도 전체 순위 유지, 모바일 선수 이름 고정과 표 내부 가로 스크롤.
|
||||||
|
- 개인 전적 라우트, 시즌/포지션/챔피언별 집계와 세트 목록, 참가 내전 및 상세 분석 연결. URL에 조건과 로드한 페이지 수를 보존한다.
|
||||||
|
- 상세 분석의 기존 타임라인·스코어보드·라인전·룬/빌드는 유지하고 헤더, 선수 링크, 분석 탭 URL, 복귀 경로를 연결했다. 복귀 시 스크롤과 포커스를 복원하며 중첩 경로의 이전 링크는 세션에 보관한다.
|
||||||
|
- 실패/빈 결과/로딩/원본 없음 상태, 재시도와 복귀 동작, 키보드 탭 이동, 감소된 모션 설정을 지원한다.
|
||||||
|
|
||||||
|
## API 계약
|
||||||
|
|
||||||
|
기존 공개 읽기 API를 확장했다. 스키마 마이그레이션이나 새 서비스 의존성은 없다.
|
||||||
|
|
||||||
|
| 경로 (`/communities/:communityId` 기준) | 변경 |
|
||||||
|
| --- | --- |
|
||||||
|
| `/internal-stats/matches` | 내전명·팀명·선수명 검색, 공식 series/팀 ID와 세트 순번·분석 상태 반환. 날짜 범위와 커서 조건을 함께 유지한다. |
|
||||||
|
| `/internal-stats/leaderboard` | `lane=TOP/JUNGLE/MIDDLE/BOTTOM/UTILITY` 검증, 해당 경기만으로 모든 지표 재집계. lane별 캐시 분리. |
|
||||||
|
| `/internal-stats/team-insights` | `totals.matches/games/analyzedGames/players`, 단일 경기 기록의 `internalMatchId/gameNumber` 추가. |
|
||||||
|
| `/users/:userId/internal-history` | 포지션 필터, `playerStats`, `internalMatchTitle`. 챔피언 선택 목록은 선택한 챔피언으로 축소하지 않는다. |
|
||||||
|
| `/internal-stats/match/:matchId` | 목록과 같은 공식 시리즈 식별자 및 분석 상태 제공. 상세 응답 캐시 버전 9. |
|
||||||
|
|
||||||
|
날짜만 받은 경우 한국 시간 00:00:00.000~23:59:59.999로 해석하며 시즌 범위와 교집합을 사용한다. 잘못된 날짜와 역전된 범위는 400이다. 원본이 없는 세트는 공식 결과/세트 수에는 남기고 KDA 등 상세 지표에서는 제외한다. API 응답 캐시의 presentation 버전을 변경해 예전 응답과 분리했다.
|
||||||
|
|
||||||
|
## 검증
|
||||||
|
|
||||||
|
- 전적 API 8개 suite, 60개 테스트 통과. 새 테스트는 실제 Nest HTTP 라우트에 Supertest 요청을 보내 포지션별 응답과 400을 확인한다. DB/캐시 경계에는 fixture를 사용했다.
|
||||||
|
- 웹 전체 테스트 186개 통과. 제품용 추가 테스트는 자격 판수 우선 정렬, 원본 배열 불변, 공식 재대결/순번, 검색·시즌 조건을 담은 복귀 URL을 검증한다.
|
||||||
|
- 웹 TypeScript/변경 범위 ESLint, API TypeScript/변경 범위 ESLint 통과. API build와 웹 staging build 통과. 웹에는 기존 큰 번들 경고가 남는다.
|
||||||
|
- 기존 개발 서버 데이터를 연결한 브라우저에서 검색 `귤`, KDA 정렬, 순위 1/45 유지, 개인 화면 이동 후 검색·정렬·선수 포커스 복귀를 확인했다.
|
||||||
|
- 390px 모바일에서 문서 폭 375px=내용 폭 375px(스크롤바 제외), 표 내부 780px 스크롤과 sticky 선수 열 확인. 데스크톱도 문서 가로 넘침 없음.
|
||||||
|
- 상세 API 실패 시 모바일에 복귀 링크와 재시도 버튼이 표시된다. 변경 중 HMR에서 발생한 hook 순서 경고는 최종 새로고침 뒤 추가 발생하지 않았다.
|
||||||
|
|
||||||
|
## 증거와 검증 한계
|
||||||
|
|
||||||
|
화면 자료: `C:/Users/park/.codex/visualizations/2026/11/11/01a1c9d5-e028-75a0-8b1b-f70126da1d08/internal-stats-production/`
|
||||||
|
|
||||||
|
- `01-desktop-ranking.jpg`: 조건과 포커스 복귀.
|
||||||
|
- `02-mobile-ranking.jpg`: 고정 선수 열과 가로 스크롤.
|
||||||
|
- `03-mobile-error.jpg`: 상세 요청 실패에서 복귀/재시도.
|
||||||
|
- `04-final-desktop.jpg`: 최종 새로고침한 화면.
|
||||||
|
|
||||||
|
현재 개발 서버 API는 이번 변경을 배포하지 않은 상태다. 새 `totals`, `series`, `playerStats`와 포지션 집계의 실제 서버 검증은 미완료이며, 화면 자료의 `—`는 새 집계 항목이 없는 응답이다. 상세 분석 요청도 실패하여 실제 데이터 차트의 최종 시각 검증은 배포 후 필요하다. 이 항목들은 fixture HTTP 계약 테스트 통과와 구분한다.
|
||||||
|
|
||||||
|
사용자의 최종 지시에 따라 커밋, main 푸시, 배포를 수행하지 않았다. 배포 후에는 시즌 요약 수치, 포지션별 모든 지표, 공식 시리즈·원본 없는 세트, 개인 전적→분석→목록 복귀를 실제 데이터로 확인한다.
|
||||||
|
|
||||||
|
final result: local checks passed; staging integration pending deployment
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,54 @@
|
|||||||
|
import type { ApiInternalMatchCard, ApiLeaderboardRow } from "../../api/types";
|
||||||
|
export const STATS_SORTS = {
|
||||||
|
games: "참여 경기 수",
|
||||||
|
winRate: "승률",
|
||||||
|
kda: "KDA",
|
||||||
|
avgGoldPerMin: "분당 골드",
|
||||||
|
avgKillParticipation: "킬 관여율",
|
||||||
|
avgCsPerMin: "분당 CS",
|
||||||
|
};
|
||||||
|
export type StatsSort = keyof typeof STATS_SORTS;
|
||||||
|
export function parseStatsSort(value: string | null): StatsSort {
|
||||||
|
return value && Object.hasOwn(STATS_SORTS, value)
|
||||||
|
? (value as StatsSort)
|
||||||
|
: "games";
|
||||||
|
}
|
||||||
|
export function sortStatsRows(
|
||||||
|
rows: readonly ApiLeaderboardRow[],
|
||||||
|
sort: StatsSort,
|
||||||
|
minimum: number,
|
||||||
|
direction: "asc" | "desc",
|
||||||
|
) {
|
||||||
|
return [...rows]
|
||||||
|
.sort(
|
||||||
|
(a, b) =>
|
||||||
|
Number(b.games >= minimum) - Number(a.games >= minimum) ||
|
||||||
|
(a[sort] - b[sort]) * (direction === "desc" ? -1 : 1) ||
|
||||||
|
b.games - a.games ||
|
||||||
|
a.summonerName.localeCompare(b.summonerName, "ko") ||
|
||||||
|
a.userId.localeCompare(b.userId),
|
||||||
|
)
|
||||||
|
.map((row, i) => ({ ...row, rank: i + 1 }));
|
||||||
|
}
|
||||||
|
export function statsGroups(match: ApiInternalMatchCard) {
|
||||||
|
const series = match.series ?? [];
|
||||||
|
const known = new Set<string>(series.map((s) => s.seriesId));
|
||||||
|
return [
|
||||||
|
...series.map((s) => ({
|
||||||
|
id: s.seriesId,
|
||||||
|
series: s,
|
||||||
|
games: match.games
|
||||||
|
.filter((g) => g.seriesId === s.seriesId)
|
||||||
|
.sort(
|
||||||
|
(a, b) => (a.ordinal ?? a.gameNumber) - (b.ordinal ?? b.gameNumber),
|
||||||
|
),
|
||||||
|
})),
|
||||||
|
...match.games
|
||||||
|
.filter((g) => !g.seriesId || !known.has(g.seriesId))
|
||||||
|
.map((g) => ({
|
||||||
|
id: `game-${g.gameNumber}`,
|
||||||
|
series: undefined,
|
||||||
|
games: [g],
|
||||||
|
})),
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
import { useLayoutEffect, useRef } from "react";
|
||||||
|
import { useLocation, useSearchParams } from "react-router";
|
||||||
|
import type { ApiHistorySeason, RiotLane } from "../../api/types";
|
||||||
|
export const STATS_LANES: RiotLane[] = [
|
||||||
|
"TOP",
|
||||||
|
"JUNGLE",
|
||||||
|
"MIDDLE",
|
||||||
|
"BOTTOM",
|
||||||
|
"UTILITY",
|
||||||
|
];
|
||||||
|
export function parseStatsLane(value: string | null): RiotLane | undefined {
|
||||||
|
return STATS_LANES.includes(value as RiotLane)
|
||||||
|
? (value as RiotLane)
|
||||||
|
: undefined;
|
||||||
|
}
|
||||||
|
export function statsRoot(cid: string) {
|
||||||
|
return `/communities/${cid}/internal-stats`;
|
||||||
|
}
|
||||||
|
export function statsDate(value: string) {
|
||||||
|
return new Intl.DateTimeFormat("ko-KR", {
|
||||||
|
month: "numeric",
|
||||||
|
day: "numeric",
|
||||||
|
weekday: "short",
|
||||||
|
timeZone: "Asia/Seoul",
|
||||||
|
}).format(new Date(value));
|
||||||
|
}
|
||||||
|
export function statsDuration(seconds: number) {
|
||||||
|
return seconds > 0
|
||||||
|
? `${Math.floor(seconds / 60)}:${String(Math.floor(seconds % 60)).padStart(2, "0")}`
|
||||||
|
: "시간 미확인";
|
||||||
|
}
|
||||||
|
export function statsPeriod(season?: ApiHistorySeason) {
|
||||||
|
if (!season) return "시즌을 불러오는 중";
|
||||||
|
const date = (value: string) =>
|
||||||
|
new Intl.DateTimeFormat("ko-KR", {
|
||||||
|
year: "numeric",
|
||||||
|
month: "2-digit",
|
||||||
|
day: "2-digit",
|
||||||
|
timeZone: "Asia/Seoul",
|
||||||
|
}).format(new Date(value));
|
||||||
|
return season.startedAt
|
||||||
|
? `${date(season.startedAt)} — ${season.endedAt ? date(season.endedAt) : "현재"}`
|
||||||
|
: "전체 기록";
|
||||||
|
}
|
||||||
|
export function statsTarget(
|
||||||
|
path: string,
|
||||||
|
params: URLSearchParams,
|
||||||
|
returnTo?: string,
|
||||||
|
) {
|
||||||
|
const query = new URLSearchParams();
|
||||||
|
for (const key of ["seasonId", "lane", "championId"]) {
|
||||||
|
const value = params.get(key);
|
||||||
|
if (value) query.set(key, value);
|
||||||
|
}
|
||||||
|
if (returnTo) {
|
||||||
|
// Keep the immediate parent in the URL. Its own return link is restored
|
||||||
|
// from the saved visit, so repeated player/game hops cannot grow the URL.
|
||||||
|
query.set("returnTo", visitKey(returnTo));
|
||||||
|
}
|
||||||
|
return `${path}${query.size ? `?${query}` : ""}`;
|
||||||
|
}
|
||||||
|
function visitKey(value: string) {
|
||||||
|
const url = new URL(value, "https://internal-stats.local");
|
||||||
|
url.searchParams.delete("returnTo");
|
||||||
|
return url.pathname + url.search;
|
||||||
|
}
|
||||||
|
export function rememberStatsVisit() {
|
||||||
|
const key = visitKey(location.pathname + location.search);
|
||||||
|
try {
|
||||||
|
const previous = JSON.parse(
|
||||||
|
sessionStorage.getItem(`internal-stats:${key}`) ?? "null",
|
||||||
|
);
|
||||||
|
sessionStorage.setItem(
|
||||||
|
`internal-stats:${key}`,
|
||||||
|
JSON.stringify({
|
||||||
|
y: scrollY,
|
||||||
|
focus: document.activeElement?.getAttribute("data-return-id"),
|
||||||
|
back:
|
||||||
|
new URLSearchParams(location.search).get("returnTo") ??
|
||||||
|
previous?.back,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
/* Storage can be unavailable. */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export function useStatsRestoration(ready: boolean) {
|
||||||
|
const location = useLocation();
|
||||||
|
const previousPath = useRef<string | null>(null);
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
if (!ready) return;
|
||||||
|
const changedPage = previousPath.current !== location.pathname;
|
||||||
|
previousPath.current = location.pathname;
|
||||||
|
let saved: { y: number; focus?: string } | null = null;
|
||||||
|
try {
|
||||||
|
saved = JSON.parse(
|
||||||
|
sessionStorage.getItem(
|
||||||
|
`internal-stats:${visitKey(location.pathname + location.search)}`,
|
||||||
|
) ?? "null",
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
/* Ignore corrupt storage. */
|
||||||
|
}
|
||||||
|
const frame = requestAnimationFrame(() => {
|
||||||
|
if (saved && Number.isFinite(saved.y)) {
|
||||||
|
window.scrollTo({ top: saved.y, behavior: "instant" });
|
||||||
|
if (saved.focus)
|
||||||
|
document
|
||||||
|
.querySelector<HTMLElement>(
|
||||||
|
`[data-return-id="${CSS.escape(saved.focus)}"]`,
|
||||||
|
)
|
||||||
|
?.focus({ preventScroll: true });
|
||||||
|
} else if (changedPage) window.scrollTo({ top: 0, behavior: "instant" });
|
||||||
|
});
|
||||||
|
return () => cancelAnimationFrame(frame);
|
||||||
|
}, [location.pathname, location.search, ready]);
|
||||||
|
}
|
||||||
|
export function useStatsBack(fallback: string) {
|
||||||
|
const location = useLocation();
|
||||||
|
const [params] = useSearchParams();
|
||||||
|
let savedBack: unknown;
|
||||||
|
try {
|
||||||
|
savedBack = JSON.parse(
|
||||||
|
sessionStorage.getItem(
|
||||||
|
`internal-stats:${visitKey(location.pathname + location.search)}`,
|
||||||
|
) ?? "null",
|
||||||
|
)?.back;
|
||||||
|
} catch {
|
||||||
|
/* A direct visit can use the fallback without storage. */
|
||||||
|
}
|
||||||
|
const back = params.get("returnTo") ?? location.state?.backTo ?? savedBack;
|
||||||
|
return typeof back === "string" &&
|
||||||
|
/^\/(communities|users|match)\//.test(back) &&
|
||||||
|
!back.includes("\\")
|
||||||
|
? back
|
||||||
|
: fallback;
|
||||||
|
}
|
||||||
@@ -3,7 +3,9 @@ import { useSyncExternalStore } from 'react';
|
|||||||
const AUTH_USER_ID_STORAGE_KEY = 'lolympus.authUserId';
|
const AUTH_USER_ID_STORAGE_KEY = 'lolympus.authUserId';
|
||||||
const THEME_STORAGE_KEY = 'lolympus.theme';
|
const THEME_STORAGE_KEY = 'lolympus.theme';
|
||||||
const AUTH_USER_CHANGED_EVENT = 'lolympus:auth-user-changed';
|
const AUTH_USER_CHANGED_EVENT = 'lolympus:auth-user-changed';
|
||||||
|
const AUCTION_ROLE_CHANGED_EVENT = 'lolympus:auction-role-changed';
|
||||||
const THEME_CHANGED_EVENT = 'lolympus:theme-changed';
|
const THEME_CHANGED_EVENT = 'lolympus:theme-changed';
|
||||||
|
const auctionRoleFallback = new Map<string, number | null>();
|
||||||
|
|
||||||
export type AppTheme = 'light' | 'dark';
|
export type AppTheme = 'light' | 'dark';
|
||||||
|
|
||||||
@@ -55,6 +57,46 @@ export function setAuthUserId(userId: string | null) {
|
|||||||
dispatchWindowEvent(AUTH_USER_CHANGED_EVENT);
|
dispatchWindowEvent(AUTH_USER_CHANGED_EVENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAuctionCaptainTeamIndex(matchId: string | undefined): number | null | undefined {
|
||||||
|
if (!matchId || typeof window === 'undefined') return undefined;
|
||||||
|
if (auctionRoleFallback.has(matchId)) return auctionRoleFallback.get(matchId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const value = window.localStorage.getItem(`lolympus.auctionRole.${matchId}`);
|
||||||
|
if (value === null) return undefined;
|
||||||
|
if (value === 'spectator') return null;
|
||||||
|
const teamIndex = Number(value);
|
||||||
|
return Number.isInteger(teamIndex) && teamIndex > 0 ? teamIndex : null;
|
||||||
|
} catch {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setAuctionCaptainTeamIndex(matchId: string, teamIndex: number | null) {
|
||||||
|
if (typeof window === 'undefined') return;
|
||||||
|
const selectedTeamIndex = teamIndex !== null && Number.isInteger(teamIndex) && teamIndex > 0
|
||||||
|
? teamIndex
|
||||||
|
: null;
|
||||||
|
try {
|
||||||
|
window.localStorage.setItem(
|
||||||
|
`lolympus.auctionRole.${matchId}`,
|
||||||
|
selectedTeamIndex === null ? 'spectator' : String(selectedTeamIndex),
|
||||||
|
);
|
||||||
|
auctionRoleFallback.delete(matchId);
|
||||||
|
} catch {
|
||||||
|
auctionRoleFallback.set(matchId, selectedTeamIndex);
|
||||||
|
}
|
||||||
|
dispatchWindowEvent(AUCTION_ROLE_CHANGED_EVENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useAuctionCaptainTeamIndex(matchId: string | undefined) {
|
||||||
|
return useSyncExternalStore<number | null | undefined>(
|
||||||
|
(callback) => subscribeToWindowChanges(AUCTION_ROLE_CHANGED_EVENT, callback),
|
||||||
|
() => getAuctionCaptainTeamIndex(matchId),
|
||||||
|
() => undefined,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function normalizeTheme(value: string | null | undefined): AppTheme {
|
function normalizeTheme(value: string | null | undefined): AppTheme {
|
||||||
return value === 'dark' ? 'dark' : 'light';
|
return value === 'dark' ? 'dark' : 'light';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,240 @@
|
|||||||
|
import { useEffect, useLayoutEffect, useRef, useState, type ComponentProps, type ReactNode } from 'react';
|
||||||
|
import { Link, useLocation, useSearchParams } from 'react-router';
|
||||||
|
import { ArrowDown, ArrowDownUp, ArrowLeft, ArrowRight, CalendarDays, Check, ChevronRight, Clock3, Copy, Filter, Info, List, LoaderCircle, Moon, Search, ShieldAlert, Sun, Trophy, Users, X } from 'lucide-react';
|
||||||
|
import { CartesianGrid, Legend, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts';
|
||||||
|
import { Btn, Chip } from '../../ui';
|
||||||
|
import { setTheme, useTheme } from '../../config';
|
||||||
|
import { champions, championImage, events, games, lanes, laneNames, ORIGINAL_PATH, playerById, PREVIEW_PATH, seasons, type Event, type Game, type Lane, type Participant, type Series } from './data';
|
||||||
|
import { aggregateRows, filterEvents, formatDate, formatDuration, playerGames, seasonMetrics, sortLabels, teamName, type PlayerRow, type SortKey } from './model';
|
||||||
|
|
||||||
|
type Changes = Record<string, string | null>;
|
||||||
|
const visits = new Map<string, { y: number; focus: string | null }>();
|
||||||
|
function visitKey(pathname: string, search: string) {
|
||||||
|
const query = new URLSearchParams(search);
|
||||||
|
query.delete('returnTo');
|
||||||
|
return `${pathname}?${query.toString()}`;
|
||||||
|
}
|
||||||
|
function rememberVisit() {
|
||||||
|
const focus = document.activeElement?.getAttribute('data-return-id') ?? null;
|
||||||
|
const key = visitKey(location.pathname, location.search);
|
||||||
|
const value = { y: window.scrollY, focus };
|
||||||
|
visits.set(key, value);
|
||||||
|
try { sessionStorage.setItem(`stats-preview:${key}`, JSON.stringify(value)); } catch { /* Memory restoration still works. */ }
|
||||||
|
}
|
||||||
|
function PreviewLink(props: ComponentProps<typeof Link>) {
|
||||||
|
return <Link {...props} onClick={event => { rememberVisit(); props.onClick?.(event); }} />;
|
||||||
|
}
|
||||||
|
function Champion({ id, size = 'normal' }: { id: number; size?: 'small' | 'normal' | 'large' }) {
|
||||||
|
const champion = champions[id];
|
||||||
|
return <img className={`is-champion is-champion-${size}`} src={championImage(champion.key)} alt={champion.name} title={champion.name} loading="lazy" />;
|
||||||
|
}
|
||||||
|
function Feedback({ type, title, children, action }: { type: 'empty' | 'error' | 'loading'; title: string; children?: ReactNode; action?: ReactNode }) {
|
||||||
|
const Icon = type === 'loading' ? LoaderCircle : type === 'error' ? ShieldAlert : Search;
|
||||||
|
return <section className={`is-feedback is-feedback-${type}`} role={type === 'error' ? 'alert' : 'status'} aria-live="polite"><Icon size={26} aria-hidden="true" /><h2>{title}</h2>{children && <p>{children}</p>}{action && <div className="is-feedback-actions">{action}</div>}</section>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Preview() {
|
||||||
|
const [params, setParams] = useSearchParams();
|
||||||
|
const location = useLocation();
|
||||||
|
const theme = useTheme();
|
||||||
|
const [copied, setCopied] = useState(false);
|
||||||
|
const [copyError, setCopyError] = useState(false);
|
||||||
|
const [retrying, setRetrying] = useState(false);
|
||||||
|
const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
|
const view = params.get('view') === 'players' ? 'players' : 'matches';
|
||||||
|
const season = seasons.some(s => s.id === params.get('season')) || params.get('season') === 'all' ? params.get('season')! : '2026-2';
|
||||||
|
const lane = lanes.includes(params.get('lane') as Lane) ? params.get('lane') as Lane : 'all';
|
||||||
|
const sort = Object.hasOwn(sortLabels, params.get('sort') ?? '') ? params.get('sort') as SortKey : 'games';
|
||||||
|
const direction = params.get('dir') === 'asc' ? 'asc' : 'desc';
|
||||||
|
const minimum = ['0', '5', '10', '20'].includes(params.get('min') ?? '') ? Number(params.get('min')) : 5;
|
||||||
|
const detail = params.get('detail');
|
||||||
|
const state = params.get('state');
|
||||||
|
const matchQuery = params.get('matchQ') ?? '';
|
||||||
|
const playerQuery = params.get('playerQ') ?? '';
|
||||||
|
const format = ['pair', 'tournament'].includes(params.get('format') ?? '') ? params.get('format')! : 'all';
|
||||||
|
const from = params.get('from') ?? '', to = params.get('to') ?? '';
|
||||||
|
const selectedPlayer = params.get('player') ?? '';
|
||||||
|
const selected = playerById.get(selectedPlayer);
|
||||||
|
const shown = Math.max(4, Math.min(100, Number(params.get('shown')) || 4));
|
||||||
|
const rawReturn = params.get('returnTo');
|
||||||
|
const listParams = new URLSearchParams(params);
|
||||||
|
['detail', 'event', 'game', 'profile', 'returnTo', 'state'].forEach(key => listParams.delete(key));
|
||||||
|
const listHref = `${PREVIEW_PATH}?${listParams.toString()}`;
|
||||||
|
const backHref = rawReturn?.startsWith(`${PREVIEW_PATH}?`) ? rawReturn : listHref;
|
||||||
|
const current = visitKey(location.pathname, location.search);
|
||||||
|
const metrics = seasonMetrics(season);
|
||||||
|
const seasonLabel = season === 'all' ? '전체 시즌' : seasons.find(s => s.id === season)!.name;
|
||||||
|
const period = season === 'all' ? '2026.05.01 — 06.30' : season === '2026-2' ? '2026.06.01 — 06.30' : '2026.05.01 — 05.31';
|
||||||
|
const invalidDates = Boolean(from && to && from > to);
|
||||||
|
const filteredEvents = invalidDates ? [] : filterEvents({ season, query: matchQuery, format, from, to, player: selectedPlayer });
|
||||||
|
const visibleEvents = filteredEvents.slice(0, shown);
|
||||||
|
const rankedRows = aggregateRows(season, lane, minimum, sort, direction);
|
||||||
|
const query = playerQuery.trim().toLocaleLowerCase('ko-KR');
|
||||||
|
const visibleRows = rankedRows.filter(row => row.name.toLocaleLowerCase('ko-KR').includes(query) && (params.get('qualified') !== '1' || row.games >= minimum));
|
||||||
|
const event = events.find(e => e.id === params.get('event'));
|
||||||
|
const game = games.find(g => g.id === params.get('game'));
|
||||||
|
const profile = playerById.get(params.get('profile') ?? '');
|
||||||
|
|
||||||
|
function update(changes: Changes, replace = false) {
|
||||||
|
const next = new URLSearchParams(params);
|
||||||
|
for (const [key, value] of Object.entries(changes)) {
|
||||||
|
if (value === null || value === '') next.delete(key); else next.set(key, value);
|
||||||
|
}
|
||||||
|
setParams(next, { replace, preventScrollReset: true });
|
||||||
|
}
|
||||||
|
function target(changes: Changes, asDetail = true) {
|
||||||
|
const next = new URLSearchParams(params);
|
||||||
|
['detail', 'event', 'game', 'profile', 'state'].forEach(k => next.delete(k));
|
||||||
|
Object.entries(changes).forEach(([key, value]) => value === null ? next.delete(key) : next.set(key, value));
|
||||||
|
if (asDetail) next.set('returnTo', current); else next.delete('returnTo');
|
||||||
|
return `${PREVIEW_PATH}?${next.toString()}`;
|
||||||
|
}
|
||||||
|
const eventHref = (id: string) => target({ detail: 'event', event: id });
|
||||||
|
const gameHref = (id: string) => target({ detail: 'game', game: id });
|
||||||
|
const profileHref = (id: string) => target({ detail: 'player', profile: id });
|
||||||
|
const participationHref = (id: string) => target({ view: 'matches', player: id, shown: null }, false);
|
||||||
|
function resetFilters() {
|
||||||
|
update(view === 'matches' ? { matchQ: null, format: null, from: null, to: null, player: null, shown: null } : { playerQ: null, lane: null, min: null, qualified: null, sort: null, dir: null });
|
||||||
|
}
|
||||||
|
function retry() {
|
||||||
|
setRetrying(true);
|
||||||
|
timer.current = setTimeout(() => { setRetrying(false); update({ state: null }, true); }, 700);
|
||||||
|
}
|
||||||
|
async function copyLink() {
|
||||||
|
try { await navigator.clipboard.writeText(window.location.href); setCopied(true); setCopyError(false); }
|
||||||
|
catch { setCopyError(true); }
|
||||||
|
}
|
||||||
|
useEffect(() => () => { if (timer.current) clearTimeout(timer.current); }, []);
|
||||||
|
useEffect(() => {
|
||||||
|
if (!copied && !copyError) return;
|
||||||
|
const timeout = setTimeout(() => { setCopied(false); setCopyError(false); }, 3500);
|
||||||
|
return () => clearTimeout(timeout);
|
||||||
|
}, [copied, copyError]);
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
const key = visitKey(location.pathname, location.search);
|
||||||
|
let saved = visits.get(key);
|
||||||
|
if (!saved) try { saved = JSON.parse(sessionStorage.getItem(`stats-preview:${key}`) ?? 'null'); } catch { /* Ignore obsolete preview state. */ }
|
||||||
|
const frame = requestAnimationFrame(() => {
|
||||||
|
if (saved) {
|
||||||
|
window.scrollTo({ top: saved.y, behavior: 'instant' });
|
||||||
|
if (saved.focus) document.querySelector<HTMLElement>(`[data-return-id="${CSS.escape(saved.focus)}"]`)?.focus({ preventScroll: true });
|
||||||
|
} else if (detail) {
|
||||||
|
window.scrollTo({ top: 0, behavior: 'instant' });
|
||||||
|
document.getElementById('stats-detail-title')?.focus({ preventScroll: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return () => cancelAnimationFrame(frame);
|
||||||
|
}, [location.key, location.pathname, location.search, detail]);
|
||||||
|
|
||||||
|
const activeFilters: Array<{ label: string; clear: Changes }> = view === 'matches' ? [
|
||||||
|
...(matchQuery ? [{ label: `검색: ${matchQuery}`, clear: { matchQ: null } }] : []),
|
||||||
|
...(format !== 'all' ? [{ label: format === 'pair' ? '두 팀 내전' : '대회', clear: { format: null } }] : []),
|
||||||
|
...(from || to ? [{ label: `${from || '처음'} ~ ${to || '마지막'}`, clear: { from: null, to: null } }] : []),
|
||||||
|
...(selectedPlayer ? [{ label: `${selected?.name ?? '선수'} 참가 내전`, clear: { player: null } }] : []),
|
||||||
|
] : [
|
||||||
|
...(playerQuery ? [{ label: `검색: ${playerQuery}`, clear: { playerQ: null } }] : []),
|
||||||
|
...(lane !== 'all' ? [{ label: `${laneNames[lane]}에서 플레이한 기록`, clear: { lane: null } }] : []),
|
||||||
|
...(params.get('qualified') === '1' ? [{ label: `${minimum}판 이상만`, clear: { qualified: null } }] : []),
|
||||||
|
];
|
||||||
|
const secondaryControls = <div className="is-page-actions"><button className="is-icon-button" onClick={copyLink} aria-label="현재 전적 링크 복사">{copied ? <Check size={17} /> : <Copy size={17} />}</button><label className="is-season-select"><span>집계 시즌</span><select value={season} onChange={e => update({ season: e.target.value, shown: null, returnTo: null, ...(detail !== 'player' ? { detail: null, event: null, game: null } : {}) })}>{seasons.map(s => <option value={s.id} key={s.id}>{s.name}</option>)}<option value="all">전체 시즌</option></select></label></div>;
|
||||||
|
|
||||||
|
return <div className="internal-stats-preview">
|
||||||
|
<a className="is-skip-link" href="#stats-main">전적 본문으로 건너뛰기</a>
|
||||||
|
<div className="is-preview-notice"><span><span className="is-preview-dot" /> 인터랙티브 시안 <span className="is-notice-separator">/</span> 예시 데이터</span><a href={ORIGINAL_PATH}>현재 페이지와 비교 <ArrowRight size={13} /></a></div>
|
||||||
|
<header className="is-site-header"><a className="is-brand" href="/">LOLYMPUS<span>TOURNAMENT</span></a><nav aria-label="주 메뉴"><a href="/">홈</a><a href="/inhouse">내전</a><a href="/tournaments">멸망전</a><PreviewLink to={PREVIEW_PATH} aria-current="page">전적</PreviewLink></nav><button className="is-icon-button" aria-label={theme === 'dark' ? '라이트 테마로 전환' : '다크 테마로 전환'} onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}>{theme === 'dark' ? <Sun size={19} /> : <Moon size={19} />}</button></header>
|
||||||
|
<main id="stats-main" className="is-page">
|
||||||
|
{!detail ? <>
|
||||||
|
<header className="is-page-heading"><div><p className="is-eyebrow">LOLYMPUS COMMUNITY</p><h1>내전 전적</h1><p className="is-muted">함께한 경기와 선수들의 기록을 만나보세요.</p></div>{secondaryControls}</header>
|
||||||
|
<SeasonSummary metrics={metrics} label={seasonLabel} period={period} profileHref={id => target({ detail: 'player', profile: id, lane: null })} gameHref={gameHref} />
|
||||||
|
<div className="is-workspace">
|
||||||
|
<div className="is-view-tabs" role="tablist" aria-label="전적 보기">
|
||||||
|
{(['matches', 'players'] as const).map((v, index) => <button key={v} id={`tab-${v}`} role="tab" aria-selected={view === v} aria-controls="stats-view-panel" tabIndex={view === v ? 0 : -1} onClick={() => update({ view: v })} onKeyDown={e => { if (['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(e.key)) { e.preventDefault(); const next = e.key === 'Home' ? 'matches' : e.key === 'End' ? 'players' : index === 0 ? 'players' : 'matches'; update({ view: next }); document.getElementById(`tab-${next}`)?.focus(); } }}>{v === 'matches' ? <List size={17} /> : <Users size={17} />}{v === 'matches' ? '최근 내전' : '선수 전적·순위'}<span>{v === 'matches' ? metrics.events : metrics.players}</span></button>)}
|
||||||
|
<span className="is-tabs-caption">{seasonLabel} <span>·</span> {period}</span>
|
||||||
|
</div>
|
||||||
|
<section id="stats-view-panel" role="tabpanel" aria-labelledby={`tab-${view}`}>
|
||||||
|
<div className="is-filter-bar">
|
||||||
|
<label className="is-search"><Search size={18} aria-hidden="true" /><input type="search" maxLength={100} aria-label={view === 'matches' ? '내전·팀·선수 검색' : '선수 검색'} placeholder={view === 'matches' ? '내전명, 팀명, 선수 이름 검색' : '선수 이름 검색'} value={view === 'matches' ? matchQuery : playerQuery} onChange={e => update({ [view === 'matches' ? 'matchQ' : 'playerQ']: e.target.value, shown: null }, true)} />{(view === 'matches' ? matchQuery : playerQuery) && <button aria-label="검색어 지우기" onClick={() => update({ [view === 'matches' ? 'matchQ' : 'playerQ']: null }, true)}><X size={16} /></button>}</label>
|
||||||
|
{view === 'matches' ? <>
|
||||||
|
<div className="is-type-filters" role="group" aria-label="내전 유형">{[['all', '전체'], ['pair', '두 팀 내전'], ['tournament', '대회']].map(([value, label]) => <Chip key={value} selected={format === value} onClick={() => update({ format: value === 'all' ? null : value, shown: null })}>{label}</Chip>)}</div>
|
||||||
|
<div className="is-date-range"><CalendarDays size={16} aria-hidden="true" /><label><span className="sr-only">시작일</span><input type="date" aria-label="시작일" value={from} onInput={e => update({ from: e.currentTarget.value, shown: null })} /></label><span>—</span><label><span className="sr-only">종료일</span><input type="date" aria-label="종료일" value={to} onInput={e => update({ to: e.currentTarget.value, shown: null })} /></label></div>
|
||||||
|
</> : <><label className="is-select"><Filter size={15} /><span className="sr-only">플레이 포지션</span><select aria-label="플레이 포지션" value={lane} onChange={e => update({ lane: e.target.value })}><option value="all">전체 포지션</option>{lanes.map(l => <option value={l} key={l}>{laneNames[l]}</option>)}</select></label><label className="is-select"><span>순위 기준</span><select aria-label="최소 판수" value={minimum} onChange={e => update({ min: e.target.value })}>{[0, 5, 10, 20].map(n => <option key={n} value={n}>{n === 0 ? '모든 선수' : `최소 ${n}판`}</option>)}</select></label><label className="is-sort-select"><ArrowDownUp size={16} /><select aria-label="순위 정렬" value={sort} onChange={e => update({ sort: e.target.value, dir: null })}>{Object.entries(sortLabels).map(([key, value]) => <option value={key} key={key}>{value} 순</option>)}</select></label></>}
|
||||||
|
</div>
|
||||||
|
{activeFilters.length > 0 && <div className="is-active-filters"><span>적용 조건</span>{activeFilters.map(filter => <button key={filter.label} onClick={() => update({ ...filter.clear, shown: null })} aria-label={`${filter.label} 해제`}>{filter.label}<X size={13} /></button>)}<button className="is-reset" onClick={resetFilters}>전체 초기화</button></div>}
|
||||||
|
{view === 'matches' && invalidDates && <p className="is-inline-error" role="alert">종료일을 시작일과 같거나 이후 날짜로 선택해 주세요.</p>}
|
||||||
|
{(state === 'error' || state === 'loading' || retrying) ? <Feedback type={retrying || state === 'loading' ? 'loading' : 'error'} title={retrying || state === 'loading' ? '전적을 불러오는 중입니다' : '전적을 불러오지 못했습니다'} action={<><Btn onClick={retry} disabled={retrying}>다시 시도</Btn><Btn variant="ghost" onClick={() => update({ state: null })}>목록으로 돌아가기</Btn></>}>선택한 시즌과 검색 조건은 유지됩니다.</Feedback> : view === 'matches' ? <>
|
||||||
|
<div className="is-result-heading"><h2>경기 기록 <span>{filteredEvents.length}회</span></h2><p role="status">{visibleEvents.length}개 표시{filteredEvents.length > shown && ` / 검색 결과 ${filteredEvents.length}개`}</p></div>
|
||||||
|
{visibleEvents.length ? <div className="is-events-layout"><EventJumpNav events={visibleEvents} /><div className="is-events-list">{visibleEvents.map(e => <EventSection key={e.id} event={e} eventHref={eventHref} gameHref={gameHref} />)}{filteredEvents.length > shown && <button className="is-load-more" onClick={() => update({ shown: String(shown + 2) })}>이전 내전 2개 더 보기 <ArrowDown size={16} /><span>{filteredEvents.length - shown}개 남음</span></button>}</div></div> : <Feedback type="empty" title={invalidDates ? '조회 기간을 확인해 주세요' : '조건에 맞는 내전이 없습니다'} action={<Btn onClick={resetFilters}>검색 조건 초기화</Btn>}>날짜나 검색어를 바꾸면 다른 내전을 찾을 수 있습니다.</Feedback>}
|
||||||
|
</> : <>
|
||||||
|
<div className="is-result-heading"><div><h2>{sortLabels[sort]} 순 <span>{visibleRows.length}명</span></h2><p>{lane === 'all' ? '전체 포지션' : `${laneNames[lane]} 플레이만 집계`} · {minimum > 0 ? `${minimum}판 미만은 기준 미달로 뒤에 표시` : '판수 제한 없음'}</p></div><label className="is-checkbox"><input type="checkbox" checked={params.get('qualified') === '1'} onChange={e => update({ qualified: e.target.checked ? '1' : null })} />기준 충족 선수만</label></div>
|
||||||
|
{visibleRows.length ? <LeaderboardTable rows={visibleRows} minimum={minimum} lane={lane} sort={sort} direction={direction} onSort={key => update({ sort: key, dir: sort === key && direction === 'desc' ? 'asc' : 'desc' })} profileHref={profileHref} participationHref={participationHref} /> : <Feedback type="empty" title="조건에 맞는 선수가 없습니다" action={<Btn onClick={resetFilters}>검색 조건 초기화</Btn>}>검색어, 포지션 또는 최소 판수를 바꿔 보세요.</Feedback>}
|
||||||
|
</>}
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</> : <>
|
||||||
|
<PreviewLink className="is-back-link" to={backHref}><ArrowLeft size={16} />{rawReturn?.includes('detail=') ? '이전 기록으로' : '내전 전적으로 돌아가기'}</PreviewLink>
|
||||||
|
<header className="is-page-heading is-detail-heading"><div><p className="is-eyebrow">{seasonLabel} · {period}</p><h1 id="stats-detail-title" tabIndex={-1}>{detail === 'event' ? event?.name ?? '내전 기록' : detail === 'game' ? '세트 상세 분석' : profile?.name ?? '선수 전적'}</h1><p className="is-muted">{detail === 'player' ? '선택한 시즌의 개인 기록과 참가 경기를 확인합니다.' : '공식 경기 결과와 수집된 분석 기록을 함께 확인합니다.'}</p></div>{secondaryControls}</header>
|
||||||
|
{(state === 'error' || state === 'loading' || retrying) ? <Feedback type={retrying || state === 'loading' ? 'loading' : 'error'} title={retrying || state === 'loading' ? '기록을 불러오는 중입니다' : '기록을 불러오지 못했습니다'} action={<><Btn onClick={retry} disabled={retrying}>다시 시도</Btn><Btn to={backHref} variant="ghost">이전 기록으로</Btn></>}>경기 제목과 선택한 조건을 유지했습니다. 다시 시도하거나 이전 화면으로 돌아갈 수 있습니다.</Feedback> : detail === 'event' && event ? <><EventOverview event={event} /><div className="is-detail-series">{event.series.map(series => <SeriesResultGroup key={series.id} series={series} event={event} gameHref={gameHref} />)}</div></> : detail === 'game' && game ? <GameAnalysis game={game} profileHref={profileHref} eventHref={eventHref} /> : detail === 'player' && profile ? <PlayerDetail playerId={profile.id} season={season} lane={lane} onLane={value => update({ lane: value })} gameHref={gameHref} participationHref={participationHref} /> : <Feedback type="empty" title="요청한 기록을 찾을 수 없습니다" action={<Btn to={listHref}>내전 전적으로 돌아가기</Btn>}>기록의 링크를 확인하거나 목록에서 다시 선택해 주세요.</Feedback>}
|
||||||
|
</>}
|
||||||
|
<div className="is-announcement" role="status">{copyError ? '링크를 복사하지 못했습니다. 주소 표시줄의 주소를 복사해 주세요.' : copied ? '현재 검색 조건이 포함된 링크를 복사했습니다.' : ''}</div>
|
||||||
|
<footer className="is-page-footer"><span>LOLYMPUS <span>·</span> 함께하는 모든 게임의 기록</span><span>예시 데이터로 구성한 디자인 시안</span></footer>
|
||||||
|
<aside className="is-preview-tools" aria-label="시안 상태 확인"><span>시안 상태 확인</span><button onClick={() => update({ state: null })} aria-pressed={!state}>정상</button><button onClick={() => update({ state: 'loading' })} aria-pressed={state === 'loading'}>로딩</button><button onClick={() => update({ state: 'error' })} aria-pressed={state === 'error'}>조회 오류</button></aside>
|
||||||
|
</main>
|
||||||
|
</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function SeasonSummary({ metrics: m, label, period, profileHref, gameHref }: { metrics: ReturnType<typeof seasonMetrics>; label: string; period: string; profileHref: (id: string) => string; gameHref: (id: string) => string }) {
|
||||||
|
const records = [
|
||||||
|
{ title: '평균 KDA', value: m.topKda?.kda.toFixed(2), suffix: '', name: m.topKda?.name, href: m.topKda ? profileHref(m.topKda.id) : '', scope: '시즌 최고 · 최소 5판' },
|
||||||
|
{ title: '누적 킬', value: m.kills?.kills.toLocaleString(), suffix: '킬', name: m.kills?.player.name, href: m.kills ? profileHref(m.kills.player.id) : '', scope: '시즌 누적' },
|
||||||
|
{ title: '분당 골드', value: m.bestGpm?.gpm.toFixed(1), suffix: '', name: m.bestGpm ? playerById.get(m.bestGpm.p.playerId)?.name : '', href: m.bestGpm ? gameHref(m.bestGpm.game.id) : '', scope: '단일 경기 최고' },
|
||||||
|
{ title: '평균 킬 관여', value: m.topKp?.kp.toFixed(1), suffix: '%', name: m.topKp?.name, href: m.topKp ? profileHref(m.topKp.id) : '', scope: '시즌 최고 · 최소 5판' },
|
||||||
|
{ title: '평균 분당 CS', value: m.topCs?.cspm.toFixed(1), suffix: '', name: m.topCs?.name, href: m.topCs ? profileHref(m.topCs.id) : '', scope: '시즌 최고 · 최소 5판' },
|
||||||
|
];
|
||||||
|
return <section className="is-season-summary" aria-label="커뮤니티 전체 시즌 요약"><div className="is-summary-topline"><span><span className="is-current-dot" />{label} <span className="is-muted">시즌 요약</span></span><span className="is-muted">커뮤니티 전체 · {period}</span></div><div className="is-summary-metrics"><div><span>진행한 내전</span><strong>{m.events}<small>회</small></strong></div><div><span>확정 세트</span><strong>{m.sets}<small>판</small></strong></div><div><span>참가 선수</span><strong>{m.players}<small>명</small></strong></div><div className="is-side-rate"><span>진영 승률 <small>{m.sets}세트 기준</small></span><div><strong className="is-blue">{Math.round(m.blue)}<small>%</small></strong><span>BLUE / RED</span><strong className="is-red">{100 - Math.round(m.blue)}<small>%</small></strong></div><div className="is-side-track" aria-hidden="true"><span style={{ width: `${m.blue}%` }} /></div></div></div><div className="is-records-heading"><Trophy size={14} /><h2>시즌 기록</h2><span>분석 가능한 {m.ready}세트 기준 · 검색 조건과 별도 집계</span></div><div className="is-records">{records.map(record => <div className="is-record" key={record.title}><p>{record.title}<span>{record.scope}</span></p><div><strong>{record.value ?? '—'}<small>{record.suffix}</small></strong>{record.href ? <PreviewLink to={record.href} aria-label={`${record.title} ${record.name}의 ${record.scope === '단일 경기 최고' ? '근거 경기' : '시즌 전적'} 보기`}>{record.name}<ChevronRight size={13} /></PreviewLink> : <span>기록 없음</span>}</div></div>)}</div></section>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function EventJumpNav({ events: items }: { events: Event[] }) {
|
||||||
|
return <nav className="is-event-jump" aria-label="내전 바로가기"><div className="is-jump-desktop"><p><CalendarDays size={15} /> 내전 바로가기</p>{items.map(event => <a href={`#event-${event.id}`} key={event.id}><span>{formatDate(event.date)}</span><strong>{event.name}</strong><small>{event.formatLabel}</small></a>)}</div><label className="is-jump-mobile"><CalendarDays size={16} /><span>내전 이동</span><select aria-label="내전 바로가기" defaultValue="" onChange={e => { if (e.target.value) { document.getElementById(`event-${e.target.value}`)?.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }}><option value="" disabled>날짜로 바로가기</option>{items.map(e => <option key={e.id} value={e.id}>{formatDate(e.date)} · {e.name}</option>)}</select></label></nav>;
|
||||||
|
}
|
||||||
|
function EventOverview({ event }: { event: Event }) {
|
||||||
|
const sets = event.series.flatMap(s => s.games), ready = sets.filter(g => g.evidence === 'ready').length;
|
||||||
|
const single = event.series.length === 1 ? event.series[0] : null;
|
||||||
|
return <div className="is-event-overview"><div className="is-event-meta"><span><CalendarDays size={14} />{formatDate(event.date)} {event.time}</span><span><Users size={14} />{event.teamIds.length}팀 · {event.teamIds.length * 5}명</span><span>{sets.length}세트 결과</span><span className="is-analysis-count">{ready}세트 분석 가능</span></div>{event.champion ? <span className="is-champion-label"><Trophy size={15} />우승 <strong>{teamName(event.champion)}</strong></span> : single && <span className="is-series-score">{teamName(single.a)} <strong>{single.scoreA} : {single.scoreB}</strong> {teamName(single.b)}</span>}</div>;
|
||||||
|
}
|
||||||
|
function EventSection({ event, eventHref, gameHref }: { event: Event; eventHref: (id: string) => string; gameHref: (id: string) => string }) {
|
||||||
|
return <article className="is-event-section" id={`event-${event.id}`}><header><div><div className="is-event-kicker"><span>{event.formatLabel}</span><span>{event.series.length}개 시리즈</span></div><h3><PreviewLink to={eventHref(event.id)} data-return-id={`event-link-${event.id}`}>{event.name}<ChevronRight size={18} /></PreviewLink></h3></div><PreviewLink className="is-text-link is-event-detail-link" to={eventHref(event.id)} data-return-id={`event-detail-${event.id}`}>전체 기록<ArrowRight size={15} /></PreviewLink></header><EventOverview event={event} /><div className="is-series-grid">{event.series.map(series => <SeriesResultGroup key={series.id} series={series} event={event} gameHref={gameHref} />)}</div></article>;
|
||||||
|
}
|
||||||
|
function SeriesResultGroup({ series, event, gameHref }: { series: Series; event: Event; gameHref: (id: string) => string }) {
|
||||||
|
return <section className="is-series-group" aria-label={`${series.label} ${teamName(series.a)} 대 ${teamName(series.b)}`}><header><span>{series.label}</span><span>{series.games.length}세트</span></header><div className="is-matchup"><strong className={series.winner === series.a ? 'is-winner' : ''}>{teamName(series.a)}</strong><span className="is-score"><b className={series.scoreA > series.scoreB ? 'is-winner' : ''}>{series.scoreA}</b><i>:</i><b className={series.scoreB > series.scoreA ? 'is-winner' : ''}>{series.scoreB}</b></span><strong className={series.winner === series.b ? 'is-winner' : ''}>{teamName(series.b)}</strong></div><ul>{series.games.map(game => <li key={game.id}><span className="is-set-number">{game.ordinal}세트<small>전체 #{game.number}</small></span><span className="is-set-winner"><span className="is-win-badge">승</span>{teamName(game.winner)}</span><span className="is-duration"><Clock3 size={12} />{formatDuration(game.duration)}</span><PreviewLink className={`is-analysis-link ${game.evidence !== 'ready' ? 'is-unavailable' : ''}`} to={gameHref(game.id)} data-return-id={`game-link-${game.id}`} aria-label={`${formatDate(event.date)} ${series.label} ${game.ordinal}세트 ${game.evidence === 'ready' ? '상세 분석' : '기록 상태 확인'}`}>{game.evidence === 'ready' ? '분석' : game.evidence === 'missing' ? '원본 없음' : '수집 중'}{game.evidence === 'ready' ? <ChevronRight size={13} /> : <Info size={12} />}</PreviewLink></li>)}</ul></section>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function LeaderboardTable({ rows, minimum, lane, sort, direction, onSort, profileHref, participationHref }: { rows: PlayerRow[]; minimum: number; lane: Lane | 'all'; sort: SortKey; direction: 'asc' | 'desc'; onSort: (key: SortKey) => void; profileHref: (id: string) => string; participationHref: (id: string) => string }) {
|
||||||
|
const firstUnder = rows.findIndex(row => row.games < minimum);
|
||||||
|
const metric = (key: SortKey, label: string) => <th scope="col" aria-sort={sort === key ? direction === 'desc' ? 'descending' : 'ascending' : 'none'}><button className={sort === key ? 'is-sorted' : ''} onClick={() => onSort(key)}>{label}{sort === key ? <ArrowDown size={13} className={direction === 'asc' ? 'is-arrow-up' : ''} /> : <ArrowDownUp size={12} />}</button></th>;
|
||||||
|
return <><div className="is-table-hint"><ArrowRight size={14} />옆으로 이동하면 모든 지표를 볼 수 있어요. 선수 이름은 고정됩니다.</div><div className="is-table-scroll" role="region" aria-label="선수 순위표, 좌우 방향키로 지표 이동" tabIndex={0}><table className="is-leaderboard"><caption className="sr-only">{lane === 'all' ? '전체 포지션' : laneNames[lane]} 선수 순위. {sortLabels[sort]} {direction === 'desc' ? '높은' : '낮은'} 순. 최소 {minimum}판 기준.</caption><colgroup><col className="is-col-rank" /><col className="is-col-player" /><col className="is-col-win" /><col className="is-col-games" /><col className="is-col-kda" /><col className="is-col-champions" /><col /><col /><col /></colgroup><thead><tr><th scope="col" className="is-sticky-rank">순위</th><th scope="col" className="is-sticky-player">선수</th>{metric('winRate', '승률')}{metric('games', '판수')}{metric('kda', 'KDA')}<th scope="col">주 챔피언</th>{metric('gpm', 'GPM')}{metric('kp', '킬 관여')}{metric('cspm', 'CS/분')}</tr></thead><tbody>{rows.map((row, index) => <tr key={row.id} className={`${row.games < minimum ? 'is-under-qualified' : ''} ${index === firstUnder ? 'is-threshold-first' : ''}`}><td className="is-sticky-rank"><span className="is-rank-number">{row.rank}</span></td><th scope="row" className="is-sticky-player"><div className="is-player-identity"><Champion id={row.champions[0].id} /><div><PreviewLink to={profileHref(row.id)} data-return-id={`player-link-${row.id}`}>{row.name}</PreviewLink><small>{lane === 'all' ? laneNames[row.lane] : laneNames[lane]}<span>·</span><PreviewLink to={participationHref(row.id)}>참가 내전</PreviewLink></small>{row.games < minimum && <span className="is-sample-badge">기준 미달</span>}</div></div></th><td><strong className={row.winRate >= 50 ? 'is-blue' : ''}>{Math.round(row.winRate)}<small>%</small></strong><div className="is-win-track" aria-hidden="true"><span style={{ width: `${row.winRate}%` }} /></div></td><td><strong>{row.games}</strong><small className="is-win-loss">{row.wins}승 {row.losses}패</small></td><td><strong className={row.kda >= 3 ? 'is-green' : ''}>{row.kda.toFixed(2)}</strong></td><td><div className="is-champion-list">{row.champions.map(c => <span key={c.id}><Champion id={c.id} size="small" /><small>{c.games}</small></span>)}</div></td><td>{row.gpm.toFixed(1)}</td><td>{row.kp.toFixed(1)}%</td><td>{row.cspm.toFixed(1)}</td></tr>)}</tbody></table></div><div className="is-table-footnote"><Info size={14} /><p>KDA는 (킬 + 어시스트) ÷ 데스, GPM은 분당 골드입니다. {lane !== 'all' && `${laneNames[lane]}로 플레이한 경기의 모든 지표를 다시 집계했습니다. `}검색 결과의 순위는 전체 순위를 유지합니다.</p></div></>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function GameAnalysis({ game, profileHref, eventHref }: { game: Game; profileHref: (id: string) => string; eventHref: (id: string) => string }) {
|
||||||
|
const event = events.find(e => e.id === game.eventId)!;
|
||||||
|
const series = event.series.find(s => s.id === game.seriesId)!;
|
||||||
|
const [retryMessage, setRetryMessage] = useState('');
|
||||||
|
const totals = [game.blue, game.red].map(id => game.participants.filter(p => p.teamId === id).reduce((sum, p) => ({ gold: sum.gold + p.gold, kills: sum.kills + p.kills, damage: sum.damage + p.damage }), { gold: 0, kills: 0, damage: 0 }));
|
||||||
|
const timeline = [0, 5, 10, 15, 20, Math.round(game.duration / 60)].filter((n, i, a) => a.indexOf(n) === i).map((minute, i) => ({ minute, 블루: Math.round(totals[0].gold * minute / Math.round(game.duration / 60) * (i < 3 ? .85 : 1)), 레드: Math.round(totals[1].gold * minute / Math.round(game.duration / 60) * (i < 3 ? .9 : 1)) }));
|
||||||
|
return <>
|
||||||
|
<div className="is-game-context"><PreviewLink to={eventHref(event.id)}>{event.name}<ChevronRight size={14} /></PreviewLink><span>{series.label}</span><strong>{game.ordinal}세트 <span className="is-muted">· 전체 #{game.number}</span></strong><span><Clock3 size={14} />{formatDuration(game.duration)}</span></div>
|
||||||
|
<div className="is-game-result"><div className={game.winner === game.blue ? 'is-result-win' : ''}><span className="is-blue">BLUE SIDE</span><h2>{teamName(game.blue)}</h2><b>{game.winner === game.blue ? '승리' : '패배'}</b></div><strong>{game.evidence === 'ready' ? `${totals[0].kills} : ${totals[1].kills}` : 'VS'}<small>{game.evidence === 'ready' ? '팀 킬 스코어' : '공식 세트 결과'}</small></strong><div className={game.winner === game.red ? 'is-result-win' : ''}><span className="is-red">RED SIDE</span><h2>{teamName(game.red)}</h2><b>{game.winner === game.red ? '승리' : '패배'}</b></div></div>
|
||||||
|
{game.evidence !== 'ready' ? <Feedback type="empty" title={game.evidence === 'missing' ? '공식 결과만 남아 있는 경기입니다' : '상세 기록을 수집하고 있습니다'} action={<><Btn to={eventHref(event.id)}>내전의 전체 기록 보기</Btn>{game.evidence === 'pending' && <Btn variant="ghost" onClick={() => setRetryMessage('아직 새로운 분석 기록이 없습니다. 공식 결과는 위에서 확인할 수 있습니다.')}>수집 상태 다시 확인</Btn>}</>}>{retryMessage || (game.evidence === 'missing' ? 'Riot 원본 기록이 없어 선수별 지표와 그래프를 제공하지 않습니다. 승패 결과는 계속 확인할 수 있습니다.' : '선수별 지표는 수집이 완료되면 표시됩니다. 공식 승패와 경기 시간은 먼저 확인할 수 있습니다.')}</Feedback> : <>
|
||||||
|
<div className="is-analysis-top"><section className="is-analysis-panel"><header><h2>골드 흐름</h2><span>예시 타임라인 · 팀 누적 골드</span></header><div className="is-chart"><ResponsiveContainer width="100%" height="100%" minWidth={0} initialDimension={{ width: 520, height: 215 }}><LineChart data={timeline} margin={{ left: 0, right: 12, top: 10, bottom: 0 }} accessibilityLayer><CartesianGrid strokeDasharray="3 3" vertical={false} stroke="var(--color-border)" /><XAxis dataKey="minute" tickFormatter={n => `${n}분`} tickLine={false} axisLine={false} fontSize={11} /><YAxis tickFormatter={n => `${Number(n) / 1000}k`} width={40} tickLine={false} axisLine={false} fontSize={11} /><Tooltip formatter={value => Number(value).toLocaleString()} labelFormatter={label => `${label}분`} contentStyle={{ background: 'var(--color-background-card)', color: 'var(--color-text-primary)', border: '1px solid var(--color-border)', borderRadius: 8 }} /><Legend /><Line type="monotone" dataKey="블루" stroke="var(--color-win)" strokeWidth={2} dot={false} isAnimationActive={false} /><Line type="monotone" dataKey="레드" stroke="var(--color-loss)" strokeWidth={2} dot={false} isAnimationActive={false} /></LineChart></ResponsiveContainer></div><p className="is-muted is-chart-description">최종 골드: 블루 {totals[0].gold.toLocaleString()} · 레드 {totals[1].gold.toLocaleString()}</p></section><section className="is-analysis-panel"><header><h2>팀 비교</h2><span>블루 / 레드</span></header><div className="is-team-comparison">{(['kills', 'gold', 'damage'] as const).map((key, i) => <div key={key}><div><strong className="is-blue">{totals[0][key].toLocaleString()}</strong><span>{['킬', '골드', '챔피언 피해량'][i]}</span><strong className="is-red">{totals[1][key].toLocaleString()}</strong></div><div className="is-comparison-track" aria-hidden="true"><span style={{ width: `${totals[0][key] / (totals[0][key] + totals[1][key]) * 100}%` }} /></div></div>)}</div></section></div>
|
||||||
|
{[game.blue, game.red].map((id, index) => <section key={id} className="is-scoreboard"><header><h2><span className={index === 0 ? 'is-blue' : 'is-red'}>{game.winner === id ? '승리' : '패배'}</span>{teamName(id)}</h2><span>{index === 0 ? '블루' : '레드'} · {totals[index].kills}킬 · {totals[index].gold.toLocaleString()}골드</span></header><div className="is-table-scroll" tabIndex={0} role="region" aria-label={`${teamName(id)} 선수별 스코어보드`}><table><thead><tr><th scope="col">선수 / 챔피언</th><th scope="col">K / D / A</th><th scope="col">킬 관여</th><th scope="col">피해량</th><th scope="col">골드</th><th scope="col">CS / 분당</th><th scope="col">시야 점수</th></tr></thead><tbody>{game.participants.filter(p => p.teamId === id).map(p => <ScoreboardRow key={p.playerId} participant={p} duration={game.duration} profileHref={profileHref} />)}</tbody></table></div></section>)}
|
||||||
|
</>}
|
||||||
|
</>;
|
||||||
|
}
|
||||||
|
function ScoreboardRow({ participant: p, duration, profileHref }: { participant: Participant; duration: number; profileHref: (id: string) => string }) {
|
||||||
|
return <tr><th scope="row"><div className="is-player-identity"><Champion id={p.champion} /><div><PreviewLink to={profileHref(p.playerId)}>{playerById.get(p.playerId)!.name}</PreviewLink><small>{laneNames[p.lane]} · {champions[p.champion].name}</small></div></div></th><td><strong>{p.kills} / {p.deaths} / {p.assists}</strong><small>{((p.kills + p.assists) / Math.max(1, p.deaths)).toFixed(2)} KDA</small></td><td>{p.kp.toFixed(1)}%</td><td>{p.damage.toLocaleString()}</td><td>{p.gold.toLocaleString()}</td><td>{p.cs}<small>{(p.cs / (duration / 60)).toFixed(1)} / 분</small></td><td>{p.vision}</td></tr>;
|
||||||
|
}
|
||||||
|
function PlayerDetail({ playerId, season, lane, onLane, gameHref, participationHref }: { playerId: string; season: string; lane: Lane | 'all'; onLane: (lane: string) => void; gameHref: (id: string) => string; participationHref: (id: string) => string }) {
|
||||||
|
const player = playerById.get(playerId)!;
|
||||||
|
const row = aggregateRows(season, lane, 5, 'games').find(r => r.id === playerId);
|
||||||
|
const appearances = playerGames(playerId, season, lane);
|
||||||
|
return <><div className="is-profile-heading"><Champion id={player.champion} size="large" /><div><h2>{player.name}</h2><span>{teamName(player.teamId)} · 주 포지션 {laneNames[player.lane]}</span></div><PreviewLink className="is-action-link" to={participationHref(playerId)}>참가 내전 보기<ArrowRight size={16} /></PreviewLink></div><div className="is-profile-filters"><label className="is-select"><span>집계 포지션</span><select aria-label="선수 집계 포지션" value={lane} onChange={e => onLane(e.target.value)}><option value="all">전체 포지션</option>{lanes.map(l => <option value={l} key={l}>{laneNames[l]}</option>)}</select></label><p className="is-muted">선택한 시즌과 포지션으로 모든 지표를 집계합니다.</p></div>{row ? <><div className="is-profile-stats">{[['판수', `${row.games}`, `${row.wins}승 ${row.losses}패`], ['승률', `${Math.round(row.winRate)}%`, '수집된 경기 기준'], ['KDA', row.kda.toFixed(2), '(킬 + 어시스트) / 데스'], ['GPM', row.gpm.toFixed(1), '평균 분당 골드'], ['킬 관여', `${row.kp.toFixed(1)}%`, '평균 킬 관여율'], ['분당 CS', row.cspm.toFixed(1), '평균 CS']].map(([label, value, desc]) => <div key={label}><span>{label}</span><strong>{value}</strong><small>{desc}</small></div>)}</div><div className="is-result-heading"><h2>참가 세트 기록 <span>{appearances.length}판</span></h2><p>최근 내전부터 표시</p></div><div className="is-personal-games">{appearances.map(({ game, participant: p }) => { const event = events.find(e => e.id === game.eventId)!; return <article key={game.id} className={p.won ? 'is-personal-win' : 'is-personal-loss'}><span className={`is-personal-result ${p.won ? 'is-blue' : 'is-red'}`}>{p.won ? '승리' : '패배'}</span><Champion id={p.champion} /><div className="is-personal-event"><strong>{event.name}</strong><small>{formatDate(event.date)} · 전체 {game.number}세트 · {laneNames[p.lane]}</small></div><span className="is-personal-kda"><strong>{p.kills} / {p.deaths} / {p.assists}</strong><small>{((p.kills + p.assists) / Math.max(p.deaths, 1)).toFixed(2)} KDA</small></span><span className="is-duration">{formatDuration(game.duration)}</span><PreviewLink className="is-analysis-link" to={gameHref(game.id)} data-return-id={`personal-${game.id}`} aria-label={`${event.name} 전체 ${game.number}세트 분석`}>분석<ChevronRight size={14} /></PreviewLink></article>; })}</div></> : <Feedback type="empty" title="이 포지션의 기록이 없습니다" action={<Btn onClick={() => onLane('all')}>전체 포지션 보기</Btn>}>다른 포지션이나 시즌을 선택해 주세요.</Feedback>}</>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
// Deterministic, preview-only fixtures. Every displayed aggregate is calculated
|
||||||
|
// from these games. These are illustrative records, not imported live results.
|
||||||
|
export const PREVIEW_PATH = '/design-previews/internal-stats.html';
|
||||||
|
export const ORIGINAL_PATH = '/communities/69ebe0adf627c11be2f020a1/internal-stats';
|
||||||
|
export const lanes = ['TOP', 'JUNGLE', 'MIDDLE', 'BOTTOM', 'UTILITY'] as const;
|
||||||
|
export type Lane = typeof lanes[number];
|
||||||
|
export const laneNames: Record<Lane, string> = { TOP: '탑', JUNGLE: '정글', MIDDLE: '미드', BOTTOM: '원딜', UTILITY: '서포터' };
|
||||||
|
export const seasons = [
|
||||||
|
{ id: '2026-2', name: '2026 시즌 2', from: '2026-06-01', to: '2026-06-30' },
|
||||||
|
{ id: '2026-1', name: '2026 시즌 1', from: '2026-05-01', to: '2026-05-31' },
|
||||||
|
];
|
||||||
|
export const champions = [
|
||||||
|
{ key: 'Ornn', name: '오른' }, { key: 'LeeSin', name: '리 신' },
|
||||||
|
{ key: 'Ahri', name: '아리' }, { key: 'Ezreal', name: '이즈리얼' }, { key: 'Thresh', name: '쓰레쉬' },
|
||||||
|
{ key: 'Gnar', name: '나르' }, { key: 'Viego', name: '비에고' },
|
||||||
|
{ key: 'Orianna', name: '오리아나' }, { key: 'Jinx', name: '징크스' }, { key: 'Leona', name: '레오나' },
|
||||||
|
{ key: 'Renekton', name: '레넥톤' }, { key: 'Sejuani', name: '세주아니' },
|
||||||
|
{ key: 'Syndra', name: '신드라' }, { key: 'Kaisa', name: '카이사' }, { key: 'Nautilus', name: '노틸러스' },
|
||||||
|
];
|
||||||
|
export function championImage(key: string) {
|
||||||
|
return `https://ddragon.leagueoflegends.com/cdn/15.24.1/img/champion/${key}.png`;
|
||||||
|
}
|
||||||
|
export type Player = { id: string; name: string; lane: Lane; teamId: string; champion: number };
|
||||||
|
export type Team = { id: string; name: string; players: Player[] };
|
||||||
|
const names = [
|
||||||
|
'덕 덕', '정 웅', '장금순', '귤팽이', 'Choco Queen',
|
||||||
|
'으악도망처', '정공글주', '프리리', '멘헤라 원딜', '달래줘',
|
||||||
|
'그 냥', '하냥이', '귤딱콩', '김꾸루꾸루', '서폿의 품격',
|
||||||
|
'캐리요정', 'Horra', '던 던', '포악한 너구리', '여름밤',
|
||||||
|
'오른손', '달빛정글', '민트초코', '봄날의 원딜', '구름산책',
|
||||||
|
'단단한 바위', '바람길', '새벽별', '라임소다', '느린우체통',
|
||||||
|
'탑의기억', '초록숲', '고양이발', '은빛화살', '작은파도',
|
||||||
|
'도토리', '숲속여우', '별사탕', '노을빛', '밤하늘',
|
||||||
|
];
|
||||||
|
export const teams: Team[] = ['포구리야~', '나물장수', '해온해줘', '똥칼라파워', '참봉발사', '월요일의 기적', '바텀 듀오', '다섯 번째 계절'].map((name, t) => ({
|
||||||
|
id: `t${t}`, name,
|
||||||
|
players: lanes.map((lane, i) => ({ id: `p${t * 5 + i}`, name: names[t * 5 + i], lane, teamId: `t${t}`, champion: (t % 3) * 5 + i })),
|
||||||
|
}));
|
||||||
|
export const players = teams.flatMap(t => t.players);
|
||||||
|
export const teamById = new Map(teams.map(t => [t.id, t]));
|
||||||
|
export const playerById = new Map(players.map(p => [p.id, p]));
|
||||||
|
export type Participant = {
|
||||||
|
playerId: string; teamId: string; lane: Lane; champion: number;
|
||||||
|
kills: number; deaths: number; assists: number; cs: number; gold: number;
|
||||||
|
damage: number; vision: number; kp: number; won: boolean;
|
||||||
|
};
|
||||||
|
export type Game = {
|
||||||
|
id: string; eventId: string; seriesId: string; number: number; ordinal: number;
|
||||||
|
blue: string; red: string; winner: string; duration: number;
|
||||||
|
evidence: 'ready' | 'missing' | 'pending'; participants: Participant[];
|
||||||
|
};
|
||||||
|
export type Series = { id: string; label: string; a: string; b: string; games: Game[]; winner: string; scoreA: number; scoreB: number };
|
||||||
|
export type Event = {
|
||||||
|
id: string; name: string; date: string; time: string; season: string;
|
||||||
|
format: 'pair' | 'tournament'; formatLabel: string; teamIds: string[];
|
||||||
|
champion: string | null; series: Series[];
|
||||||
|
};
|
||||||
|
function makeEvent(id: string, name: string, date: string, kind: 'double' | 'league' | 'pair', seed: number): Event {
|
||||||
|
const event: Event = { id, name, date, time: '21:00', season: date.startsWith('2026-06') ? '2026-2' : '2026-1', format: kind === 'pair' ? 'pair' : 'tournament', formatLabel: kind === 'double' ? '더블 엘리미네이션' : kind === 'league' ? '리그전' : '두 팀 내전', teamIds: [], champion: null, series: [] };
|
||||||
|
let serial = 0;
|
||||||
|
const series = (label: string, a: string, b: string, winner: string, count = 3) => {
|
||||||
|
const sid = `${id}-s${event.series.length + 1}`;
|
||||||
|
const games: Game[] = Array.from({ length: count }, (_, i) => {
|
||||||
|
serial += 1;
|
||||||
|
const n = serial;
|
||||||
|
const losingTeam = winner === a ? b : a;
|
||||||
|
const won = count === 3 && i === 1 ? losingTeam : winner;
|
||||||
|
const blue = i % 2 ? b : a;
|
||||||
|
const red = blue === a ? b : a;
|
||||||
|
const duration = 1560 + ((n * 127 + seed * 79) % 900);
|
||||||
|
const kills = [0, 1].map(side => lanes.map((_, slot) => 2 + (n * 7 + seed * 3 + side * 5 + slot * 3) % 10));
|
||||||
|
const participants = [blue, red].flatMap((tid, side) => teamById.get(tid)!.players.map((player, slot): Participant => {
|
||||||
|
const lane = lanes[(slot + (n % 7 === 0 ? 1 : 0)) % 5];
|
||||||
|
const teamKills = kills[side].reduce((sum, k) => sum + k, 0);
|
||||||
|
const assists = Math.min(teamKills - kills[side][slot], 5 + (n + slot * 4 + seed) % 17);
|
||||||
|
const gpm = (lane === 'UTILITY' ? 260 : lane === 'BOTTOM' ? 460 : 370) + (n * 13 + slot * 21 + seed * 7 + side * 37) % 100 + (won === tid ? 28 : 0);
|
||||||
|
return { playerId: player.id, teamId: tid, lane, champion: (player.champion + (n % 3) * 5) % champions.length, kills: kills[side][slot], deaths: kills[1 - side][slot], assists, cs: Math.round((lane === 'UTILITY' ? 1.2 : 5.5 + (n + slot) % 4) * duration / 60), gold: Math.round(gpm * duration / 60), damage: 8000 + ((n * 1331 + slot * 3443 + seed * 701 + side * 3911) % 24000), vision: lane === 'UTILITY' ? 45 + n % 42 : 12 + n % 30, kp: (kills[side][slot] + assists) / teamKills * 100, won: won === tid };
|
||||||
|
}));
|
||||||
|
const evidence = id === 'summer-finals' && [3, 6, 9, 12, 15, 18, 21].includes(n) ? 'missing' : id === 'friday-league' && n === 12 ? 'pending' : 'ready';
|
||||||
|
return { id: `${id}-g${n}`, eventId: id, seriesId: sid, number: n, ordinal: i + 1, blue, red, winner: won, duration, evidence, participants };
|
||||||
|
});
|
||||||
|
const result = { id: sid, label, a, b, games, winner, scoreA: games.filter(g => g.winner === a).length, scoreB: games.filter(g => g.winner === b).length };
|
||||||
|
event.series.push(result);
|
||||||
|
return { win: winner, loss: winner === a ? b : a };
|
||||||
|
};
|
||||||
|
if (kind === 'double') {
|
||||||
|
const q1 = series('승자조 1라운드 · 1경기', 't0', 't7', 't0', 2);
|
||||||
|
const q2 = series('승자조 1라운드 · 2경기', 't1', 't6', 't1', 2);
|
||||||
|
const q3 = series('승자조 1라운드 · 3경기', 't2', 't5', 't2', 2);
|
||||||
|
const q4 = series('승자조 1라운드 · 4경기', 't3', 't4', 't3', 2);
|
||||||
|
const s1 = series('승자조 준결승 · 1경기', q1.win, q2.win, q1.win, 2);
|
||||||
|
const s2 = series('승자조 준결승 · 2경기', q3.win, q4.win, q3.win, 2);
|
||||||
|
const l1 = series('패자조 1라운드 · 1경기', q1.loss, q2.loss, q2.loss, 2);
|
||||||
|
const l2 = series('패자조 1라운드 · 2경기', q3.loss, q4.loss, q4.loss, 2);
|
||||||
|
const l3 = series('패자조 2라운드 · 1경기', l1.win, s2.loss, s2.loss, 2);
|
||||||
|
const l4 = series('패자조 2라운드 · 2경기', l2.win, s1.loss, s1.loss, 2);
|
||||||
|
const wf = series('승자조 결승', s1.win, s2.win, s1.win, 2);
|
||||||
|
const ls = series('패자조 준결승', l3.win, l4.win, l4.win, 2);
|
||||||
|
const lf = series('패자조 결승', ls.win, wf.loss, ls.win, 2);
|
||||||
|
const final = series('최종 결승', wf.win, lf.win, wf.win, 3);
|
||||||
|
event.champion = final.win;
|
||||||
|
} else if (kind === 'league') {
|
||||||
|
const ids = seed % 2 ? ['t0', 't1', 't2', 't3'] : ['t4', 't5', 't6', 't7'];
|
||||||
|
for (let i = 0; i < 4; i++) for (let j = i + 1; j < 4; j++) series(`리그 ${event.series.length + 1}경기`, ids[i], ids[j], ids[i], 2);
|
||||||
|
event.champion = ids[0];
|
||||||
|
} else {
|
||||||
|
const a = `t${seed % 8}`, b = `t${(seed + 3) % 8}`;
|
||||||
|
series('3판 2선승', a, b, seed % 2 ? a : b);
|
||||||
|
}
|
||||||
|
event.teamIds = [...new Set(event.series.flatMap(s => [s.a, s.b]))];
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
export const events: Event[] = [
|
||||||
|
makeEvent('summer-finals', '6월 정기 멸망전', '2026-06-27', 'double', 1),
|
||||||
|
makeEvent('friday-league', '목요일, 한 판 더', '2026-06-25', 'league', 3),
|
||||||
|
makeEvent('tuesday-pair', '화요일 저녁 내전', '2026-06-23', 'pair', 2),
|
||||||
|
makeEvent('monday-league', '월요 내전 리그', '2026-06-22', 'league', 4),
|
||||||
|
makeEvent('weekend-pair', '주말 자유 내전', '2026-06-21', 'pair', 5),
|
||||||
|
makeEvent('saturday-pair', '토요일 리매치', '2026-06-20', 'pair', 6),
|
||||||
|
makeEvent('may-finals', '5월 마무리 리그', '2026-05-30', 'league', 7),
|
||||||
|
makeEvent('may-pair', '수요일 저녁 내전', '2026-05-27', 'pair', 0),
|
||||||
|
];
|
||||||
|
export const games = events.flatMap(e => e.series.flatMap(s => s.games));
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
# 내전 전적 코드 시안 — 2026-11-11
|
||||||
|
|
||||||
|
## 범위와 실행
|
||||||
|
|
||||||
|
- URL: http://localhost:5173/design-previews/internal-stats.html
|
||||||
|
- React / TypeScript / 기존 Vite 서버, 제품 테마 토큰과 Btn·Chip·AppTheme 재사용.
|
||||||
|
- 기존 전적 페이지를 대체하지 않는 독립 HTML 진입점. 제품 라우터와 API를 수정하지 않았다.
|
||||||
|
- 2시즌, 8내전, 40선수의 결정적인 예시 데이터. 실제 전적을 가져오거나 수정하지 않는다. 골드 흐름도 예시 타임라인이라고 화면에 표시한다.
|
||||||
|
- 원본의 색상과 서체를 유지하면서 이전 UX 검토 제안을 구현한 재설계다. 원본의 픽셀 복제가 목표가 아니다.
|
||||||
|
|
||||||
|
## 제안 반영
|
||||||
|
|
||||||
|
| 검토 항목 | 구현 |
|
||||||
|
| --- | --- |
|
||||||
|
| 요약 때문에 좁아지는 본문 | 상단 SeasonSummary, 전체 너비 순위표. 시즌 최고/누적/단일 경기 기록의 범위를 각각 표기 |
|
||||||
|
| 세트의 맥락 부족 | EventSection → SeriesResultGroup. 양 팀, 라운드, 시리즈 점수, 승리 팀, 개별/전체 세트 번호, 시간, 원본 상태 |
|
||||||
|
| 긴 경기 목록 탐색 | 데스크톱 날짜 인덱스, 모바일 바로가기, 내전 단위 추가 로드. 표시한 내전의 세트는 모두 공개 |
|
||||||
|
| 순위의 의미 | 기본값은 참여 경기 수. 중립적인 숫자 순위, 명시적 정렬, 최소 판수와 기준 미달 표기, 기준 충족 필터 |
|
||||||
|
| 모바일 표 | 순위·이름 고정, 승률·판수 우선, 나머지 지표를 가로 스크롤. 챔피언/상세 지표 삭제 없음 |
|
||||||
|
| 필터와 시즌 | 시즌·기간·유형·선수/팀/내전 검색, 개별 조건 해제와 초기화. 검색 순위는 원래 순위 유지 |
|
||||||
|
| 포지션 정확성 | 해당 포지션으로 플레이한 세트만 판수·승률·KDA·GPM·킬 관여·CS/분 재집계 |
|
||||||
|
| 탐색 복귀 | URL에 탭과 조건 저장. 개인 전적/내전/세트 분석 왕복 시 스크롤·포커스 복원. returnTo 중첩 제거 |
|
||||||
|
| 개인 및 경기 상세 | 같은 시즌의 개인 지표와 참가 세트, 근거 경기 링크, 10인 스코어보드, 골드 그래프/팀 비교 |
|
||||||
|
| 실패/부족한 데이터 | 빈 결과 초기화, 기간 오류, 로딩/조회 오류와 재시도, 원본 없음/수집 중과 공식 결과 분리 |
|
||||||
|
| 접근성 | 탭 방향키/Home/End, 표 헤더/aria-sort, 고정 열, 포커스 표시, skip link, 상태 알림, 이미지 alt, reduced-motion |
|
||||||
|
|
||||||
|
이전 조사에서 OpenDota·Lichess의 경기 맥락, Umami·Plausible·Metabase의 범위와 필터, TanStack Table의 정렬·고정 열, Radix·shadcn의 상태와 접근성, Recharts의 데이터 표현, brackets-viewer·react-tournament-brackets의 시리즈 계층을 검토했다. 이 시안은 해당 패턴을 현재 제품의 정보 상시 노출 원칙에 맞춰 구현한다. 라이브러리를 새로 추가하지 않았다. LeagueStats는 비상업 라이선스의 추가 참고 자료이며 코드를 복제하지 않았다.
|
||||||
|
|
||||||
|
## 시각 검수
|
||||||
|
|
||||||
|
증거 폴더: `C:/Users/park/.codex/visualizations/2026/11/11/01a1c9d5-e028-75a0-8b1b-f70126da1d08/internal-stats-preview/`
|
||||||
|
|
||||||
|
- 원본: 같은 상위 폴더의 `internal-stats-audit/01-recent.jpg`, `02-ranking.jpg`, `07-mobile-recent.jpg`, `08-mobile-ranking.jpg` 및 사용자 첨부 이미지.
|
||||||
|
- 구현: `01-desktop-matches.jpg`, `02-desktop-ranking.jpg`, `03-player-detail.jpg`, `04-set-analysis.jpg`, `05-mobile-overview.jpg`, `06-mobile-ranking.jpg`, `07-mobile-matches.jpg`, `08-mobile-analysis.jpg`, `09-mobile-error.jpg`, `10-missing-record.jpg`, `11-dark-missing-record.jpg`, `12-dark-ranking.jpg`.
|
||||||
|
- 1440×1050, 390×844 CSS viewport에서 실제 렌더를 확인. 원본의 밀집된 세트 행을 상대·점수가 있는 묶음으로 바꾸고 기존의 흰색/잉크/코랄 위계를 유지했다.
|
||||||
|
- 모바일 문서 가로 넘침 없음. 341px 표 컨테이너에서 이름·승률·판수 확인. 가로 스크롤 374px 후에도 이름 열의 x좌표 유지.
|
||||||
|
- 경기·선수·세트 화면의 글꼴, 카드 여백, 상태색, 선/표 정렬, 이미지 로딩, 라이트/다크를 확인. 확인한 화면의 깨진 이미지 없음.
|
||||||
|
- 발견 후 수정: 날짜 입력 이벤트가 UI와 URL에 반영되도록 onInput 사용, 차트 초기 크기 경고 제거, 한국어 설명 줄바꿈 개선, 시즌 요약 링크의 포지션 필터 제거, 경기 상세에서 시즌 변경 시 해당 시즌 목록으로 이동, 복귀 URL 중첩 제거.
|
||||||
|
- 승인된 재설계 범위에서 남은 P0/P1/P2 시각 문제 없음. 모바일 표의 나머지 열은 의도적으로 가로 스크롤한다. 정량 색 대비 감사·모든 브라우저 전수 검증은 수행하지 않았다.
|
||||||
|
|
||||||
|
## 동작 검증
|
||||||
|
|
||||||
|
- 시즌 2: 6내전, 62공식 세트, 54분석 가능 세트, 40선수. 시즌 1: 2내전, 15세트, 20선수로 전환됨.
|
||||||
|
- 14시리즈/29세트 내전의 공식 결과가 모두 보이며, 7개의 원본 누락은 분석 지표에서 제외됨.
|
||||||
|
- 선수 검색 + 정글 필터 → 개인 전적 → 세트 분석 → 복귀. 필터, 스크롤, 포커스 복원 확인.
|
||||||
|
- KDA/승률 정렬, 빈 선수 검색/초기화, 모바일 고정 열, 날짜 바로가기, 키보드 탭 전환 확인.
|
||||||
|
- 6월25일 이후 필터 2내전. 역전 날짜의 오류와 초기화, 목록 4→6개 추가 로드 확인.
|
||||||
|
- 조회 오류 → 다시 시도 → 같은 목록 복귀. 원본 없음에서 공식 결과만 표시하며 분석표 미생성. 수집 중 상태 재확인 문구 확인.
|
||||||
|
- 최종 차트 재진입 후 새 browser error/warn 로그 없음.
|
||||||
|
- TypeScript 검사, 대상 ESLint, 데이터 집계/시즌/상대·점수/필터/포지션/판수·정렬/최고 기록 근거를 검증하는 6개 테스트 통과.
|
||||||
|
- 독립 HTML을 대상으로 Vite production build 통과. 기존 전체 테마 CSS와 Recharts를 포함하므로 500KB chunk 안내가 있다. 시안 단계에서 분할 로딩 최적화는 적용하지 않았다.
|
||||||
|
|
||||||
|
## 적용 시 필요한 경계
|
||||||
|
|
||||||
|
이 결과는 검토 가능한 코드 시안이다. 실제 API의 오류 복구, 원본 가용성/시리즈/포지션별 집계 계약 연결은 제품 적용 단계의 작업이며 이 시안으로 실서버 오류가 해결된 것은 아니다. DDragon 챔피언 이미지에는 네트워크 연결이 필요하다. 배포하지 않았다.
|
||||||
|
|
||||||
|
final result: passed
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { StrictMode } from 'react';
|
||||||
|
import { createRoot } from 'react-dom/client';
|
||||||
|
import { BrowserRouter } from 'react-router';
|
||||||
|
import { AppTheme } from '../../ui/AppTheme';
|
||||||
|
import { initializeTheme } from '../../config';
|
||||||
|
import Preview from './Preview';
|
||||||
|
import '../../index.css';
|
||||||
|
import './preview.css';
|
||||||
|
|
||||||
|
initializeTheme();
|
||||||
|
createRoot(document.getElementById('root')!).render(
|
||||||
|
<StrictMode><BrowserRouter><AppTheme><Preview /></AppTheme></BrowserRouter></StrictMode>,
|
||||||
|
);
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import { events, games, players, teamById, type Event, type Game, type Lane, type Participant, type Player } from './data.ts';
|
||||||
|
|
||||||
|
export type SortKey = 'games' | 'winRate' | 'kda' | 'gpm' | 'kp' | 'cspm';
|
||||||
|
export const sortLabels: Record<SortKey, string> = { games: '참여 경기 수', winRate: '승률', kda: 'KDA', gpm: '분당 골드', kp: '킬 관여율', cspm: '분당 CS' };
|
||||||
|
export type PlayerRow = Player & { games: number; wins: number; losses: number; winRate: number; kda: number; gpm: number; kp: number; cspm: number; champions: Array<{ id: number; games: number }>; rank: number };
|
||||||
|
export function seasonEvents(season: string) { return events.filter(e => season === 'all' || e.season === season); }
|
||||||
|
export function gamesForSeason(season: string) {
|
||||||
|
const ids = new Set(seasonEvents(season).map(e => e.id));
|
||||||
|
return games.filter(g => ids.has(g.eventId));
|
||||||
|
}
|
||||||
|
export function formatDuration(seconds: number) { return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`; }
|
||||||
|
export function formatDate(date: string) { return new Intl.DateTimeFormat('ko-KR', { month: 'numeric', day: 'numeric', weekday: 'short', timeZone: 'Asia/Seoul' }).format(new Date(`${date}T12:00:00+09:00`)); }
|
||||||
|
export function teamName(id: string) { return teamById.get(id)?.name ?? '팀 미확인'; }
|
||||||
|
export function aggregateRows(season: string, lane: string, minimum: number, sort: SortKey, direction: 'asc' | 'desc' = 'desc'): PlayerRow[] {
|
||||||
|
const scope = gamesForSeason(season).filter(g => g.evidence === 'ready');
|
||||||
|
return players.flatMap(player => {
|
||||||
|
const appearances = scope.flatMap(game => game.participants.filter(p => p.playerId === player.id && (lane === 'all' || p.lane === lane)).map(p => ({ ...p, duration: game.duration })));
|
||||||
|
if (!appearances.length) return [];
|
||||||
|
const count = appearances.length;
|
||||||
|
const sum = (key: keyof Pick<Participant, 'kills' | 'deaths' | 'assists' | 'kp'>) => appearances.reduce((n, p) => n + p[key], 0);
|
||||||
|
const wins = appearances.filter(p => p.won).length;
|
||||||
|
const champCounts = new Map<number, number>();
|
||||||
|
appearances.forEach(p => champCounts.set(p.champion, (champCounts.get(p.champion) ?? 0) + 1));
|
||||||
|
return [{ ...player, games: count, wins, losses: count - wins, winRate: wins / count * 100, kda: (sum('kills') + sum('assists')) / Math.max(sum('deaths'), 1), gpm: appearances.reduce((n, p) => n + p.gold / (p.duration / 60), 0) / count, kp: sum('kp') / count, cspm: appearances.reduce((n, p) => n + p.cs / (p.duration / 60), 0) / count, champions: [...champCounts].map(([id, games]) => ({ id, games })).sort((a, b) => b.games - a.games).slice(0, 3), rank: 0 }];
|
||||||
|
}).sort((a, b) => Number(b.games >= minimum) - Number(a.games >= minimum) || (a[sort] - b[sort]) * (direction === 'desc' ? -1 : 1) || b.games - a.games || a.name.localeCompare(b.name, 'ko')).map((row, index) => ({ ...row, rank: index + 1 }));
|
||||||
|
}
|
||||||
|
export type MatchFilters = { season: string; query: string; format: string; from: string; to: string; player: string };
|
||||||
|
export function filterEvents(filters: MatchFilters): Event[] {
|
||||||
|
const query = filters.query.trim().toLocaleLowerCase('ko-KR');
|
||||||
|
return seasonEvents(filters.season).filter(event => {
|
||||||
|
if (filters.format !== 'all' && event.format !== filters.format) return false;
|
||||||
|
if (filters.from && event.date < filters.from) return false;
|
||||||
|
if (filters.to && event.date > filters.to) return false;
|
||||||
|
if (filters.player && !event.series.some(s => s.games.some(g => g.participants.some(p => p.playerId === filters.player)))) return false;
|
||||||
|
const haystack = [event.name, event.date, ...event.teamIds.flatMap(id => { const t = teamById.get(id)!; return [t.name, ...t.players.map(p => p.name)]; })].join(' ').toLocaleLowerCase('ko-KR');
|
||||||
|
return !query || haystack.includes(query);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
export function playerGames(id: string, season: string, lane: Lane | 'all' = 'all'): Array<{ game: Game; participant: Participant }> {
|
||||||
|
return gamesForSeason(season).filter(g => g.evidence === 'ready').flatMap(game => game.participants.filter(p => p.playerId === id && (lane === 'all' || p.lane === lane)).map(participant => ({ game, participant })));
|
||||||
|
}
|
||||||
|
export function seasonMetrics(season: string) {
|
||||||
|
const scopedEvents = seasonEvents(season), scopedGames = gamesForSeason(season), ready = scopedGames.filter(g => g.evidence === 'ready');
|
||||||
|
const rows = aggregateRows(season, 'all', 5, 'games');
|
||||||
|
const eligible = rows.filter(row => row.games >= 5);
|
||||||
|
const max = (key: 'kda' | 'kp' | 'cspm') => [...eligible].sort((a, b) => b[key] - a[key])[0];
|
||||||
|
const contributions = ready.flatMap(game => game.participants.map(p => ({ p, game, gpm: p.gold / (game.duration / 60) })));
|
||||||
|
const bestGpm = [...contributions].sort((a, b) => b.gpm - a.gpm)[0];
|
||||||
|
const kills = players.map(player => ({ player, kills: contributions.filter(v => v.p.playerId === player.id).reduce((n, v) => n + v.p.kills, 0) })).sort((a, b) => b.kills - a.kills)[0];
|
||||||
|
return { events: scopedEvents.length, sets: scopedGames.length, ready: ready.length, players: rows.length, blue: scopedGames.length ? scopedGames.filter(g => g.winner === g.blue).length / scopedGames.length * 100 : 0, topKda: max('kda'), topKp: max('kp'), topCs: max('cspm'), kills, bestGpm };
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
.internal-stats-preview{--is-ink:var(--color-text-primary);--is-muted:var(--color-text-secondary);--is-line:var(--color-border);--is-card:var(--color-background-card);--is-soft:var(--lts-sunken);--is-accent:var(--color-brand-coral);color:var(--is-ink);min-height:100vh;font-size:14px;line-height:1.55;background:var(--color-background-body);font-variant-numeric:tabular-nums}
|
||||||
|
.internal-stats-preview *{box-sizing:border-box}.internal-stats-preview button,.internal-stats-preview select{cursor:pointer}.internal-stats-preview button:disabled{cursor:wait}.internal-stats-preview a,.internal-stats-preview button,.internal-stats-preview input,.internal-stats-preview select{ -webkit-tap-highlight-color:transparent}.internal-stats-preview :focus-visible{outline:2px solid var(--color-win);outline-offset:3px}.internal-stats-preview a:hover{text-decoration-color:currentColor}.internal-stats-preview button{font:inherit}.internal-stats-preview h1,.internal-stats-preview h2,.internal-stats-preview h3,.internal-stats-preview p{margin:0}.internal-stats-preview a{color:inherit;text-decoration:none}.internal-stats-preview input,.internal-stats-preview select{font:inherit;color:inherit;background:transparent;min-width:0}.internal-stats-preview small{font-size:12px}.internal-stats-preview svg{flex-shrink:0}.is-muted{color:var(--is-muted)}.is-blue{color:var(--color-win)}.is-red{color:var(--color-loss)}.is-green{color:var(--color-leaf)}
|
||||||
|
.is-preview-notice{height:30px;display:flex;justify-content:space-between;align-items:center;padding:0 32px;font-size:11px;font-weight:600;letter-spacing:.01em;background:var(--is-soft);border-bottom:1px solid var(--is-line);color:var(--is-muted)}.is-preview-notice>span,.is-preview-notice a{display:flex;align-items:center;gap:8px}.is-preview-dot{width:5px;height:5px;background:var(--is-accent);border-radius:50%}.is-notice-separator{opacity:.4}.is-site-header{height:74px;display:flex;align-items:center;justify-content:space-between;max-width:1320px;margin:auto;padding:0 40px;border-bottom:1px solid var(--is-line)}.is-brand{font-size:22px;font-weight:850;letter-spacing:-.7px;line-height:1.1}.is-brand>span{display:block;font-size:8px;letter-spacing:2.5px;color:var(--is-muted);margin-top:6px}.is-site-header nav{height:100%;display:flex;gap:36px;align-items:stretch}.is-site-header nav a{display:flex;align-items:center;position:relative;font-size:14px;font-weight:650;color:var(--is-muted)}.is-site-header nav a[aria-current]{color:var(--is-ink)}.is-site-header nav a[aria-current]:after{content:"";position:absolute;bottom:-1px;left:0;right:0;height:3px;background:var(--is-accent);border-radius:3px 3px 0 0}.is-icon-button{display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;border:1px solid var(--is-line);border-radius:9px;background:var(--is-card);color:var(--is-muted)}.is-icon-button:hover{background:var(--is-soft)}
|
||||||
|
.is-page{max-width:1320px;padding:34px 40px 24px;margin:auto}.is-page-heading{display:flex;align-items:center;justify-content:space-between;gap:24px;margin-bottom:26px}.is-eyebrow{color:var(--is-muted);font-size:10px;font-weight:700;letter-spacing:1.8px;margin-bottom:8px!important}.is-page-heading h1{font-size:30px;line-height:1.25;letter-spacing:-1px;font-weight:800;margin-bottom:9px}.is-page-heading>.is-muted,.is-page-heading .is-muted{font-size:13px}.is-page-actions{display:flex;gap:10px;align-items:center}.is-season-select{display:flex;align-items:center;gap:10px;font-size:12px;font-weight:600;color:var(--is-muted)}.is-season-select select{min-height:40px;border:1px solid var(--is-line);background:var(--is-card);border-radius:9px;padding:7px 12px;font-size:13px;font-weight:650;color:var(--is-ink);min-width:145px}.is-season-select option,.is-select option,.is-sort-select option,.is-jump-mobile option{background:var(--is-card);color:var(--is-ink)}
|
||||||
|
.is-season-summary{border:1px solid var(--is-line);border-radius:12px;background:var(--is-card);overflow:hidden;margin-bottom:28px}.is-summary-topline{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:14px 22px 0;font-size:11px}.is-summary-topline>span:first-child{display:flex;align-items:center;gap:7px;font-weight:700;font-size:12px}.is-current-dot{height:6px;width:6px;background:var(--color-leaf);border-radius:50%}.is-summary-metrics{display:grid;grid-template-columns:1fr 1fr 1fr 1.5fr;padding:18px 22px 20px}.is-summary-metrics>div{padding:0 24px;border-right:1px solid var(--is-line)}.is-summary-metrics>div:first-child{padding-left:0}.is-summary-metrics>div:last-child{padding-right:0;border:0}.is-summary-metrics>div>span{display:block;color:var(--is-muted);font-size:12px;margin-bottom:5px}.is-summary-metrics>div>strong{font-size:27px;font-weight:800;letter-spacing:-.8px}.is-summary-metrics strong small{font-size:13px;font-weight:500;color:var(--is-muted);margin-left:5px}.is-side-rate>span{display:flex!important;align-items:center;justify-content:space-between;gap:12px}.is-side-rate>span small{font-size:10px}.is-side-rate>div:nth-child(2){display:flex;align-items:center;justify-content:space-between;gap:8px}.is-side-rate>div:nth-child(2)>strong{font-size:22px;font-weight:750}.is-side-rate>div:nth-child(2)>span{font-size:9px;font-weight:650;letter-spacing:1px;color:var(--is-muted)}.is-side-track,.is-comparison-track{height:4px;border-radius:4px;overflow:hidden;background:var(--color-loss);display:flex;margin-top:7px}.is-side-track>span,.is-comparison-track>span{display:block;height:100%;background:var(--color-win);border-right:2px solid var(--is-card)}.is-records-heading{display:flex;align-items:center;gap:7px;padding:10px 22px 0;border-top:1px solid var(--is-line);color:var(--is-muted);font-size:10px}.is-records-heading h2{font-size:11px;font-weight:700}.is-records-heading>span{margin-left:auto;font-size:10px}.is-records{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));padding:12px 8px 16px}.is-record{padding:0 14px;border-right:1px solid var(--is-line);min-width:0}.is-record:last-child{border-right:0}.is-record>p{display:flex;flex-direction:column;font-size:12px;font-weight:600;gap:1px}.is-record>p>span{font-size:10px;font-weight:400;color:var(--is-muted)}.is-record>div{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin-top:7px}.is-record strong{font-size:21px;letter-spacing:-.5px;white-space:nowrap;line-height:1.2}.is-record strong small{font-size:12px;margin-left:3px;font-weight:500}.is-record a{display:inline-flex;align-items:center;font-size:11px;gap:2px;word-break:keep-all;color:var(--is-muted)}.is-record a:hover{color:var(--color-win);text-decoration:underline}
|
||||||
|
.is-view-tabs{display:flex;border-bottom:1px solid var(--is-line);align-items:stretch;gap:28px}.is-view-tabs>button{display:flex;align-items:center;gap:8px;min-height:52px;font-size:15px;font-weight:700;border-bottom:3px solid transparent;color:var(--is-muted);background:transparent;padding:0 2px}.is-view-tabs>button[aria-selected=true]{color:var(--is-ink);border-color:var(--is-accent)}.is-view-tabs>button>span{font-size:11px;font-weight:650;color:var(--is-muted);background:var(--is-soft);padding:1px 6px;border-radius:5px}.is-tabs-caption{margin-left:auto;align-self:center;display:flex;gap:8px;color:var(--is-muted);font-size:11px}.is-tabs-caption>span{opacity:.5}.is-filter-bar{display:flex;align-items:center;gap:12px;flex-wrap:wrap;padding:17px 0;background:var(--color-background-body)}.is-search{display:flex;align-items:center;gap:9px;min-height:42px;border:1px solid var(--is-line);border-radius:8px;padding:0 12px;flex:1;min-width:220px;max-width:350px;background:var(--is-card);color:var(--is-muted)}.is-search:focus-within{border-color:var(--color-win);box-shadow:0 0 0 2px color-mix(in srgb,var(--color-win) 10%,transparent)}.is-search input{height:40px;flex:1;border:0;outline:none!important;font-size:13px;width:100%;color:var(--is-ink)}.is-search input::-webkit-search-cancel-button{display:none}.is-search input::placeholder{color:var(--is-muted);opacity:.85}.is-search button{border:0;background:none;display:grid;place-items:center;width:24px;height:30px}.is-type-filters{display:flex;gap:4px}.is-type-filters button{border-radius:6px!important;height:36px;font-size:12px;padding:0 12px}.is-date-range{margin-left:auto;display:flex;align-items:center;gap:8px;color:var(--is-muted);font-size:12px;border:1px solid var(--is-line);border-radius:8px;min-height:40px;padding:0 10px;background:var(--is-card)}.is-date-range input{font-size:12px;max-width:115px;border:0;min-height:36px}.is-select,.is-sort-select{display:flex;align-items:center;gap:7px;border:1px solid var(--is-line);border-radius:8px;padding:0 10px;min-height:40px;background:var(--is-card);font-size:12px}.is-select>span{color:var(--is-muted);font-size:11px}.is-select select,.is-sort-select select{border:0;min-height:38px;max-width:150px;font-size:12px}.is-sort-select{margin-left:auto}.is-active-filters{display:flex;align-items:center;flex-wrap:wrap;gap:7px;padding:0 0 16px;font-size:11px}.is-active-filters>span{color:var(--is-muted);margin-right:4px}.is-active-filters>button{display:flex;align-items:center;gap:8px;min-height:28px;padding:3px 8px;background:var(--is-soft);border:1px solid var(--is-line);border-radius:5px;font-size:11px}.is-active-filters>.is-reset{background:transparent;color:var(--is-muted);border:0;text-decoration:underline;text-underline-offset:3px}.is-inline-error{font-size:12px;color:var(--color-loss);padding:0 0 16px}.is-result-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:7px 0 15px}.is-result-heading h2{font-size:15px;font-weight:750;display:flex;gap:8px;align-items:center}.is-result-heading h2>span{font-size:12px;font-weight:500;color:var(--is-muted)}.is-result-heading p{color:var(--is-muted);font-size:11px;margin-top:3px}.is-checkbox{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--is-muted)}.is-checkbox input{accent-color:var(--color-brand-ink);width:15px;height:15px}
|
||||||
|
.is-events-layout{display:grid;grid-template-columns:155px minmax(0,1fr);gap:24px;align-items:start}.is-event-jump{position:sticky;top:20px}.is-jump-desktop>p{display:flex;gap:7px;align-items:center;font-weight:650;font-size:11px;color:var(--is-muted);margin:1px 0 14px}.is-jump-desktop>a{display:flex;flex-direction:column;padding:10px 12px;margin-bottom:5px;border-left:2px solid var(--is-line);gap:3px}.is-jump-desktop>a:hover{background:var(--is-soft);border-left-color:var(--is-accent)}.is-jump-desktop>a>span{font-size:11px;color:var(--is-muted)}.is-jump-desktop>a>strong{font-size:12px;font-weight:650;word-break:keep-all}.is-jump-desktop>a>small{font-size:10px;color:var(--is-muted)}.is-jump-mobile{display:none}.is-events-list{min-width:0}.is-event-section{border:1px solid var(--is-line);border-radius:11px;margin-bottom:22px;background:var(--is-card);scroll-margin-top:24px;overflow:hidden}.is-event-section>header{display:flex;align-items:center;justify-content:space-between;padding:20px 22px 10px;gap:12px}.is-event-kicker{display:flex;gap:8px;font-size:10px;color:var(--is-muted);align-items:center;margin-bottom:7px}.is-event-kicker>span:first-child{background:var(--is-soft);border:1px solid var(--is-line);border-radius:4px;padding:1px 6px;font-weight:600}.is-event-section h3{font-size:19px;letter-spacing:-.5px;font-weight:750}.is-event-section h3 a{display:inline-flex;gap:5px;align-items:center}.is-event-section h3 a:hover{color:var(--color-win)}.is-text-link{display:inline-flex;align-items:center;gap:7px;font-size:12px;font-weight:650;min-height:36px;white-space:nowrap}.is-event-overview{padding:0 22px 17px;display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}.is-event-meta{display:flex;align-items:center;gap:10px;flex-wrap:wrap;color:var(--is-muted);font-size:10px}.is-event-meta>span{display:flex;align-items:center;gap:4px}.is-event-meta .is-analysis-count{color:var(--color-win)}.is-champion-label{display:flex;gap:5px;align-items:center;font-size:11px;color:var(--color-gold)}.is-champion-label strong{font-size:12px;font-weight:700}.is-series-score{display:flex;align-items:center;gap:8px;font-size:11px}.is-series-score>strong{font-size:14px}.is-series-grid,.is-detail-series{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 22px;padding:0 22px 6px}.is-series-group{border-top:1px solid var(--is-line);padding:12px 0 10px;min-width:0}.is-series-group>header{display:flex;align-items:center;justify-content:space-between;color:var(--is-muted);font-size:10px;margin-bottom:8px}.is-series-group>header>span:first-child{font-weight:600}.is-matchup{display:grid;grid-template-columns:minmax(0,1fr) 44px minmax(0,1fr);align-items:center;gap:8px;margin-bottom:6px;min-height:30px}.is-matchup>strong{font-size:12px;font-weight:500;color:var(--is-muted);word-break:keep-all}.is-matchup>strong:last-child{text-align:right}.is-matchup .is-winner{color:var(--is-ink);font-weight:750}.is-score{display:flex;align-items:center;justify-content:space-between;gap:5px;font-size:16px;font-weight:750;color:var(--is-muted)}.is-score i{font-size:12px;font-style:normal;font-weight:400;color:var(--is-muted)}.is-series-group ul{list-style:none;padding:0;margin:0}.is-series-group li{display:grid;grid-template-columns:51px minmax(0,1fr) 47px 68px;align-items:center;gap:6px;min-height:46px;border-top:1px solid color-mix(in srgb,var(--is-line) 65%,transparent);font-size:11px}.is-set-number{font-weight:600;font-size:11px}.is-set-number small{display:block;color:var(--is-muted);font-size:9px;font-weight:400}.is-set-winner{display:flex;align-items:center;gap:5px;min-width:0;overflow-wrap:anywhere;font-size:11px}.is-win-badge{font-size:9px;line-height:17px;width:17px;flex-shrink:0;text-align:center;background:var(--color-win-tint);color:var(--color-win);font-weight:750;border-radius:3px}.is-duration{display:flex;gap:3px;align-items:center;font-size:10px;color:var(--is-muted);white-space:nowrap}.is-analysis-link{display:flex;align-items:center;justify-content:flex-end;gap:1px;min-height:40px;font-size:11px;font-weight:650;color:var(--color-win)!important;border-radius:4px;padding:0 2px}.is-analysis-link:hover{background:var(--is-soft)}.is-analysis-link.is-unavailable{color:var(--is-muted)!important;font-size:10px;font-weight:450}.is-load-more{min-height:48px;border:1px solid var(--is-line);border-radius:8px;display:flex;align-items:center;justify-content:center;gap:8px;width:100%;background:var(--is-card);font-size:13px!important;font-weight:650!important}.is-load-more span{margin-left:6px;color:var(--is-muted);font-size:11px;font-weight:400}
|
||||||
|
.is-table-scroll{width:100%;overflow:auto;border:1px solid var(--is-line);border-radius:9px;background:var(--is-card);scrollbar-width:thin;overscroll-behavior-x:contain}.is-leaderboard{width:100%;min-width:850px;table-layout:fixed;border-collapse:separate;border-spacing:0;font-size:13px}.is-col-rank{width:48px}.is-col-player{width:210px}.is-col-win{width:105px}.is-col-games{width:85px}.is-col-kda{width:80px}.is-col-champions{width:145px}.is-leaderboard th,.is-leaderboard td{text-align:right;padding:12px 14px;border-bottom:1px solid var(--is-line);vertical-align:middle;background:var(--is-card);height:72px}.is-leaderboard thead th{height:45px;background:var(--is-soft);font-size:11px;color:var(--is-muted);font-weight:600;white-space:nowrap}.is-leaderboard thead button{display:inline-flex;align-items:center;gap:4px;background:transparent;border:0;font-size:11px;padding:4px 0;min-height:28px}.is-leaderboard thead button.is-sorted{color:var(--color-win);font-weight:750}.is-leaderboard tbody tr:last-child>*{border-bottom:0}.is-leaderboard tbody tr:hover>*{background:color-mix(in srgb,var(--is-soft) 50%,var(--is-card))}.is-leaderboard .is-sticky-rank{position:sticky;left:0;z-index:2;text-align:center;padding:12px 4px}.is-leaderboard .is-sticky-player{position:sticky;left:48px;z-index:2;text-align:left;box-shadow:6px 0 8px -8px #0006}.is-leaderboard thead .is-sticky-rank,.is-leaderboard thead .is-sticky-player{z-index:3}.is-rank-number{font-size:12px;color:var(--is-muted);font-weight:500}.is-player-identity{display:flex;align-items:center;gap:10px;text-align:left;min-width:0}.is-player-identity>div{min-width:0}.is-player-identity a{font-size:13px;font-weight:700;overflow-wrap:anywhere}.is-player-identity a:hover{color:var(--color-win);text-decoration:underline}.is-player-identity small{display:flex;align-items:center;gap:4px;font-size:10px;color:var(--is-muted);margin-top:3px;font-weight:400}.is-player-identity small a{font-size:10px;font-weight:450}.is-champion{width:32px;height:32px;border-radius:7px;object-fit:cover;border:1px solid var(--is-line);flex-shrink:0}.is-champion-small{width:27px;height:27px;border-radius:5px}.is-champion-large{width:72px;height:72px;border-radius:14px}.is-champion-list{display:flex;gap:6px;justify-content:flex-end}.is-champion-list>span{text-align:center}.is-champion-list small{display:block;color:var(--is-muted);font-size:9px;line-height:1.4;margin-top:3px}.is-leaderboard td>strong{font-size:14px;font-weight:650}.is-leaderboard td>strong small{font-size:10px;margin-left:1px}.is-win-track{height:3px;background:color-mix(in srgb,var(--color-loss) 24%,transparent);border-radius:3px;overflow:hidden;margin-top:7px}.is-win-track span{display:block;background:var(--color-win);height:100%}.is-win-loss{display:block;font-size:10px!important;margin-top:4px;color:var(--is-muted);white-space:nowrap}.is-sample-badge{font-size:9px;font-weight:500;color:var(--is-muted);border:1px solid var(--is-line);padding:1px 4px;border-radius:3px;display:inline-block;margin-top:3px}.is-threshold-first>*{border-top:2px solid var(--is-line)}.is-under-qualified td{color:var(--is-muted)}.is-arrow-up{transform:rotate(180deg)}.is-table-hint{display:none;align-items:center;gap:5px;font-size:10px;color:var(--is-muted);margin:0 0 8px}.is-table-footnote{display:flex;align-items:flex-start;gap:6px;font-size:11px;color:var(--is-muted);margin-top:12px}.is-table-footnote svg{margin-top:2px}
|
||||||
|
.is-feedback{border:1px solid var(--is-line);border-radius:10px;background:var(--is-card);padding:50px 20px;text-align:center;display:flex;flex-direction:column;align-items:center;gap:12px;margin:18px 0;color:var(--is-muted)}.is-feedback h2{font-size:17px;color:var(--is-ink);font-weight:700}.is-feedback p{max-width:520px;font-size:13px;line-height:1.7}.is-feedback-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:center;margin-top:5px}.is-feedback-error{border-color:color-mix(in srgb,var(--color-loss) 30%,var(--is-line));background:color-mix(in srgb,var(--color-loss) 3%,var(--is-card))}.is-feedback-error>svg{color:var(--color-loss)}.is-feedback-loading>svg{animation:is-spin 1.2s linear infinite}@keyframes is-spin{to{transform:rotate(360deg)}}.is-back-link{display:inline-flex;align-items:center;gap:7px;min-height:36px;font-size:12px;color:var(--is-muted)!important;margin-bottom:15px}.is-back-link:hover{color:var(--is-ink)!important}.is-detail-heading{margin-bottom:22px}.is-detail-heading+ .is-event-overview{padding:16px 20px;background:var(--is-card);border:1px solid var(--is-line);border-radius:9px;margin-bottom:24px}.is-detail-series{padding:0;gap:18px}.is-detail-series .is-series-group{background:var(--is-card);border:1px solid var(--is-line);border-radius:9px;padding:17px 20px}.is-detail-series .is-matchup>strong{font-size:14px}.is-detail-series .is-series-group li{font-size:12px;min-height:52px;grid-template-columns:65px minmax(0,1fr) 60px 80px}.is-detail-series .is-set-winner{font-size:12px}.is-detail-series .is-analysis-link{font-size:12px}
|
||||||
|
.is-game-context{display:flex;align-items:center;flex-wrap:wrap;gap:8px 16px;font-size:12px;color:var(--is-muted);border-top:1px solid var(--is-line);padding-top:17px}.is-game-context>a,.is-game-context>span{display:flex;align-items:center;gap:5px}.is-game-context>a{color:var(--color-win);font-weight:600}.is-game-context>span:last-child{margin-left:auto}.is-game-result{display:grid;grid-template-columns:1fr auto 1fr;gap:30px;align-items:center;padding:32px 36px;background:var(--is-card);border:1px solid var(--is-line);border-radius:11px;margin:20px 0 24px;text-align:center}.is-game-result>div>span{font-size:10px;font-weight:650;letter-spacing:1.2px}.is-game-result h2{font-size:22px;font-weight:750;margin:5px 0}.is-game-result>div>b{font-size:12px;color:var(--is-muted)}.is-game-result>div.is-result-win>b{color:var(--color-win)}.is-game-result>strong{font-size:34px;font-weight:800;letter-spacing:-.6px}.is-game-result>strong>small{font-size:10px;color:var(--is-muted);font-weight:400;display:block;letter-spacing:0;margin-top:4px}.is-analysis-top{display:grid;grid-template-columns:1.6fr 1fr;gap:20px;margin-bottom:24px}.is-analysis-panel{padding:20px;border:1px solid var(--is-line);border-radius:10px;background:var(--is-card);min-width:0}.is-analysis-panel>header{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:14px}.is-analysis-panel h2{font-size:15px;font-weight:750}.is-analysis-panel>header>span{font-size:10px;color:var(--is-muted)}.is-chart{height:215px;width:100%;min-width:0}.is-chart-description{font-size:10px;text-align:center;margin-top:7px!important}.is-team-comparison{display:flex;flex-direction:column;gap:30px;padding:22px 0 15px}.is-team-comparison>div>div:first-child{display:flex;justify-content:space-between;align-items:center;font-size:12px}.is-team-comparison strong{font-size:17px;font-weight:700}.is-comparison-track{height:6px;margin-top:10px}.is-scoreboard{border:1px solid var(--is-line);border-radius:10px;overflow:hidden;background:var(--is-card);margin-bottom:24px}.is-scoreboard>header{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:16px 20px}.is-scoreboard h2{display:flex;align-items:center;gap:12px;font-size:16px;font-weight:750}.is-scoreboard h2>span{font-size:12px}.is-scoreboard>header>span{font-size:11px;color:var(--is-muted)}.is-scoreboard .is-table-scroll{border:0;border-top:1px solid var(--is-line);border-radius:0}.is-scoreboard table{width:100%;min-width:800px;border-collapse:separate;border-spacing:0;font-size:12px}.is-scoreboard thead th{background:var(--is-soft);font-size:11px;font-weight:550;text-align:right;padding:10px 18px;color:var(--is-muted)}.is-scoreboard th:first-child{position:sticky;left:0;min-width:190px;text-align:left;z-index:2}.is-scoreboard tbody th:first-child{background:var(--is-card)}.is-scoreboard tbody th,.is-scoreboard td{padding:12px 18px;border-top:1px solid var(--is-line);text-align:right;white-space:nowrap}.is-scoreboard td>small{display:block;font-size:10px;color:var(--is-muted);margin-top:3px}
|
||||||
|
.is-profile-heading{display:flex;align-items:center;gap:18px;padding:22px;border:1px solid var(--is-line);border-radius:10px;background:var(--is-card)}.is-profile-heading h2{font-size:23px;letter-spacing:-.7px;font-weight:800;margin-bottom:5px}.is-profile-heading>div>span{font-size:12px;color:var(--is-muted)}.is-action-link{margin-left:auto;display:flex;align-items:center;justify-content:center;gap:8px;padding:9px 13px;min-height:40px;border:1px solid var(--is-line);border-radius:8px;font-size:12px;font-weight:650;background:var(--is-card)}.is-action-link:hover{background:var(--is-soft)}.is-profile-filters{display:flex;align-items:center;gap:14px;margin:20px 0}.is-profile-filters>p{font-size:11px}.is-profile-stats{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:0;border:1px solid var(--is-line);border-radius:9px;background:var(--is-card);padding:18px 4px;margin-bottom:28px}.is-profile-stats>div{padding:0 18px;border-right:1px solid var(--is-line)}.is-profile-stats>div:last-child{border:0}.is-profile-stats span{font-size:11px;color:var(--is-muted)}.is-profile-stats strong{display:block;font-size:24px;line-height:1.5;letter-spacing:-.6px;font-weight:750}.is-profile-stats small{font-size:10px;color:var(--is-muted)}.is-personal-games{border:1px solid var(--is-line);border-radius:10px;overflow:hidden}.is-personal-games article{display:flex;gap:18px;align-items:center;border-bottom:1px solid var(--is-line);padding:16px 20px;background:var(--is-card);border-left:3px solid var(--color-win)}.is-personal-games article:last-child{border-bottom:0}.is-personal-games article.is-personal-loss{border-left-color:var(--color-loss)}.is-personal-result{font-size:12px;font-weight:700}.is-personal-event{flex:1;min-width:0}.is-personal-event>strong{font-size:13px;font-weight:650}.is-personal-event>small{font-size:11px;color:var(--is-muted);display:block;margin-top:3px}.is-personal-kda{font-size:13px;text-align:center}.is-personal-kda>small{display:block;color:var(--is-muted);font-size:10px;margin-top:4px}.is-personal-games .is-analysis-link{padding:0 8px;min-width:50px}.is-personal-games .is-duration{font-size:11px}
|
||||||
|
.is-announcement{position:fixed;bottom:22px;left:50%;transform:translateX(-50%);z-index:20;border-radius:8px;box-shadow:0 4px 20px #0002;background:var(--color-brand-ink);color:#fff;font-size:12px;padding:12px 18px;max-width:90vw;width:max-content}.is-announcement:empty{display:none}.is-page-footer{border-top:1px solid var(--is-line);margin-top:45px;padding:22px 0;display:flex;justify-content:space-between;gap:14px;font-size:10px;color:var(--is-muted)}.is-page-footer>span:first-child>span{margin:0 6px}.is-preview-tools{display:flex;align-items:center;justify-content:center;gap:6px;font-size:10px;color:var(--is-muted);padding:10px;border:1px dashed var(--is-line);border-radius:7px}.is-preview-tools>span{margin-right:8px}.is-preview-tools button{border:1px solid var(--is-line);background:var(--is-card);border-radius:4px;padding:4px 10px;font-size:10px}.is-preview-tools button[aria-pressed=true]{background:var(--is-soft);color:var(--is-ink)}.is-skip-link{position:fixed;top:-100px;left:16px;padding:12px 18px;background:var(--is-card);border:2px solid var(--color-win);z-index:100}.is-skip-link:focus{top:12px}
|
||||||
|
@media(min-width:1100px){.is-filter-bar{position:sticky;top:0;z-index:5;border-bottom:1px solid transparent}.is-filter-bar:focus-within{z-index:6}}
|
||||||
|
@media(max-width:1100px){.is-page{padding:28px 24px 20px}.is-site-header{padding:0 24px}.is-events-layout{grid-template-columns:130px minmax(0,1fr);gap:18px}.is-series-grid{grid-template-columns:1fr}.is-record>div{align-items:flex-start;flex-direction:column;gap:4px}.is-date-range{margin-left:0}.is-filter-bar{gap:8px}.is-search{min-width:200px;max-width:none}.is-col-player{width:180px}.is-table-hint{display:flex}.is-tabs-caption{display:none}.is-leaderboard .is-sticky-player{left:48px}.is-profile-stats>div{padding:0 12px}.is-analysis-top{grid-template-columns:1.3fr 1fr}.is-team-comparison strong{font-size:15px}}
|
||||||
|
@media(max-width:760px){.is-page{padding:22px 16px 16px}.is-preview-notice{padding:0 16px;height:28px;font-size:10px}.is-preview-notice a{font-size:9px}.is-site-header{padding:0 16px;height:64px}.is-brand{font-size:19px}.is-brand>span{font-size:6px;letter-spacing:1.8px;margin-top:4px}.is-site-header nav{gap:18px}.is-site-header nav a{font-size:12px}.is-site-header>.is-icon-button{width:31px;height:31px;border:0;background:transparent}.is-page-heading{align-items:flex-start;gap:12px;margin-bottom:20px}.is-page-heading h1{font-size:26px}.is-eyebrow{font-size:8px;letter-spacing:1.2px}.is-page-heading .is-muted{font-size:11px;max-width:185px}.is-page-actions{gap:5px}.is-page-actions>.is-icon-button{width:30px;height:34px;margin-top:20px}.is-season-select{flex-direction:column;align-items:flex-start;gap:4px;font-size:10px}.is-season-select select{min-width:120px;min-height:34px;padding:5px 7px;font-size:11px}.is-summary-topline{padding:12px 14px 0;flex-wrap:wrap;gap:4px}.is-summary-topline>span:first-child{font-size:11px}.is-summary-topline>.is-muted{font-size:9px}.is-summary-metrics{grid-template-columns:repeat(3,1fr);padding:15px 14px}.is-summary-metrics>div{padding:0 14px}.is-summary-metrics>div:nth-child(3){border:0}.is-summary-metrics>div>span{font-size:10px}.is-summary-metrics>div>strong{font-size:24px}.is-summary-metrics .is-side-rate{grid-column:1/-1;padding:12px 0 0;margin-top:13px;border-top:1px solid var(--is-line);display:grid;grid-template-columns:1fr 1fr;gap:3px 10px;align-items:center}.is-side-rate>span{margin:0!important;font-size:10px}.is-side-rate>span small{font-size:9px}.is-side-rate>div:nth-child(2)>strong{font-size:16px}.is-side-rate strong small{font-size:10px;margin-left:1px}.is-side-rate>div:nth-child(2)>span{font-size:7px;letter-spacing:.5px}.is-side-rate .is-side-track{grid-column:1/-1;margin-top:3px;height:3px}.is-records-heading{padding:10px 14px 0;flex-wrap:wrap;font-size:10px}.is-records-heading>span{font-size:9px;margin-left:0;flex:1;text-align:right;min-width:160px}.is-records{grid-template-columns:repeat(2,minmax(0,1fr));gap:13px 0;padding:12px 0 15px}.is-record{padding:0 14px}.is-record:nth-child(2n){border-right:0}.is-record:last-child{border:0}.is-record>p{font-size:10px}.is-record>p>span{font-size:9px}.is-record>div{flex-direction:row;align-items:baseline;gap:5px;margin-top:4px}.is-record strong{font-size:18px}.is-record strong small{font-size:10px}.is-record a{font-size:10px}.is-season-summary{margin-bottom:18px;border-radius:9px}.is-view-tabs{gap:22px}.is-view-tabs>button{font-size:13px;gap:6px;min-height:46px}.is-view-tabs>button>span{font-size:10px}.is-filter-bar{padding:14px 0;gap:9px}.is-search{width:100%;flex-basis:100%;min-height:40px;max-width:none}.is-search input{height:38px;font-size:12px}.is-type-filters{flex:1}.is-type-filters button{height:34px;font-size:11px;padding:0 11px}.is-date-range{width:100%;justify-content:space-between;min-height:37px;padding:0 9px}.is-date-range input{max-width:125px;font-size:11px}.is-date-range label{flex:1}.is-select,.is-sort-select{padding:0 7px;min-height:36px;font-size:11px;gap:4px}.is-select>span{font-size:9px}.is-select select,.is-sort-select select{font-size:11px;min-height:34px;max-width:112px}.is-sort-select{margin-left:0;flex:1;justify-content:space-between}.is-sort-select svg{width:13px}.is-sort-select select{max-width:100px;width:100%}.is-active-filters{font-size:10px;padding-bottom:12px;gap:5px}.is-active-filters>button{font-size:10px}.is-result-heading{align-items:flex-start;gap:8px;margin-top:4px}.is-result-heading h2{font-size:14px}.is-result-heading p{font-size:10px;max-width:230px}.is-result-heading .is-checkbox{font-size:9px;white-space:nowrap;gap:4px;margin-top:3px}.is-result-heading .is-checkbox input{width:12px;height:12px}.is-events-layout{display:block}.is-jump-desktop{display:none}.is-event-jump{top:0;z-index:5;margin:0 -1px 14px;padding:5px 1px;background:var(--color-background-body)}.is-jump-mobile{display:flex;align-items:center;gap:8px;padding:0 9px;min-height:40px;border:1px solid var(--is-line);border-radius:7px;background:var(--is-card);font-size:11px}.is-jump-mobile>span{color:var(--is-muted);white-space:nowrap}.is-jump-mobile>select{flex:1;max-width:100%;min-width:0;height:38px;font-size:11px;border:0}.is-event-section{border-radius:9px;margin-bottom:16px;scroll-margin-top:60px}.is-event-section>header{padding:16px 14px 9px;gap:8px}.is-event-section h3{font-size:17px}.is-event-section h3 svg{display:none}.is-event-kicker{font-size:9px;margin-bottom:6px}.is-event-detail-link{font-size:10px;gap:3px}.is-event-detail-link svg{width:12px}.is-event-overview{padding:0 14px 14px;gap:9px}.is-event-meta{font-size:9px;gap:5px 9px}.is-event-meta svg{width:12px}.is-event-meta .is-analysis-count{font-size:9px}.is-champion-label{font-size:10px}.is-champion-label strong{font-size:11px}.is-series-grid{padding:0 14px 3px;grid-template-columns:1fr}.is-series-group{padding:11px 0 9px}.is-series-group>header{font-sizLine truncated
|
||||||
|
@media(max-width:370px){.is-site-header nav{gap:12px}.is-brand{font-size:17px}.is-page{padding-left:12px;padding-right:12px}.is-season-select select{min-width:110px}.is-page-actions>.is-icon-button{display:none}.is-records{grid-template-columns:1fr 1fr}.is-record>div{flex-direction:column;gap:3px}.is-series-group li{grid-template-columns:40px minmax(0,1fr) 38px 59px}.is-select{padding:0 5px}.is-select>span{font-size:8px}.is-sort-select{padding:0 5px}}
|
||||||
|
@media(prefers-reduced-motion:reduce){.internal-stats-preview *{scroll-behavior:auto!important;animation:none!important;transition:none!important}}
|
||||||
|
|
||||||
|
.internal-stats-preview .is-page-heading p{word-break:keep-all}
|
||||||
|
.internal-stats-preview .is-feedback p{word-break:keep-all}
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
import { useId, useState, type KeyboardEvent } from "react";
|
||||||
|
import { ArrowUpRight } from "lucide-react";
|
||||||
|
import { Tooltip } from "@astryxdesign/core/Tooltip";
|
||||||
|
import { RankBadge } from "../../components/RankBadge";
|
||||||
|
import { formatRankDetail } from "../../components/rankBadgeUtils";
|
||||||
|
import { championDisplayName, championIconUrl, profileIconUrl } from "../../lib/ddragon";
|
||||||
|
import { POSITION_ORDER, positionIcon, positionLabel } from "../../lib/league";
|
||||||
|
import { gamesByQueue, manifest, profile, snapshot } from "./data";
|
||||||
|
import { selectRecentGames, summarizeGames, type ExampleGame, type PositionFilter, type Queue } from "./stats";
|
||||||
|
import "../player-information/preview.css";
|
||||||
|
import "./preview.css";
|
||||||
|
|
||||||
|
const POSITIONS: PositionFilter[] = ["ALL", ...POSITION_ORDER];
|
||||||
|
const QUEUES: Queue[] = ["internal", "solo"];
|
||||||
|
const PREFERENCES = [...snapshot.preferredPositions].sort((a, b) => a.priority - b.priority);
|
||||||
|
const queueName = (queue: Queue) => queue === "internal" ? "내전" : "솔로랭크";
|
||||||
|
const positionName = (position: PositionFilter) => position === "ALL" ? "전체" : positionLabel[position];
|
||||||
|
const dateLabel = (date: string) => date.slice(5).replace("-", ".");
|
||||||
|
|
||||||
|
function moveTab<T extends string>(event: KeyboardEvent<HTMLButtonElement>, values: T[], current: T, select: (value: T) => void, prefix: string) {
|
||||||
|
if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;
|
||||||
|
event.preventDefault();
|
||||||
|
const index = values.indexOf(current);
|
||||||
|
const next = event.key === "Home" ? values[0] : event.key === "End" ? values[values.length - 1] : values[(index + (event.key === "ArrowRight" ? 1 : -1) + values.length) % values.length];
|
||||||
|
select(next);
|
||||||
|
document.getElementById(`${prefix}-${next}`)?.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
function Portrait({ championId }: { championId: number }) {
|
||||||
|
return <span className="pi-champion-portrait"><img src={championIconUrl(manifest, championId) ?? undefined} alt="" /></span>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ChampionGroup({ summary }: { summary: NonNullable<ReturnType<typeof summarizeGames>> }) {
|
||||||
|
return <div className="p2-champions">
|
||||||
|
<h3>최근 챔피언</h3>
|
||||||
|
<div className="p2-avatar-group" aria-label="최근 사용 챔피언">
|
||||||
|
{summary.champions.slice(0, 10).map(champion => {
|
||||||
|
const name = championDisplayName(manifest, champion.championId);
|
||||||
|
const description = `${name} · ${champion.games}경기 · ${champion.wins}승 ${champion.games - champion.wins}패 · 승률 ${Math.round(champion.wins / champion.games * 100)}%`;
|
||||||
|
return <Tooltip content={description} placement="below" key={champion.championId}>
|
||||||
|
<span className="p2-avatar" role="img" tabIndex={0} aria-label={description}><Portrait championId={champion.championId} /></span>
|
||||||
|
</Tooltip>;
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function Metrics({ summary }: { summary: ReturnType<typeof summarizeGames> }) {
|
||||||
|
return <div className="p2-metrics" aria-label="선택한 포지션의 요약">
|
||||||
|
<div><span>승률</span><strong>{summary ? <>{summary.winRate}<small>%</small></> : "—"}</strong><p>{summary ? `${summary.wins}승 ${summary.losses}패 · ${summary.games}경기` : "기록 없음"}</p></div>
|
||||||
|
<div><span>KDA</span><strong data-perfect={summary?.kda === "Perfect"}>{summary?.kda ?? "—"}</strong><p>{summary?.averageKda ?? "기록 없음"}</p></div>
|
||||||
|
<div><span>평균 킬 관여율</span><strong>{summary ? <>{Math.round(summary.killParticipation)}<small>%</small></> : "—"}</strong><p>팀 처치 참여 비율</p></div>
|
||||||
|
</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function PlayMetrics({ summary, position }: { summary: NonNullable<ReturnType<typeof summarizeGames>>; position: PositionFilter }) {
|
||||||
|
const values = [
|
||||||
|
{ key: "cs", label: "분당 CS", value: summary.csPerMinute.toFixed(1) },
|
||||||
|
{ key: "damage", label: "팀 내 피해량 비중", value: `${Math.round(summary.damageShare)}%` },
|
||||||
|
{ key: "vision", label: "분당 시야 점수", value: summary.visionPerMinute.toFixed(2) },
|
||||||
|
];
|
||||||
|
if (position === "SUP") values.unshift(values.splice(2, 1)[0]);
|
||||||
|
return <section className="p2-play-metrics" aria-label={`${positionName(position)} ${summary.games}경기 평균 플레이 지표`}>
|
||||||
|
<dl>{values.map(metric => <div key={metric.key}><dt>{metric.label}</dt><dd>{metric.value}</dd></div>)}</dl>
|
||||||
|
</section>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function RecentGames({ games, queue }: { games: ExampleGame[]; queue: Queue }) {
|
||||||
|
return <section className="p2-recent">
|
||||||
|
<div className="p2-section-heading"><h3>최근 {queueName(queue)}</h3><span>{games.length}경기 · 최신순</span></div>
|
||||||
|
<div className="p2-game-scroll" tabIndex={0} role="region" aria-label={`${queueName(queue)} 최근 ${games.length}경기 목록`}>
|
||||||
|
<table>
|
||||||
|
<thead><tr><th>경기</th><th>K / D / A</th><th>CS/분</th><th>킬 관여</th></tr></thead>
|
||||||
|
<tbody>{games.map(game => <tr key={game.id}>
|
||||||
|
<td><div className="p2-game-identity"><Portrait championId={game.championId} /><div><strong><b data-result={game.win ? "win" : "loss"}>{game.win ? "승리" : "패배"}</b> {championDisplayName(manifest, game.championId)}</strong><p>{dateLabel(game.date)} · {positionLabel[game.position]} · {game.minutes}분</p></div></div></td>
|
||||||
|
<td>{game.kills}/{game.deaths}/{game.assists}</td>
|
||||||
|
<td>{(game.cs / game.minutes).toFixed(1)}</td>
|
||||||
|
<td>{Math.round((game.kills + game.assists) / game.teamKills * 100)}%</td>
|
||||||
|
</tr>)}</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</section>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function Masteries() {
|
||||||
|
return <div className="p2-masteries"><span>누적 숙련도</span><div className="p2-mastery-icons">{snapshot.masteries.map(champion => {
|
||||||
|
const label = `${championDisplayName(manifest, champion.championId)} · Lv.${champion.championLevel} · ${(champion.championPoints / 1000).toFixed(0)}K`;
|
||||||
|
return <Tooltip content={label} placement="below" key={champion.championId}><span role="img" aria-label={label} tabIndex={0}><Portrait championId={champion.championId} /></span></Tooltip>;
|
||||||
|
})}</div><small>포지션 무관</small></div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function PlayerCard({ initialQueue }: { initialQueue: Queue }) {
|
||||||
|
const prefix = useId();
|
||||||
|
const [queue, setQueue] = useState(initialQueue);
|
||||||
|
const [position, setPosition] = useState<PositionFilter>(() => PREFERENCES[0]?.position ?? "ALL");
|
||||||
|
const history = gamesByQueue[queue];
|
||||||
|
const allGames = selectRecentGames(history, "ALL");
|
||||||
|
const games = selectRecentGames(history, position);
|
||||||
|
const summary = summarizeGames(games);
|
||||||
|
const historyHref = `/users/69ed3d75f3a6fd129207196b/history?queueGroup=${queue === "internal" ? "internal" : "summoners-rift&rank=solo"}`;
|
||||||
|
|
||||||
|
return <section className="pi-preview-state" data-card={initialQueue}>
|
||||||
|
<p className="pi-state-label">{queueName(queue)} · {positionName(position)} 포지션</p>
|
||||||
|
<article className="pi-player-card">
|
||||||
|
<header className="pi-identity">
|
||||||
|
<img className="pi-player-avatar" src={profileIconUrl(manifest, profile.profileIconId)} alt="" />
|
||||||
|
<div className="pi-player-info">
|
||||||
|
<div className="pi-player-name"><h2>{profile.gameName}</h2><span>#{profile.tagLine}</span></div>
|
||||||
|
<div className="pi-rank"><RankBadge tier={profile.tier} /><span>{formatRankDetail(profile.tier)}</span><span className="pi-secondary">현재</span></div>
|
||||||
|
<p className="pi-peak">기록된 최고 <strong>{formatRankDetail(profile.peak)}</strong></p>
|
||||||
|
<div className="pi-preferences"><span>신청 포지션</span>{PREFERENCES.map((preference, index) => <span className="pi-role-chip" data-primary={index === 0} key={preference.position}><img src={positionIcon[preference.position]} alt="" />{positionLabel[preference.position]}<small>{index + 1}순위</small></span>)}</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div className="pi-tabs" role="tablist" aria-label={`${queueName(initialQueue)} 카드 전적 종류`}>
|
||||||
|
{QUEUES.map(value => <button type="button" role="tab" key={value} id={`${prefix}-queue-${value}`} aria-selected={queue === value} aria-controls={`${prefix}-queue-panel`} tabIndex={queue === value ? 0 : -1} onClick={() => setQueue(value)} onKeyDown={event => moveTab(event, QUEUES, queue, setQueue, `${prefix}-queue`)}>{queueName(value)}</button>)}
|
||||||
|
</div>
|
||||||
|
<div className="pi-card-body" role="tabpanel" id={`${prefix}-queue-panel`} aria-labelledby={`${prefix}-queue-${queue}`}>
|
||||||
|
<div className="pi-summary-heading"><h3>최근 {queueName(queue)}</h3><a href={historyHref} target="_blank" rel="noreferrer">전체 전적<ArrowUpRight size={13} aria-hidden="true" /></a></div>
|
||||||
|
<div className="p2-position-tabs" role="tablist" aria-label="플레이 포지션">
|
||||||
|
{POSITIONS.map(value => {
|
||||||
|
const count = selectRecentGames(history, value).length;
|
||||||
|
return <button type="button" role="tab" id={`${prefix}-position-${value}`} aria-controls={`${prefix}-position-panel`} aria-selected={position === value} aria-label={`${positionName(value)} ${count}경기`} tabIndex={position === value ? 0 : -1} data-empty={count === 0} key={value} onClick={() => setPosition(value)} onKeyDown={event => moveTab(event, POSITIONS, position, setPosition, `${prefix}-position`)}><span>{value !== "ALL" && <img src={positionIcon[value]} alt="" />}{positionName(value)}</span><small>{count}</small></button>;
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" id={`${prefix}-position-panel`} aria-labelledby={`${prefix}-position-${position}`}>
|
||||||
|
<p className="p2-sample-context" aria-live="polite">{position === "ALL" ? "전체 포지션" : positionName(position)} 최근 {games.length}경기{games[0] && <span>{dateLabel(games[games.length - 1].date)} – {dateLabel(games[0].date)}</span>}</p>
|
||||||
|
<Metrics summary={summary} />
|
||||||
|
{summary ? <>
|
||||||
|
<ChampionGroup summary={summary} />
|
||||||
|
<PlayMetrics summary={summary} position={position} />
|
||||||
|
<RecentGames key={`${queue}-${position}`} games={games} queue={queue} />
|
||||||
|
</> : <div className="p2-empty"><strong>{positionName(position)} 플레이 기록이 없습니다.</strong><p>포지션별로 최근 20경기까지 집계합니다.</p><button type="button" onClick={() => { setPosition("ALL"); document.getElementById(`${prefix}-position-ALL`)?.focus(); }}>전체 {allGames.length}경기 보기</button></div>}
|
||||||
|
</div>
|
||||||
|
{queue === "solo" && <Masteries />}
|
||||||
|
<p className="p2-data-note">예시 전적 · 지표는 선택한 경기 기준{games.length === 1 ? " · 1경기 표본" : ""}</p>
|
||||||
|
</div>
|
||||||
|
<footer className="pi-auction-status">유찰 — 강제 배정 대상</footer>
|
||||||
|
</article>
|
||||||
|
</section>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Preview() {
|
||||||
|
return <main className="player-info-preview player-info-preview-v2">
|
||||||
|
<header className="pi-workbench-header"><div><p className="pi-eyebrow">LOLYMPUS · 선수 정보 시안 02</p><h1>포지션을 고르면, 기록도 함께</h1><p>포지션 탭을 눌러 요약·챔피언·플레이 지표·최근 경기를 함께 확인하세요.</p></div><a className="pi-original-link" href="/design-previews/player-information.html" target="_blank" rel="noreferrer">첫 번째 시안<ArrowUpRight size={15} aria-hidden="true" /></a></header>
|
||||||
|
<p className="pi-fixture-note">필터 동작을 확인하기 위한 예시 전적입니다. 실제 선수 기록과 다를 수 있습니다.</p>
|
||||||
|
<div className="pi-preview-columns"><PlayerCard initialQueue="internal" /><PlayerCard initialQueue="solo" /></div>
|
||||||
|
</main>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
import { manifest as originalManifest } from "../player-information/data.ts";
|
||||||
|
import type { ExampleGame, Queue } from "./stats";
|
||||||
|
|
||||||
|
export { profile, snapshot } from "../player-information/data.ts";
|
||||||
|
|
||||||
|
export const manifest = {
|
||||||
|
...originalManifest,
|
||||||
|
champions: {
|
||||||
|
...originalManifest.champions,
|
||||||
|
"81": { key: "Ezreal", name: "이즈리얼" },
|
||||||
|
"117": { key: "Lulu", name: "룰루" },
|
||||||
|
"16": { key: "Soraka", name: "소라카" },
|
||||||
|
"267": { key: "Nami", name: "나미" },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Deliberate design fixtures, not a live record or a claim about this player's
|
||||||
|
// performance. Every displayed metric and champion count is derived from these
|
||||||
|
// same rows, so position filtering cannot mix overall and filtered samples.
|
||||||
|
const internal: ExampleGame[] = [
|
||||||
|
{ id: "i1", date: "2026-07-14", position: "MID", championId: 127, win: false, kills: 0, deaths: 6, assists: 7, minutes: 28, cs: 182, teamKills: 18, damage: 18000, teamDamage: 76000, vision: 21 },
|
||||||
|
{ id: "i2", date: "2026-07-13", position: "MID", championId: 800, win: true, kills: 7, deaths: 0, assists: 5, minutes: 26, cs: 190, teamKills: 21, damage: 26000, teamDamage: 88000, vision: 20 },
|
||||||
|
{ id: "i3", date: "2026-07-07", position: "MID", championId: 516, win: false, kills: 1, deaths: 7, assists: 5, minutes: 24, cs: 146, teamKills: 15, damage: 13000, teamDamage: 63000, vision: 18 },
|
||||||
|
{ id: "i4", date: "2026-07-07", position: "MID", championId: 3, win: false, kills: 1, deaths: 6, assists: 6, minutes: 31, cs: 201, teamKills: 17, damage: 21000, teamDamage: 81000, vision: 27 },
|
||||||
|
{ id: "i5", date: "2026-06-25", position: "MID", championId: 134, win: true, kills: 7, deaths: 2, assists: 16, minutes: 35, cs: 269, teamKills: 32, damage: 38000, teamDamage: 112000, vision: 30 },
|
||||||
|
{ id: "i6", date: "2026-06-20", position: "MID", championId: 127, win: true, kills: 3, deaths: 3, assists: 10, minutes: 27, cs: 186, teamKills: 24, damage: 23000, teamDamage: 92000, vision: 23 },
|
||||||
|
{ id: "i7", date: "2026-06-17", position: "MID", championId: 127, win: true, kills: 3, deaths: 4, assists: 12, minutes: 32, cs: 218, teamKills: 27, damage: 27000, teamDamage: 101000, vision: 29 },
|
||||||
|
];
|
||||||
|
|
||||||
|
// Champion, result and K/D/A define the specimen. The remaining fixture fields
|
||||||
|
// vary deterministically to exercise averaging and the one-game ADC state.
|
||||||
|
const soloRows: Array<[number, boolean, number, number, number]> = [
|
||||||
|
[89, false, 1, 6, 12], [43, true, 3, 3, 18], [201, false, 0, 7, 10],
|
||||||
|
[412, true, 2, 4, 20], [81, true, 8, 3, 7], [89, true, 2, 3, 16],
|
||||||
|
[43, true, 4, 4, 19], [53, false, 1, 7, 9], [201, true, 1, 4, 22],
|
||||||
|
[412, false, 2, 8, 11], [89, false, 1, 7, 10], [43, false, 2, 6, 12],
|
||||||
|
[79, false, 3, 8, 8], [89, true, 2, 4, 19], [412, false, 1, 6, 12],
|
||||||
|
[201, false, 0, 7, 11], [43, true, 3, 3, 17], [117, true, 1, 4, 19],
|
||||||
|
[16, false, 1, 7, 10], [267, false, 2, 8, 13],
|
||||||
|
];
|
||||||
|
const solo: ExampleGame[] = soloRows.map(([championId, win, kills, deaths, assists], index) => {
|
||||||
|
const adc = championId === 81;
|
||||||
|
const minutes = 26 + index % 9;
|
||||||
|
return {
|
||||||
|
id: `s${index + 1}`, date: new Date(Date.UTC(2026, 10, 7 - Math.floor(index / 2))).toISOString().slice(0, 10),
|
||||||
|
position: adc ? "ADC" : "SUP", championId, win, kills, deaths, assists, minutes,
|
||||||
|
teamKills: kills + assists + 7 + index % 8,
|
||||||
|
cs: Math.round(minutes * (adc ? 7.8 : 0.8 + index % 4 * 0.1)),
|
||||||
|
damage: adc ? 29000 : 9000 + index % 6 * 1400,
|
||||||
|
teamDamage: 86000 + index % 5 * 7000,
|
||||||
|
vision: Math.round(minutes * (adc ? 0.6 : 1.6 + index % 4 * 0.15)),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Older fixture history demonstrates independent per-position windows. These
|
||||||
|
// matches are deliberately older than the original overall recent sample.
|
||||||
|
function olderGames(queue: Queue, position: ExampleGame["position"], count: number, championIds: number[]): ExampleGame[] {
|
||||||
|
return Array.from({ length: count }, (_, index) => {
|
||||||
|
const base = (queue === "solo" ? solo : internal)[index % (queue === "solo" ? solo.length : internal.length)];
|
||||||
|
const date = queue === "solo"
|
||||||
|
? new Date(Date.UTC(2026, 9, 28 - index))
|
||||||
|
: new Date(Date.UTC(2026, 5, 16 - index));
|
||||||
|
return {
|
||||||
|
...base,
|
||||||
|
id: `${queue}-${position}-older-${index}`,
|
||||||
|
date: date.toISOString().slice(0, 10),
|
||||||
|
position,
|
||||||
|
championId: championIds[index % championIds.length],
|
||||||
|
cs: Math.round(base.minutes * (position === "SUP" ? 0.9 : 6.2 + index % 5 * 0.4)),
|
||||||
|
vision: Math.round(base.minutes * (position === "SUP" ? 1.8 : 0.7 + index % 3 * 0.1)),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export const gamesByQueue: Record<Queue, ExampleGame[]> = {
|
||||||
|
internal: [
|
||||||
|
...internal,
|
||||||
|
...olderGames("internal", "MID", 17, [127, 800, 134, 3, 7]),
|
||||||
|
...olderGames("internal", "SUP", 22, [412, 89, 117, 267, 43]),
|
||||||
|
...olderGames("internal", "TOP", 4, [516, 79]),
|
||||||
|
...olderGames("internal", "ADC", 3, [81]),
|
||||||
|
],
|
||||||
|
solo: [
|
||||||
|
...solo,
|
||||||
|
...olderGames("solo", "MID", 24, [127, 800, 134, 3, 7, 43, 79, 81, 117, 16]),
|
||||||
|
...olderGames("solo", "ADC", 22, [81]),
|
||||||
|
...olderGames("solo", "SUP", 6, [412, 89, 267]),
|
||||||
|
...olderGames("solo", "TOP", 6, [516, 79]),
|
||||||
|
],
|
||||||
|
};
|
||||||
@@ -0,0 +1,184 @@
|
|||||||
|
# Player information prototype 02
|
||||||
|
|
||||||
|
final result: passed
|
||||||
|
|
||||||
|
## Scope and visual sources
|
||||||
|
|
||||||
|
Separate code preview: <http://localhost:5173/design-previews/player-information-v2.html>.
|
||||||
|
Version 1 and the production auction are unchanged. The user explicitly selected
|
||||||
|
the three-part summary, avatar group and linked position tabs for this second
|
||||||
|
proposal. No image-generated UI is used.
|
||||||
|
|
||||||
|
Visual truth:
|
||||||
|
- Existing first proposal: <http://localhost:5173/design-previews/player-information.html>.
|
||||||
|
- Avatar-group structure reference: `C:/Users/park/AppData/Local/Temp/codex-clipboard-bbfae0d1-62e4-4304-ab22-6c5e100145d7.png`.
|
||||||
|
- The original auction screenshots remain the product typography/token reference.
|
||||||
|
|
||||||
|
Evidence directory:
|
||||||
|
`C:/Users/park/.codex/visualizations/2026/11/11/01a1c930-2c9b-7531-a709-2ebb87701e9a/player-information-v2/`
|
||||||
|
|
||||||
|
Source screenshot: `source-v1.png` (798 × 1937).
|
||||||
|
Implementation screenshot: `desktop.png` (1264 × 1078).
|
||||||
|
Mobile implementation: `mobile.png` (374 × 2017).
|
||||||
|
Combined full-card comparisons: `comparison-0.png`, `comparison-1.png`.
|
||||||
|
Focused summary/avatar comparison: `focus-metrics.png`.
|
||||||
|
Measured geometry: `geometry.json`.
|
||||||
|
|
||||||
|
## Viewports and normalization
|
||||||
|
|
||||||
|
Implementation desktop CSS viewport: 1280 × 1000, reported DPR approximately 1.
|
||||||
|
Both cards are 540 CSS px wide; internal height 812.01 px, solo 859.29 px.
|
||||||
|
The original tab retained an 814 × 962 viewport, DPR 1.5, and 560 px cards.
|
||||||
|
Browser full-page exports are normalized to CSS-pixel size and omit the scrollbar.
|
||||||
|
The source cards were cropped and scaled from 560 to 540 px for the combined
|
||||||
|
comparison. Because the viewport and scaling differ, this is a visual-language
|
||||||
|
and information-layout comparison, not a claim of pixel-exact reproduction.
|
||||||
|
Mobile viewport: 390 × 900, with both cards stacked in normal document flow.
|
||||||
|
|
||||||
|
State compared: light theme; internal/all and solo/all. Account header is the
|
||||||
|
same as version 1. The new match dataset deliberately contains example values;
|
||||||
|
both the workbench and each card label the data as illustrative. These values
|
||||||
|
must not be interpreted as verified player performance.
|
||||||
|
|
||||||
|
## Findings
|
||||||
|
|
||||||
|
No actionable P0/P1/P2 findings remain in the requested prototype scope.
|
||||||
|
The combined full-card comparisons and focused summary/avatar crop were opened
|
||||||
|
and reviewed. The formal comparison passed on its first pass. Earlier layout
|
||||||
|
refinement reduced the initial implementation's 72 px summary to 49 px and
|
||||||
|
removed redundant metric headings before this comparison; it is not counted as
|
||||||
|
a separate comparison iteration.
|
||||||
|
|
||||||
|
## Required fidelity surfaces
|
||||||
|
|
||||||
|
- **Fonts/typography:** Reuses SuitVariable, existing RankBadge and established
|
||||||
|
body hierarchy. No new font. Primary figures are 24 px; ordinary data is
|
||||||
|
11–13 px. Secondary table dates are smaller. Measured mobile names, dates and
|
||||||
|
metric sublines have no overflow at 390 px.
|
||||||
|
- **Spacing/layout:** Three summary columns use fine vertical separators,
|
||||||
|
without individual large card boxes. The summary is approximately 49 px
|
||||||
|
high on desktop. Six position tabs stay visible at mobile width, using a
|
||||||
|
two-line label/count treatment. Recent games use aligned table columns.
|
||||||
|
Internal card gains 16 px over version 1 while adding three play metrics,
|
||||||
|
kill participation and richer match rows. Solo gains approximately 79 px
|
||||||
|
because it now includes a five-game list as well as lifetime mastery.
|
||||||
|
- **Colors/tokens:** Reuses product card, border, foreground, muted, accent and
|
||||||
|
gold tokens. Selected tab has an accent background and underline. Win/loss
|
||||||
|
is also written in text. No new theme preference is persisted.
|
||||||
|
- **Image quality/assets:** Reuses the real profile icon, Riot champion art
|
||||||
|
and existing product role SVGs. Champion portraits retain scale(1.18) and
|
||||||
|
clipping. Recent champions use overlapping circular images with a 5 px
|
||||||
|
overlap in the original second proposal; source initials and dark colors were not adopted because the user
|
||||||
|
referenced the grouping pattern. No broken images at desktop validation.
|
||||||
|
- **Copy/content:** Counts refer to the currently selected sample. Zero-game
|
||||||
|
selections show dashes and an explicit empty state, never overall stats.
|
||||||
|
One-game selections retain the sample-size note. Lifetime mastery remains
|
||||||
|
labelled independent of position. No disclosure or accordion is added.
|
||||||
|
|
||||||
|
## Primary interactions verified
|
||||||
|
|
||||||
|
- Solo/all: 20 games, 9 wins, 45%; five visible recent rows.
|
||||||
|
- Solo/support: 19 games, 8 wins, 42%; the ADC match disappears from the list,
|
||||||
|
champion group and aggregate. Vision per minute moves to the first play
|
||||||
|
metric position. Lifetime mastery remains unchanged.
|
||||||
|
- Solo/ADC: one Ezreal game; 100%, 5.00 KDA, 58% participation. The recent
|
||||||
|
champion group contains Ezreal only, and the list contains one row.
|
||||||
|
- Solo/mid: zero records, no champion group or recent table, and an explicit
|
||||||
|
empty state. The return-to-all button restores 20 games and focuses its tab.
|
||||||
|
- Position End/Home keys move selection and focus to support/all. Tab controls
|
||||||
|
have selected state, roving tabindex and connected tabpanels.
|
||||||
|
- Avatar keyboard focus opens the existing tooltip with champion name, games,
|
||||||
|
wins/losses and win rate. Escape dismisses the tooltip.
|
||||||
|
- Mobile 390 px: no horizontal page overflow or measured text overflow;
|
||||||
|
both tables retain all five rows and all stat columns.
|
||||||
|
- Final browser console check: no errors.
|
||||||
|
|
||||||
|
## Code checks
|
||||||
|
|
||||||
|
- TypeScript build check passed.
|
||||||
|
- ESLint passed for the new preview and test file.
|
||||||
|
- Four focused tests passed: shared filtered samples, empty selections,
|
||||||
|
aggregate KDA/Perfect and average rates/zero denominators.
|
||||||
|
|
||||||
|
## Boundaries and remaining checks
|
||||||
|
|
||||||
|
This is an interactive fixed-data proposal. It does not add backend endpoints,
|
||||||
|
change live auction state, or link synthetic match rows to real match details.
|
||||||
|
The existing player-history link remains available. Production integration,
|
||||||
|
live API loading/error states, dark-theme visual QA and wider record coverage
|
||||||
|
are outside this prototype handoff. No remaining changes block this preview.
|
||||||
|
|
||||||
|
## Follow-up: ten overlapping champion portraits
|
||||||
|
|
||||||
|
Latest result: passed. Recent champion limit increased from five to ten, with
|
||||||
|
10 px overlap instead of 5 px. The explicit source for this refinement is
|
||||||
|
`C:/Users/park/AppData/Local/Temp/codex-clipboard-52d981da-465a-4007-93c3-d29d3c810f62.png`
|
||||||
|
(203 × 61 px). `avatar-comparison.png` combines that reference at 75% scale
|
||||||
|
with the 519 × 61 px rendered row, aligning approximate portrait size. The
|
||||||
|
different champion artwork and five-versus-ten count are intentional.
|
||||||
|
|
||||||
|
Latest implementation evidence in the same directory: `ten-champions-desktop.png`
|
||||||
|
(1280 × 1000 CSS viewport, full-page export), `ten-champions-row.png`, and
|
||||||
|
`ten-champions-mobile.png` (360 × 900 CSS viewport, full-page export).
|
||||||
|
The fixed solo fixture now includes ten distinct champions without changing
|
||||||
|
its 20-game sample, results, position distribution, or performance metrics.
|
||||||
|
|
||||||
|
Mobile refinement: the initial ten-portrait row measured 305 px of content
|
||||||
|
inside 295 px. Fixed by placing title/count above the uninterrupted avatar
|
||||||
|
row for eight or more champions at mobile widths. Rechecked the same 360 px
|
||||||
|
viewport: both clientWidth and scrollWidth are 295 px, with no page overflow.
|
||||||
|
The tenth portrait remains keyboard-focusable and shows the correct Nami
|
||||||
|
tooltip. Desktop renders ten 34 px outer circles, offset by 24 px, confirming
|
||||||
|
the requested 10 px overlap. No broken avatar images were observed.
|
||||||
|
|
||||||
|
The combined comparison preserves fonts, colors, crop quality and white
|
||||||
|
separation rings; only count, overlap, and the narrow-screen arrangement
|
||||||
|
change. Existing position filters and small-sample states remain functional.
|
||||||
|
ESLint and all four aggregation/filter tests pass. No new tests were added
|
||||||
|
for this small visual adjustment.
|
||||||
|
|
||||||
|
## Follow-up: preferred position and independent history windows
|
||||||
|
|
||||||
|
Latest visual result: passed. This section supersedes the earlier overall-window
|
||||||
|
filter semantics and five-row display checks.
|
||||||
|
|
||||||
|
- Removed the champion-count text and its CSS.
|
||||||
|
- Initial position is the lowest-priority-number preference (MID in this
|
||||||
|
fixture), with ALL only when no preference exists. A fresh reload selected
|
||||||
|
MID in both queue cards.
|
||||||
|
- `selectRecentGames` filters the full queue history, sorts by date descending,
|
||||||
|
then takes twenty. It does not derive a lane sample from the overall twenty.
|
||||||
|
- The same selected sample supplies every metric, champion group and table.
|
||||||
|
The list contains all twenty rows, in a 228 px scroll region with sticky
|
||||||
|
headings. Switching position or queue remounts the list at scroll position 0.
|
||||||
|
- Fixture history was extended with older games. Overall solo now selects
|
||||||
|
2026-10-29 through 2026-11-07 (no MID matches), while the MID tab independently
|
||||||
|
selects twenty games from 2026-10-09 through 2026-10-28. Short lanes show the
|
||||||
|
available count; the empty jungle lane does not fall back to overall data.
|
||||||
|
|
||||||
|
Visual evidence: `lane-history-desktop.png`, `lane-history-mobile.png`,
|
||||||
|
`lane-history-focus.png`, and the combined `lane-history-comparison.png` in the
|
||||||
|
evidence directory above. Source is the preceding `ten-champions-desktop.png`.
|
||||||
|
Both desktop captures use a 1280 × 1000 CSS viewport and CSS-pixel full-page
|
||||||
|
exports; the comparison places equal 540 px card crops together. Mobile uses
|
||||||
|
360 × 900. The source is intentionally ALL-selected and the update MID-selected
|
||||||
|
to show the requested default; values and date windows are expected to differ.
|
||||||
|
|
||||||
|
The combined comparison and current rendered screen were inspected. Fonts,
|
||||||
|
colors, image crop/quality and header spacing remain consistent. The 10 px
|
||||||
|
avatar overlap is retained. The copy now names the selected lane's recent
|
||||||
|
sample and its date range without the former subset fraction. No champion
|
||||||
|
count label remains. There is no horizontal overflow, clipped row text, or
|
||||||
|
avatar-row overflow at 360 px. No new P0/P1/P2 visual issue was found.
|
||||||
|
|
||||||
|
Interaction checks: both default MID tabs show twenty matching rows; ALL shows
|
||||||
|
twenty overall rows with zero MID rows; jungle shows an empty state. PageDown
|
||||||
|
inside the focused match-list region changes its scrollTop to 199.33 px while
|
||||||
|
all twenty records remain available. Tab switching returns the list to 0.
|
||||||
|
Browser console error check is empty.
|
||||||
|
|
||||||
|
Validation: five aggregation/window tests and ESLint pass. The targeted
|
||||||
|
TypeScript program for the preview and its dependencies passes. The full web
|
||||||
|
TypeScript check is not clean: it reports four TS18048 errors at line 31 of
|
||||||
|
`src/components/internal-stats/StatsEvent.tsx`, outside this change. That file
|
||||||
|
was not modified here. Production/backend integration remains out of scope.
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { StrictMode } from "react";
|
||||||
|
import { createRoot } from "react-dom/client";
|
||||||
|
import { BrowserRouter } from "react-router";
|
||||||
|
import { initializeTheme } from "../../config";
|
||||||
|
import { AppTheme } from "../../ui/AppTheme";
|
||||||
|
import Preview from "./Preview";
|
||||||
|
import "../../index.css";
|
||||||
|
|
||||||
|
initializeTheme();
|
||||||
|
createRoot(document.getElementById("root")!).render(
|
||||||
|
<StrictMode><BrowserRouter><AppTheme><Preview /></AppTheme></BrowserRouter></StrictMode>,
|
||||||
|
);
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
.player-info-preview-v2 .pi-card-body { padding: 14px 18px 10px; }
|
||||||
|
.player-info-preview-v2 .pi-identity { padding: 18px; }
|
||||||
|
.p2-position-tabs { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 3px; margin-top: 13px; border-bottom: 1px solid var(--color-border); }
|
||||||
|
.p2-position-tabs button { display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 41px; position: relative; border-radius: 5px 5px 0 0; font-size: 12px; cursor: pointer; color: var(--lts-text-subtle); padding: 6px 2px; }
|
||||||
|
.p2-position-tabs button > span { display: flex; align-items: center; gap: 3px; }
|
||||||
|
.p2-position-tabs img { width: 12px; height: 12px; border-radius: 0; }
|
||||||
|
.p2-position-tabs small { font-size: 11px; font-variant-numeric: tabular-nums; }
|
||||||
|
.p2-position-tabs button[data-empty="true"] { color: var(--lts-text-subtle); }
|
||||||
|
.p2-position-tabs button[aria-selected="true"] { background: color-mix(in srgb,var(--color-text-accent) 5%,transparent); color: var(--color-text-accent); font-weight: 700; }
|
||||||
|
.p2-position-tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 7px; right: 7px; bottom: -1px; height: 2px; background: var(--color-text-accent); }
|
||||||
|
.p2-position-tabs button:hover { background: var(--color-background-muted); }
|
||||||
|
.p2-position-tabs button:focus-visible, .p2-avatar:focus-visible, .p2-mastery-icons > span:focus-visible { outline: 2px solid var(--color-text-accent); outline-offset: 2px; z-index: 5; }
|
||||||
|
.p2-sample-context { display: flex; justify-content: space-between; gap: 6px; margin-top: 9px; font-size: 11px; color: var(--lts-text-subtle); }
|
||||||
|
.p2-metrics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); margin: 13px 0 9px; }
|
||||||
|
.p2-metrics > div { min-width: 0; padding-inline: 13px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 3px 5px; }
|
||||||
|
.p2-metrics > div:first-child { padding-left: 0; }
|
||||||
|
.p2-metrics > div:last-child { padding-right: 0; }
|
||||||
|
.p2-metrics > div + div { border-left: 1px solid var(--color-border); }
|
||||||
|
.p2-metrics > div > span { font-size: 11px; color: var(--lts-text-subtle); }
|
||||||
|
.p2-metrics strong { display: block; font-size: 24px; font-weight: 750; line-height: 1.25; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
|
||||||
|
.p2-metrics strong[data-perfect="true"] { font-size: 16px; line-height: 1.875; }
|
||||||
|
.p2-metrics small { font-size: 14px; margin-left: 1px; font-weight: 500; }
|
||||||
|
.p2-metrics p { grid-column: 1 / -1; font-size: 11px; color: var(--lts-text-subtle); white-space: nowrap; }
|
||||||
|
.p2-champions { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; min-height: 49px; padding-block: 6px; }
|
||||||
|
.p2-champions h3 { font-size: 12px; color: var(--lts-text-subtle); font-weight: 500; flex-shrink: 0; }
|
||||||
|
.p2-avatar-group { display: flex; align-items: center; padding-left: 10px; }
|
||||||
|
.p2-avatar { display: inline-flex; position: relative; border-radius: 50%; border: 2px solid var(--color-background-card); margin-left: -10px; background: var(--color-background-card); cursor: help; }
|
||||||
|
.p2-avatar:hover, .p2-avatar:focus { z-index: 4; }
|
||||||
|
.p2-avatar .pi-champion-portrait { width: 30px; height: 30px; flex-basis: 30px; border-radius: 50%; }
|
||||||
|
.p2-play-metrics { padding-block: 9px; border-block: 1px solid var(--color-border); margin: 2px 0 14px; }
|
||||||
|
.p2-section-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 9px; }
|
||||||
|
.p2-section-heading h3 { font-size: 13px; font-weight: 700; }
|
||||||
|
.p2-section-heading > span { font-size: 11px; color: var(--lts-text-subtle); }
|
||||||
|
.p2-play-metrics dl { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
|
||||||
|
.p2-play-metrics dt { font-size: 11px; color: var(--lts-text-subtle); }
|
||||||
|
.p2-play-metrics dd { font-size: 18px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
|
||||||
|
.p2-recent table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
|
||||||
|
.p2-game-scroll { max-height: 228px; overflow-y: auto; overscroll-behavior-y: contain; scrollbar-width: thin; scrollbar-color: var(--color-border) transparent; }
|
||||||
|
.p2-game-scroll:focus-visible { outline: 2px solid var(--color-text-accent); outline-offset: 3px; }
|
||||||
|
.p2-recent thead { position: sticky; top: 0; z-index: 1; background: var(--color-background-card); }
|
||||||
|
.p2-recent th { color: var(--lts-text-subtle); font-size: 10px; font-weight: 500; text-align: right; padding: 0 0 6px; }
|
||||||
|
.p2-recent th:first-child { width: auto; text-align: left; }
|
||||||
|
.p2-recent th:nth-child(2) { width: 78px; }
|
||||||
|
.p2-recent th:nth-child(3) { width: 58px; }
|
||||||
|
.p2-recent th:nth-child(4) { width: 62px; }
|
||||||
|
.p2-recent td { text-align: right; padding: 5px 0; border-top: 1px solid var(--color-border); }
|
||||||
|
.p2-recent td:first-child { text-align: left; }
|
||||||
|
.p2-game-identity { display: flex; align-items: center; gap: 7px; }
|
||||||
|
.p2-game-identity > div { min-width: 0; }
|
||||||
|
.p2-game-identity .pi-champion-portrait { width: 28px; height: 28px; flex-basis: 28px; }
|
||||||
|
.p2-game-identity strong { display: block; font-size: 12px; line-height: 1.25; font-weight: 550; white-space: nowrap; }
|
||||||
|
.p2-game-identity b { font-weight: 700; }
|
||||||
|
.p2-game-identity b[data-result="win"] { color: var(--color-palette-win-text-light); }
|
||||||
|
.p2-game-identity b[data-result="loss"] { color: var(--color-palette-loss-text-light); }
|
||||||
|
[data-theme="dark"] .p2-game-identity b[data-result="win"] { color: var(--color-palette-win-text-dark); }
|
||||||
|
[data-theme="dark"] .p2-game-identity b[data-result="loss"] { color: var(--color-palette-loss-text-dark); }
|
||||||
|
.p2-game-identity p { font-size: 10px; line-height: 1.2; color: var(--lts-text-subtle); white-space: nowrap; margin-top: 1px; }
|
||||||
|
.p2-masteries { display: flex; align-items: center; gap: 10px; padding-top: 12px; margin-top: 8px; border-top: 1px solid var(--color-border); color: var(--lts-text-subtle); font-size: 11px; }
|
||||||
|
.p2-mastery-icons { display: flex; align-items: center; gap: 5px; }
|
||||||
|
.p2-mastery-icons > span { display: inline-flex; border-radius: var(--radius-inner); cursor: help; }
|
||||||
|
.p2-masteries .pi-champion-portrait { width: 22px; height: 22px; flex-basis: 22px; }
|
||||||
|
.p2-masteries small { margin-left: auto; font-size: 10px; white-space: nowrap; }
|
||||||
|
.p2-data-note { font-size: 10px; color: var(--lts-text-subtle); margin-top: 11px; }
|
||||||
|
.p2-empty { padding: 32px 8px 40px; text-align: center; }
|
||||||
|
.p2-empty strong { font-size: 13px; font-weight: 600; }
|
||||||
|
.p2-empty p { color: var(--lts-text-subtle); font-size: 12px; margin-top: 8px; }
|
||||||
|
.p2-empty button { color: var(--color-text-accent); font-size: 12px; border: 1px solid var(--color-border); border-radius: var(--radius-element); padding: 8px 12px; margin-top: 16px; cursor: pointer; }
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.player-info-preview-v2 .pi-card-body { padding-inline: 12px; }
|
||||||
|
.p2-position-tabs { gap: 1px; }
|
||||||
|
.p2-position-tabs button { flex-direction: column; gap: 2px; font-size: 11px; min-height: 48px; }
|
||||||
|
.p2-position-tabs img { width: 11px; height: 11px; }
|
||||||
|
.p2-metrics > div { padding-inline: 9px; }
|
||||||
|
.p2-metrics { gap: 0; }
|
||||||
|
.p2-metrics > div { display: block; }
|
||||||
|
.p2-metrics > div > span { font-size: 11px; }
|
||||||
|
.p2-metrics strong { font-size: 23px; }
|
||||||
|
.p2-metrics p { font-size: 10px; margin-top: 2px; }
|
||||||
|
.p2-metrics strong[data-perfect="true"] { font-size: 17px; }
|
||||||
|
.p2-champions { gap: 8px; }
|
||||||
|
.p2-champions h3 { font-size: 11px; }
|
||||||
|
.p2-avatar .pi-champion-portrait { width: 27px; height: 27px; flex-basis: 27px; }
|
||||||
|
.p2-recent th:nth-child(2) { width: 58px; }
|
||||||
|
.p2-recent th:nth-child(3) { width: 43px; }
|
||||||
|
.p2-recent th:nth-child(4) { width: 46px; }
|
||||||
|
.p2-recent table { font-size: 11px; }
|
||||||
|
.p2-game-identity { gap: 5px; }
|
||||||
|
.p2-game-identity strong { font-size: 11px; }
|
||||||
|
.p2-game-identity p { font-size: 9px; }
|
||||||
|
.p2-masteries { gap: 7px; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import type { Position } from "../../api/types";
|
||||||
|
|
||||||
|
export type Queue = "internal" | "solo";
|
||||||
|
export type PositionFilter = "ALL" | Position;
|
||||||
|
export type ExampleGame = {
|
||||||
|
id: string;
|
||||||
|
date: string;
|
||||||
|
position: Position;
|
||||||
|
championId: number;
|
||||||
|
win: boolean;
|
||||||
|
kills: number;
|
||||||
|
deaths: number;
|
||||||
|
assists: number;
|
||||||
|
minutes: number;
|
||||||
|
cs: number;
|
||||||
|
teamKills: number;
|
||||||
|
damage: number;
|
||||||
|
teamDamage: number;
|
||||||
|
vision: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const RECENT_GAME_LIMIT = 20;
|
||||||
|
|
||||||
|
export function selectRecentGames(history: ExampleGame[], position: PositionFilter) {
|
||||||
|
// Filter the full history before limiting. A lane's latest twenty matches
|
||||||
|
// can predate every match in the overall latest-twenty window.
|
||||||
|
return history
|
||||||
|
.filter(game => position === "ALL" || game.position === position)
|
||||||
|
.sort((a, b) => Date.parse(b.date) - Date.parse(a.date))
|
||||||
|
.slice(0, RECENT_GAME_LIMIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function summarizeGames(games: ExampleGame[]) {
|
||||||
|
if (!games.length) return null;
|
||||||
|
const average = (read: (game: ExampleGame) => number) => games.reduce((sum, game) => sum + read(game), 0) / games.length;
|
||||||
|
const kills = games.reduce((sum, game) => sum + game.kills, 0);
|
||||||
|
const deaths = games.reduce((sum, game) => sum + game.deaths, 0);
|
||||||
|
const assists = games.reduce((sum, game) => sum + game.assists, 0);
|
||||||
|
const wins = games.filter(game => game.win).length;
|
||||||
|
const championGroups = new Map<number, { championId: number; games: number; wins: number }>();
|
||||||
|
for (const game of games) {
|
||||||
|
const champion = championGroups.get(game.championId) ?? { championId: game.championId, games: 0, wins: 0 };
|
||||||
|
champion.games++;
|
||||||
|
champion.wins += Number(game.win);
|
||||||
|
championGroups.set(game.championId, champion);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
games: games.length, wins, losses: games.length - wins,
|
||||||
|
winRate: Math.round(wins / games.length * 100),
|
||||||
|
kda: deaths ? ((kills + assists) / deaths).toFixed(2) : "Perfect",
|
||||||
|
averageKda: [kills, deaths, assists].map(value => (value / games.length).toFixed(1)).join(" / "),
|
||||||
|
killParticipation: average(game => game.teamKills ? (game.kills + game.assists) / game.teamKills * 100 : 0),
|
||||||
|
csPerMinute: average(game => game.minutes > 0 ? game.cs / game.minutes : 0),
|
||||||
|
damageShare: average(game => game.teamDamage > 0 ? game.damage / game.teamDamage * 100 : 0),
|
||||||
|
visionPerMinute: average(game => game.minutes > 0 ? game.vision / game.minutes : 0),
|
||||||
|
champions: [...championGroups.values()].sort((a, b) => b.games - a.games || b.wins - a.wins),
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,207 @@
|
|||||||
|
import { useState, type KeyboardEvent } from "react";
|
||||||
|
import { ArrowUpRight } from "lucide-react";
|
||||||
|
import type {
|
||||||
|
DdragonManifest,
|
||||||
|
Position,
|
||||||
|
RiotLane,
|
||||||
|
} from "../../api/types";
|
||||||
|
import { RankBadge } from "../../components/RankBadge";
|
||||||
|
import { formatRankDetail } from "../../components/rankBadgeUtils";
|
||||||
|
import { DEFAULT_COMMUNITY_ID } from "../../config";
|
||||||
|
import { championDisplayName, championIconUrl, profileIconUrl } from "../../lib/ddragon";
|
||||||
|
import { internalMatchGamePath } from "../../lib/internal-match-routes";
|
||||||
|
import { POSITION_ORDER, positionIcon, positionLabel } from "../../lib/league";
|
||||||
|
import { internalMatches, manifest, profile, snapshot, summaries, type PreviewMatch, type PreviewProfile, type PreviewSnapshot, type PreviewSummary } from "./data";
|
||||||
|
import "./preview.css";
|
||||||
|
|
||||||
|
const MATCH_ID = "6a3b94bccb8a54219653f457";
|
||||||
|
const USER_ID = "69ed3d75f3a6fd129207196b";
|
||||||
|
const LANES: Record<Position, RiotLane> = {
|
||||||
|
TOP: "TOP", JGL: "JUNGLE", MID: "MIDDLE", ADC: "BOTTOM", SUP: "UTILITY",
|
||||||
|
};
|
||||||
|
type ProfileTab = "internal" | "solo";
|
||||||
|
|
||||||
|
function formatDate(value: string | number | null | undefined) {
|
||||||
|
if (!value) return "기록 없음";
|
||||||
|
const date = new Date(value);
|
||||||
|
if (Number.isNaN(date.getTime())) return "기록 없음";
|
||||||
|
return new Intl.DateTimeFormat("ko-KR", {
|
||||||
|
timeZone: "Asia/Seoul", year: "numeric", month: "2-digit", day: "2-digit",
|
||||||
|
}).format(date).replace(/\s/g, "").replace(/\.$/, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
function Portrait({ championId, manifest }: { championId: number; manifest: DdragonManifest }) {
|
||||||
|
const src = championIconUrl(manifest, championId);
|
||||||
|
return (
|
||||||
|
<span className="pi-champion-portrait">
|
||||||
|
{src && <img src={src} alt="" loading="lazy" />}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function PositionExperience({ summary, mainPosition, tab }: {
|
||||||
|
summary: PreviewSummary;
|
||||||
|
mainPosition: Position;
|
||||||
|
tab: ProfileTab;
|
||||||
|
}) {
|
||||||
|
const mainRate = summary.positionRates[LANES[mainPosition]] ?? 0;
|
||||||
|
return (
|
||||||
|
<section className="pi-experience" aria-label="실제 플레이 포지션">
|
||||||
|
<div className="pi-section-heading">
|
||||||
|
<h3>실제 플레이 포지션</h3>
|
||||||
|
<span>최근 {summary.windowSize}경기</span>
|
||||||
|
</div>
|
||||||
|
<div className="pi-position-grid">
|
||||||
|
{POSITION_ORDER.map(position => {
|
||||||
|
const rate = summary.positionRates[LANES[position]] ?? 0;
|
||||||
|
const games = Math.round(summary.windowSize * rate / 100);
|
||||||
|
return (
|
||||||
|
<div className="pi-position-stat" data-played={games > 0} key={position}>
|
||||||
|
<div><img src={positionIcon[position]} alt="" />{positionLabel[position]}</div>
|
||||||
|
<strong>{games}<span>경기</span></strong>
|
||||||
|
<div className="pi-position-track" aria-hidden="true"><span style={{ width: `${rate}%` }} /></div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
{summary.windowSize > 0 && mainRate === 0 && (
|
||||||
|
<p className="pi-position-note">신청 1순위는 {positionLabel[mainPosition]} · 최근 {tab === "solo" ? "솔로랭크" : "내전"}에서 해당 포지션 기록은 없습니다.</p>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Metrics({ summary }: { summary: PreviewSummary }) {
|
||||||
|
return (
|
||||||
|
<div className="pi-metrics">
|
||||||
|
<div><span>승률</span><strong>{summary.winRate}<small>%</small></strong><p>{summary.wins}승 {summary.losses}패 · {summary.windowSize}경기</p></div>
|
||||||
|
<div><span>KDA</span><strong>{summary.kda}</strong><p>{summary.avgKills} / {summary.avgDeaths} / {summary.avgAssists}</p></div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function RecentChampions({ summary, manifest }: { summary: PreviewSummary; manifest: DdragonManifest }) {
|
||||||
|
return (
|
||||||
|
<section>
|
||||||
|
<div className="pi-section-heading"><h3>최근 사용 챔피언</h3><span>{summary.windowSize}경기 기준</span></div>
|
||||||
|
<div className="pi-champion-list">
|
||||||
|
{summary.topChampions.slice(0, 5).map(champion => {
|
||||||
|
const wins = Math.round(champion.games * champion.winRate / 100);
|
||||||
|
return (
|
||||||
|
<div className="pi-champion-row" key={champion.championId}>
|
||||||
|
<Portrait championId={champion.championId} manifest={manifest} />
|
||||||
|
<div><strong>{championDisplayName(manifest, champion.championId)}</strong><p>{champion.games}경기 · {wins}승 {champion.games - wins}패</p></div>
|
||||||
|
<span className="pi-champion-rate">{champion.winRate}%</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
{summary.topChampions.length === 0 && <p className="pi-empty">최근 챔피언 기록이 없습니다.</p>}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function RecentGames({ matches, manifest }: { matches: PreviewMatch[]; manifest: DdragonManifest }) {
|
||||||
|
return (
|
||||||
|
<section>
|
||||||
|
<div className="pi-section-heading"><h3>최근 내전</h3><span>{Math.min(5, matches.length)}경기</span></div>
|
||||||
|
<div className="pi-recent-list">
|
||||||
|
{matches.slice(0, 5).map(match => {
|
||||||
|
const name = championDisplayName(manifest, match.championId);
|
||||||
|
const href = match.internalMatchId && match.gameNumber
|
||||||
|
? internalMatchGamePath(DEFAULT_COMMUNITY_ID, match.internalMatchId, match.gameNumber)
|
||||||
|
: `/users/${USER_ID}/history?queueGroup=internal`;
|
||||||
|
return (
|
||||||
|
<a className="pi-recent-game" key={match.matchId} href={href} target="_blank" rel="noreferrer" aria-label={`${name} ${match.win ? "승리" : "패배"} 경기 상세 새 탭에서 보기`}>
|
||||||
|
<Portrait championId={match.championId} manifest={manifest} />
|
||||||
|
<div><strong><b data-result={match.win ? "win" : "loss"}>{match.remake ? "다시하기" : match.win ? "승리" : "패배"}</b> {name}</strong><p>{formatDate(match.gameCreation).slice(5)}</p></div>
|
||||||
|
<span className="pi-game-kda">{match.kills}/{match.deaths}/{match.assists}</span>
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Masteries({ snapshot, manifest }: { snapshot: PreviewSnapshot; manifest: DdragonManifest }) {
|
||||||
|
return (
|
||||||
|
<section>
|
||||||
|
<div className="pi-section-heading"><h3>누적 숙련도</h3><span>경매 등록 기준</span></div>
|
||||||
|
<div className="pi-champion-list">
|
||||||
|
{(snapshot.masteries ?? []).slice(0, 5).map(champion => (
|
||||||
|
<div className="pi-champion-row" key={champion.championId}>
|
||||||
|
<Portrait championId={champion.championId} manifest={manifest} />
|
||||||
|
<div><strong>{championDisplayName(manifest, champion.championId)}</strong><p>Lv.{champion.championLevel} · {(champion.championPoints / 1000).toFixed(0)}K</p></div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function PlayerCard({ initialTab, label, profile, snapshot, manifest }: {
|
||||||
|
initialTab: ProfileTab;
|
||||||
|
label: string;
|
||||||
|
profile: PreviewProfile;
|
||||||
|
snapshot: PreviewSnapshot;
|
||||||
|
manifest: DdragonManifest;
|
||||||
|
}) {
|
||||||
|
const [tab, setTab] = useState<ProfileTab>(initialTab);
|
||||||
|
const summary = summaries[tab];
|
||||||
|
const preferences = [...snapshot.preferredPositions].sort((a, b) => a.priority - b.priority);
|
||||||
|
const mainPosition = preferences[0]?.position ?? "MID";
|
||||||
|
const tier = profile.tier;
|
||||||
|
const peakLabel = formatRankDetail(profile.peak);
|
||||||
|
const historyHref = `/users/${USER_ID}/history?queueGroup=${tab === "internal" ? "internal" : "summoners-rift"}${tab === "solo" ? "&rank=solo" : ""}`;
|
||||||
|
const tabPrefix = `profile-${initialTab}`;
|
||||||
|
|
||||||
|
function handleTabKey(event: KeyboardEvent<HTMLButtonElement>) {
|
||||||
|
if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;
|
||||||
|
event.preventDefault();
|
||||||
|
const next = event.key === "Home" ? "internal" : event.key === "End" ? "solo" : tab === "internal" ? "solo" : "internal";
|
||||||
|
setTab(next);
|
||||||
|
document.getElementById(`${tabPrefix}-${next}`)?.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className="pi-preview-state">
|
||||||
|
<div className="pi-state-label">{initialTab === "internal" ? "01" : "02"} · {tab === "internal" ? "내전" : "솔로랭크"}</div>
|
||||||
|
<article className="pi-player-card">
|
||||||
|
<header className="pi-identity">
|
||||||
|
<img className="pi-player-avatar" src={profileIconUrl(manifest, profile.profileIconId)} alt="" />
|
||||||
|
<div className="pi-player-info">
|
||||||
|
<div className="pi-player-name"><h2>{profile.gameName}</h2><span>#{profile.tagLine}</span></div>
|
||||||
|
<div className="pi-rank"><RankBadge tier={tier} /><span>{formatRankDetail(tier)}</span><span className="pi-secondary">현재</span></div>
|
||||||
|
{peakLabel && <p className="pi-peak">기록된 최고 <strong>{peakLabel}</strong></p>}
|
||||||
|
<div className="pi-preferences"><span>신청 포지션</span>{preferences.slice(0, 2).map((preference, index) => <span className="pi-role-chip" data-primary={index === 0} key={preference.position}><img src={positionIcon[preference.position]} alt="" />{positionLabel[preference.position]}<small>{index + 1}순위</small></span>)}</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div className="pi-tabs" role="tablist" aria-label={`${label} 전적 종류`}>
|
||||||
|
{(["internal", "solo"] as const).map(value => <button key={value} type="button" role="tab" id={`${tabPrefix}-${value}`} aria-selected={tab === value} aria-controls={`${tabPrefix}-panel`} tabIndex={tab === value ? 0 : -1} onClick={() => setTab(value)} onKeyDown={handleTabKey}>{value === "internal" ? "내전" : "솔로랭크"}</button>)}
|
||||||
|
</div>
|
||||||
|
<div className="pi-card-body" id={`${tabPrefix}-panel`} role="tabpanel" aria-labelledby={`${tabPrefix}-${tab}`}>
|
||||||
|
<div className="pi-summary-heading"><h3>최근 {summary.windowSize}경기 · {tab === "internal" ? "내전" : "솔로랭크"}</h3><a href={historyHref} target="_blank" rel="noreferrer">전체 전적<ArrowUpRight size={13} aria-hidden="true" /></a></div>
|
||||||
|
<p className="pi-record-basis">전체 포지션 기준<span>·</span>마지막 경기 {formatDate(summary.lastGameAt)}</p>
|
||||||
|
<PositionExperience summary={summary} mainPosition={mainPosition} tab={tab} />
|
||||||
|
<Metrics summary={summary} />
|
||||||
|
<div className="pi-detail-columns"><RecentChampions summary={summary} manifest={manifest} />{tab === "internal" ? <RecentGames matches={internalMatches} manifest={manifest} /> : <Masteries snapshot={snapshot} manifest={manifest} />}</div>
|
||||||
|
<div className="pi-data-note">{tab === "solo" && summary.lastFetchedAt && <span>전적 수집 기준 {formatDate(summary.lastFetchedAt)}</span>}<span>티어 확인 {formatDate(tier?.fetchedAt)}</span></div>
|
||||||
|
</div>
|
||||||
|
<footer className="pi-auction-status">{snapshot.passCount > 0 ? "유찰 — 강제 배정 대상" : "경매 참가 선수"}</footer>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Preview() {
|
||||||
|
return (
|
||||||
|
<main className="player-info-preview">
|
||||||
|
<header className="pi-workbench-header"><div><p className="pi-eyebrow">LOLYMPUS · 선수 정보 개선 시안</p><h1>신청 포지션과 실제 경험을 한눈에</h1><p>같은 선수의 두 탭을 나란히 볼 수 있습니다. 탭과 전적 링크를 직접 눌러보세요.</p></div><a className="pi-original-link" href={`/match/${MATCH_ID}/auction`} target="_blank" rel="noreferrer">원래 경매 페이지<ArrowUpRight size={15} aria-hidden="true" /></a></header>
|
||||||
|
<p className="pi-fixture-note">2026.11.11 확인 기록을 바탕으로 구성한 고정 시안 데이터입니다.</p>
|
||||||
|
<div className="pi-preview-columns"><PlayerCard initialTab="internal" label="01 · 내전" profile={profile} snapshot={snapshot} manifest={manifest} /><PlayerCard initialTab="solo" label="02 · 솔로랭크" profile={profile} snapshot={snapshot} manifest={manifest} /></div>
|
||||||
|
<div className="pi-design-notes"><p><b>01</b> 신청한 포지션과 실제 플레이 기록을 구분합니다.</p><p><b>02</b> 최근 챔피언과 누적 숙련도를 따로 보여줍니다.</p><p><b>03</b> 경기수와 기준일을 펼치기 없이 표시합니다.</p></div>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
import type {
|
||||||
|
ApiAuctionPlayerSnapshot,
|
||||||
|
ApiRecentMatchView,
|
||||||
|
ApiRecentSummaryResponse,
|
||||||
|
ApiTierInfo,
|
||||||
|
DdragonManifest,
|
||||||
|
} from "../../api/types";
|
||||||
|
|
||||||
|
// Preview-only fixtures transcribed from the rendered development data on
|
||||||
|
// 2026-11-11. Rounded mastery totals and date-only timestamps are intentional.
|
||||||
|
// No requests, auction mutations, or production data imports are made here.
|
||||||
|
export type PreviewSummary = Pick<ApiRecentSummaryResponse,
|
||||||
|
"windowSize" | "winRate" | "wins" | "losses" | "kda" |
|
||||||
|
"avgKills" | "avgDeaths" | "avgAssists" | "positionRates" | "lastFetchedAt"
|
||||||
|
> & {
|
||||||
|
lastGameAt: string;
|
||||||
|
topChampions: Array<Pick<ApiRecentSummaryResponse["topChampions"][number], "championId" | "games" | "winRate">>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type PreviewMatch = Pick<ApiRecentMatchView,
|
||||||
|
"matchId" | "internalMatchId" | "gameNumber" | "championId" |
|
||||||
|
"win" | "remake" | "gameCreation" | "kills" | "deaths" | "assists"
|
||||||
|
>;
|
||||||
|
export type PreviewSnapshot = Pick<ApiAuctionPlayerSnapshot, "preferredPositions" | "masteries" | "passCount">;
|
||||||
|
export type PreviewProfile = {
|
||||||
|
gameName: string;
|
||||||
|
tagLine: string;
|
||||||
|
profileIconId: number;
|
||||||
|
tier: ApiTierInfo;
|
||||||
|
peak: Pick<ApiTierInfo, "tier" | "rank" | "leaguePoints">;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const profile: PreviewProfile = {
|
||||||
|
gameName: "붕어베이글", tagLine: "1003", profileIconId: 5755,
|
||||||
|
tier: {
|
||||||
|
queueType: "RANKED_SOLO_5x5", tier: "EMERALD", rank: "III", leaguePoints: 18,
|
||||||
|
// Season wins/losses are not part of this preview and are never displayed.
|
||||||
|
wins: 0, losses: 0, fetchedAt: "2026-11-11T00:00:00+09:00",
|
||||||
|
},
|
||||||
|
peak: { tier: "EMERALD", rank: "II", leaguePoints: 55 },
|
||||||
|
};
|
||||||
|
|
||||||
|
export const snapshot: PreviewSnapshot = {
|
||||||
|
preferredPositions: [{ position: "MID", priority: 1 }, { position: "SUP", priority: 2 }],
|
||||||
|
passCount: 1,
|
||||||
|
masteries: [
|
||||||
|
{ championId: 412, championLevel: 21, championPoints: 223000 },
|
||||||
|
{ championId: 79, championLevel: 18, championPoints: 174000 },
|
||||||
|
{ championId: 53, championLevel: 18, championPoints: 169000 },
|
||||||
|
{ championId: 516, championLevel: 13, championPoints: 167000 },
|
||||||
|
{ championId: 7, championLevel: 12, championPoints: 149000 },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const summaries: Record<"internal" | "solo", PreviewSummary> = {
|
||||||
|
internal: {
|
||||||
|
windowSize: 7, winRate: 57, wins: 4, losses: 3, kda: 3,
|
||||||
|
avgKills: 3.1, avgDeaths: 4, avgAssists: 8.7,
|
||||||
|
positionRates: { MIDDLE: 100 }, lastFetchedAt: null, lastGameAt: "2026-07-14T00:00:00+09:00",
|
||||||
|
topChampions: [
|
||||||
|
{ championId: 127, games: 3, winRate: 67 },
|
||||||
|
{ championId: 800, games: 1, winRate: 100 },
|
||||||
|
{ championId: 134, games: 1, winRate: 100 },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
solo: {
|
||||||
|
windowSize: 20, winRate: 45, wins: 9, losses: 11, kda: 2.7,
|
||||||
|
avgKills: 2, avgDeaths: 5.5, avgAssists: 12.9,
|
||||||
|
positionRates: { BOTTOM: 5, UTILITY: 95 },
|
||||||
|
lastFetchedAt: "2026-10-30T00:00:00+09:00", lastGameAt: "2026-11-07T00:00:00+09:00",
|
||||||
|
topChampions: [
|
||||||
|
{ championId: 89, games: 5, winRate: 40 },
|
||||||
|
{ championId: 43, games: 4, winRate: 75 },
|
||||||
|
{ championId: 201, games: 3, winRate: 33 },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const game = (championId: number, win: boolean, kills: number, deaths: number, assists: number, date: string, gameNumber: number, internalMatchId = "6a3e0c2c8ade90b14b72f335"): PreviewMatch => ({
|
||||||
|
championId, win, kills, deaths, assists, gameNumber, internalMatchId,
|
||||||
|
matchId: `${internalMatchId}-${gameNumber}`, remake: false,
|
||||||
|
gameCreation: new Date(`${date}T00:00:00+09:00`).getTime(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const internalMatches: PreviewMatch[] = [
|
||||||
|
game(127, false, 0, 6, 7, "2026-07-14", 25),
|
||||||
|
game(800, true, 7, 0, 5, "2026-07-13", 23),
|
||||||
|
game(516, false, 1, 7, 5, "2026-07-07", 8),
|
||||||
|
game(3, false, 1, 6, 6, "2026-07-07", 7),
|
||||||
|
game(134, true, 7, 2, 16, "2026-06-25", 6, "6a3e266b987c121c66c0d537"),
|
||||||
|
];
|
||||||
|
|
||||||
|
export const manifest: DdragonManifest = {
|
||||||
|
version: "16.22.1", cdn: "https://ddragon.leagueoflegends.com/cdn", locale: "ko_KR",
|
||||||
|
fetchedAt: "2026-11-11T00:00:00+09:00",
|
||||||
|
champions: {
|
||||||
|
"127": { key: "Lissandra", name: "리산드라" }, "800": { key: "Mel", name: "멜" },
|
||||||
|
"134": { key: "Syndra", name: "신드라" }, "516": { key: "Ornn", name: "오른" },
|
||||||
|
"3": { key: "Galio", name: "갈리오" }, "89": { key: "Leona", name: "레오나" },
|
||||||
|
"43": { key: "Karma", name: "카르마" }, "201": { key: "Braum", name: "브라움" },
|
||||||
|
"412": { key: "Thresh", name: "쓰레쉬" }, "79": { key: "Gragas", name: "그라가스" },
|
||||||
|
"53": { key: "Blitzcrank", name: "블리츠크랭크" }, "7": { key: "Leblanc", name: "르블랑" },
|
||||||
|
},
|
||||||
|
summonerSpells: {}, runesReforged: [], items: {},
|
||||||
|
};
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
# Player information code preview QA
|
||||||
|
|
||||||
|
final result: passed
|
||||||
|
|
||||||
|
## Scope and visual truth
|
||||||
|
|
||||||
|
This is a separate, interactive React proposal. The auction page and its live
|
||||||
|
components are not changed by this preview. The user requested code, not an
|
||||||
|
image-generated mockup. The existing screenshots define the visual language;
|
||||||
|
the proposed information architecture is intentionally different.
|
||||||
|
|
||||||
|
Source visual truth paths:
|
||||||
|
|
||||||
|
- `C:/Users/park/AppData/Local/Temp/codex-clipboard-4f76c508-99b8-4878-9093-8b61a16d6622.png` — internal tab, 679 × 1097 px.
|
||||||
|
- `C:/Users/park/AppData/Local/Temp/codex-clipboard-08295402-c611-4686-a7a2-f6cec9350c64.png` — solo tab, 703 × 1140 px.
|
||||||
|
|
||||||
|
Implementation: <http://localhost:5173/design-previews/player-information.html>
|
||||||
|
|
||||||
|
Evidence directory:
|
||||||
|
`C:/Users/park/.codex/visualizations/2026/11/11/01a1c930-2c9b-7531-a709-2ebb87701e9a/player-information-prototype/`
|
||||||
|
|
||||||
|
- Browser-rendered implementation screenshot: `desktop-v2.jpg`.
|
||||||
|
- Mobile implementation screenshot: `mobile-v2.jpg`.
|
||||||
|
- Full-view, combined source/implementation comparisons: `comparison-final-0.png`, `comparison-final-1.png`.
|
||||||
|
- Earlier combined comparisons: `comparison-0.png`, `comparison-1.png`.
|
||||||
|
- Focused identity/header comparison: `identity-comparison-0.png`.
|
||||||
|
- Geometry evidence: `measurements-v2.json`.
|
||||||
|
|
||||||
|
## Viewport, density and state
|
||||||
|
|
||||||
|
Desktop CSS viewport: 1280 × 1000; reported devicePixelRatio approximately 1.
|
||||||
|
Browser screenshot: 1265 × 988 px. Comparison crop coordinates account for this
|
||||||
|
capture scaling independently on both axes. Each implementation card measures
|
||||||
|
540 CSS px wide, with heights 796.05 px (internal) and 780.38 px (solo).
|
||||||
|
|
||||||
|
The source card regions are cropped at (7,15,660,1074) and (18,46,660,1074),
|
||||||
|
then normalized to 540 px wide. Source capture density is unknown, so no
|
||||||
|
pixel-exact typography match is asserted. Comparisons align card width and
|
||||||
|
exclude the surrounding canvas. Mobile CSS viewport: 390 × 900; stacked cards.
|
||||||
|
|
||||||
|
State: light theme, same player identity, left internal tab and right solo tab.
|
||||||
|
Current account avatar, tier, and solo record differ from the older source
|
||||||
|
screenshots: the preview uses values observed on 2026-11-11. The backend became
|
||||||
|
unavailable during implementation, so the preview now uses clearly labelled
|
||||||
|
fixed fixtures. Mastery totals are rounded and fixture dates are date-only.
|
||||||
|
It does not present the fixtures as live data.
|
||||||
|
|
||||||
|
## Findings and comparison history
|
||||||
|
|
||||||
|
1. First combined comparison found a P2 readability issue: 9–10 px record
|
||||||
|
labels and 11 px champion names were too small relative to the original
|
||||||
|
card. Evidence: `comparison-0.png` and `comparison-1.png`.
|
||||||
|
2. Fixed by increasing metadata to 11 px, champion names and section titles
|
||||||
|
to 13 px, tab labels to 13 px, and list portraits to 32 px. The spacing
|
||||||
|
remains compact without hiding rows. Recaptured the same desktop viewport
|
||||||
|
and default tab states as `desktop-v2.jpg`.
|
||||||
|
3. Compared both revised states in `comparison-final-0.png` and
|
||||||
|
`comparison-final-1.png`, and inspected revised mobile rendering. No
|
||||||
|
actionable P0/P1/P2 issue remains within this separate prototype's scope.
|
||||||
|
|
||||||
|
The identity crop was examined for font family, rank badge, role icon fidelity,
|
||||||
|
alignment and avatar treatment. The final full-card comparisons are readable
|
||||||
|
enough to verify the revised list typography and spacing without additional
|
||||||
|
region crops.
|
||||||
|
|
||||||
|
## Required fidelity surfaces
|
||||||
|
|
||||||
|
- **Fonts/typography:** Reuses SuitVariable and the application's fallback
|
||||||
|
stack. Name is 20 px / 750; tabs 13 px / 650; section titles 13 px / 700.
|
||||||
|
Secondary data is 11–12 px. No measured champion-name truncation at either
|
||||||
|
tested viewport; mobile KDA wraps to its own line and remains present.
|
||||||
|
- **Spacing/layout:** Reuses existing radii, fine borders, tabs and two-column
|
||||||
|
lists. The preview workbench puts both states side by side, stacking below
|
||||||
|
950 px. Position counts remain visible without a disclosure. No horizontal
|
||||||
|
overflow at 1280 or 390 px. Both complete cards fit the 1000 px desktop
|
||||||
|
viewport; mobile uses ordinary document scrolling.
|
||||||
|
- **Colors/tokens:** Uses application foreground, muted foreground, border,
|
||||||
|
card background, accent and gold tokens. Existing green rank badge and gold
|
||||||
|
role assets are reused. Result text distinguishes wins and losses with text
|
||||||
|
as well as color. No new palette or dark-theme preference is persisted.
|
||||||
|
- **Image quality:** Uses the observed Riot profile icon and genuine champion
|
||||||
|
assets; existing product position SVGs and RankBadge component are reused.
|
||||||
|
Champion portraits retain overflow clipping and scale(1.18), removing dark
|
||||||
|
source edges. No broken images were observed at final desktop verification.
|
||||||
|
- **Copy/content:** Requested positions are explicitly separated from actual
|
||||||
|
recent positions. Counts and denominator, last-game date and collection
|
||||||
|
basis are visible. Recent champions and cumulative mastery are distinguished.
|
||||||
|
The no-recent-main-role note describes missing sample evidence rather than
|
||||||
|
judging player ability. No accordion or triangle disclosure is introduced.
|
||||||
|
|
||||||
|
## Intentional proposal differences
|
||||||
|
|
||||||
|
- Compact current/peak rank text replaces the large rank-history chart to
|
||||||
|
prioritize position experience in this alternative. This is not applied
|
||||||
|
to the real card.
|
||||||
|
- Both tabs share the same summary hierarchy. Recent champions (three entries
|
||||||
|
supplied by the observed summary) sit beside recent internal games or five
|
||||||
|
lifetime mastery entries.
|
||||||
|
- Per-champion rating, duplicate per-match role/rating and solo CS/role KDA
|
||||||
|
details are omitted in this compact proposal. Overall KDA, win rate, game
|
||||||
|
count and individual internal game K/D/A remain visible; history links lead
|
||||||
|
to the existing detailed screens.
|
||||||
|
- The lower auction-status strip is retained. No team layout or auction
|
||||||
|
action changes are part of this mockup.
|
||||||
|
|
||||||
|
## Interaction and implementation checks
|
||||||
|
|
||||||
|
- Mouse tab change: internal to solo updates counts, champions and summary.
|
||||||
|
- ArrowLeft returns to internal and moves focus to the selected tab.
|
||||||
|
- Each card maintains independent tab state and valid tab/tabpanel relations.
|
||||||
|
- After the typography fix, all five internal KDA rows remain in the DOM and
|
||||||
|
visible at 390 px; no clipped champion names or horizontal overflow.
|
||||||
|
- Final browser console error check returned no errors after fixture reload.
|
||||||
|
- `pnpm exec tsc -b --pretty false` passed.
|
||||||
|
- `pnpm exec eslint src/design-previews/player-information` passed.
|
||||||
|
- All links use real existing routes and open a new tab. Live destination
|
||||||
|
data could not be revalidated after the development API outage.
|
||||||
|
|
||||||
|
## Residual gaps and implementation checklist
|
||||||
|
|
||||||
|
- This handoff validates a fixed-data proposal, not production loading/error
|
||||||
|
states, live auction behavior, or every possible player record.
|
||||||
|
- Dark mode is inherited from the product but was not visually reviewed.
|
||||||
|
- Keep the live auction unchanged until the information layout is selected.
|
||||||
|
- Before production integration, connect the same sections to the existing
|
||||||
|
queries and verify the selected layout at the actual auction panel width.
|
||||||
|
|
||||||
|
No further fixes are required to open and interact with this preview.
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { StrictMode } from "react";
|
||||||
|
import { createRoot } from "react-dom/client";
|
||||||
|
import { BrowserRouter } from "react-router";
|
||||||
|
import { initializeTheme } from "../../config";
|
||||||
|
import { AppTheme } from "../../ui/AppTheme";
|
||||||
|
import Preview from "./Preview";
|
||||||
|
import "../../index.css";
|
||||||
|
|
||||||
|
initializeTheme();
|
||||||
|
createRoot(document.getElementById("root")!).render(
|
||||||
|
<StrictMode>
|
||||||
|
<BrowserRouter>
|
||||||
|
<AppTheme><Preview /></AppTheme>
|
||||||
|
</BrowserRouter>
|
||||||
|
</StrictMode>,
|
||||||
|
);
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
.player-info-preview {
|
||||||
|
min-height: 100vh;
|
||||||
|
background: var(--color-background-card);
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
font-family: var(--font-family-body);
|
||||||
|
padding: 28px 32px 32px;
|
||||||
|
}
|
||||||
|
.pi-workbench-header, .pi-preview-columns, .pi-design-notes, .pi-fixture-note { max-width: 1104px; margin-inline: auto; }
|
||||||
|
.pi-fixture-note { color: var(--lts-text-subtle); font-size: 11px; margin-top: -14px; margin-bottom: 20px; }
|
||||||
|
.pi-workbench-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
|
||||||
|
.pi-eyebrow { font-size: 11px; color: var(--lts-text-subtle); letter-spacing: .06em; margin-bottom: 7px; }
|
||||||
|
.pi-workbench-header h1 { font-size: 23px; font-weight: 750; line-height: 1.35; letter-spacing: -.035em; }
|
||||||
|
.pi-workbench-header h1 + p { font-size: 12px; color: var(--lts-text-subtle); margin-top: 8px; }
|
||||||
|
.pi-original-link { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; flex-shrink: 0; border: 1px solid var(--color-border); border-radius: var(--radius-element); padding: 10px 12px; }
|
||||||
|
.pi-original-link:hover { background: var(--color-background-muted); }
|
||||||
|
.pi-preview-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
|
||||||
|
.pi-state-label { font-size: 11px; font-weight: 700; color: var(--lts-text-subtle); margin: 0 0 9px 2px; }
|
||||||
|
.pi-player-card { border: 1px solid var(--color-border); border-radius: var(--radius-container); background: var(--color-background-card); overflow: hidden; font-size: 13px; line-height: 1.45; }
|
||||||
|
.pi-identity { padding: 20px; display: flex; align-items: flex-start; gap: 16px; }
|
||||||
|
.pi-player-avatar { width: 64px; height: 64px; flex-shrink: 0; object-fit: cover; border-radius: var(--radius-inner); }
|
||||||
|
.pi-player-info { min-width: 0; }
|
||||||
|
.pi-player-name { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; }
|
||||||
|
.pi-player-name h2 { font-size: 20px; font-weight: 750; line-height: 1.2; letter-spacing: -.02em; }
|
||||||
|
.pi-player-name > span, .pi-secondary { font-size: 12px; color: var(--lts-text-subtle); }
|
||||||
|
.pi-rank { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
|
||||||
|
.pi-peak { font-size: 12px; color: var(--lts-text-subtle); margin-top: 4px; }
|
||||||
|
.pi-peak strong { font-weight: 500; color: var(--color-text-primary); margin-left: 4px; }
|
||||||
|
.pi-preferences { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
|
||||||
|
.pi-preferences > span:first-child { font-size: 11px; color: var(--lts-text-subtle); margin-right: 2px; }
|
||||||
|
.pi-role-chip { border: 1px solid var(--color-border); border-radius: 7px; padding: 2px 6px; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
|
||||||
|
.pi-role-chip[data-primary="true"] { color: var(--color-text-accent); border-color: color-mix(in srgb, var(--color-text-accent) 22%, transparent); background: color-mix(in srgb, var(--color-text-accent) 4%, transparent); }
|
||||||
|
.pi-role-chip img { width: 13px; height: 13px; border-radius: 0; }
|
||||||
|
.pi-role-chip small { font-size: 10px; opacity: .8; }
|
||||||
|
.pi-tabs { display: flex; border-block: 1px solid var(--color-border); padding-inline: 12px; gap: 5px; }
|
||||||
|
.pi-tabs button { position: relative; padding: 12px 11px; color: var(--lts-text-subtle); font-size: 13px; font-weight: 650; cursor: pointer; border-radius: 0; }
|
||||||
|
.pi-tabs button[aria-selected="true"] { color: var(--color-text-accent); }
|
||||||
|
.pi-tabs button[aria-selected="true"]::after { content: ""; position: absolute; height: 2px; background: currentColor; bottom: -1px; left: 11px; right: 11px; }
|
||||||
|
.pi-tabs button:hover { color: var(--color-text-primary); }
|
||||||
|
.pi-tabs button:focus-visible, .pi-recent-game:focus-visible, .pi-summary-heading a:focus-visible { outline: 2px solid var(--color-text-accent); outline-offset: -2px; }
|
||||||
|
.pi-card-body { padding: 16px 18px 12px; }
|
||||||
|
.pi-summary-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
|
||||||
|
.pi-summary-heading h3 { font-size: 14px; font-weight: 700; }
|
||||||
|
.pi-summary-heading a { color: var(--color-text-accent); display: inline-flex; align-items: center; gap: 3px; font-size: 12px; }
|
||||||
|
.pi-record-basis { color: var(--lts-text-subtle); font-size: 11px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 5px; }
|
||||||
|
.pi-experience { margin-block: 15px; }
|
||||||
|
.pi-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 9px; }
|
||||||
|
.pi-section-heading h3 { font-size: 13px; font-weight: 700; }
|
||||||
|
.pi-section-heading > span { font-size: 11px; color: var(--lts-text-subtle); white-space: nowrap; }
|
||||||
|
.pi-position-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
|
||||||
|
.pi-position-stat { min-width: 0; color: var(--lts-text-subtle); }
|
||||||
|
.pi-position-stat > div:first-child { display: flex; align-items: center; gap: 4px; font-size: 11px; }
|
||||||
|
.pi-position-stat img { width: 12px; height: 12px; border-radius: 0; opacity: .65; }
|
||||||
|
.pi-position-stat > strong { display: block; font-size: 15px; font-weight: 500; margin-top: 2px; font-variant-numeric: tabular-nums; }
|
||||||
|
.pi-position-stat > strong > span { font-size: 11px; font-weight: 400; margin-left: 3px; }
|
||||||
|
.pi-position-stat[data-played="true"] { color: var(--color-text-primary); }
|
||||||
|
.pi-position-stat[data-played="true"] > strong { font-weight: 750; }
|
||||||
|
.pi-position-stat[data-played="true"] img { opacity: 1; }
|
||||||
|
.pi-position-track { height: 3px; border-radius: 99px; overflow: hidden; background: color-mix(in srgb, var(--color-text-primary) 7%, transparent); margin-top: 4px; }
|
||||||
|
.pi-position-track > span { height: 100%; display: block; background: var(--color-text-accent); border-radius: 99px; opacity: .65; }
|
||||||
|
.pi-position-note { font-size: 11px; color: var(--lts-text-subtle); margin-top: 9px; }
|
||||||
|
.pi-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 17px; }
|
||||||
|
.pi-metrics > div { display: grid; grid-template-columns: 1fr auto; align-items: center; border: 1px solid var(--color-border); border-radius: var(--radius-element); padding: 10px 12px; gap: 2px 6px; }
|
||||||
|
.pi-metrics > div > span { font-size: 12px; color: var(--lts-text-subtle); }
|
||||||
|
.pi-metrics strong { grid-column: 2; grid-row: 1 / 3; font-size: 25px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
|
||||||
|
.pi-metrics strong small { font-size: 14px; margin-left: 1px; font-weight: 500; }
|
||||||
|
.pi-metrics p { font-size: 11px; font-variant-numeric: tabular-nums; color: var(--lts-text-subtle); }
|
||||||
|
.pi-detail-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
|
||||||
|
.pi-detail-columns > section { min-width: 0; }
|
||||||
|
.pi-champion-list, .pi-recent-list { display: flex; flex-direction: column; gap: 6px; }
|
||||||
|
.pi-champion-row { min-height: 38px; display: flex; align-items: center; gap: 7px; }
|
||||||
|
.pi-champion-portrait { display: inline-block; height: 32px; width: 32px; flex: 0 0 32px; overflow: hidden; border-radius: var(--radius-inner); background: var(--color-background-muted); }
|
||||||
|
.pi-champion-portrait img { height: 100%; width: 100%; object-fit: cover; transform: scale(1.18); }
|
||||||
|
.pi-champion-row > div, .pi-recent-game > div { min-width: 0; }
|
||||||
|
.pi-champion-row strong, .pi-recent-game strong { font-weight: 550; font-size: 13px; white-space: nowrap; display: block; overflow: hidden; text-overflow: ellipsis; }
|
||||||
|
.pi-champion-row p, .pi-recent-game p { color: var(--lts-text-subtle); font-size: 11px; white-space: nowrap; }
|
||||||
|
.pi-champion-rate { font-size: 12px; font-variant-numeric: tabular-nums; margin-left: auto; }
|
||||||
|
.pi-recent-game { display: flex; align-items: center; gap: 6px; padding: 5px 6px; min-height: 36px; border: 1px solid var(--color-border); border-radius: var(--radius-element); }
|
||||||
|
.pi-recent-game:hover { background: var(--color-background-muted); }
|
||||||
|
.pi-recent-game .pi-champion-portrait { width: 28px; height: 28px; flex-basis: 28px; }
|
||||||
|
.pi-recent-game b { font-weight: 700; }
|
||||||
|
.pi-recent-game b[data-result="win"] { color: var(--color-palette-win-text-light); }
|
||||||
|
.pi-recent-game b[data-result="loss"] { color: var(--color-palette-loss-text-light); }
|
||||||
|
[data-theme="dark"] .pi-recent-game b[data-result="win"] { color: var(--color-palette-win-text-dark); }
|
||||||
|
[data-theme="dark"] .pi-recent-game b[data-result="loss"] { color: var(--color-palette-loss-text-dark); }
|
||||||
|
.pi-game-kda { font-size: 11px; margin-left: auto; font-variant-numeric: tabular-nums; flex-shrink: 0; }
|
||||||
|
.pi-data-note { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--color-border); display: flex; gap: 6px 15px; flex-wrap: wrap; font-size: 11px; color: var(--lts-text-subtle); }
|
||||||
|
.pi-auction-status { background: color-mix(in srgb, var(--lts-gold) 5%, transparent); color: var(--lts-gold); border-top: 1px solid var(--color-border); padding: 10px 16px; text-align: center; font-size: 12px; font-weight: 650; }
|
||||||
|
.pi-empty { font-size: 11px; color: var(--lts-text-subtle); padding-block: 16px; }
|
||||||
|
.pi-design-notes { display: flex; flex-wrap: wrap; gap: 10px 28px; margin-top: 20px; font-size: 11px; color: var(--lts-text-subtle); }
|
||||||
|
.pi-design-notes b { font-weight: 650; color: var(--color-text-primary); margin-right: 6px; }
|
||||||
|
@media (max-width: 950px) {
|
||||||
|
.pi-preview-columns { grid-template-columns: minmax(0, 560px); justify-content: center; gap: 28px; }
|
||||||
|
.pi-workbench-header { max-width: 560px; align-items: flex-start; }
|
||||||
|
.pi-workbench-header h1 { font-size: 21px; }
|
||||||
|
.pi-original-link { font-size: 0; gap: 0; padding: 9px; }
|
||||||
|
.pi-design-notes { max-width: 560px; flex-direction: column; }
|
||||||
|
.pi-fixture-note { max-width: 560px; }
|
||||||
|
}
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.player-info-preview { padding: 20px 12px; }
|
||||||
|
.pi-workbench-header { gap: 12px; margin-bottom: 24px; }
|
||||||
|
.pi-workbench-header h1 { font-size: 19px; }
|
||||||
|
.pi-identity { padding: 16px; gap: 11px; }
|
||||||
|
.pi-player-avatar { width: 52px; height: 52px; }
|
||||||
|
.pi-player-name h2 { font-size: 18px; }
|
||||||
|
.pi-preferences > span:first-child { width: 100%; }
|
||||||
|
.pi-card-body { padding-inline: 14px; }
|
||||||
|
.pi-detail-columns { gap: 14px; }
|
||||||
|
.pi-section-heading { align-items: flex-start; flex-direction: column; gap: 2px; }
|
||||||
|
.pi-experience > .pi-section-heading { flex-direction: row; }
|
||||||
|
.pi-recent-game { flex-wrap: wrap; }
|
||||||
|
.pi-game-kda { flex-basis: 100%; padding-left: 34px; }
|
||||||
|
.pi-metrics > div { padding: 9px; }
|
||||||
|
.pi-metrics strong { font-size: 23px; }
|
||||||
|
.pi-champion-rate { font-size: 11px; }
|
||||||
|
}
|
||||||
@@ -77,8 +77,8 @@
|
|||||||
--color-palette-loss-fill-light: #d75464;
|
--color-palette-loss-fill-light: #d75464;
|
||||||
--color-palette-loss-fill-dark: #ea7583;
|
--color-palette-loss-fill-dark: #ea7583;
|
||||||
--color-palette-loss-tint-dark: #39272b;
|
--color-palette-loss-tint-dark: #39272b;
|
||||||
--color-palette-gold-text-light: #805213;
|
--color-palette-gold-text-light: #8a5a00;
|
||||||
--color-palette-gold-text-dark: #f1cd82;
|
--color-palette-gold-text-dark: #f2c14e;
|
||||||
--color-palette-gold-tint-light: #fbf2df;
|
--color-palette-gold-tint-light: #fbf2df;
|
||||||
--color-palette-gold-tint-dark: #3b3020;
|
--color-palette-gold-tint-dark: #3b3020;
|
||||||
--color-palette-leaf-text-light: #246a46;
|
--color-palette-leaf-text-light: #246a46;
|
||||||
@@ -390,16 +390,16 @@
|
|||||||
|
|
||||||
@layer components {
|
@layer components {
|
||||||
.lts-app-shell {
|
.lts-app-shell {
|
||||||
--app-header-row-height: 3.25rem;
|
--app-header-row-height: 3.75rem;
|
||||||
/* 페이지 내부 고정 탭의 위쪽 여백은 메뉴 줄 높이만 사용한다. */
|
/* 스크롤 후 남는 상단 바 높이: 모바일 메뉴 줄 / 데스크톱 전체 헤더. */
|
||||||
--app-header-nav-height: 3rem;
|
--app-header-nav-height: 3rem;
|
||||||
--app-header-height: calc(var(--app-header-row-height) + var(--app-header-nav-height));
|
--app-header-height: calc(var(--app-header-row-height) + var(--app-header-nav-height));
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (width >= 48rem) {
|
@media (width >= 48rem) {
|
||||||
.lts-app-shell {
|
.lts-app-shell {
|
||||||
--app-header-row-height: 3.5rem;
|
--app-header-row-height: 0px;
|
||||||
--app-header-nav-height: 4rem;
|
--app-header-nav-height: 4.625rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,25 @@ export function sortLeaderboardRows<
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 검색 ID가 없는 API 응답도 표시된 선수 이름과 Riot ID로 검색할 수 있다. */
|
||||||
|
export function filterLeaderboardRows<
|
||||||
|
T extends Pick<ApiLeaderboardRow, 'userId' | 'summonerName' | 'tagLine'>,
|
||||||
|
>(rows: readonly T[], query: string, matchedUserIds?: readonly string[]): T[] {
|
||||||
|
const keyword = query.trim().toLocaleLowerCase('ko-KR');
|
||||||
|
if (!keyword) return [...rows];
|
||||||
|
|
||||||
|
if (matchedUserIds !== undefined) {
|
||||||
|
const matchedUsers = new Set(matchedUserIds);
|
||||||
|
return rows.filter((row) => matchedUsers.has(row.userId));
|
||||||
|
}
|
||||||
|
|
||||||
|
return rows.filter(({ summonerName, tagLine }) =>
|
||||||
|
(tagLine ? `${summonerName}#${tagLine}` : summonerName)
|
||||||
|
.toLocaleLowerCase('ko-KR')
|
||||||
|
.includes(keyword),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 한 라인만의 순위표. 그 라인 기록이 있는 선수만 남기고 전적을 라인 전적으로
|
* 한 라인만의 순위표. 그 라인 기록이 있는 선수만 남기고 전적을 라인 전적으로
|
||||||
* 바꾼 뒤 승률 순으로 놓는다. 최소 판수도 그 라인 판수로 따진다.
|
* 바꾼 뒤 승률 순으로 놓는다. 최소 판수도 그 라인 판수로 따진다.
|
||||||
|
|||||||
+159
-1022
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,310 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
import { ArrowDown, ArrowRight, ChevronRight } from "lucide-react";
|
||||||
|
import { useLocation, useParams, useSearchParams } from "react-router";
|
||||||
|
import {
|
||||||
|
useCommunityStatsSeasons,
|
||||||
|
useDdragonManifest,
|
||||||
|
useUserHistoryProfile,
|
||||||
|
useUserInternalHistory,
|
||||||
|
} from "../api/hooks";
|
||||||
|
import { DEFAULT_COMMUNITY_ID } from "../config";
|
||||||
|
import { championDisplayName, profileIconUrl } from "../lib/ddragon";
|
||||||
|
import { internalMatchGamePath } from "../lib/internal-match-routes";
|
||||||
|
import { LANE_LABELS } from "../lib/riot-history";
|
||||||
|
import { Btn } from "../ui";
|
||||||
|
import {
|
||||||
|
StatsBack,
|
||||||
|
StatsChampion,
|
||||||
|
StatsFeedback,
|
||||||
|
StatsLaneSelect,
|
||||||
|
StatsLink,
|
||||||
|
StatsSeasonControls,
|
||||||
|
} from "../components/internal-stats/StatsShared";
|
||||||
|
import {
|
||||||
|
parseStatsLane,
|
||||||
|
statsDate,
|
||||||
|
statsDuration,
|
||||||
|
statsPeriod,
|
||||||
|
statsRoot,
|
||||||
|
statsTarget,
|
||||||
|
useStatsBack,
|
||||||
|
useStatsRestoration,
|
||||||
|
} from "../components/internal-stats/stats-navigation";
|
||||||
|
|
||||||
|
export default function CommunityInternalPlayerPage() {
|
||||||
|
const { cid, userId } = useParams();
|
||||||
|
const communityId = cid ?? DEFAULT_COMMUNITY_ID,
|
||||||
|
root = statsRoot(communityId);
|
||||||
|
const location = useLocation();
|
||||||
|
const [params, setParams] = useSearchParams();
|
||||||
|
const seasonId = params.get("seasonId") ?? "current",
|
||||||
|
lane = parseStatsLane(params.get("lane"));
|
||||||
|
const champion = Number(params.get("championId"));
|
||||||
|
const history = useUserInternalHistory(
|
||||||
|
userId,
|
||||||
|
{ seasonId, lane, championId: champion > 0 ? champion : undefined },
|
||||||
|
communityId,
|
||||||
|
);
|
||||||
|
const profile = useUserHistoryProfile(userId, communityId);
|
||||||
|
const seasons = useCommunityStatsSeasons(communityId);
|
||||||
|
const { data: manifest } = useDdragonManifest();
|
||||||
|
const first = history.data?.pages[0],
|
||||||
|
row = first?.playerStats;
|
||||||
|
const matches = history.data?.pages.flatMap((page) => page.matches) ?? [];
|
||||||
|
const name = row?.summonerName ?? profile.data?.gameName ?? "선수 전적";
|
||||||
|
const back = useStatsBack(
|
||||||
|
`${root}?view=ranking&seasonId=${encodeURIComponent(seasonId)}`,
|
||||||
|
);
|
||||||
|
const current = location.pathname + location.search;
|
||||||
|
const pageCount = history.data?.pages.length ?? 0;
|
||||||
|
const requestedPages = Math.max(
|
||||||
|
1,
|
||||||
|
Math.min(30, Number(params.get("pages")) || 1),
|
||||||
|
);
|
||||||
|
const {
|
||||||
|
fetchNextPage,
|
||||||
|
hasNextPage,
|
||||||
|
isFetchingNextPage,
|
||||||
|
isFetchNextPageError,
|
||||||
|
} = history;
|
||||||
|
useEffect(() => {
|
||||||
|
if (
|
||||||
|
pageCount > 0 &&
|
||||||
|
pageCount < requestedPages &&
|
||||||
|
hasNextPage &&
|
||||||
|
!isFetchingNextPage &&
|
||||||
|
!isFetchNextPageError
|
||||||
|
)
|
||||||
|
void fetchNextPage();
|
||||||
|
}, [
|
||||||
|
pageCount,
|
||||||
|
requestedPages,
|
||||||
|
hasNextPage,
|
||||||
|
isFetchingNextPage,
|
||||||
|
isFetchNextPageError,
|
||||||
|
fetchNextPage,
|
||||||
|
]);
|
||||||
|
useStatsRestoration(
|
||||||
|
!history.isPending && (pageCount >= requestedPages || !hasNextPage),
|
||||||
|
);
|
||||||
|
function update(key: string, value: string) {
|
||||||
|
const next = new URLSearchParams(params);
|
||||||
|
if (value) next.set(key, value);
|
||||||
|
else next.delete(key);
|
||||||
|
if (key !== "pages") next.delete("pages");
|
||||||
|
setParams(next, { preventScrollReset: true });
|
||||||
|
}
|
||||||
|
const participation = new URLSearchParams({
|
||||||
|
seasonId,
|
||||||
|
player: userId ?? "",
|
||||||
|
playerName: name,
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<div className="internal-stats">
|
||||||
|
<main className="is-page">
|
||||||
|
<StatsBack to={back} />
|
||||||
|
<header className="is-page-heading is-detail-heading">
|
||||||
|
<div>
|
||||||
|
<p className="is-eyebrow">
|
||||||
|
{first?.season.label ?? "시즌 전적"} ·{" "}
|
||||||
|
{statsPeriod(first?.season)}
|
||||||
|
</p>
|
||||||
|
<h1>{name}</h1>
|
||||||
|
<p className="is-muted">
|
||||||
|
선택한 시즌의 개인 기록과 참가 경기를 확인합니다.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<StatsSeasonControls
|
||||||
|
value={seasonId}
|
||||||
|
seasons={seasons.data?.seasons}
|
||||||
|
onChange={(value) => update("seasonId", value)}
|
||||||
|
/>
|
||||||
|
</header>
|
||||||
|
<div className="is-profile-heading">
|
||||||
|
<img
|
||||||
|
className="is-champion is-champion-large"
|
||||||
|
src={profileIconUrl(
|
||||||
|
manifest,
|
||||||
|
row?.profileIconId ?? profile.data?.profileIconId ?? 0,
|
||||||
|
)}
|
||||||
|
alt=""
|
||||||
|
/>
|
||||||
|
<div>
|
||||||
|
<h2>{name}</h2>
|
||||||
|
<span>
|
||||||
|
{profile.data?.tagLine ? `#${profile.data.tagLine}` : "내전 전적"}{" "}
|
||||||
|
· {first?.season.label}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<StatsLink
|
||||||
|
className="is-action-link"
|
||||||
|
to={`${root}?${participation}`}
|
||||||
|
data-return-id="player-participation"
|
||||||
|
>
|
||||||
|
참가 내전 보기
|
||||||
|
<ArrowRight size={16} />
|
||||||
|
</StatsLink>
|
||||||
|
</div>
|
||||||
|
<div className="is-profile-filters">
|
||||||
|
<StatsLaneSelect
|
||||||
|
value={lane}
|
||||||
|
onChange={(value) => update("lane", value)}
|
||||||
|
/>
|
||||||
|
<label className="is-select">
|
||||||
|
<span className="sr-only">플레이 챔피언</span>
|
||||||
|
<select
|
||||||
|
aria-label="플레이 챔피언"
|
||||||
|
value={champion > 0 ? champion : ""}
|
||||||
|
onChange={(event) => update("championId", event.target.value)}
|
||||||
|
>
|
||||||
|
<option value="">전체 챔피언</option>
|
||||||
|
{first?.championStats.champions.map((champ) => (
|
||||||
|
<option value={champ.championId} key={champ.championId}>
|
||||||
|
{championDisplayName(manifest, champ.championId) ??
|
||||||
|
`챔피언 #${champ.championId}`}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
{champion > 0 &&
|
||||||
|
!first?.championStats.champions.some(
|
||||||
|
(champ) => champ.championId === champion,
|
||||||
|
) && (
|
||||||
|
<option value={champion}>
|
||||||
|
{championDisplayName(manifest, champion) ??
|
||||||
|
`챔피언 #${champion}`}
|
||||||
|
</option>
|
||||||
|
)}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<p className="is-muted">
|
||||||
|
선택한 시즌과 포지션의 분석 가능한 세트만 집계합니다.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{history.isPending ? (
|
||||||
|
<StatsFeedback type="loading" title="선수 전적을 불러오는 중입니다" />
|
||||||
|
) : (history.isError && !first) || (first && row === undefined) ? (
|
||||||
|
<StatsFeedback
|
||||||
|
type="error"
|
||||||
|
title="선수 전적을 불러오지 못했습니다"
|
||||||
|
action={<Btn onClick={() => void history.refetch()}>다시 시도</Btn>}
|
||||||
|
/>
|
||||||
|
) : row ? (
|
||||||
|
<>
|
||||||
|
<div className="is-profile-stats">
|
||||||
|
{[
|
||||||
|
["판수", `${row.games}`, `${row.wins}승 ${row.losses}패`],
|
||||||
|
["승률", `${row.winRate}%`, "분석 가능한 경기 기준"],
|
||||||
|
["KDA", row.kda.toFixed(2), "(킬 + 어시스트) / 데스"],
|
||||||
|
["GPM", `${row.avgGoldPerMin}`, "평균 분당 골드"],
|
||||||
|
["킬 관여", `${row.avgKillParticipation}%`, "평균 킬 관여율"],
|
||||||
|
["분당 CS", `${row.avgCsPerMin}`, "평균 CS"],
|
||||||
|
].map(([label, value, desc]) => (
|
||||||
|
<div key={label}>
|
||||||
|
<span>{label}</span>
|
||||||
|
<strong>{value}</strong>
|
||||||
|
<small>{desc}</small>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="is-result-heading">
|
||||||
|
<h2>
|
||||||
|
참가 세트 기록 <span>{matches.length}판 표시</span>
|
||||||
|
</h2>
|
||||||
|
<p>최근 내전부터 표시 · 시즌 총 {row.games}판</p>
|
||||||
|
</div>
|
||||||
|
<div className="is-personal-games">
|
||||||
|
{matches.map((game) => (
|
||||||
|
<article
|
||||||
|
key={game.matchId}
|
||||||
|
className={game.win ? "is-personal-win" : "is-personal-loss"}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className={`is-personal-result ${game.win ? "is-blue" : "is-red"}`}
|
||||||
|
>
|
||||||
|
{game.win ? "승리" : "패배"}
|
||||||
|
</span>
|
||||||
|
<StatsChampion id={game.championId} manifest={manifest} />
|
||||||
|
<div className="is-personal-event">
|
||||||
|
<strong>
|
||||||
|
{game.internalMatchTitle || game.queueLabel || "내전"}
|
||||||
|
</strong>
|
||||||
|
<small>
|
||||||
|
{statsDate(new Date(game.gameCreation).toISOString())} ·
|
||||||
|
전체 {game.gameNumber}세트 ·{" "}
|
||||||
|
{LANE_LABELS[game.teamPosition] ?? "포지션 미확인"}
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
<span className="is-personal-kda">
|
||||||
|
<strong>
|
||||||
|
{game.kills} / {game.deaths} / {game.assists}
|
||||||
|
</strong>
|
||||||
|
<small>{game.kda} KDA</small>
|
||||||
|
</span>
|
||||||
|
<span className="is-duration">
|
||||||
|
{statsDuration(game.gameDuration)}
|
||||||
|
</span>
|
||||||
|
{game.internalMatchId && game.gameNumber && (
|
||||||
|
<StatsLink
|
||||||
|
className="is-analysis-link"
|
||||||
|
to={statsTarget(
|
||||||
|
internalMatchGamePath(
|
||||||
|
communityId,
|
||||||
|
game.internalMatchId,
|
||||||
|
game.gameNumber,
|
||||||
|
),
|
||||||
|
params,
|
||||||
|
current,
|
||||||
|
)}
|
||||||
|
data-return-id={`personal-${game.matchId}`}
|
||||||
|
aria-label={`${statsDate(new Date(game.gameCreation).toISOString())} 전체 ${game.gameNumber}세트 상세 분석`}
|
||||||
|
>
|
||||||
|
분석
|
||||||
|
<ChevronRight size={14} />
|
||||||
|
</StatsLink>
|
||||||
|
)}
|
||||||
|
</article>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
{history.isFetchNextPageError && (
|
||||||
|
<StatsFeedback
|
||||||
|
type="error"
|
||||||
|
title="이전 기록을 불러오지 못했습니다"
|
||||||
|
action={
|
||||||
|
<Btn onClick={() => void history.fetchNextPage()}>
|
||||||
|
다시 시도
|
||||||
|
</Btn>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{history.hasNextPage && (
|
||||||
|
<button
|
||||||
|
className="is-load-more"
|
||||||
|
disabled={history.isFetchingNextPage}
|
||||||
|
onClick={() => update("pages", String(pageCount + 1))}
|
||||||
|
>
|
||||||
|
{history.isFetchingNextPage
|
||||||
|
? "기록을 불러오는 중"
|
||||||
|
: "이전 기록 더 보기"}
|
||||||
|
<ArrowDown size={16} />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<StatsFeedback
|
||||||
|
type="empty"
|
||||||
|
title="조건에 맞는 분석 기록이 없습니다"
|
||||||
|
action={
|
||||||
|
lane ? (
|
||||||
|
<Btn onClick={() => update("lane", "")}>전체 포지션 보기</Btn>
|
||||||
|
) : (
|
||||||
|
<Btn to={`${root}?${participation}`}>참가 내전 보기</Btn>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
다른 포지션이나 시즌을 선택해 주세요. 원본 없는 세트의 공식 결과는
|
||||||
|
참가 내전에서 확인할 수 있습니다.
|
||||||
|
</StatsFeedback>
|
||||||
|
)}
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
+284
-200
@@ -4,7 +4,7 @@ import type {
|
|||||||
MatchEventType,
|
MatchEventType,
|
||||||
MatchSummaryResponse,
|
MatchSummaryResponse,
|
||||||
} from '@lolympus/contracts';
|
} from '@lolympus/contracts';
|
||||||
import { ChevronLeft, ChevronRight, Trophy } from 'lucide-react';
|
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
||||||
import { Link, useSearchParams } from 'react-router';
|
import { Link, useSearchParams } from 'react-router';
|
||||||
import {
|
import {
|
||||||
useCommunityLeaderboard,
|
useCommunityLeaderboard,
|
||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
useMatchesPage,
|
useMatchesPage,
|
||||||
} from '../api/hooks';
|
} from '../api/hooks';
|
||||||
import nextMatchArtwork from '../assets/next-match-hero.webp';
|
import nextMatchArtwork from '../assets/next-match-hero.webp';
|
||||||
|
import pixelMedal from '../assets/pixel-medal-first.svg';
|
||||||
import HomeHallOfFame from '../components/HomeHallOfFame';
|
import HomeHallOfFame from '../components/HomeHallOfFame';
|
||||||
import { championIconUrl, profileIconUrl } from '../lib/ddragon';
|
import { championIconUrl, profileIconUrl } from '../lib/ddragon';
|
||||||
import { rankLeaderboardByLane } from '../lib/internal-stats-presentation';
|
import { rankLeaderboardByLane } from '../lib/internal-stats-presentation';
|
||||||
@@ -24,10 +25,7 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
EmptyNote,
|
EmptyNote,
|
||||||
ErrorNote,
|
ErrorNote,
|
||||||
LoadingNote,
|
|
||||||
Panel,
|
|
||||||
PanelHeader,
|
PanelHeader,
|
||||||
Pill,
|
|
||||||
PlainPage,
|
PlainPage,
|
||||||
Skeleton,
|
Skeleton,
|
||||||
pageWidthClass,
|
pageWidthClass,
|
||||||
@@ -45,8 +43,13 @@ const MATCH_ARCHIVE_PAGE_SIZE = 10;
|
|||||||
const HOME_HISTORY_LIMIT = 4;
|
const HOME_HISTORY_LIMIT = 4;
|
||||||
const HOME_RANKING_LIMIT = 5;
|
const HOME_RANKING_LIMIT = 5;
|
||||||
const DEFAULT_MAP_ID = 11;
|
const DEFAULT_MAP_ID = 11;
|
||||||
|
const SCHEDULE_LIST_CLASS = 'divide-y divide-line border-y border-line';
|
||||||
|
const SCHEDULE_ROW_CLASS =
|
||||||
|
'grid grid-cols-[minmax(0,1fr)_auto] gap-x-3 gap-y-2 px-2 py-3.5 md:grid-cols-[7.5rem_minmax(0,1fr)_auto] md:items-center md:gap-4';
|
||||||
const RANKING_COLUMNS_CLASS =
|
const RANKING_COLUMNS_CLASS =
|
||||||
'grid grid-cols-[1.5rem_minmax(0,1fr)_3rem] items-center gap-3 px-3';
|
'grid grid-cols-[1.5rem_minmax(0,1fr)_3rem] items-center gap-3 px-3';
|
||||||
|
const NEXT_MATCH_CONTENT_CLASS =
|
||||||
|
'flex min-h-[16rem] items-center py-8 md:min-h-[clamp(22rem,29vw,30rem)] md:py-12';
|
||||||
/** 순위 카드의 슬라이드 순서. undefined는 종합 순위. */
|
/** 순위 카드의 슬라이드 순서. undefined는 종합 순위. */
|
||||||
const RANKING_SLIDES = [
|
const RANKING_SLIDES = [
|
||||||
undefined,
|
undefined,
|
||||||
@@ -84,7 +87,7 @@ function NextMatch({ match }: { match: MatchDetailResponse }) {
|
|||||||
className="absolute inset-y-0 left-1/2 -z-20 h-full w-full max-w-[112rem] -translate-x-1/2 object-cover object-[75%_center] md:object-center"
|
className="absolute inset-y-0 left-1/2 -z-20 h-full w-full max-w-[112rem] -translate-x-1/2 object-cover object-[75%_center] md:object-center"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
className={`${pageWidthClass()} flex min-h-[16rem] items-center py-8 md:min-h-[clamp(22rem,29vw,30rem)] md:py-12`}
|
className={`${pageWidthClass()} ${NEXT_MATCH_CONTENT_CLASS}`}
|
||||||
>
|
>
|
||||||
<div className="w-full max-w-xl">
|
<div className="w-full max-w-xl">
|
||||||
<p
|
<p
|
||||||
@@ -125,63 +128,161 @@ function NextMatch({ match }: { match: MatchDetailResponse }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function NextMatchSkeleton() {
|
||||||
|
return (
|
||||||
|
<section className="bg-sunken" aria-busy="true" aria-label="다음 내전">
|
||||||
|
<span role="status" className="sr-only">다음 내전을 불러오는 중</span>
|
||||||
|
<div className={`${pageWidthClass()} ${NEXT_MATCH_CONTENT_CLASS}`}>
|
||||||
|
<div className="w-full max-w-xl">
|
||||||
|
<h1 className="text-sm font-semibold text-content-muted md:text-base">다음 내전</h1>
|
||||||
|
<div className="mt-3">
|
||||||
|
<Skeleton width="80%" height="clamp(2.3rem,5.75vw,4.025rem)" radius={2} />
|
||||||
|
</div>
|
||||||
|
<div className="mt-4 md:mt-6">
|
||||||
|
<Skeleton width="min(16rem,70%)" height="1.75rem" index={1} />
|
||||||
|
</div>
|
||||||
|
<div className="mt-3">
|
||||||
|
<Skeleton width="min(12rem,55%)" height="1.5rem" index={2} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function UpcomingMatchesSkeleton({ title, limit }: { title: string; limit: number }) {
|
||||||
|
return (
|
||||||
|
<section aria-busy="true" aria-label={title}>
|
||||||
|
<PanelHeader title={title} variant="section" />
|
||||||
|
<span role="status" className="sr-only">{title}을 불러오는 중</span>
|
||||||
|
<ScheduleRowsSkeleton limit={limit} />
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function UpcomingMatches({
|
function UpcomingMatches({
|
||||||
matches,
|
matches,
|
||||||
title = '이어지는 내전',
|
title = '이어지는 내전',
|
||||||
|
actions,
|
||||||
footer,
|
footer,
|
||||||
}: {
|
}: {
|
||||||
matches: MatchDetailResponse[];
|
matches: MatchDetailResponse[];
|
||||||
title?: string;
|
title?: string;
|
||||||
|
actions?: ReactNode;
|
||||||
footer?: ReactNode;
|
footer?: ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Panel>
|
<section>
|
||||||
<PanelHeader title={title} />
|
<PanelHeader title={title} variant="section" actions={actions} />
|
||||||
<ul className="divide-y divide-line">
|
<ul className={SCHEDULE_LIST_CLASS}>
|
||||||
{matches.map((match) => {
|
{matches.map((match) => (
|
||||||
const schedule = getHomeMatchSchedule(match.scheduledAt);
|
|
||||||
const { capacity, label } = getHomeMatchEnrollment(match);
|
|
||||||
return (
|
|
||||||
<li key={match._id}>
|
<li key={match._id}>
|
||||||
<Link
|
<ScheduleMatchRow match={match} />
|
||||||
to={`/match/${match._id}`}
|
|
||||||
className="group grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 px-4 py-3 transition-colors hover:bg-sunken sm:grid-cols-[8rem_minmax(0,1fr)_auto_1rem] sm:px-5"
|
|
||||||
>
|
|
||||||
<time
|
|
||||||
dateTime={match.scheduledAt}
|
|
||||||
className="tabular col-start-1 text-xs text-content-muted"
|
|
||||||
>
|
|
||||||
{schedule?.compact ?? '일정 미정'}
|
|
||||||
</time>
|
|
||||||
<h3 className="col-start-1 mt-0.5 truncate text-[15px] font-semibold group-hover:underline sm:col-start-2 sm:row-start-1 sm:mt-0">
|
|
||||||
{match.title}
|
|
||||||
</h3>
|
|
||||||
<p className="tabular col-start-1 mt-1 text-[13px] text-content-muted sm:col-start-3 sm:row-start-1 sm:mt-0">
|
|
||||||
{match.status === 'recruiting'
|
|
||||||
? label
|
|
||||||
: getMatchStageLabel(match)}{' '}
|
|
||||||
· {capacity}
|
|
||||||
</p>
|
|
||||||
<ChevronRight
|
|
||||||
className="col-start-2 row-span-3 row-start-1 size-4 text-content-muted sm:col-start-4 sm:row-span-1"
|
|
||||||
aria-hidden="true"
|
|
||||||
/>
|
|
||||||
</Link>
|
|
||||||
</li>
|
</li>
|
||||||
);
|
))}
|
||||||
})}
|
|
||||||
</ul>
|
</ul>
|
||||||
{matches.length === 0 && (
|
{matches.length === 0 && (
|
||||||
<EmptyNote size="sm" title="이 페이지에 표시할 일정이 없습니다." />
|
<EmptyNote size="sm" title="이 페이지에 표시할 일정이 없습니다." />
|
||||||
)}
|
)}
|
||||||
{footer}
|
{footer}
|
||||||
</Panel>
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ScheduleMatchRow({ match }: { match: MatchDetailResponse }) {
|
||||||
|
const { capacity, label } = getHomeMatchEnrollment(match);
|
||||||
|
return (
|
||||||
|
<ScheduleRow
|
||||||
|
href={`/match/${match._id}`}
|
||||||
|
scheduledAt={match.scheduledAt}
|
||||||
|
title={match.title}
|
||||||
|
meta={`참가 ${capacity}`}
|
||||||
|
result={<ScheduleStatus match={match} label={match.status === 'recruiting' ? label : undefined} />}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ScheduleStatus({
|
||||||
|
match,
|
||||||
|
label = getMatchStageLabel(match),
|
||||||
|
}: {
|
||||||
|
match: Pick<MatchSummaryResponse, 'status' | 'eventProgress'>;
|
||||||
|
label?: string;
|
||||||
|
}) {
|
||||||
|
const stage = match.eventProgress?.stage ?? match.status;
|
||||||
|
const statusColor = stage === 'in-progress'
|
||||||
|
? 'text-leaf'
|
||||||
|
: stage === 'auction'
|
||||||
|
? 'text-gold'
|
||||||
|
: 'text-content-muted';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span className={`inline-flex min-h-6 items-center gap-1.5 whitespace-nowrap rounded-full border border-current/25 px-2.5 py-0.5 text-xs font-semibold ${statusColor}`}>
|
||||||
|
{label}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ScheduleRow({
|
||||||
|
href,
|
||||||
|
scheduledAt,
|
||||||
|
title,
|
||||||
|
meta,
|
||||||
|
result,
|
||||||
|
resultBelowOnMobile = false,
|
||||||
|
}: {
|
||||||
|
href: string;
|
||||||
|
scheduledAt: string;
|
||||||
|
title: string;
|
||||||
|
meta: ReactNode;
|
||||||
|
result: ReactNode;
|
||||||
|
resultBelowOnMobile?: boolean;
|
||||||
|
}) {
|
||||||
|
const schedule = getHomeMatchSchedule(scheduledAt);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
to={href}
|
||||||
|
className={`${SCHEDULE_ROW_CLASS} group transition-colors hover:bg-sunken focus-visible:-outline-offset-2`}
|
||||||
|
>
|
||||||
|
<time
|
||||||
|
dateTime={schedule ? scheduledAt : undefined}
|
||||||
|
className="tabular flex flex-wrap items-baseline gap-x-2 md:block"
|
||||||
|
>
|
||||||
|
<span className="text-[15px] font-semibold leading-snug text-content">
|
||||||
|
{schedule ? `${schedule.month}/${schedule.day} (${schedule.weekday})` : '일정 미정'}
|
||||||
|
</span>
|
||||||
|
{schedule && (
|
||||||
|
<span className="text-xs text-content-subtle md:mt-0.5 md:block">
|
||||||
|
{schedule.time}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</time>
|
||||||
|
<div className="col-span-2 col-start-1 row-start-2 min-w-0 md:col-span-1 md:col-start-2 md:row-start-1">
|
||||||
|
<h3 className="text-[15px] font-semibold leading-snug text-content [overflow-wrap:anywhere] group-hover:underline group-hover:underline-offset-2">
|
||||||
|
{title}
|
||||||
|
</h3>
|
||||||
|
<p className="tabular mt-0.5 text-[13px] text-content-subtle">
|
||||||
|
{meta}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className={`flex min-w-0 items-center gap-2 md:col-start-3 md:row-start-1 md:max-w-72 md:justify-self-end ${
|
||||||
|
resultBelowOnMobile
|
||||||
|
? 'col-span-2 col-start-1 row-start-3 md:col-span-1'
|
||||||
|
: 'col-start-2 row-start-1'
|
||||||
|
}`}>
|
||||||
|
<span className="min-w-0 text-[13px]">
|
||||||
|
{result}
|
||||||
|
</span>
|
||||||
|
<ChevronRight className="hidden size-4 shrink-0 text-content-muted md:block" aria-hidden="true" />
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function HistoryResult({ match }: { match: MatchSummaryResponse }) {
|
function HistoryResult({ match }: { match: MatchSummaryResponse }) {
|
||||||
const result = match.historyResult;
|
const result = match.historyResult;
|
||||||
const teamLabelClass = 'min-w-0 break-words text-content-muted md:truncate';
|
const teamLabelClass = 'min-w-0 text-content-muted [overflow-wrap:anywhere]';
|
||||||
if (match.status === 'finished' && result) {
|
if (match.status === 'finished' && result) {
|
||||||
switch (result.type) {
|
switch (result.type) {
|
||||||
case 'score': {
|
case 'score': {
|
||||||
@@ -240,14 +341,7 @@ function HistoryResult({ match }: { match: MatchSummaryResponse }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (match.status === 'team-built' || match.status === 'in-progress') {
|
if (match.status === 'team-built' || match.status === 'in-progress') {
|
||||||
return (
|
return <ScheduleStatus match={match} />;
|
||||||
<Pill
|
|
||||||
tone={match.status === 'in-progress' ? 'live' : 'neutral'}
|
|
||||||
dot={match.status === 'in-progress'}
|
|
||||||
>
|
|
||||||
{getMatchStageLabel(match)}
|
|
||||||
</Pill>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<span className="text-content-muted">
|
<span className="text-content-muted">
|
||||||
@@ -256,65 +350,41 @@ function HistoryResult({ match }: { match: MatchSummaryResponse }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function HistoryTableColumns() {
|
function ScheduleRowsSkeleton({
|
||||||
|
limit,
|
||||||
|
resultBelowOnMobile = false,
|
||||||
|
}: {
|
||||||
|
limit: number;
|
||||||
|
resultBelowOnMobile?: boolean;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<ul className={SCHEDULE_LIST_CLASS} aria-hidden="true">
|
||||||
<colgroup>
|
{Array.from({ length: limit }, (_, index) => (
|
||||||
<col className="w-36" />
|
<li key={index} className={SCHEDULE_ROW_CLASS}>
|
||||||
<col />
|
<div className="flex items-center gap-2 md:block md:space-y-0.5">
|
||||||
<col className="w-44" />
|
<Skeleton width={76} height={21} index={index} />
|
||||||
<col className="w-16" />
|
<Skeleton width={32} height={16} index={index} />
|
||||||
</colgroup>
|
</div>
|
||||||
<thead>
|
<div className="col-span-2 col-start-1 row-start-2 min-w-0 space-y-0.5 md:col-span-1 md:col-start-2 md:row-start-1">
|
||||||
<tr>
|
<Skeleton width="60%" height={21} index={index} />
|
||||||
<th scope="col">일정</th>
|
<Skeleton width={64} height={20} index={index} />
|
||||||
<th scope="col">대회</th>
|
</div>
|
||||||
<th scope="col">상태·결과</th>
|
<div className={`flex items-center gap-2 md:col-start-3 md:row-start-1 md:justify-self-end ${
|
||||||
<th scope="col" className="!text-right">
|
resultBelowOnMobile
|
||||||
참가
|
? 'col-span-2 col-start-1 row-start-3 md:col-span-1'
|
||||||
</th>
|
: 'col-start-2 row-start-1'
|
||||||
</tr>
|
}`}>
|
||||||
</thead>
|
<Skeleton
|
||||||
</>
|
width={resultBelowOnMobile ? 96 : 64}
|
||||||
);
|
height={resultBelowOnMobile ? 20 : 24}
|
||||||
}
|
radius={resultBelowOnMobile ? 3 : 'rounded'}
|
||||||
|
index={index}
|
||||||
function HistoryRecordsSkeleton({ limit }: { limit: number }) {
|
/>
|
||||||
const rows = Array.from({ length: limit });
|
<span className="hidden size-4 md:block" />
|
||||||
return (
|
</div>
|
||||||
<>
|
</li>
|
||||||
<div className="hidden md:block">
|
|
||||||
<table className="lts-table table-fixed" aria-hidden="true">
|
|
||||||
<HistoryTableColumns />
|
|
||||||
<tbody>
|
|
||||||
{rows.map((_, index) => (
|
|
||||||
<tr key={index}>
|
|
||||||
<td>
|
|
||||||
<Skeleton width={96} height={14} index={index} />
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<Skeleton width="60%" height={14} index={index} />
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<Skeleton width={56} height={14} index={index} />
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<Skeleton width={28} height={14} className="ml-auto" />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</ul>
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div className="divide-y divide-line md:hidden" aria-hidden="true">
|
|
||||||
{rows.map((_, index) => (
|
|
||||||
<div key={index} className="space-y-2 px-4 py-3">
|
|
||||||
<Skeleton width={110} height={12} index={index} />
|
|
||||||
<Skeleton width="70%" height={16} index={index} />
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,67 +405,26 @@ function HistoryRecords({
|
|||||||
match,
|
match,
|
||||||
title: getHistoryMatchTitle(match.title, schedule),
|
title: getHistoryMatchTitle(match.title, schedule),
|
||||||
href: `/match/${match._id}`,
|
href: `/match/${match._id}`,
|
||||||
schedule: schedule?.compact ?? '일정 미정',
|
|
||||||
map:
|
map:
|
||||||
match.mapId === DEFAULT_MAP_ID ? undefined : mapIdToLabel(match.mapId),
|
match.mapId === DEFAULT_MAP_ID ? undefined : mapIdToLabel(match.mapId),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<ul className={SCHEDULE_LIST_CLASS}>
|
||||||
<div className="hidden md:block">
|
{rows.map(({ match, title, href, map }) => (
|
||||||
<table className="lts-table table-fixed">
|
|
||||||
<HistoryTableColumns />
|
|
||||||
<tbody>
|
|
||||||
{rows.map(({ match, title, href, schedule, map }) => (
|
|
||||||
<tr key={match._id} className="transition-colors hover:bg-sunken">
|
|
||||||
<td className="tabular whitespace-nowrap text-[13px] text-content-muted">
|
|
||||||
<time dateTime={match.scheduledAt}>{schedule}</time>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<Link
|
|
||||||
to={href}
|
|
||||||
className="block truncate font-semibold text-content hover:underline"
|
|
||||||
title={match.title}
|
|
||||||
>
|
|
||||||
{title}
|
|
||||||
</Link>
|
|
||||||
{map && <p className="text-xs text-content-muted">{map}</p>}
|
|
||||||
</td>
|
|
||||||
<td className="text-[13px]">
|
|
||||||
<HistoryResult match={match} />
|
|
||||||
</td>
|
|
||||||
<td className="tabular whitespace-nowrap text-right text-[13px] text-content-muted">
|
|
||||||
{match.participants.length}명
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<ul className="divide-y divide-line md:hidden">
|
|
||||||
{rows.map(({ match, title, href, schedule, map }) => (
|
|
||||||
<li key={match._id}>
|
<li key={match._id}>
|
||||||
<Link
|
<ScheduleRow
|
||||||
to={href}
|
href={href}
|
||||||
className="group block px-4 py-3 transition-colors hover:bg-sunken"
|
scheduledAt={match.scheduledAt}
|
||||||
>
|
title={title}
|
||||||
<div className="tabular flex flex-wrap justify-between gap-x-3 text-xs text-content-muted">
|
meta={<>참가 {match.participants.length}명{map && <> · {map}</>}</>}
|
||||||
<time dateTime={match.scheduledAt}>{schedule}</time>
|
result={<HistoryResult match={match} />}
|
||||||
<span>{match.participants.length}명</span>
|
resultBelowOnMobile
|
||||||
</div>
|
/>
|
||||||
<p className="mt-0.5 break-words text-[15px] font-semibold leading-snug text-content group-hover:underline">
|
|
||||||
{title}
|
|
||||||
</p>
|
|
||||||
<div className="mt-1 flex flex-wrap items-baseline gap-x-2 gap-y-1 text-[13px]">
|
|
||||||
<HistoryResult match={match} />
|
|
||||||
{map && <span className="text-content-muted">· {map}</span>}
|
|
||||||
</div>
|
|
||||||
</Link>
|
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,7 +568,7 @@ function WinnerTeam({ team, label }: { team: WinnerTeamSummary; label: string })
|
|||||||
return (
|
return (
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<p className="flex min-w-0 items-center gap-1.5">
|
<p className="flex min-w-0 items-center gap-1.5">
|
||||||
<Trophy className="size-4 shrink-0 text-gold" aria-hidden="true" />
|
<img src={pixelMedal} alt="" className="size-4 shrink-0 [image-rendering:pixelated]" />
|
||||||
<span className="shrink-0 text-xs font-semibold text-gold">{label}</span>
|
<span className="shrink-0 text-xs font-semibold text-gold">{label}</span>
|
||||||
<strong className="truncate text-[15px] font-semibold text-content group-hover:underline">
|
<strong className="truncate text-[15px] font-semibold text-content group-hover:underline">
|
||||||
{team.name}
|
{team.name}
|
||||||
@@ -574,13 +603,27 @@ function RecentMatchResultsSkeleton({ limit }: { limit: number }) {
|
|||||||
<div className="divide-y divide-line border-y border-line" aria-hidden="true">
|
<div className="divide-y divide-line border-y border-line" aria-hidden="true">
|
||||||
{Array.from({ length: limit }, (_, index) => (
|
{Array.from({ length: limit }, (_, index) => (
|
||||||
<div key={index} className={RECENT_RESULT_ROW_CLASS}>
|
<div key={index} className={RECENT_RESULT_ROW_CLASS}>
|
||||||
<div className="space-y-1">
|
<div className="flex items-center gap-2 md:block md:space-y-0.5">
|
||||||
<Skeleton width={80} height={16} index={index} />
|
<Skeleton width={80} height={21} index={index} />
|
||||||
<Skeleton width={64} height={12} index={index} />
|
<Skeleton width={48} height={16} index={index} />
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-2">
|
<div className="min-w-0">
|
||||||
<Skeleton width={140} height={16} index={index} />
|
<div className="flex items-center gap-1.5">
|
||||||
<Skeleton width={200} height={28} index={index} />
|
<Skeleton width={16} height={16} index={index} />
|
||||||
|
<Skeleton width="min(10rem,70%)" height={23} index={index} />
|
||||||
|
</div>
|
||||||
|
<div className="mt-1.5 flex min-w-0 items-center gap-2.5">
|
||||||
|
<div className="flex shrink-0 -space-x-1.5">
|
||||||
|
{Array.from({ length: 5 }, (_, memberIndex) => (
|
||||||
|
<Skeleton key={memberIndex} width={28} height={28} radius="rounded" index={index} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<Skeleton width="35%" height={16} index={index} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2 md:justify-self-end">
|
||||||
|
<Skeleton width={40} height={23} index={index} />
|
||||||
|
<span className="hidden size-4 md:block" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@@ -594,6 +637,26 @@ const RANK_BADGE_CLASS = [
|
|||||||
'bg-gold-tint text-gold',
|
'bg-gold-tint text-gold',
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
function RankingSkeleton() {
|
||||||
|
return (
|
||||||
|
<div className="min-h-[17.5rem]" aria-hidden="true">
|
||||||
|
{Array.from({ length: HOME_RANKING_LIMIT }, (_, index) => (
|
||||||
|
<div key={index} className={`${RANKING_COLUMNS_CLASS} py-2.5`}>
|
||||||
|
<Skeleton width={24} height={24} radius="rounded" index={index} />
|
||||||
|
<div className="flex min-w-0 items-center gap-2">
|
||||||
|
<Skeleton width={36} height={36} radius="rounded" index={index} className="shrink-0" />
|
||||||
|
<div className="min-w-0 flex-1 space-y-1">
|
||||||
|
<Skeleton width="80%" height={16} index={index} />
|
||||||
|
<Skeleton width="95%" height={12} index={index} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Skeleton width={40} height={20} index={index} className="justify-self-end" />
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/** 현재 시즌 순위표의 앞부분. 전적 화면과 같은 집계를 그대로 보여준다. */
|
/** 현재 시즌 순위표의 앞부분. 전적 화면과 같은 집계를 그대로 보여준다. */
|
||||||
function RankingPreview({ statsPath }: { statsPath: string }) {
|
function RankingPreview({ statsPath }: { statsPath: string }) {
|
||||||
const leaderboardQuery = useCommunityLeaderboard({ seasonId: 'current' });
|
const leaderboardQuery = useCommunityLeaderboard({ seasonId: 'current' });
|
||||||
@@ -622,16 +685,16 @@ function RankingPreview({ statsPath }: { statsPath: string }) {
|
|||||||
|
|
||||||
// 읽거나 누르려는 동안에는 멈추고, 직접 넘기면 그 슬라이드부터 다시 센다.
|
// 읽거나 누르려는 동안에는 멈추고, 직접 넘기면 그 슬라이드부터 다시 센다.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (paused || window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
if (leaderboardQuery.isPending || paused || window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const timer = window.setTimeout(() => move(1), RANKING_SLIDE_INTERVAL_MS);
|
const timer = window.setTimeout(() => move(1), RANKING_SLIDE_INTERVAL_MS);
|
||||||
return () => window.clearTimeout(timer);
|
return () => window.clearTimeout(timer);
|
||||||
}, [paused, slide]);
|
}, [leaderboardQuery.isPending, paused, slide]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<aside
|
<aside
|
||||||
aria-busy={leaderboardQuery.isLoading}
|
aria-busy={leaderboardQuery.isPending}
|
||||||
onMouseEnter={() => setPaused(true)}
|
onMouseEnter={() => setPaused(true)}
|
||||||
onMouseLeave={() => setPaused(false)}
|
onMouseLeave={() => setPaused(false)}
|
||||||
onFocus={() => setPaused(true)}
|
onFocus={() => setPaused(true)}
|
||||||
@@ -639,7 +702,7 @@ function RankingPreview({ statsPath }: { statsPath: string }) {
|
|||||||
onTouchStart={(event) => setTouchStartX(event.touches[0]?.clientX)}
|
onTouchStart={(event) => setTouchStartX(event.touches[0]?.clientX)}
|
||||||
onTouchEnd={(event) => {
|
onTouchEnd={(event) => {
|
||||||
const endX = event.changedTouches[0]?.clientX;
|
const endX = event.changedTouches[0]?.clientX;
|
||||||
if (touchStartX === undefined || endX === undefined) return;
|
if (leaderboardQuery.isPending || touchStartX === undefined || endX === undefined) return;
|
||||||
const distance = endX - touchStartX;
|
const distance = endX - touchStartX;
|
||||||
if (Math.abs(distance) > 48) move(distance < 0 ? 1 : -1);
|
if (Math.abs(distance) > 48) move(distance < 0 ? 1 : -1);
|
||||||
setTouchStartX(undefined);
|
setTouchStartX(undefined);
|
||||||
@@ -651,20 +714,19 @@ function RankingPreview({ statsPath }: { statsPath: string }) {
|
|||||||
actions={
|
actions={
|
||||||
<Link
|
<Link
|
||||||
to={`${statsPath}?view=ranking`}
|
to={`${statsPath}?view=ranking`}
|
||||||
className="inline-flex items-center gap-0.5 text-[13px] font-semibold text-content-muted hover:text-content hover:underline"
|
className="inline-flex items-center gap-0.5 whitespace-nowrap text-[13px] font-semibold text-content-muted hover:text-content hover:underline"
|
||||||
>
|
>
|
||||||
전체 보기
|
선수 전적·순위 보기
|
||||||
<ChevronRight className="size-4" aria-hidden="true" />
|
<ChevronRight className="size-4" aria-hidden="true" />
|
||||||
</Link>
|
</Link>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<div className="overflow-hidden rounded-2xl bg-sunken p-2">
|
<div className="overflow-hidden rounded-2xl bg-sunken p-2">
|
||||||
{leaderboardQuery.isLoading ? (
|
{leaderboardQuery.isPending ? (
|
||||||
<div className="space-y-3 p-3" aria-hidden="true">
|
<>
|
||||||
{Array.from({ length: HOME_RANKING_LIMIT }, (_, index) => (
|
<span role="status" className="sr-only">시즌 순위를 불러오는 중</span>
|
||||||
<Skeleton key={index} width="100%" height={36} index={index} />
|
<RankingSkeleton />
|
||||||
))}
|
</>
|
||||||
</div>
|
|
||||||
) : leaderboardQuery.isError ? (
|
) : leaderboardQuery.isError ? (
|
||||||
<p className="p-3 text-sm text-content-muted">
|
<p className="p-3 text-sm text-content-muted">
|
||||||
순위를 불러오지 못했습니다.
|
순위를 불러오지 못했습니다.
|
||||||
@@ -744,7 +806,8 @@ function RankingPreview({ statsPath }: { statsPath: string }) {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="이전 순위"
|
aria-label="이전 순위"
|
||||||
className="grid size-8 place-items-center rounded-full text-content-muted transition-colors hover:bg-card hover:text-content"
|
disabled={leaderboardQuery.isPending}
|
||||||
|
className="grid size-8 place-items-center rounded-full text-content-muted transition-colors hover:bg-card hover:text-content disabled:pointer-events-none disabled:opacity-40"
|
||||||
onClick={() => move(-1)}
|
onClick={() => move(-1)}
|
||||||
>
|
>
|
||||||
<ChevronLeft className="size-4" aria-hidden="true" />
|
<ChevronLeft className="size-4" aria-hidden="true" />
|
||||||
@@ -760,7 +823,8 @@ function RankingPreview({ statsPath }: { statsPath: string }) {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="다음 순위"
|
aria-label="다음 순위"
|
||||||
className="grid size-8 place-items-center rounded-full text-content-muted transition-colors hover:bg-card hover:text-content"
|
disabled={leaderboardQuery.isPending}
|
||||||
|
className="grid size-8 place-items-center rounded-full text-content-muted transition-colors hover:bg-card hover:text-content disabled:pointer-events-none disabled:opacity-40"
|
||||||
onClick={() => move(1)}
|
onClick={() => move(1)}
|
||||||
>
|
>
|
||||||
<ChevronRight className="size-4" aria-hidden="true" />
|
<ChevronRight className="size-4" aria-hidden="true" />
|
||||||
@@ -772,6 +836,7 @@ function RankingPreview({ statsPath }: { statsPath: string }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface MatchPaginationProps {
|
interface MatchPaginationProps {
|
||||||
|
label: string;
|
||||||
page: number;
|
page: number;
|
||||||
pageCount: number;
|
pageCount: number;
|
||||||
total: number;
|
total: number;
|
||||||
@@ -781,6 +846,7 @@ interface MatchPaginationProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function MatchPagination({
|
function MatchPagination({
|
||||||
|
label,
|
||||||
page,
|
page,
|
||||||
pageCount,
|
pageCount,
|
||||||
total,
|
total,
|
||||||
@@ -789,7 +855,7 @@ function MatchPagination({
|
|||||||
onNext,
|
onNext,
|
||||||
}: MatchPaginationProps) {
|
}: MatchPaginationProps) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-wrap items-center justify-between gap-x-3 gap-y-1 border-t border-line px-4 py-2.5 sm:px-5">
|
<nav aria-label={label} className="flex flex-wrap items-center justify-between gap-x-3 gap-y-1 px-2 py-2.5">
|
||||||
<span className="tabular text-xs text-content-muted">
|
<span className="tabular text-xs text-content-muted">
|
||||||
총 {total.toLocaleString('ko-KR')}개 · {page} / {pageCount}
|
총 {total.toLocaleString('ko-KR')}개 · {page} / {pageCount}
|
||||||
</span>
|
</span>
|
||||||
@@ -811,7 +877,7 @@ function MatchPagination({
|
|||||||
onClick={onNext}
|
onClick={onNext}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</nav>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -876,6 +942,7 @@ export default function HomePage({ eventType }: { eventType?: MatchEventType })
|
|||||||
const allUpcomingMatches = upcomingMatchesQuery.data ?? [];
|
const allUpcomingMatches = upcomingMatchesQuery.data ?? [];
|
||||||
const [nextMatch, ...upcomingMatches] = allUpcomingMatches;
|
const [nextMatch, ...upcomingMatches] = allUpcomingMatches;
|
||||||
const bannerMatch = showArchive ? undefined : nextMatch;
|
const bannerMatch = showArchive ? undefined : nextMatch;
|
||||||
|
const isBannerLoading = !showArchive && upcomingMatchesQuery.isPending;
|
||||||
const visibleUpcomingMatches = showArchive ? allUpcomingMatches : upcomingMatches;
|
const visibleUpcomingMatches = showArchive ? allUpcomingMatches : upcomingMatches;
|
||||||
const historyTotal = historyMatchesQuery.data?.total ?? 0;
|
const historyTotal = historyMatchesQuery.data?.total ?? 0;
|
||||||
const activeTotal = activeMatchesQuery.data?.total ?? 0;
|
const activeTotal = activeMatchesQuery.data?.total ?? 0;
|
||||||
@@ -888,15 +955,17 @@ export default function HomePage({ eventType }: { eventType?: MatchEventType })
|
|||||||
Math.ceil(historyTotal / (historyMatchesQuery.data?.limit ?? historyLimit)),
|
Math.ceil(historyTotal / (historyMatchesQuery.data?.limit ?? historyLimit)),
|
||||||
);
|
);
|
||||||
const isHistoryPageLoading =
|
const isHistoryPageLoading =
|
||||||
historyMatchesQuery.isLoading ||
|
historyMatchesQuery.isPending ||
|
||||||
(historyMatchesQuery.isFetching && historyMatchesQuery.isPlaceholderData);
|
(historyMatchesQuery.isFetching && historyMatchesQuery.isPlaceholderData);
|
||||||
|
const isActivePageLoading =
|
||||||
|
activeMatchesQuery.isPending ||
|
||||||
|
(activeMatchesQuery.isFetching && activeMatchesQuery.isPlaceholderData);
|
||||||
const hasHistoryError =
|
const hasHistoryError =
|
||||||
Boolean(historyMatchesQuery.error) && !historyMatchesQuery.data;
|
Boolean(historyMatchesQuery.error) && !historyMatchesQuery.data;
|
||||||
const statsPath = `/communities/${DEFAULT_COMMUNITY_ID}/internal-stats`;
|
const statsPath = `/communities/${DEFAULT_COMMUNITY_ID}/internal-stats`;
|
||||||
const HistorySection = showArchive ? Panel : 'section';
|
|
||||||
const UpcomingStatusHeading = showArchive ? 'p' : 'h1';
|
const UpcomingStatusHeading = showArchive ? 'p' : 'h1';
|
||||||
const contentSpacing = showArchive ? 'space-y-5 pb-16' : 'space-y-8 pb-10 md:pb-16';
|
const contentSpacing = 'space-y-8 pb-10 md:pb-16';
|
||||||
const contentTopPadding = bannerMatch ? 'pt-10 md:pt-16' : 'pt-5 sm:pt-6';
|
const contentTopPadding = bannerMatch || isBannerLoading ? 'pt-10 md:pt-16' : 'pt-5 sm:pt-6';
|
||||||
|
|
||||||
const content = (
|
const content = (
|
||||||
<div className={`${pageWidthClass()} ${contentSpacing} ${contentTopPadding}`}>
|
<div className={`${pageWidthClass()} ${contentSpacing} ${contentTopPadding}`}>
|
||||||
@@ -908,18 +977,28 @@ export default function HomePage({ eventType }: { eventType?: MatchEventType })
|
|||||||
{activeMatchesQuery.isError && !activeMatchesQuery.data ? (
|
{activeMatchesQuery.isError && !activeMatchesQuery.data ? (
|
||||||
<ErrorNote title="진행 중인 일정을 불러오지 못했습니다"
|
<ErrorNote title="진행 중인 일정을 불러오지 못했습니다"
|
||||||
action={<Button size="sm" label="다시 시도" onClick={() => void activeMatchesQuery.refetch()} />} />
|
action={<Button size="sm" label="다시 시도" onClick={() => void activeMatchesQuery.refetch()} />} />
|
||||||
) : activeMatchesQuery.isPlaceholderData ? (
|
) : isActivePageLoading ? (
|
||||||
<Panel aria-busy="true">
|
<UpcomingMatchesSkeleton
|
||||||
<PanelHeader title="진행 중인 일정" />
|
title="진행 중인 일정"
|
||||||
<LoadingNote label="일정을 불러오는 중" />
|
limit={activeMatchesQuery.data?.matches.length || activeLimit}
|
||||||
</Panel>
|
/>
|
||||||
) : activeMatchesQuery.data &&
|
) : activeMatchesQuery.data &&
|
||||||
(activeMatchesQuery.data.matches.length > 0 || activePage > 1) ? (
|
(activeMatchesQuery.data.matches.length > 0 || activePage > 1) ? (
|
||||||
<UpcomingMatches
|
<UpcomingMatches
|
||||||
matches={activeMatchesQuery.data.matches}
|
matches={activeMatchesQuery.data.matches}
|
||||||
title="진행 중인 일정"
|
title="진행 중인 일정"
|
||||||
|
actions={!showArchive && (
|
||||||
|
<Link
|
||||||
|
to="/inhouse"
|
||||||
|
className="inline-flex min-h-6 items-center gap-0.5 text-[13px] font-semibold text-content-muted hover:text-content hover:underline"
|
||||||
|
>
|
||||||
|
전체 일정
|
||||||
|
<ChevronRight className="size-4" aria-hidden="true" />
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
footer={showArchive && (activePageCount > 1 || activePage > 1) && (
|
footer={showArchive && (activePageCount > 1 || activePage > 1) && (
|
||||||
<MatchPagination
|
<MatchPagination
|
||||||
|
label="진행 중인 일정 페이지"
|
||||||
page={activePage}
|
page={activePage}
|
||||||
pageCount={activePageCount}
|
pageCount={activePageCount}
|
||||||
total={activeTotal}
|
total={activeTotal}
|
||||||
@@ -930,10 +1009,11 @@ export default function HomePage({ eventType }: { eventType?: MatchEventType })
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
{upcomingMatchesQuery.isLoading ? (
|
{upcomingMatchesQuery.isPending ? (
|
||||||
<UpcomingStatusHeading className="text-sm text-content-muted" aria-busy="true">
|
<UpcomingMatchesSkeleton
|
||||||
{eventLabel} 일정을 불러오는 중
|
title={showArchive ? '다가오는 일정' : '이어지는 내전'}
|
||||||
</UpcomingStatusHeading>
|
limit={showArchive ? UPCOMING_MATCH_LIST_LIMIT : UPCOMING_MATCH_LIST_LIMIT - 1}
|
||||||
|
/>
|
||||||
) : upcomingMatchesQuery.isError && !upcomingMatchesQuery.data ? (
|
) : upcomingMatchesQuery.isError && !upcomingMatchesQuery.data ? (
|
||||||
<div className="flex flex-wrap items-center gap-3">
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
<UpcomingStatusHeading className="text-sm text-content-muted">
|
<UpcomingStatusHeading className="text-sm text-content-muted">
|
||||||
@@ -967,10 +1047,10 @@ export default function HomePage({ eventType }: { eventType?: MatchEventType })
|
|||||||
: 'grid items-start gap-8 lg:grid-cols-[minmax(0,1fr)_20rem]'
|
: 'grid items-start gap-8 lg:grid-cols-[minmax(0,1fr)_20rem]'
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<HistorySection aria-busy={isHistoryPageLoading} aria-live="polite">
|
<section aria-busy={isHistoryPageLoading} aria-live="polite">
|
||||||
<PanelHeader
|
<PanelHeader
|
||||||
title={showArchive ? '종료된 일정과 결과' : '최근 내전 결과'}
|
title={showArchive ? '종료된 일정과 결과' : '최근 내전 결과'}
|
||||||
variant={showArchive ? 'panel' : 'section'}
|
variant="section"
|
||||||
actions={
|
actions={
|
||||||
<Link
|
<Link
|
||||||
to={showArchive ? statsPath : '/inhouse'}
|
to={showArchive ? statsPath : '/inhouse'}
|
||||||
@@ -982,11 +1062,14 @@ export default function HomePage({ eventType }: { eventType?: MatchEventType })
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{isHistoryPageLoading ? (
|
{isHistoryPageLoading ? (
|
||||||
showArchive ? (
|
<>
|
||||||
<HistoryRecordsSkeleton limit={historyLimit} />
|
<span role="status" className="sr-only">{showArchive ? '종료된 일정과 결과' : '최근 내전 결과'}를 불러오는 중</span>
|
||||||
|
{showArchive ? (
|
||||||
|
<ScheduleRowsSkeleton limit={historyLimit} resultBelowOnMobile />
|
||||||
) : (
|
) : (
|
||||||
<RecentMatchResultsSkeleton limit={historyLimit} />
|
<RecentMatchResultsSkeleton limit={historyLimit} />
|
||||||
)
|
)}
|
||||||
|
</>
|
||||||
) : hasHistoryError ? (
|
) : hasHistoryError ? (
|
||||||
<div className="p-4">
|
<div className="p-4">
|
||||||
<ErrorNote
|
<ErrorNote
|
||||||
@@ -1011,6 +1094,7 @@ export default function HomePage({ eventType }: { eventType?: MatchEventType })
|
|||||||
)}
|
)}
|
||||||
{showArchive && !hasHistoryError && (historyTotal > 0 || historyPage > 1) && (
|
{showArchive && !hasHistoryError && (historyTotal > 0 || historyPage > 1) && (
|
||||||
<MatchPagination
|
<MatchPagination
|
||||||
|
label="종료된 일정 페이지"
|
||||||
page={historyPage}
|
page={historyPage}
|
||||||
pageCount={historyPageCount}
|
pageCount={historyPageCount}
|
||||||
total={historyTotal}
|
total={historyTotal}
|
||||||
@@ -1019,15 +1103,15 @@ export default function HomePage({ eventType }: { eventType?: MatchEventType })
|
|||||||
onNext={() => setPage('page', historyPage + 1)}
|
onNext={() => setPage('page', historyPage + 1)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</HistorySection>
|
</section>
|
||||||
{!showArchive && <RankingPreview statsPath={statsPath} />}
|
{!showArchive && <RankingPreview statsPath={statsPath} />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main>
|
<main className="[--color-skeleton:var(--color-text-disabled)]">
|
||||||
{bannerMatch && <NextMatch match={bannerMatch} />}
|
{isBannerLoading ? <NextMatchSkeleton /> : bannerMatch && <NextMatch match={bannerMatch} />}
|
||||||
{content}
|
{content}
|
||||||
{!showArchive && (
|
{!showArchive && (
|
||||||
<HomeHallOfFame introReady={!upcomingMatchesQuery.isPending} />
|
<HomeHallOfFame introReady={!upcomingMatchesQuery.isPending} />
|
||||||
|
|||||||
@@ -1,380 +1,118 @@
|
|||||||
import { Link, useLocation, useParams } from "react-router";
|
import { ArrowRight } from "lucide-react";
|
||||||
import { useDdragonManifest, useInternalMatchDetail } from "../api/hooks";
|
import {
|
||||||
import type { ApiInternalMatchDetailResponse, TeamSide } from "../api/types";
|
useLocation,
|
||||||
|
useNavigate,
|
||||||
|
useParams,
|
||||||
|
useSearchParams,
|
||||||
|
} from "react-router";
|
||||||
|
import { useCommunityStatsSeasons, useInternalMatchDetail } from "../api/hooks";
|
||||||
import { DEFAULT_COMMUNITY_ID } from "../config";
|
import { DEFAULT_COMMUNITY_ID } from "../config";
|
||||||
import { ApiError } from "../lib/api";
|
|
||||||
import {
|
|
||||||
championDisplayName,
|
|
||||||
championIconUrl,
|
|
||||||
} from "../lib/ddragon";
|
|
||||||
import {
|
|
||||||
sideShortLabel,
|
|
||||||
teamIndexLabel,
|
|
||||||
} from "../lib/league";
|
|
||||||
import { internalMatchGamePath } from "../lib/internal-match-routes";
|
import { internalMatchGamePath } from "../lib/internal-match-routes";
|
||||||
import { groupRecordedSets } from "../lib/internal-match-series";
|
import { Btn } from "../ui";
|
||||||
import { riotMatchIdForDisplay } from "../lib/internal-game-evidence";
|
|
||||||
import { formatOfficialMatchResult } from "../lib/internal-stats-presentation";
|
|
||||||
import { LANE_LABELS } from "../lib/riot-history";
|
|
||||||
import { ItemIcon } from "../components/ItemTooltip";
|
|
||||||
import { BasicGameScoreboard } from "../components/BasicGameScoreboard";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Btn,
|
StatsEventOverview,
|
||||||
EmptyNote,
|
StatsSeries,
|
||||||
ErrorNote,
|
} from "../components/internal-stats/StatsEvent";
|
||||||
LoadingNote,
|
import {
|
||||||
MetaDot,
|
StatsBack,
|
||||||
PageBody,
|
StatsFeedback,
|
||||||
PageHero,
|
StatsLink,
|
||||||
Panel,
|
StatsSeasonControls,
|
||||||
PlainPage,
|
} from "../components/internal-stats/StatsShared";
|
||||||
} from "../ui";
|
import {
|
||||||
|
statsRoot,
|
||||||
function formatDateTime(value: string | number) {
|
statsTarget,
|
||||||
return new Intl.DateTimeFormat("ko-KR", {
|
useStatsBack,
|
||||||
month: "long",
|
useStatsRestoration,
|
||||||
day: "numeric",
|
} from "../components/internal-stats/stats-navigation";
|
||||||
hour: "2-digit",
|
|
||||||
minute: "2-digit",
|
|
||||||
}).format(new Date(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatDuration(seconds: number) {
|
|
||||||
const minutes = Math.floor(seconds / 60);
|
|
||||||
const rest = seconds % 60;
|
|
||||||
return `${minutes}:${String(rest).padStart(2, "0")}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function sideLabel(side: TeamSide) {
|
|
||||||
return sideShortLabel(side);
|
|
||||||
}
|
|
||||||
|
|
||||||
function sideClass(side: TeamSide) {
|
|
||||||
return side === "blue"
|
|
||||||
? "text-win border-win-line"
|
|
||||||
: "text-loss border-loss-line";
|
|
||||||
}
|
|
||||||
|
|
||||||
function ChampionCell({
|
|
||||||
championId,
|
|
||||||
manifest,
|
|
||||||
}: {
|
|
||||||
championId: number;
|
|
||||||
manifest: ReturnType<typeof useDdragonManifest>["data"];
|
|
||||||
}) {
|
|
||||||
const icon = championIconUrl(manifest, championId);
|
|
||||||
const name = championDisplayName(manifest, championId) ?? String(championId);
|
|
||||||
return (
|
|
||||||
<div className="flex items-center gap-2 min-w-0">
|
|
||||||
<span className="w-8 h-8 bg-base-content/10 overflow-hidden shrink-0">
|
|
||||||
{icon ? (
|
|
||||||
<img src={icon} alt="" className="w-full h-full object-cover" />
|
|
||||||
) : null}
|
|
||||||
</span>
|
|
||||||
<span className="font-bold text-sm truncate">{name}</span>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function ItemStrip({
|
|
||||||
items,
|
|
||||||
trinket,
|
|
||||||
manifest,
|
|
||||||
}: {
|
|
||||||
items: number[];
|
|
||||||
trinket: number;
|
|
||||||
manifest: ReturnType<typeof useDdragonManifest>["data"];
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<div className="flex flex-wrap gap-1">
|
|
||||||
{[...items, trinket].map((itemId, index) => (
|
|
||||||
<ItemIcon
|
|
||||||
key={`${itemId}-${index}`}
|
|
||||||
itemId={itemId}
|
|
||||||
manifest={manifest}
|
|
||||||
trinket={index === items.length}
|
|
||||||
className="h-5 w-5"
|
|
||||||
imageClassName=""
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function GamePanel({
|
|
||||||
communityId,
|
|
||||||
matchId,
|
|
||||||
game,
|
|
||||||
teams,
|
|
||||||
ordinal,
|
|
||||||
riotMatchId,
|
|
||||||
manifest,
|
|
||||||
}: {
|
|
||||||
communityId: string;
|
|
||||||
matchId: string;
|
|
||||||
game: ApiInternalMatchDetailResponse["games"][number];
|
|
||||||
teams: ApiInternalMatchDetailResponse["match"]["teams"];
|
|
||||||
ordinal?: number;
|
|
||||||
riotMatchId: string | null;
|
|
||||||
manifest: ReturnType<typeof useDdragonManifest>["data"];
|
|
||||||
}) {
|
|
||||||
const location = useLocation();
|
|
||||||
const historyBackTo = `${location.pathname}${location.search}${location.hash}`;
|
|
||||||
const hasAnalysis = !game.analysisAvailability || game.analysisAvailability === "available";
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="lts-panel overflow-hidden">
|
|
||||||
<div className="flex flex-wrap items-center justify-between gap-3 border-b border-line px-4 py-3 sm:px-5">
|
|
||||||
<div>
|
|
||||||
<h3 className="text-sm font-black">
|
|
||||||
{ordinal === undefined ? `전체 ${game.gameNumber}세트` : `${ordinal}세트`}
|
|
||||||
{ordinal !== undefined && ordinal !== game.gameNumber && (
|
|
||||||
<span className="ml-2 text-xs font-medium text-content-muted">전체 {game.gameNumber}</span>
|
|
||||||
)}
|
|
||||||
</h3>
|
|
||||||
<p className="mt-1 text-xs text-base-content/35">
|
|
||||||
{formatDateTime(game.gameCreation)} ·{" "}
|
|
||||||
{formatDuration(game.gameDuration)}
|
|
||||||
{riotMatchId && (
|
|
||||||
<> · <span className="font-mono">{riotMatchId}</span></>
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div className="flex gap-2">
|
|
||||||
<Link
|
|
||||||
to={internalMatchGamePath(communityId, matchId, game.gameNumber)}
|
|
||||||
state={{ backTo: historyBackTo }}
|
|
||||||
className="inline-flex h-7 items-center rounded-full bg-primary-tint px-3 text-xs font-bold text-primary transition-colors hover:brightness-95"
|
|
||||||
>
|
|
||||||
{hasAnalysis ? "상세 분석" : "경기 기록"}
|
|
||||||
</Link>
|
|
||||||
{game.teams.map((team) => (
|
|
||||||
<span
|
|
||||||
key={team.side}
|
|
||||||
className={`inline-flex h-7 items-center rounded-full px-3 text-xs font-bold ${
|
|
||||||
team.win
|
|
||||||
? team.side === "blue"
|
|
||||||
? "bg-win-tint text-win"
|
|
||||||
: "bg-loss-tint text-loss"
|
|
||||||
: "bg-sunken text-content-muted"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{teamIndexLabel(team.teamIndex)} ({sideLabel(team.side)}){" "}
|
|
||||||
{team.win ? "승" : "패"}
|
|
||||||
</span>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{hasAnalysis ? game.teams.map((team) => (
|
|
||||||
<div
|
|
||||||
key={team.side}
|
|
||||||
className="border-b border-base-content/8 last:border-b-0"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className={`px-4 py-2 text-xs font-black uppercase tracking-wider ${sideClass(team.side)}`}
|
|
||||||
>
|
|
||||||
{teamIndexLabel(team.teamIndex)} ({sideLabel(team.side)}) · 바론{" "}
|
|
||||||
{team.objectives.baron} · 드래곤 {team.objectives.dragon} · 타워{" "}
|
|
||||||
{team.objectives.tower}
|
|
||||||
</div>
|
|
||||||
<div className="overflow-x-auto">
|
|
||||||
<table className="w-full text-left min-w-[980px]">
|
|
||||||
<thead>
|
|
||||||
<tr className="bg-base-content/[0.02] text-xs text-base-content/35 uppercase tracking-wider">
|
|
||||||
<th className="px-3 py-2">소환사</th>
|
|
||||||
<th className="px-3 py-2">챔피언</th>
|
|
||||||
<th className="px-3 py-2 text-center">포지션</th>
|
|
||||||
<th className="px-3 py-2 text-center">K/D/A</th>
|
|
||||||
<th className="px-3 py-2 text-center">CS</th>
|
|
||||||
<th className="px-3 py-2 text-center">GPM</th>
|
|
||||||
<th className="px-3 py-2 text-center">킬관여</th>
|
|
||||||
<th className="px-3 py-2 text-center">피해비중</th>
|
|
||||||
<th className="px-3 py-2">아이템</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{team.participants.map((participant) => (
|
|
||||||
<tr
|
|
||||||
key={`${team.side}-${participant.userId}-${participant.championId}`}
|
|
||||||
className="border-t border-base-content/5"
|
|
||||||
>
|
|
||||||
<td className="px-3 py-2">
|
|
||||||
{participant.userId ? (
|
|
||||||
<Link
|
|
||||||
to={`/users/${participant.userId}/history?queueGroup=internal`}
|
|
||||||
state={{ backTo: historyBackTo }}
|
|
||||||
className="font-bold text-sm hover:text-primary"
|
|
||||||
>
|
|
||||||
{participant.summonerName}
|
|
||||||
</Link>
|
|
||||||
) : (
|
|
||||||
<span className="font-bold text-sm">
|
|
||||||
{participant.summonerName}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
<td className="px-3 py-2">
|
|
||||||
<ChampionCell
|
|
||||||
championId={participant.championId}
|
|
||||||
manifest={manifest}
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td className="px-3 py-2 text-center text-xs">
|
|
||||||
{LANE_LABELS[participant.teamPosition] ??
|
|
||||||
participant.teamPosition ??
|
|
||||||
"-"}
|
|
||||||
</td>
|
|
||||||
<td className="px-3 py-2 text-center text-sm font-black tabular-nums">
|
|
||||||
{participant.kills}
|
|
||||||
<span className="text-base-content/25"> / </span>
|
|
||||||
<span className="text-loss">{participant.deaths}</span>
|
|
||||||
<span className="text-base-content/25"> / </span>
|
|
||||||
{participant.assists}
|
|
||||||
</td>
|
|
||||||
<td className="px-3 py-2 text-center text-xs tabular-nums">
|
|
||||||
{participant.cs} ({participant.csPerMin}/m)
|
|
||||||
</td>
|
|
||||||
<td className="px-3 py-2 text-center text-xs tabular-nums">
|
|
||||||
{participant.gpm}
|
|
||||||
</td>
|
|
||||||
<td className="px-3 py-2 text-center text-xs tabular-nums">
|
|
||||||
{participant.killParticipation}%
|
|
||||||
</td>
|
|
||||||
<td className="px-3 py-2 text-center text-xs tabular-nums">
|
|
||||||
{participant.damageShare}%
|
|
||||||
</td>
|
|
||||||
<td className="px-3 py-2">
|
|
||||||
<ItemStrip
|
|
||||||
items={participant.items}
|
|
||||||
trinket={participant.trinket}
|
|
||||||
manifest={manifest}
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)) : <BasicGameScoreboard game={game} teams={teams} manifest={manifest} />}
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function InternalMatchDetailPage() {
|
export default function InternalMatchDetailPage() {
|
||||||
const { cid, matchId } = useParams();
|
const { cid, matchId } = useParams();
|
||||||
const location = useLocation();
|
|
||||||
const communityId = cid ?? DEFAULT_COMMUNITY_ID;
|
const communityId = cid ?? DEFAULT_COMMUNITY_ID;
|
||||||
const requestedBack = location.state?.backTo;
|
const location = useLocation(),
|
||||||
const backTo = typeof requestedBack === "string" && requestedBack.startsWith("/") && !requestedBack.startsWith("//")
|
navigate = useNavigate();
|
||||||
? requestedBack
|
const [params] = useSearchParams();
|
||||||
: `/communities/${communityId}/internal-stats`;
|
const seasonId = params.get("seasonId") ?? "current";
|
||||||
const detailQuery = useInternalMatchDetail(matchId, communityId);
|
const query = useInternalMatchDetail(matchId, communityId),
|
||||||
const { data: ddragon } = useDdragonManifest();
|
seasons = useCommunityStatsSeasons(communityId);
|
||||||
const detail = detailQuery.data;
|
const back = useStatsBack(
|
||||||
|
`${statsRoot(communityId)}?seasonId=${encodeURIComponent(seasonId)}`,
|
||||||
if (detailQuery.isLoading) {
|
|
||||||
return (
|
|
||||||
<PlainPage>
|
|
||||||
<LoadingNote label="내전 기록을 불러오는 중" />
|
|
||||||
</PlainPage>
|
|
||||||
);
|
);
|
||||||
}
|
const detail = query.data;
|
||||||
|
useStatsRestoration(!query.isPending);
|
||||||
if (detailQuery.isError && !(detailQuery.error instanceof ApiError && detailQuery.error.status === 404)) {
|
|
||||||
return (
|
return (
|
||||||
<PlainPage>
|
<div className="internal-stats">
|
||||||
<ErrorNote title="내전 기록을 불러오지 못했습니다"
|
<main className="is-page">
|
||||||
action={<Btn onClick={() => void detailQuery.refetch()}>다시 시도</Btn>} />
|
<StatsBack to={back} />
|
||||||
</PlainPage>
|
<header className="is-page-heading is-detail-heading">
|
||||||
);
|
<div>
|
||||||
}
|
<p className="is-eyebrow">내전 전체 기록</p>
|
||||||
if (!detail) {
|
<h1>{detail?.match.title ?? "내전 기록"}</h1>
|
||||||
return (
|
<p className="is-muted">
|
||||||
<PlainPage>
|
공식 경기 결과와 수집된 분석 기록을 함께 확인합니다.
|
||||||
<EmptyNote
|
</p>
|
||||||
title="내전 기록을 찾을 수 없습니다"
|
</div>
|
||||||
action={
|
<StatsSeasonControls
|
||||||
<Btn to={backTo}>
|
value={seasonId}
|
||||||
내전 전적으로
|
seasons={seasons.data?.seasons}
|
||||||
</Btn>
|
onChange={(value) =>
|
||||||
|
navigate(
|
||||||
|
`${statsRoot(communityId)}?seasonId=${encodeURIComponent(value)}`,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</PlainPage>
|
</header>
|
||||||
);
|
{query.isPending ? (
|
||||||
}
|
<StatsFeedback type="loading" title="내전 기록을 불러오는 중입니다" />
|
||||||
|
) : query.isError ? (
|
||||||
const groups = groupRecordedSets(detail);
|
<StatsFeedback
|
||||||
const competition = detail.competition;
|
type="error"
|
||||||
const unanalysedGames = competition?.projection.games.filter(
|
title="내전 기록을 불러오지 못했습니다"
|
||||||
(game) => !detail.games.some((record) => record.gameId === game.id),
|
action={<Btn onClick={() => void query.refetch()}>다시 시도</Btn>}
|
||||||
) ?? [];
|
>
|
||||||
|
목록으로 돌아가거나 다시 시도할 수 있습니다.
|
||||||
return (
|
</StatsFeedback>
|
||||||
|
) : detail ? (
|
||||||
<>
|
<>
|
||||||
<PageHero
|
<StatsEventOverview match={detail.match} />
|
||||||
width="xl"
|
<div className="is-result-heading">
|
||||||
crumbs={[
|
<h2>
|
||||||
{ label: "전적", to: backTo },
|
대결별 세트 기록 <span>{detail.match.games.length}판</span>
|
||||||
{ label: detail.match.title },
|
|
||||||
]}
|
|
||||||
title={detail.match.title}
|
|
||||||
meta={
|
|
||||||
<>
|
|
||||||
<span>{formatDateTime(detail.match.scheduledAt)}</span>
|
|
||||||
<MetaDot />
|
|
||||||
<span>{detail.match.teams.length}팀</span>
|
|
||||||
<MetaDot />
|
|
||||||
<span>{detail.games.length}세트 수집</span>
|
|
||||||
{competition && (
|
|
||||||
<>
|
|
||||||
<MetaDot />
|
|
||||||
<span>{formatOfficialMatchResult(detail.match.resultPresentation)}</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
actions={
|
|
||||||
<Btn to={`/match/${detail.match.matchId}`} variant="primary">
|
|
||||||
{detail.match.teams.length === 2 ? "내전 보기" : "대진표 보기"}
|
|
||||||
</Btn>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<PageBody width="xl" className="space-y-4">
|
|
||||||
{detail.games.length === 0 && unanalysedGames.length === 0 && (
|
|
||||||
<Panel>
|
|
||||||
<EmptyNote title="수집된 경기 기록이 없습니다" />
|
|
||||||
</Panel>
|
|
||||||
)}
|
|
||||||
{groups.map((group) => (
|
|
||||||
<section key={group.id} className="space-y-3">
|
|
||||||
<h2 className="flex flex-wrap items-baseline gap-x-2 px-1 text-base font-bold">
|
|
||||||
{group.label}
|
|
||||||
<span className="text-xs font-medium text-content-muted">
|
|
||||||
{group.series ? "시리즈" : "공식 시리즈 정보 없음"} · {group.sets.length}세트 수집
|
|
||||||
</span>
|
|
||||||
</h2>
|
</h2>
|
||||||
{group.sets.map(({ game, official }) => (
|
<StatsLink
|
||||||
<GamePanel key={game.riotMatchId} communityId={communityId} matchId={detail.match.matchId} game={game} teams={detail.match.teams} ordinal={official?.ordinal} riotMatchId={riotMatchIdForDisplay(game, official)} manifest={ddragon} />
|
className="is-event-detail-link"
|
||||||
))}
|
to={`/match/${detail.match.matchId}`}
|
||||||
</section>
|
>
|
||||||
))}
|
대진·팀 현황
|
||||||
{unanalysedGames.length > 0 && (
|
<ArrowRight size={15} />
|
||||||
<Panel className="space-y-2 p-4">
|
</StatsLink>
|
||||||
<h2 className="font-semibold">공식 세트 결과</h2>
|
</div>
|
||||||
<ul className="space-y-1 text-sm">
|
<div className="is-detail-series">
|
||||||
{unanalysedGames.map((game) => (
|
<StatsSeries
|
||||||
<li key={game.id}>
|
match={detail.match}
|
||||||
전체 {game.displayNumber}세트 · {competition?.teams.find((team) => team.teamId === game.winnerTeamId)?.name ?? "팀 미확인"} 승리
|
gameHref={(number) =>
|
||||||
{" · "}{game.evidence.type === "legacy" ? "Riot 원본 없음" : "상세 분석 준비 중"}
|
statsTarget(
|
||||||
</li>
|
internalMatchGamePath(
|
||||||
))}
|
communityId,
|
||||||
</ul>
|
detail.match.matchId,
|
||||||
</Panel>
|
number,
|
||||||
|
),
|
||||||
|
params,
|
||||||
|
location.pathname + location.search,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{!detail.match.games.length && (
|
||||||
|
<StatsFeedback type="empty" title="기록된 세트가 없습니다">
|
||||||
|
공식 대진과 팀 현황에서 진행 상태를 확인할 수 있습니다.
|
||||||
|
</StatsFeedback>
|
||||||
)}
|
)}
|
||||||
</PageBody>
|
|
||||||
</>
|
</>
|
||||||
|
) : (
|
||||||
|
<StatsFeedback type="empty" title="내전 기록을 찾을 수 없습니다" />
|
||||||
|
)}
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useMsal } from "@azure/msal-react";
|
import { useMsal } from "@azure/msal-react";
|
||||||
import { KeyRound } from "lucide-react";
|
import { ArrowRight } from "lucide-react";
|
||||||
import { Link, useSearchParams } from "react-router";
|
import { Link, useSearchParams } from "react-router";
|
||||||
import {
|
import {
|
||||||
isMsalConfigured,
|
isMsalConfigured,
|
||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
msalInstance,
|
msalInstance,
|
||||||
} from "../lib/auth/msal.config";
|
} from "../lib/auth/msal.config";
|
||||||
import { Button, ErrorNote, PlainPage } from "../ui";
|
import { Button, ErrorNote, PlainPage } from "../ui";
|
||||||
|
import "./login.css";
|
||||||
|
|
||||||
function LoginButton({ returnPath }: { returnPath?: string }) {
|
function LoginButton({ returnPath }: { returnPath?: string }) {
|
||||||
const { instance } = useMsal();
|
const { instance } = useMsal();
|
||||||
@@ -17,6 +18,7 @@ function LoginButton({ returnPath }: { returnPath?: string }) {
|
|||||||
variant="primary"
|
variant="primary"
|
||||||
size="lg"
|
size="lg"
|
||||||
width="100%"
|
width="100%"
|
||||||
|
className="login-submit"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
void instance.loginRedirect({
|
void instance.loginRedirect({
|
||||||
scopes: [MSAL_API_SCOPE],
|
scopes: [MSAL_API_SCOPE],
|
||||||
@@ -36,32 +38,31 @@ export default function LoginPage() {
|
|||||||
const returnPath = next && /^\/match\/[a-f\d]{24}$/i.test(next) ? next : undefined;
|
const returnPath = next && /^\/match\/[a-f\d]{24}$/i.test(next) ? next : undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PlainPage width="md" className="py-16 sm:py-24">
|
<PlainPage width="md" className="login-page">
|
||||||
<div className="lts-panel mx-auto max-w-sm p-6 sm:p-8">
|
<section className="login-content" aria-labelledby="login-title">
|
||||||
<span className="grid size-11 place-items-center rounded-full bg-primary-tint text-primary">
|
<h1 id="login-title" className="login-title">로그인</h1>
|
||||||
<KeyRound className="size-5" aria-hidden="true" />
|
<p className="login-description">
|
||||||
</span>
|
내전 참가와 팀장 경매를 위해 로그인하세요.
|
||||||
<h1 className="mt-4 text-xl font-extrabold">로그인</h1>
|
|
||||||
<p className="mt-1.5 text-sm leading-relaxed text-content-muted">
|
|
||||||
내전 참가 신청, 팀장 경매, 운영 기능은 로그인 후 사용할 수 있습니다.
|
|
||||||
전적과 대진은 로그인 없이 볼 수 있습니다.
|
|
||||||
</p>
|
</p>
|
||||||
<div className="mt-6">
|
<div className="login-action">
|
||||||
{isMsalConfigured && msalInstance ? (
|
{isMsalConfigured && msalInstance ? (
|
||||||
<LoginButton returnPath={returnPath} />
|
<LoginButton returnPath={returnPath} />
|
||||||
) : (
|
) : (
|
||||||
<ErrorNote
|
<ErrorNote
|
||||||
title="로그인을 사용할 수 없습니다"
|
title="로그인을 사용할 수 없습니다"
|
||||||
description="MSAL 환경변수 설정이 필요합니다."
|
description="로그인 설정을 확인하려면 운영진에게 문의해 주세요."
|
||||||
|
className="text-left"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{returnPath && (
|
<div className="login-browse">
|
||||||
<Link to={returnPath} className="mt-4 inline-block text-sm font-semibold text-primary hover:underline">
|
<p>전적과 대진은 로그인 없이 볼 수 있습니다.</p>
|
||||||
내전 상세로 돌아가기
|
<Link to={returnPath ?? "/"} className="login-browse-link">
|
||||||
|
{returnPath ? "내전 상세로 돌아가기" : "로그인 없이 둘러보기"}
|
||||||
|
<ArrowRight size={14} aria-hidden="true" />
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
</section>
|
||||||
</PlainPage>
|
</PlainPage>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Loaded 100 of 130 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user