Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlay2 stats #120

Merged
merged 5 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/widget_positions.json.overlay2
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"sizeX": 1488,
"sizeY": 984
},
"statistics": {
"positionX": 16,
"positionY": 662,
"sizeX": 1488,
"sizeY": 338
},
"ticker": {
"positionX": 16,
"positionY": 1016,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const IOITaskResult = PropTypes.shape({
const VerdictLabel = styled(ShrinkingBox)`
background-color: ${({ color }) => color};
font-size: 14px;
font-weight: 700;
font-weight: ${c.GLOBAL_DEFAULT_FONT_WEIGHT_BOLD};
display: flex;
justify-content: center;
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import {Legend, StackedBarsData} from "./types";
import styled from "styled-components";
import c from "../../../config";
import { ProblemLabel } from "../../atoms/ProblemLabel";

const BarsWrapper = styled.div`
width: 100%;
height: 100%;
display: grid;
gap: ${c.STATISTICS_BAR_GAP};
grid-auto-flow: column;
grid-template-rows: repeat(${({rowsCount}) => rowsCount}, 1fr);
`

const BarWrapper = styled.div`
width: 100%;
height: ${c.STATISTICS_BAR_HEIGHT};
line-height: ${c.STATISTICS_BAR_HEIGHT};
display: grid;
gap: 0;
grid-template-columns: ${c.STATISTICS_BAR_HEIGHT} auto;
`

const BarName = styled(ProblemLabel)`
width: ${c.STATISTICS_BAR_HEIGHT};
background-color: ${({color}) => color};
font-size: ${c.GLOBAL_DEFAULT_FONT_SIZE};
font-family: ${c.GLOBAL_DEFAULT_FONT_FAMILY};
text-align: center;
`
//todo: set font widget

const BarValues = styled.div`
width: 100%;
display: flex;
justify-content: flex-start;
background-color: ${c.QUEUE_ROW_BACKGROUND};
border-radius: 0 ${c.GLOBAL_BORDER_RADIUS} ${c.GLOBAL_BORDER_RADIUS} 0;
overflow: hidden;
`

const BarValue = styled.div.attrs(({ value, caption }) => ({
style: {
width: `calc(max(${value * 100}%, ${value === 0 ? 0 : ((caption?.length ?? -1) + 1)}ch))`,
}
}))`
height: ${c.STATISTICS_BAR_HEIGHT};
line-height: ${c.STATISTICS_BAR_HEIGHT};
transition: width linear ${c.STATISTICS_CELL_MORPH_TIME}ms;
overflow: hidden;
box-sizing: border-box;

font-size: ${c.GLOBAL_DEFAULT_FONT_SIZE};
font-family: ${c.GLOBAL_DEFAULT_FONT_FAMILY};

background-color: ${({color}) => color};
color: ${c.STATISTICS_TITLE_COLOR};
text-align: center;
`

interface StackedBarsProps {
data: StackedBarsData;
legend: Legend;
}
export const StackedBars = ({data}: StackedBarsProps) => {
const rowsCount = data.length
return (
<BarsWrapper rowsCount={rowsCount}>
{data.map((b) => {
return (
<BarWrapper key={b.name}>
<BarName problemColor={b.color} letter={b.name}/>
<BarValues>
{b.values.map(v => (
<BarValue key={v.color} color={v.color} value={v.value} caption={v.caption}>
{v.caption}
</BarValue>
))}
</BarValues>
</BarWrapper>
)
})}
</BarsWrapper>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import {Legend} from "./types";
import styled from "styled-components";
import c from "../../../config";


const LegendsWrapper = styled.div`
width: 100%;
height: 100%;
display: grid;
gap: ${c.STATISTICS_BAR_GAP};
//grid-template-columns: auto;
grid-auto-flow: column;
justify-content: end;
align-content: center;
`

const LegendCardWrapper = styled.div`
width: 100%;
background-color: ${({color}) => color};
border-radius: ${c.GLOBAL_BORDER_RADIUS};
`

const LegendWrapper = styled.div`
line-height: ${c.STATISTICS_BAR_HEIGHT};
font-size: ${c.GLOBAL_DEFAULT_FONT_SIZE};
font-family: ${c.GLOBAL_DEFAULT_FONT_FAMILY};
text-align: center;
margin: 8px 16px;
`

type LegendCardProps = { color: string; caption: string };

export const LegendCard = ({ color, caption }: LegendCardProps) => {
return (
<LegendCardWrapper color={color}>
<LegendWrapper>
{caption}
</LegendWrapper>
</LegendCardWrapper>
);
}

type StatisticsLegendsProps = { legend: Legend };

export const StatisticsLegend = ({legend}: StatisticsLegendsProps) => {
return (
<LegendsWrapper>
{legend?.map((l) => (
<LegendCard caption={l.caption} color={l.color}></LegendCard>
))}
</LegendsWrapper>
);
}
25 changes: 25 additions & 0 deletions src/frontend/overlay/src/components/molecules/statistics/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export interface BarValue {
readonly color: string;
readonly caption: string;
readonly value: number;
}

export interface BarData {
readonly name: string;
readonly color: string;
readonly values: BarValue[];
}

export interface LegendDescription {
readonly caption: string;
readonly color: string;
}

export type Legend = LegendDescription[];

export type StackedBarsData = BarData[];

export interface StatisticsData {
readonly data: StackedBarsData; // | other statistics data
readonly legend: Legend;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import styled from "styled-components";
import c from "../../../config";

const AdvertisementContainer = styled.div`
width: 100%;
Expand All @@ -15,7 +16,7 @@ const AdvertisementWrap = styled.div`
background-color: white;
border-radius: 12px;
font-size: 24pt;
font-weight: 700;
font-weight: ${c.GLOBAL_DEFAULT_FONT_WEIGHT_BOLD};
font-family: Urbanist, Passageway, serif;
color: black;
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const fadeOut = () => keyframes`
opacity: 100%;
}
to {
opacity: 0%;
opacity: 0;
}
`;

Expand Down Expand Up @@ -189,7 +189,7 @@ const StyledQueueRow = styled.div`
gap: 5px;
color: white;
font-size: 18px;
background: rgba(0, 0, 0, 0.08);
background: ${c.QUEUE_ROW_BACKGROUND};
`;

const QueueScoreLabel = styled(ShrinkingBox)`
Expand Down Expand Up @@ -232,7 +232,7 @@ const QueueWrap = styled.div`
position: relative;
background-color: ${c.QUEUE_BACKGROUND_COLOR};
background-repeat: no-repeat;
border-radius: 16px;
border-radius: ${c.GLOBAL_BORDER_RADIUS};
padding: 8px;
box-sizing: border-box;
display: flex;
Expand All @@ -249,7 +249,7 @@ const RowsContainer = styled.div`

const QueueHeader = styled.div`
font-size: 32px;
font-weight: 700;
font-weight: ${c.GLOBAL_DEFAULT_FONT_WEIGHT_BOLD};
line-height: 44px;
color: white;
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const ScoreboardHeader = styled.div`
flex-direction: row;
font-size: ${c.SCOREBOARD_CAPTION_FONT_SIZE};
font-style: normal;
font-weight: 700;
font-weight: ${c.GLOBAL_DEFAULT_FONT_WEIGHT_BOLD};
padding-top: 0.3em;
`;

Expand Down Expand Up @@ -205,7 +205,7 @@ const ScoreboardTableHeaderWrap = styled(ScoreboardTableRowWrap)`

font-size: ${c.SCOREBOARD_TABLE_HEADER_FONT_SIZE}px;
font-style: normal;
font-weight: 700;
font-weight: ${c.GLOBAL_DEFAULT_FONT_WEIGHT_BOLD};
line-height: ${c.SCOREBOARD_TABLE_HEADER_HEIGHT};
`;

Expand Down
131 changes: 0 additions & 131 deletions src/frontend/overlay/src/components/organisms/widgets/Statistics.jsx

This file was deleted.

Loading
Loading