Files
rangerhq-buddy/assets/css/buddy.css
T
ranger 0675c9f7d8 fix: wink is now a real CSS animation, no longer sticks (v0.1.3)
The v0.1.1 wink was rendered as a static SVG (left eye drawn as a
closed curve). Once the 5% random gate picked the wink tone, the
left eye stayed closed until the next page render — if the
dashboard sat idle, Buddy was stuck mid-wink indefinitely. David's
report: "the eye does not unblink."

v0.1.2's lower probability (30% → 5%) reduced how often you'd see
the stuck state, but didn't fix the underlying issue.

This release makes the wink a real transient animation:

- sprite.php no longer swaps the left eye for a closed path when
  tone is wink — both eyes are always open circles in the SVG
- buddy.css adds @keyframes buddyWink that briefly closes the
  left eye (scaleY 0.1) for ~250ms every 2.5s, applied only when
  the parent has the .buddy-sprite--wink class
- right eye keeps its normal 5s blink — the asymmetry is what
  makes it read as a wink rather than a synchronised blink
- mouth/cheeks/label still differ for wink tone (those are valid
  static state changes); only the eye behaviour moved to animation

Net effect: when the 5% chance fires, Buddy now actually winks
(closes, opens, closes, opens) instead of freezing one-eye-shut.
2026-05-26 08:08:56 +01:00

171 lines
5.0 KiB
CSS

/*
* Buddy plugin styles.
* Scoped via .buddy-* class names so we don't bleed into the WP admin.
* No external fonts, no @import, no images — just inline-SVG + plain CSS.
*/
/* ── Sprite (the character) ──────────────────────────────────────── */
.buddy-sprite {
display: block;
user-select: none;
animation: buddyBob 4s ease-in-out infinite;
}
.buddy-sprite--sm { width: 64px; height: 64px; }
.buddy-sprite--md { width: 96px; height: 96px; }
.buddy-sprite--lg { width: 160px; height: 160px; }
/* Eyes blink every ~5s. The fast-step keyframes simulate a quick blink. */
.buddy-sprite__eye {
transform-origin: center;
animation: buddyBlink 5s infinite;
}
.buddy-sprite--sad .buddy-sprite__eye {
animation-duration: 7s; /* sadder Buddy blinks slower */
}
/* Cheeky wink: when the mood-label picks the 'wink' tone, the LEFT eye
runs a faster, more dramatic keyframe that closes for ~250ms every
2.5s. The right eye keeps its normal 5s blink — that asymmetry is
what makes it read as a wink rather than a synchronised blink.
v0.1.3 fix: previously the wink was a static SVG render (left eye
drawn as a closed curve), which got stuck on the page until the next
render. Now it's a real transient animation, so Buddy unblinks. */
.buddy-sprite--wink .buddy-sprite__eye--left {
animation: buddyWink 2.5s infinite;
}
@keyframes buddyBob {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-4px); }
}
@keyframes buddyBlink {
0%, 92%, 100% { transform: scaleY(1); }
94%, 98% { transform: scaleY(0.1); }
}
@keyframes buddyWink {
0%, 80%, 100% { transform: scaleY(1); } /* eye open most of the cycle */
85%, 95% { transform: scaleY(0.1); } /* closes briefly = the wink */
}
/* ── Dashboard widget ───────────────────────────────────────────── */
.buddy-widget {
display: flex;
gap: 16px;
align-items: center;
}
.buddy-widget__pet { flex: 0 0 auto; }
.buddy-widget__info { flex: 1 1 auto; min-width: 0; }
.buddy-widget__name {
font-size: 16px;
font-weight: 600;
margin-bottom: 8px;
}
.buddy-widget__mood {
display: inline-block;
margin-left: 6px;
padding: 2px 8px;
font-size: 11px;
font-weight: 500;
border-radius: 9px;
vertical-align: middle;
}
.buddy-widget__mood--happy { background:#e8f5ea; color:#1b6f2d; }
.buddy-widget__mood--wink { background:#fef3c7; color:#92400e; }
.buddy-widget__mood--neutral { background:#f0f0f1; color:#3c434a; }
.buddy-widget__mood--sad { background:#fcf0f1; color:#8a2424; }
.buddy-widget__cta { margin: 10px 0 0; }
/* ── Stats bars ─────────────────────────────────────────────────── */
.buddy-stats {
margin: 0;
padding: 0;
list-style: none;
}
.buddy-stat {
display: grid;
grid-template-columns: 22px 80px 1fr 36px;
align-items: center;
gap: 8px;
margin: 4px 0;
}
.buddy-stat__icon { text-align: center; font-size: 14px; }
.buddy-stat__label { font-size: 12px; color: #3c434a; }
.buddy-stat__bar {
height: 8px;
background: #f0f0f1;
border-radius: 4px;
overflow: hidden;
position: relative;
}
.buddy-stat__fill {
display: block;
height: 100%;
background: linear-gradient(90deg, #4ade80, #22c55e);
border-radius: 4px;
transition: width 0.4s ease;
}
.buddy-stat__fill--low {
background: linear-gradient(90deg, #f97316, #ef4444);
}
.buddy-stat__num {
text-align: right;
font-size: 12px;
color: #646970;
font-variant-numeric: tabular-nums;
}
/* ── Main admin page layout ─────────────────────────────────────── */
.buddy-main {
display: grid;
grid-template-columns: 280px 1fr;
gap: 22px;
margin-top: 20px;
}
@media (max-width: 782px) {
.buddy-main { grid-template-columns: 1fr; }
}
.buddy-main__card {
background: #fff;
border: 1px solid #ccd0d4;
border-radius: 4px;
padding: 22px;
}
.buddy-main__card--pet {
text-align: center;
}
.buddy-main__name {
font-size: 20px;
font-weight: 600;
margin: 14px 0 4px;
}
.buddy-main__mood {
display: inline-block;
margin-left: 8px;
padding: 2px 9px;
font-size: 12px;
font-weight: 500;
border-radius: 10px;
vertical-align: middle;
}
.buddy-main__mood--happy { background:#e8f5ea; color:#1b6f2d; }
.buddy-main__mood--wink { background:#fef3c7; color:#92400e; }
.buddy-main__mood--neutral { background:#f0f0f1; color:#3c434a; }
.buddy-main__mood--sad { background:#fcf0f1; color:#8a2424; }
.buddy-main__age { color: #646970; font-size: 13px; margin: 0; }
.buddy-main__note {
margin-top: 14px;
padding: 10px 12px;
background: #f0f6fc;
border-left: 3px solid #2271b1;
color: #135e96;
font-size: 13px;
border-radius: 0 4px 4px 0;
}