fix(ui): responsive word construction tray to fit all 4 tiles without clipping on mobile
This commit is contained in:
@@ -9,8 +9,10 @@ export function createWordBuilder({ onTileRemoved, onTilesReordered, onSubmitWor
|
|||||||
let touchMoved = false;
|
let touchMoved = false;
|
||||||
|
|
||||||
function render(state) {
|
function render(state) {
|
||||||
const hasTiles = state.activeTileIds.length > 0;
|
const tileCount = state.activeTileIds.length;
|
||||||
|
const hasTiles = tileCount > 0;
|
||||||
const tileObjects = state.activeTileIds.map(id => state.boardTiles.find(t => t.id === id)).filter(Boolean);
|
const tileObjects = state.activeTileIds.map(id => state.boardTiles.find(t => t.id === id)).filter(Boolean);
|
||||||
|
const pts = tileCount === 4 ? 8 : tileCount === 3 ? 4 : tileCount === 2 ? 2 : 1;
|
||||||
|
|
||||||
wrapper.innerHTML = `
|
wrapper.innerHTML = `
|
||||||
<div class="word-builder ${hasTiles ? 'has-tiles' : ''}" id="active-word-builder">
|
<div class="word-builder ${hasTiles ? 'has-tiles' : ''}" id="active-word-builder">
|
||||||
@@ -21,8 +23,7 @@ export function createWordBuilder({ onTileRemoved, onTilesReordered, onSubmitWor
|
|||||||
.map(
|
.map(
|
||||||
(tile, idx) => `
|
(tile, idx) => `
|
||||||
<div class="active-tile-chip" data-idx="${idx}" draggable="true" title="Tap to remove or drag to reorder">
|
<div class="active-tile-chip" data-idx="${idx}" draggable="true" title="Tap to remove or drag to reorder">
|
||||||
<span>${tile.text}</span>
|
<span class="chip-text">${tile.text}</span>
|
||||||
<span class="remove-icon">✕</span>
|
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
)
|
)
|
||||||
@@ -31,15 +32,13 @@ export function createWordBuilder({ onTileRemoved, onTilesReordered, onSubmitWor
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="builder-actions">
|
<div class="builder-actions">
|
||||||
<button class="btn-icon-tray" id="btn-builder-clear" title="Clear all tiles" ${!hasTiles ? 'style="opacity:0.3;pointer-events:none;"' : ''}>
|
<button class="btn-icon-tray" id="btn-builder-backspace" title="Remove last tile" ${!hasTiles ? 'style="opacity:0.25;pointer-events:none;"' : ''}>
|
||||||
✕
|
|
||||||
</button>
|
|
||||||
<button class="btn-icon-tray" id="btn-builder-backspace" title="Remove last tile" ${!hasTiles ? 'style="opacity:0.3;pointer-events:none;"' : ''}>
|
|
||||||
⌫
|
⌫
|
||||||
</button>
|
</button>
|
||||||
<button class="btn-submit-tray" id="btn-builder-submit" ${!hasTiles ? 'disabled' : ''}>
|
<button class="btn-submit-tray" id="btn-builder-submit" ${!hasTiles ? 'disabled' : ''} title="Submit word (Enter)">
|
||||||
<span>✓</span>
|
<span class="submit-icon">✓</span>
|
||||||
<span>ENTER</span>
|
<span class="submit-text">ENTER</span>
|
||||||
|
${hasTiles ? `<span class="submit-pts">+${pts}</span>` : ''}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -45,24 +45,23 @@
|
|||||||
.active-tiles-container {
|
.active-tiles-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 6px;
|
gap: 5px;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 48px;
|
min-width: 0;
|
||||||
overflow-x: auto;
|
min-height: 44px;
|
||||||
scrollbar-width: none;
|
overflow: visible;
|
||||||
padding: 2px 4px;
|
padding: 2px 2px;
|
||||||
}
|
|
||||||
|
|
||||||
.active-tiles-container::-webkit-scrollbar {
|
|
||||||
display: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.builder-placeholder {
|
.builder-placeholder {
|
||||||
color: var(--text-tertiary);
|
color: var(--text-tertiary);
|
||||||
font-size: 0.92rem;
|
font-size: 0.9rem;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
letter-spacing: -0.01em;
|
letter-spacing: -0.01em;
|
||||||
padding-left: 8px;
|
padding-left: 6px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Active Tile Chip */
|
/* Active Tile Chip */
|
||||||
@@ -70,19 +69,23 @@
|
|||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 8px 14px;
|
padding: 6px 10px;
|
||||||
background: var(--tile-bg);
|
background: var(--tile-bg);
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
border: 1.5px solid var(--tile-border);
|
border: 1.5px solid var(--tile-border);
|
||||||
border-radius: var(--radius-md);
|
border-radius: var(--radius-md);
|
||||||
font-size: 1.12rem;
|
font-size: 1.02rem;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
letter-spacing: 0.03em;
|
letter-spacing: 0.02em;
|
||||||
box-shadow: var(--tile-shadow);
|
box-shadow: var(--tile-shadow);
|
||||||
cursor: grab;
|
cursor: grab;
|
||||||
position: relative;
|
position: relative;
|
||||||
transition: transform var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
|
transition: transform var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
|
||||||
animation: chipInsert 0.22s var(--ease-spring);
|
animation: chipInsert 0.22s var(--ease-spring);
|
||||||
|
flex: 0 1 auto;
|
||||||
|
min-width: 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.active-tile-chip:active {
|
.active-tile-chip:active {
|
||||||
@@ -100,13 +103,6 @@
|
|||||||
transform: scale(1.06);
|
transform: scale(1.06);
|
||||||
}
|
}
|
||||||
|
|
||||||
.active-tile-chip .remove-icon {
|
|
||||||
margin-left: 6px;
|
|
||||||
font-size: 0.75rem;
|
|
||||||
color: var(--text-tertiary);
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes chipInsert {
|
@keyframes chipInsert {
|
||||||
0% { transform: scale(0.7) translateY(8px); opacity: 0; }
|
0% { transform: scale(0.7) translateY(8px); opacity: 0; }
|
||||||
100% { transform: scale(1) translateY(0); opacity: 1; }
|
100% { transform: scale(1) translateY(0); opacity: 1; }
|
||||||
@@ -116,22 +112,24 @@
|
|||||||
.builder-actions {
|
.builder-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 6px;
|
gap: 5px;
|
||||||
margin-left: 6px;
|
margin-left: 6px;
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-icon-tray {
|
.btn-icon-tray {
|
||||||
width: 40px;
|
width: 36px;
|
||||||
height: 40px;
|
height: 36px;
|
||||||
border-radius: var(--radius-md);
|
border-radius: var(--radius-md);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
background: var(--bg-tertiary);
|
background: var(--bg-tertiary);
|
||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
font-size: 1.1rem;
|
font-size: 1.05rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
transition: all var(--transition-fast);
|
transition: all var(--transition-fast);
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-icon-tray:hover {
|
.btn-icon-tray:hover {
|
||||||
@@ -145,19 +143,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.btn-submit-tray {
|
.btn-submit-tray {
|
||||||
height: 40px;
|
height: 36px;
|
||||||
padding: 0 16px;
|
padding: 0 12px;
|
||||||
border-radius: var(--radius-md);
|
border-radius: var(--radius-md);
|
||||||
background: var(--accent-submit-gradient);
|
background: var(--accent-submit-gradient);
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
font-size: 0.95rem;
|
font-size: 0.88rem;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
letter-spacing: 0.02em;
|
letter-spacing: 0.02em;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 6px;
|
gap: 5px;
|
||||||
box-shadow: 0 2px 8px var(--accent-submit-glow);
|
box-shadow: 0 2px 8px var(--accent-submit-glow);
|
||||||
transition: all var(--transition-fast);
|
transition: all var(--transition-fast);
|
||||||
|
flex-shrink: 0;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-submit-tray:hover {
|
.btn-submit-tray:hover {
|
||||||
@@ -176,6 +176,58 @@
|
|||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.submit-pts {
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 0.72rem;
|
||||||
|
background: rgba(255, 255, 255, 0.28);
|
||||||
|
padding: 1px 5px;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-weight: 800;
|
||||||
|
margin-left: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 420px) {
|
||||||
|
.word-builder {
|
||||||
|
padding: 3px 6px;
|
||||||
|
min-height: 48px;
|
||||||
|
}
|
||||||
|
.active-tiles-container {
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
.active-tile-chip {
|
||||||
|
padding: 5px 6px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
}
|
||||||
|
.builder-actions {
|
||||||
|
gap: 4px;
|
||||||
|
margin-left: 4px;
|
||||||
|
}
|
||||||
|
.btn-icon-tray {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
.btn-submit-tray {
|
||||||
|
height: 32px;
|
||||||
|
padding: 0 8px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
.submit-pts {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 350px) {
|
||||||
|
.active-tile-chip {
|
||||||
|
padding: 4px 4px;
|
||||||
|
font-size: 0.82rem;
|
||||||
|
}
|
||||||
|
.btn-submit-tray .submit-text {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* ==========================================================================
|
/* ==========================================================================
|
||||||
THE 4x5 BOARD GRID (20 TILES)
|
THE 4x5 BOARD GRID (20 TILES)
|
||||||
========================================================================== */
|
========================================================================== */
|
||||||
|
|||||||
Reference in New Issue
Block a user