← Public packages
@kentcdodds/pocket-piano
A pocket piano for choir practice: your singing part's range on your phone, installable and offline.
src/styles.ts
187 lines · 4.6 KB · TypeScriptexport const CSS = String.raw`
:root {
color-scheme: dark;
--bg: #14161c;
--panel: #1d2029;
--text: #eef0f5;
--muted: #9aa1b2;
--accent: #f2b544;
--part: #5cc8a8;
--white: #f7f6f2;
--white-down: #d9e8ff;
--black: #1b1c20;
--black-down: #3b5a8a;
}
* { box-sizing: border-box; }
html, body {
margin: 0;
height: 100%;
overflow: hidden;
overscroll-behavior: none;
touch-action: none;
-webkit-tap-highlight-color: transparent;
-webkit-user-select: none;
user-select: none;
-webkit-touch-callout: none;
}
body {
position: fixed;
inset: 0;
display: flex;
flex-direction: column;
background: var(--bg);
color: var(--text);
font: 15px/1.2 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
header {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
padding: 8px 10px;
background: var(--panel);
}
button {
font: inherit;
color: var(--text);
background: #2a2e3a;
border: 1px solid #3a3f4e;
border-radius: 10px;
min-height: 44px;
min-width: 44px;
padding: 0 12px;
touch-action: manipulation;
cursor: pointer;
}
button:active { background: #353b4b; }
button[hidden] { display: none; }
#range { min-width: 96px; font-weight: 600; }
#range.home { background: transparent; border-color: transparent; }
#readout {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-width: 84px;
background: #22262f;
line-height: 1.05;
}
#readout-note { font-size: 22px; font-weight: 800; color: var(--accent); }
#readout-hz { font-size: 11px; color: var(--muted); }
#readout:not(.has-note) #readout-note { font-size: 13px; color: var(--muted); font-weight: 500; }
#sustain[aria-pressed='true'] { background: var(--accent); color: #1a1a1a; border-color: var(--accent); font-weight: 700; }
#install { background: var(--part); color: #10231d; border-color: var(--part); font-weight: 700; }
.spacer { flex: 1 1 0; min-width: 0; }
/* Small About link: its own 44px tap target in the header, never over the keys. */
.info {
display: inline-flex;
align-items: center;
justify-content: center;
width: 44px;
height: 44px;
border-radius: 50%;
color: var(--muted);
text-decoration: none;
touch-action: manipulation;
}
.info:active { background: #2a2e3a; color: var(--text); }
#keyboard {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
gap: 10px;
margin: 6px;
touch-action: none;
}
.row {
position: relative;
flex: 1;
min-height: 0;
overflow: hidden;
border-radius: 6px;
}
.strip {
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: calc(var(--n, 52) * var(--k, 60px));
will-change: transform;
}
.key { position: absolute; touch-action: none; }
/* Low notes on the left in every orientation. */
.key.white {
top: 0;
bottom: 0;
left: calc(var(--i) * var(--k) + 1.5px);
width: calc(var(--k) - 3px);
background: linear-gradient(to bottom, #e9e7e1, var(--white) 12%);
border-radius: 0 0 8px 8px;
box-shadow: inset 0 -6px 0 #d5d2c9;
}
.key.black {
top: 0;
height: 58%;
left: calc(var(--c) * var(--k) - var(--k) * 0.31);
width: calc(var(--k) * 0.62);
z-index: 2;
background: linear-gradient(to bottom, #2c2e35, var(--black));
border-radius: 0 0 6px 6px;
box-shadow: inset 0 -5px 0 #000, 0 2px 4px rgba(0, 0, 0, 0.5);
}
.key.white.down { background: var(--white-down); box-shadow: inset 0 -2px 0 #b8c9e6; }
.key.black.down { background: var(--black-down); box-shadow: inset 0 -2px 0 #000; }
.key.in-part::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 5px;
background: var(--part);
opacity: 0.85;
}
.key.black.in-part::before { opacity: 0.6; }
.label {
position: absolute;
left: 0;
right: 0;
bottom: 12px;
text-align: center;
font-size: 13px;
font-weight: 600;
color: #5a5d66;
pointer-events: none;
}
.key.black .label { bottom: 8px; font-size: 10px; color: #a9adb8; }
.key.middle-c { background: linear-gradient(to bottom, #f6e2b3, #fff3d6 14%); box-shadow: inset 0 -6px 0 var(--accent); }
.key.middle-c.down { background: #ffe4a3; }
.key.middle-c .label { color: #9a5b00; font-weight: 800; }
.tag {
position: absolute;
left: 50%;
bottom: 32px;
transform: translateX(-50%);
background: var(--accent);
color: #1a1a1a;
font-size: 9px;
font-weight: 700;
border-radius: 6px;
padding: 2px 4px;
white-space: nowrap;
pointer-events: none;
}
@media (orientation: landscape) and (max-height: 500px) {
header { padding: 4px 8px; gap: 6px; }
button { min-height: 40px; }
#keyboard { margin-top: 4px; }
}
@media (max-width: 380px) {
.label { font-size: 11px; }
.tag { font-size: 8px; }
}
`