Стартовый контент kb-seed и макеты new_design
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script src="./support.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<x-dc>
|
||||
<div style="position:absolute;inset:0;z-index:50;background:#000000;color:#FFFFFF;display:flex;flex-direction:column;font-family:'Golos Text',system-ui,sans-serif">
|
||||
<div style="flex:none;display:flex;align-items:center;gap:10px;padding:8px 8px 8px 16px;min-height:68px">
|
||||
<div style="flex:1;min-width:0;display:flex;flex-direction:column;gap:2px"><div style="font-family:'JetBrains Mono',monospace;font-size:13px;color:#BDBDBD">{{ counter }}</div><div style="font-size:16px;font-weight:600;line-height:1.3">{{ cap }}</div></div>
|
||||
<button onClick="{{ close }}" aria-label="Закрыть" style="flex:none;width:52px;height:52px;border-radius:12px;border:1px solid #444;background:#1A1A1A;color:#FFFFFF;font-size:22px;cursor:pointer">✕</button>
|
||||
</div>
|
||||
<div onPointerDown="{{ down }}" onPointerMove="{{ move }}" onPointerUp="{{ up }}" onPointerCancel="{{ up }}" onWheel="{{ wheel }}" onDoubleClick="{{ dbl }}" style="flex:1;min-height:0;position:relative;overflow:hidden;touch-action:none;display:flex;align-items:center;justify-content:center;cursor:grab;user-select:none">
|
||||
<sc-if value="{{ has }}"><img src="{{ src }}" draggable="false" alt="{{ cap }}" style="{{ imgStyle }}"></sc-if>
|
||||
<sc-if value="{{ miss }}"><div style="{{ phStyle }}">фото · {{ file }}</div></sc-if>
|
||||
</div>
|
||||
<div style="flex:none;display:flex;flex-direction:column;gap:8px;padding:10px 12px 22px">
|
||||
<div style="display:grid;grid-template-columns:56px 1fr 56px 72px 56px 1fr 56px;gap:6px;align-items:center">
|
||||
<button onClick="{{ prev }}" aria-label="Предыдущее" style="height:52px;border-radius:12px;border:1px solid #444;background:#1A1A1A;color:#FFFFFF;font-size:22px;cursor:pointer">‹</button>
|
||||
<span></span>
|
||||
<button onClick="{{ zoomOut }}" aria-label="Уменьшить" style="height:52px;border-radius:12px;border:1px solid #444;background:#1A1A1A;color:#FFFFFF;font-size:24px;cursor:pointer">−</button>
|
||||
<button onClick="{{ reset }}" style="height:52px;border-radius:12px;border:1px solid #444;background:#1A1A1A;color:#FFFFFF;font-family:'JetBrains Mono',monospace;font-size:15px;font-weight:700;cursor:pointer">{{ zoomLabel }}</button>
|
||||
<button onClick="{{ zoomIn }}" aria-label="Увеличить" style="height:52px;border-radius:12px;border:1px solid #444;background:#1A1A1A;color:#FFFFFF;font-size:24px;cursor:pointer">+</button>
|
||||
<span></span>
|
||||
<button onClick="{{ next }}" aria-label="Следующее" style="height:52px;border-radius:12px;border:1px solid #444;background:#1A1A1A;color:#FFFFFF;font-size:22px;cursor:pointer">›</button>
|
||||
</div>
|
||||
<div style="text-align:center;font-size:13px;color:#A8A8A8">Щипок или двойной тап: зум · свайп: листать</div>
|
||||
</div>
|
||||
</div>
|
||||
</x-dc>
|
||||
<script type="text/x-dc" data-dc-script data-props="{"$preview":{"width":390,"height":800},"figs":{"editor":null,"tsType":"{src:string,cap:string,has:boolean,file:string}[]"},"start":{"editor":"int","default":0,"tsType":"number"},"onClose":{"editor":null,"tsType":"()=>void"}}">
|
||||
class Component extends DCLogic{
|
||||
state={i:null,z:1,x:0,y:0,drag:false};
|
||||
P=new Map();
|
||||
cur(){const f=this.props.figs||[];const i=this.state.i??this.props.start??0;return{f,i:Math.min(i,Math.max(0,f.length-1))}}
|
||||
go(d){const{f,i}=this.cur();if(!f.length)return;this.setState({i:(i+d+f.length)%f.length,z:1,x:0,y:0})}
|
||||
zoom(z){z=Math.max(1,Math.min(5,z));this.setState(z===1?{z,x:0,y:0}:{z})}
|
||||
down=e=>{try{e.currentTarget.setPointerCapture(e.pointerId)}catch(_){}this.P.set(e.pointerId,{x:e.clientX,y:e.clientY});
|
||||
if(this.P.size===1){this.sx=e.clientX;this.swipe=this.state.z===1}else this.swipe=false;this.setState({drag:true})};
|
||||
move=e=>{if(!this.P.has(e.pointerId))return;const ids=[...this.P.keys()];const prev=ids.map(k=>this.P.get(k));
|
||||
this.P.set(e.pointerId,{x:e.clientX,y:e.clientY});const cur=ids.map(k=>this.P.get(k));
|
||||
if(cur.length===1){if(this.state.z>1){const dx=cur[0].x-prev[0].x,dy=cur[0].y-prev[0].y;this.setState(s=>({x:s.x+dx,y:s.y+dy}))}}
|
||||
else{const d=(a,b)=>Math.hypot(a.x-b.x,a.y-b.y);const r=d(cur[0],cur[1])/(d(prev[0],prev[1])||1);
|
||||
const mx=(cur[0].x+cur[1].x-prev[0].x-prev[1].x)/2,my=(cur[0].y+cur[1].y-prev[0].y-prev[1].y)/2;
|
||||
this.setState(s=>{const z=Math.max(1,Math.min(5,s.z*r));return z===1?{z,x:0,y:0}:{z,x:s.x+mx,y:s.y+my}})}};
|
||||
up=e=>{this.P.delete(e.pointerId);if(this.P.size===0){if(this.swipe){const dx=e.clientX-this.sx;if(Math.abs(dx)>60)this.go(dx<0?1:-1)}this.setState({drag:false})}};
|
||||
wheel=e=>this.zoom(this.state.z*(e.deltaY<0?1.15:1/1.15));
|
||||
dbl=()=>this.state.z>1?this.zoom(1):this.zoom(2.5);
|
||||
renderVals(){
|
||||
const{f,i}=this.cur();const it=f[i]||{};const{z,x,y,drag}=this.state;
|
||||
return{counter:f.length?`${i+1} / ${f.length}`:'',cap:it.cap||'',src:it.src,has:!!it.has,miss:!it.has,file:it.file||'',
|
||||
imgStyle:{maxWidth:'100%',maxHeight:'100%',transform:`translate(${x}px,${y}px) scale(${z})`,transition:drag?'none':'transform .15s ease-out',pointerEvents:'none'},
|
||||
phStyle:{width:'86%',aspectRatio:'4 / 3',display:'flex',alignItems:'center',justifyContent:'center',background:'repeating-linear-gradient(135deg,#1A1A1A 0 14px,#262626 14px 28px)',fontFamily:"'JetBrains Mono',monospace",fontSize:'14px',color:'#BDBDBD',transform:`translate(${x}px,${y}px) scale(${z})`,transition:drag?'none':'transform .15s'},
|
||||
zoomLabel:Math.round(z*100)+'%',close:()=>this.props.onClose&&this.props.onClose(),
|
||||
prev:()=>this.go(-1),next:()=>this.go(1),zoomIn:()=>this.zoom(z*1.5),zoomOut:()=>this.zoom(z/1.5),reset:()=>this.zoom(1),
|
||||
down:this.down,move:this.move,up:this.up,wheel:this.wheel,dbl:this.dbl};
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user