Layout: resizable window, fluid SVG ring, no scrollbars unless overflow, opaque bg
tauri.conf: resizable=true, min 220x240, default 300x320. BlockRing: SVG scales via viewBox, claims remaining vertical space. #app uses flex column with sections flex:0 0 auto — content reflows when window resized. Bumped --bg opacity from 0.78 to 0.93 so files behind the widget don't bleed through. Themed scrollbars subtle when they do appear.
This commit is contained in:
parent
75049903e7
commit
f90bb3b0d5
4 changed files with 49 additions and 17 deletions
|
|
@ -14,11 +14,11 @@
|
||||||
{
|
{
|
||||||
"label": "main",
|
"label": "main",
|
||||||
"title": "Claude Usage",
|
"title": "Claude Usage",
|
||||||
"width": 280,
|
"width": 300,
|
||||||
"height": 360,
|
"height": 320,
|
||||||
"minWidth": 280,
|
"minWidth": 220,
|
||||||
"minHeight": 360,
|
"minHeight": 240,
|
||||||
"resizable": false,
|
"resizable": true,
|
||||||
"decorations": false,
|
"decorations": false,
|
||||||
"transparent": true,
|
"transparent": true,
|
||||||
"alwaysOnTop": true,
|
"alwaysOnTop": true,
|
||||||
|
|
|
||||||
|
|
@ -92,11 +92,10 @@
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.loading {
|
.loading {
|
||||||
flex: 1;
|
flex: 0 0 auto;
|
||||||
display: flex;
|
padding: 12px;
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
color: var(--fg-dim);
|
color: var(--fg-dim);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { UsageBar } from "../types";
|
import type { UsageBar } from "../types";
|
||||||
|
|
||||||
// Shows the *real* percentage from `claude /usage` — the
|
// Shows the *real* "Current session" percentage from `claude /usage`.
|
||||||
// "Current session" bar (5-hour rolling window).
|
// The SVG uses a viewBox so it scales to whatever container size we get.
|
||||||
let {
|
let {
|
||||||
bar,
|
bar,
|
||||||
fallbackText = "—",
|
fallbackText = "—",
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
fallbackText?: string;
|
fallbackText?: string;
|
||||||
} = $props();
|
} = $props();
|
||||||
|
|
||||||
// Geometry.
|
// Logical units; the SVG viewBox is fixed. CSS scales it.
|
||||||
const SIZE = 140;
|
const SIZE = 140;
|
||||||
const STROKE = 12;
|
const STROKE = 12;
|
||||||
const R = (SIZE - STROKE) / 2;
|
const R = (SIZE - STROKE) / 2;
|
||||||
|
|
@ -26,7 +26,12 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<svg width={SIZE} height={SIZE} viewBox={`0 0 ${SIZE} ${SIZE}`}>
|
<svg
|
||||||
|
viewBox={`0 0 ${SIZE} ${SIZE}`}
|
||||||
|
preserveAspectRatio="xMidYMid meet"
|
||||||
|
role="img"
|
||||||
|
aria-label={bar ? `${bar.percent} percent session used` : "no usage data"}
|
||||||
|
>
|
||||||
<circle
|
<circle
|
||||||
cx={SIZE / 2}
|
cx={SIZE / 2}
|
||||||
cy={SIZE / 2}
|
cy={SIZE / 2}
|
||||||
|
|
@ -60,7 +65,24 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.wrap { display: flex; justify-content: center; padding: 14px 0 6px; }
|
/*
|
||||||
|
Container reserves a roughly square area at ~50% of widget height.
|
||||||
|
The SVG fills the container and scales via viewBox.
|
||||||
|
*/
|
||||||
|
.wrap {
|
||||||
|
flex: 1 1 0;
|
||||||
|
min-height: 110px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 6px 0;
|
||||||
|
}
|
||||||
|
svg {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
max-width: 220px; /* don't get absurdly large in a wide window */
|
||||||
|
max-height: 220px;
|
||||||
|
}
|
||||||
text { fill: var(--fg); font-family: inherit; }
|
text { fill: var(--fg); font-family: inherit; }
|
||||||
text.big { font-size: 26px; font-weight: 600; }
|
text.big { font-size: 26px; font-weight: 600; }
|
||||||
text.small { font-size: 11px; fill: var(--fg-dim); }
|
text.small { font-size: 11px; fill: var(--fg-dim); }
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/* Glass / always-on-top widget look. */
|
/* Glass / always-on-top widget look. */
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--bg: rgba(18, 20, 26, 0.78);
|
--bg: rgba(18, 20, 26, 0.93);
|
||||||
--bg-card: rgba(255, 255, 255, 0.04);
|
--bg-card: rgba(255, 255, 255, 0.04);
|
||||||
--border: rgba(255, 255, 255, 0.08);
|
--border: rgba(255, 255, 255, 0.08);
|
||||||
--fg: #e8eaf0;
|
--fg: #e8eaf0;
|
||||||
|
|
@ -38,12 +38,22 @@ html, body {
|
||||||
background: var(--bg);
|
background: var(--bg);
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
overflow: hidden;
|
overflow: hidden; /* the window itself never scrolls */
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
backdrop-filter: blur(14px);
|
backdrop-filter: blur(14px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Each child of #app gets a sensible flex behavior so resizing reflows
|
||||||
|
instead of overflowing. TitleBar and section panels are flex:0 (size
|
||||||
|
to content); the BlockRing wrap is flex:1 (claims remaining space). */
|
||||||
|
|
||||||
|
/* Hide scrollbars unless content really overflows; when they do appear,
|
||||||
|
make them subtle. */
|
||||||
|
::-webkit-scrollbar { width: 6px; height: 6px; }
|
||||||
|
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 3px; }
|
||||||
|
::-webkit-scrollbar-track { background: transparent; }
|
||||||
|
|
||||||
button {
|
button {
|
||||||
font: inherit;
|
font: inherit;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
|
|
@ -78,7 +88,8 @@ input[type="number"], input[type="text"], select {
|
||||||
}
|
}
|
||||||
|
|
||||||
.section {
|
.section {
|
||||||
padding: 8px var(--pad);
|
flex: 0 0 auto;
|
||||||
|
padding: 6px var(--pad) 8px;
|
||||||
border-top: 1px solid var(--border);
|
border-top: 1px solid var(--border);
|
||||||
}
|
}
|
||||||
.section:first-child { border-top: none; }
|
.section:first-child { border-top: none; }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue