blob: 4ca0469fc9c115eec62825397e8267134ccc6711 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
import React from "react";
import styled from "styled-components";
import { StyledTooltip, lightGray, vscForeground } from ".";
const ProgressBarWrapper = styled.div`
width: 100px;
height: 6px;
border-radius: 6px;
border: 0.5px solid ${lightGray};
margin-top: 6px;
`;
const ProgressBarFill = styled.div<{ completed: number; color?: string }>`
height: 100%;
background-color: ${(props) => props.color || vscForeground};
border-radius: inherit;
transition: width 0.2s ease-in-out;
width: ${(props) => props.completed}%;
`;
const GridDiv = styled.div`
display: grid;
grid-template-rows: 1fr auto;
align-items: center;
justify-items: center;
`;
const P = styled.p`
margin: 0;
margin-top: 2px;
font-size: 11.5px;
color: ${lightGray};
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
`;
interface ProgressBarProps {
completed: number;
total: number;
}
const ProgressBar = ({ completed, total }: ProgressBarProps) => {
const fillPercentage = Math.min(100, Math.max(0, (completed / total) * 100));
return (
<>
<a
href="https://continue.dev/docs/customization/models"
className="no-underline ml-2"
>
<GridDiv data-tooltip-id="usage_progress_bar">
<ProgressBarWrapper>
<ProgressBarFill
completed={fillPercentage}
color={
completed / total > 0.75
? completed / total > 0.95
? "#f00"
: "#fc0"
: undefined
}
/>
</ProgressBarWrapper>
<P>
Free Uses: {completed} / {total}
</P>
</GridDiv>
</a>
</>
);
};
export default ProgressBar;
|