Spaces:
Running on Zero
Running on Zero
Keep layer controls compact on mobile and improve filter contrast
Browse files- style.css +11 -0
- token_space.js +10 -3
style.css
CHANGED
|
@@ -138,3 +138,14 @@ header p { font: 18px/1.6 Georgia, serif; color: #777; }
|
|
| 138 |
.attention-layer > .attention-meta { border-left:3px solid; padding-left:8px; }
|
| 139 |
.space-edge-tooltip { position:fixed; z-index:9; max-width:260px; padding:8px 10px; border:1px solid #78949d66; border-radius:7px; background:#07121ff5; color:#e2edf0; font:12px/1.5 system-ui,sans-serif; pointer-events:none; }
|
| 140 |
.space-edge-tooltip[hidden] { display:none !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
.attention-layer > .attention-meta { border-left:3px solid; padding-left:8px; }
|
| 139 |
.space-edge-tooltip { position:fixed; z-index:9; max-width:260px; padding:8px 10px; border:1px solid #78949d66; border-radius:7px; background:#07121ff5; color:#e2edf0; font:12px/1.5 system-ui,sans-serif; pointer-events:none; }
|
| 140 |
.space-edge-tooltip[hidden] { display:none !important; }
|
| 141 |
+
|
| 142 |
+
.layer-controls label,.layer-controls label > span { color:#bacdd4 !important; }
|
| 143 |
+
.layer-settings > summary { cursor:pointer; color:#f4bf67 !important; font:600 12px/1.5 system-ui,sans-serif; margin:10px 0; }
|
| 144 |
+
.layer-caption-mobile { display:none; }
|
| 145 |
+
.layer-controls input[type="range"] { appearance:none; height:20px; padding:0 !important; border:0 !important; background:transparent !important; box-shadow:none !important; }
|
| 146 |
+
.layer-controls input[type="range"]::-webkit-slider-runnable-track { height:5px; border-radius:4px; background:#354654; }
|
| 147 |
+
.layer-controls input[type="range"]::-webkit-slider-thumb { appearance:none; width:14px; height:14px; margin-top:-4.5px; border:0; border-radius:50%; background:#f4bf67; cursor:ew-resize; }
|
| 148 |
+
.layer-controls input[type="range"]::-moz-range-track { height:5px; border-radius:4px; background:#354654; }
|
| 149 |
+
.layer-controls input[type="range"]::-moz-range-thumb { width:14px; height:14px; border:0; border-radius:50%; background:#f4bf67; }
|
| 150 |
+
.layer-controls input[type="range"]:focus-visible { outline:2px solid #f4bf67; outline-offset:3px; }
|
| 151 |
+
@media(max-width:640px) { .space-detail { max-height:max(160px,min(40dvh,calc(100dvh - 440px))); } .layer-caption-desktop { display:none; } .layer-caption-mobile { display:inline; } }
|
token_space.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
| 8 |
let lastText='';
|
| 9 |
let layerCount=0,layerRows=new Map(),layerTargets=new Map();
|
| 10 |
let layerMode='three',layerLimit=3,minimumWeight=.01,hiddenLayers=new Set(),legendFocus=null;
|
| 11 |
-
let edgeHits=[],hoverEdge=null;
|
| 12 |
let paused=false, previousMode='live';
|
| 13 |
let textView=null,externalSelected=null,reader=null,readerSignature='',lastHighlighted=null;
|
| 14 |
let running=false,awaitingGPU=false,ended=false,togglePending=false,toggleButton=null;
|
|
@@ -176,8 +176,11 @@
|
|
| 176 |
ui.hidden=!layerRows.has(point.n);
|
| 177 |
const controlKey=JSON.stringify([layerMode,layerLimit,available.map(row=>row.layer),[...hiddenLayers]]);
|
| 178 |
if(!ui.hidden&&ui.dataset.controlKey!==controlKey){
|
|
|
|
| 179 |
ui.replaceChildren();ui.dataset.controlKey=controlKey;
|
| 180 |
-
const
|
|
|
|
|
|
|
| 181 |
function select(label,choices,value,change){
|
| 182 |
const field=add(controls,'label','',label),input=add(field,'select','');
|
| 183 |
for(const [key,text] of choices){const option=add(input,'option','',text);option.value=key;}
|
|
@@ -190,7 +193,9 @@
|
|
| 190 |
slider.setAttribute('aria-label','Minimum attention weight');
|
| 191 |
slider.addEventListener('input',event=>{minimumWeight=Number(event.target.value)/100;readout.textContent=`${Math.round(minimumWeight*100)}%`;});
|
| 192 |
slider.addEventListener('change',()=>details());
|
| 193 |
-
add(ui,'p','layer-caption'
|
|
|
|
|
|
|
| 194 |
const legend=add(ui,'div','layer-legend');
|
| 195 |
for(const row of available){
|
| 196 |
const button=add(legend,'button','layer-chip',`L${row.layer}`);button.type='button';
|
|
@@ -243,6 +248,8 @@
|
|
| 243 |
if(resize)resize.disconnect();
|
| 244 |
resize=new ResizeObserver(()=>{
|
| 245 |
const r=canvas.getBoundingClientRect();width=r.width;height=r.height;
|
|
|
|
|
|
|
| 246 |
const dpr=Math.min(window.devicePixelRatio||1,2);
|
| 247 |
canvas.width=Math.round(width*dpr);canvas.height=Math.round(height*dpr);ctx.setTransform(dpr,0,0,dpr,0,0);
|
| 248 |
});resize.observe(canvas);
|
|
|
|
| 8 |
let lastText='';
|
| 9 |
let layerCount=0,layerRows=new Map(),layerTargets=new Map();
|
| 10 |
let layerMode='three',layerLimit=3,minimumWeight=.01,hiddenLayers=new Set(),legendFocus=null;
|
| 11 |
+
let edgeHits=[],hoverEdge=null,lastNarrow=null;
|
| 12 |
let paused=false, previousMode='live';
|
| 13 |
let textView=null,externalSelected=null,reader=null,readerSignature='',lastHighlighted=null;
|
| 14 |
let running=false,awaitingGPU=false,ended=false,togglePending=false,toggleButton=null;
|
|
|
|
| 176 |
ui.hidden=!layerRows.has(point.n);
|
| 177 |
const controlKey=JSON.stringify([layerMode,layerLimit,available.map(row=>row.layer),[...hiddenLayers]]);
|
| 178 |
if(!ui.hidden&&ui.dataset.controlKey!==controlKey){
|
| 179 |
+
const settingsOpen=ui.querySelector('.layer-settings')?.open??(window.innerWidth>640);
|
| 180 |
ui.replaceChildren();ui.dataset.controlKey=controlKey;
|
| 181 |
+
const settings=add(ui,'details','layer-settings');settings.open=settingsOpen;
|
| 182 |
+
add(settings,'summary','','Layers & filtering');
|
| 183 |
+
const controls=add(settings,'div','layer-controls');
|
| 184 |
function select(label,choices,value,change){
|
| 185 |
const field=add(controls,'label','',label),input=add(field,'select','');
|
| 186 |
for(const [key,text] of choices){const option=add(input,'option','',text);option.value=key;}
|
|
|
|
| 193 |
slider.setAttribute('aria-label','Minimum attention weight');
|
| 194 |
slider.addEventListener('input',event=>{minimumWeight=Number(event.target.value)/100;readout.textContent=`${Math.round(minimumWeight*100)}%`;});
|
| 195 |
slider.addEventListener('change',()=>details());
|
| 196 |
+
const caption=add(ui,'p','layer-caption');
|
| 197 |
+
add(caption,'span','layer-caption-desktop','Colour = layer. Thickness = weight. Click a colour to hide it; Shift-click to isolate it. Hover a colour to highlight it.');
|
| 198 |
+
add(caption,'span','layer-caption-mobile','Tap a layer colour to hide/show it.');
|
| 199 |
const legend=add(ui,'div','layer-legend');
|
| 200 |
for(const row of available){
|
| 201 |
const button=add(legend,'button','layer-chip',`L${row.layer}`);button.type='button';
|
|
|
|
| 248 |
if(resize)resize.disconnect();
|
| 249 |
resize=new ResizeObserver(()=>{
|
| 250 |
const r=canvas.getBoundingClientRect();width=r.width;height=r.height;
|
| 251 |
+
const narrow=window.innerWidth<=640;
|
| 252 |
+
if(narrow!==lastNarrow){const settings=root.querySelector('.layer-settings');if(settings)settings.open=!narrow;lastNarrow=narrow;}
|
| 253 |
const dpr=Math.min(window.devicePixelRatio||1,2);
|
| 254 |
canvas.width=Math.round(width*dpr);canvas.height=Math.round(height*dpr);ctx.setTransform(dpr,0,0,dpr,0,0);
|
| 255 |
});resize.observe(canvas);
|