✨feature: Add responsive styles
This commit is contained in:
16
app.js
16
app.js
@@ -106,3 +106,19 @@ async function resetGame() {
|
||||
}
|
||||
|
||||
window.addEventListener('DOMContentLoaded', onLoad);
|
||||
|
||||
// Back to Top: show after scrolling, smooth-scroll on click
|
||||
function initBackToTop() {
|
||||
const btn = document.getElementById('backToTop');
|
||||
if (!btn) return;
|
||||
const onScroll = () => {
|
||||
if (window.scrollY > 200) btn.classList.add('show'); else btn.classList.remove('show');
|
||||
};
|
||||
window.addEventListener('scroll', onScroll, { passive: true });
|
||||
onScroll();
|
||||
btn.addEventListener('click', () => {
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener('DOMContentLoaded', initBackToTop);
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<section class="panel">
|
||||
<h2>Actions</h2>
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="row actions">
|
||||
<button data-action onclick="doAction('status')">Check Status</button>
|
||||
<button data-action onclick="handleWork()">Go to Work</button>
|
||||
<button data-action onclick="handleSleep()">Sleep</button>
|
||||
@@ -54,7 +54,7 @@
|
||||
<div id="state" class="content"></div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<button id="backToTop" aria-label="Back to top" title="Back to top">↑ Top</button>
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
92
style.css
92
style.css
@@ -12,6 +12,8 @@ header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 12px 16px;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
@@ -21,33 +23,38 @@ h1 {
|
||||
|
||||
main {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
grid-template-columns: 300px 1fr;
|
||||
padding: 16px;
|
||||
gap: 12px;
|
||||
grid-template-columns: 1fr;
|
||||
padding: 12px;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.panel {
|
||||
background: #111827;
|
||||
border: 1px solid #27324a;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: #a3b5d9;
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
padding: 12px 12px 0;
|
||||
}
|
||||
.panel h2 {
|
||||
color: #a3b5d9;
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
padding: 12px 12px 0;
|
||||
}
|
||||
|
||||
.content { padding: 12px; }
|
||||
.panel .content { padding: 12px; }
|
||||
|
||||
&.log { grid-column: 1 / span 2; }
|
||||
.panel.log,
|
||||
.panel.state {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
#log {
|
||||
background: #0b1020;
|
||||
color: #e9eef8;
|
||||
max-height: 60vh;
|
||||
min-height: 360px;
|
||||
max-height: 50vh;
|
||||
min-height: 240px;
|
||||
overflow: auto;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
@@ -58,20 +65,27 @@ main {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
/* Stack action buttons on small screens */
|
||||
.actions {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
button {
|
||||
background: #1f2a44;
|
||||
border: 1px solid #2c3a5e;
|
||||
border-radius: 6px;
|
||||
color: #e9eef8;
|
||||
cursor: pointer;
|
||||
padding: 8px 10px;
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
&:hover { background: #263356; }
|
||||
button:hover { background: #263356; }
|
||||
|
||||
&:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.5;
|
||||
}
|
||||
button:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
@@ -94,6 +108,42 @@ button {
|
||||
gap: 8px;
|
||||
justify-content: space-between;
|
||||
margin: 2px 0;
|
||||
|
||||
.label { color: #a3b5d9; }
|
||||
}
|
||||
|
||||
.kv .label { color: #a3b5d9; }
|
||||
|
||||
@media (min-width: 700px) {
|
||||
main { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 16px; }
|
||||
#log { max-height: 60vh; }
|
||||
.actions { display: flex; flex-wrap: wrap; }
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
main { grid-template-columns: 320px 1fr; }
|
||||
}
|
||||
|
||||
/* Back to Top */
|
||||
#backToTop {
|
||||
position: fixed;
|
||||
right: 16px;
|
||||
bottom: 16px;
|
||||
z-index: 1000;
|
||||
background: #1f2a44;
|
||||
border: 1px solid #2c3a5e;
|
||||
color: #e9eef8;
|
||||
border-radius: 999px;
|
||||
padding: 10px 14px;
|
||||
box-shadow: 0 6px 16px rgba(0,0,0,0.35);
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transform: translateY(10px);
|
||||
transition: opacity .2s ease, transform .2s ease;
|
||||
}
|
||||
|
||||
#backToTop:hover { background: #263356; }
|
||||
|
||||
#backToTop.show {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user