responsivelint 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +171 -2
- package/agents/skills/responsivelint/SKILL.md +44 -0
- package/agents/skills/responsivelint-fix/SKILL.md +38 -0
- package/agents/skills/responsivelint-fix-controls/SKILL.md +35 -0
- package/agents/skills/responsivelint-fix-cramped-text/SKILL.md +47 -0
- package/agents/skills/responsivelint-fix-overflow/SKILL.md +33 -0
- package/agents/skills/responsivelint-fix-overlap/SKILL.md +33 -0
- package/bin/responsivelint.mjs +74 -0
- package/dist/core.iife.js +773 -0
- package/dist/responsivelint.js +838 -0
- package/dist/responsivelint.min.js +3 -0
- package/docs/rules/clipped-text.md +21 -0
- package/docs/rules/disappears-in-band.md +21 -0
- package/docs/rules/hidden-control.md +21 -0
- package/docs/rules/page-overflow.md +21 -0
- package/docs/rules/squashed-text.md +21 -0
- package/docs/rules/text-overlap.md +21 -0
- package/docs/rules/width-outlier.md +21 -0
- package/llms.txt +42 -0
- package/package.json +43 -4
- package/src/browser/entry.js +138 -0
- package/src/cli/report.js +90 -0
- package/src/cli/run.js +177 -0
- package/src/cli/server.js +24 -0
- package/src/core/analyze.js +265 -0
- package/src/core/dom.js +122 -0
- package/src/core/index.js +3 -0
- package/src/core/inject.js +4 -0
- package/src/core/measure.js +241 -0
- package/src/explore/page.js +63 -0
- package/src/icons/measure.js +106 -0
- package/src/index.js +4 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
(()=>{var R=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","TITLE","OPTION","HEAD","META","LINK"]),F=["button","a[href]","summary","select","textarea","input:not([type=hidden])","[role=button]","[role=tab]","[role=link]","[role=menuitem]","[role=switch]","[role=checkbox]","[role=option]",'[tabindex]:not([tabindex="-1"])'].join(",");function k(l){let n=[];for(let s=l;s&&s.nodeType===1&&s!==document.body&&s!==document.documentElement;s=s.parentElement){if(s.id&&/^[A-Za-z][\w-]*$/.test(s.id))return n.unshift("#"+s.id),n.join(">");let u=s.parentElement,c=u?Array.prototype.indexOf.call(u.children,s)+1:1;n.unshift(s.tagName.toLowerCase()+":nth-child("+c+")")}return n.unshift("body"),n.join(">")}function E(l){let n=new Set;for(let s=l;s&&s.nodeType===1;s=s.parentElement){let u=s.getAttribute&&s.getAttribute("data-rl-ignore");u!=null&&(u===""||u==="all"?n.add("all"):u.split(/[\s,]+/).forEach(c=>n.add(c)))}return n}function I(){let l=new Map,n=new Map,s=new Map,u=new Map,c=t=>{let i=l.get(t);return i||(i=getComputedStyle(t),l.set(t,i)),i};function a(t){if(!t||t.nodeType!==1)return 1;if(n.has(t))return n.get(t);let i=parseFloat(c(t).opacity||"1")*a(t.parentElement);return n.set(t,i),i}function h(t){if(!t||t.nodeType!==1)return!1;if(u.has(t))return u.get(t);let i=c(t).position,p=i==="fixed"||i==="sticky"||h(t.parentElement);return u.set(t,p),p}function m(t){if(!t||t.nodeType!==1||t===document.documentElement)return{left:-1e9,top:-1e9,right:1e9,bottom:1e9};if(s.has(t))return s.get(t);let i=m(t.parentElement),p=c(t),g=i;if(t!==document.body&&(p.overflowX!=="visible"||p.overflowY!=="visible")){let d=t.getBoundingClientRect(),e={left:d.left+scrollX+t.clientLeft,top:d.top+scrollY+t.clientTop};e.right=e.left+t.clientWidth,e.bottom=e.top+t.clientHeight,g={left:p.overflowX==="visible"?i.left:Math.max(i.left,e.left),right:p.overflowX==="visible"?i.right:Math.min(i.right,e.right),top:p.overflowY==="visible"?i.top:Math.max(i.top,e.top),bottom:p.overflowY==="visible"?i.bottom:Math.min(i.bottom,e.bottom)}}return p.position==="fixed"&&(g={left:-1e9,top:-1e9,right:1e9,bottom:1e9}),s.set(t,g),g}function w(t){for(let p=t;p&&p.nodeType===1;p=p.parentElement)if(p.getAttribute("aria-hidden")==="true"||p.hasAttribute("inert")||p.hidden)return!0;let i=c(t);return i.visibility!=="visible"||i.display==="none"||i.contentVisibility==="hidden"}return{cs:c,effectiveOpacity:a,isPinned:h,clipRect:m,hidden:w}}var L=(l,n)=>({left:Math.max(l.left,n.left),top:Math.max(l.top,n.top),right:Math.min(l.right,n.right),bottom:Math.min(l.bottom,n.bottom)}),T=l=>Math.max(0,l.right-l.left)*Math.max(0,l.bottom-l.top);function O(l,n){let s=[],u="",c=n.clipRect(l);for(let a of l.childNodes){if(a.nodeType!==3||!a.textContent.trim())continue;u+=a.textContent;let h=document.createRange();h.selectNodeContents(a);for(let m of h.getClientRects()){if(m.width<1||m.height<1)continue;let w={left:m.left+scrollX,top:m.top+scrollY,right:m.right+scrollX,bottom:m.bottom+scrollY},t=L(w,c);T(t)>0&&s.push(t)}}return{text:u.replace(/\s+/g," ").trim(),rects:s}}function q(l){let n=l.map(c=>(c.top+c.bottom)/2).sort((c,a)=>c-a),s=0,u=-1e9;for(let c of n)c-u>3&&(s++,u=c);return s}function M(l,n){return(l.getAttribute("aria-label")||n||l.getAttribute("title")||l.getAttribute("alt")||"").replace(/\s+/g," ").trim().slice(0,60)}var P=4e3,N=2500;function C(){let l=globalThis,n=[];l.__THREE__&&n.push("three.js r"+l.__THREE__),l.AFRAME&&n.push("A-Frame "+(l.AFRAME.version||"")),l.BABYLON&&n.push("Babylon.js "+(l.BABYLON.Engine?.Version||"")),l.pc&&l.pc.version&&n.push("PlayCanvas "+l.pc.version),[...document.querySelectorAll("canvas")].some(c=>c.__r3f||c.parentElement?.__r3f)&&n.push("React Three Fiber");let s=l.__rlContexts||{},u=document.querySelectorAll("canvas").length;return{frameworks:n.map(c=>c.trim()),webgl:(s.webgl||0)+(s.webgl2||0),webgpu:s.webgpu||0,canvases:u,xr:!!l.__rlXR||!!navigator.xr&&n.length>0,is3D:n.length>0||(s.webgl||0)+(s.webgl2||0)+(s.webgpu||0)>0}}function $(l={}){let n=null;l.revealSkipped&&(n=document.createElement("style"),n.textContent="*{content-visibility:visible!important}",document.head.append(n));try{return K(l)}finally{n?.remove()}}function K(l){let n=I(),s={width:innerWidth,height:innerHeight},u=[],c=e=>u.push(e),a=[],h=[],m=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT);for(let e=m.currentNode;e&&!(a.length>=P);e=m.nextNode()){if(!(e instanceof HTMLElement)||R.has(e.tagName)||e.closest("[data-rl-overlay]"))continue;let{text:o,rects:r}=O(e,n);if(!o||!r.length||n.hidden(e)||n.effectiveOpacity(e)<.05||!l.revealSkipped&&e.checkVisibility&&!e.checkVisibility({contentVisibilityAuto:!0}))continue;let f=e.getBoundingClientRect();if(f.width<=2||f.height<=2)continue;let x=E(e);a.push({el:e,key:k(e),text:o,rects:r,ignore:x,pinned:n.isPinned(e)})}let w=[];a.forEach((e,o)=>e.rects.forEach(r=>w.push({i:o,r}))),w.sort((e,o)=>e.r.top-o.r.top);let t=new Set,i=[],p=0;for(let e=0;e<w.length;e++){let o=w[e];for(;p<e&&w[p].r.bottom<=o.r.top;)p++;for(let r=p;r<e;r++){let f=w[r];if(o.i===f.i||f.r.bottom<=o.r.top)continue;let x=a[o.i],b=a[f.i];if(x.pinned!==b.pinned||x.el.contains(b.el)||b.el.contains(x.el)||x.ignore.has("all")||x.ignore.has("text-overlap")||b.ignore.has("all")||b.ignore.has("text-overlap"))continue;let y=L(o.r,f.r),v=Math.min(T(o.r),T(f.r)),A=Math.min(o.r.bottom-o.r.top,f.r.bottom-f.r.top);if(T(y)<.25*v||y.bottom-y.top<.4*A)continue;let X=o.i<f.i?o.i+":"+f.i:f.i+":"+o.i;t.has(X)||(t.add(X),i.push({ta:x,tb:b,cut:y,share:Math.round(100*T(y)/v)}))}}for(let e of V(i)){let{ta:o,tb:r,cut:f,share:x,top:b}=e;c({rule:"text-overlap",keys:[o.key,r.key].sort(),elements:[{key:o.key,text:o.text.slice(0,60)},{key:r.key,text:r.text.slice(0,60)}],rect:f,onTop:b,measured:{overlap:x+"% of the smaller line",...b?{onTop:b.summary}:{}}})}for(let e of a){let o=e.text.split(/\s+/).filter(Boolean).length,r=q(e.rects);if(h.length<N&&e.text.length>=6){let f=Math.min(...e.rects.map(v=>v.left)),x=Math.max(...e.rects.map(v=>v.right)),b=Math.min(...e.rects.map(v=>v.top)),y=Math.max(...e.rects.map(v=>v.bottom));h.push({key:e.key,kind:"text",text:e.text.slice(0,60),words:o,lines:r,w:Math.round(x-f),rect:{left:f,top:b,right:x,bottom:y}})}if(!(e.ignore.has("all")||e.ignore.has("squashed-text"))&&o>=3&&r>=3&&o/r<=1.25&&e.text.length>=15){let f=Math.min(...e.rects.map(v=>v.left)),x=Math.max(...e.rects.map(v=>v.right)),b=Math.min(...e.rects.map(v=>v.top)),y=Math.max(...e.rects.map(v=>v.bottom));c({rule:"squashed-text",keys:[e.key],elements:[{key:e.key,text:e.text.slice(0,60)}],rect:{left:f,top:b,right:x,bottom:y},measured:{width:Math.round(x-f),lines:r,words:o}})}}let g=new Set;for(let e of a)for(let o=e.el;o&&o!==document.body;o=o.parentElement){let r=n.cs(o),f=r.overflowX==="hidden"||r.overflowX==="clip",x=r.overflowY==="hidden"||r.overflowY==="clip";if(!f&&!x)continue;if(g.has(o)||(g.add(o),o.clientWidth<2||o.clientHeight<2||n.hidden(o))||r.webkitLineClamp&&r.webkitLineClamp!=="none"||!(f&&o.scrollWidth>o.clientWidth+2||x&&o.scrollHeight>o.clientHeight+2))break;let y=o.getBoundingClientRect(),v={left:y.left+scrollX,top:y.top+scrollY,right:y.left+scrollX+o.clientWidth,bottom:y.top+scrollY+o.clientHeight},A=E(o);!A.has("all")&&!A.has("clipped-text")&&c({rule:"clipped-text",keys:[k(o)],elements:[{key:k(o),text:M(o,e.text)}],rect:v,ellipsis:r.textOverflow==="ellipsis",measured:{contentWidth:o.scrollWidth,boxWidth:o.clientWidth,contentHeight:o.scrollHeight,boxHeight:o.clientHeight}});break}let d=document.documentElement.scrollWidth;if(d>s.width+1&&!E(document.body).has("page-overflow")){let e=[],o=document.body.querySelectorAll("*");for(let r of o){if(e.length>=5)break;if(!(r instanceof HTMLElement)||R.has(r.tagName)||n.hidden(r))continue;let f=r.getBoundingClientRect();f.right+scrollX<=s.width+1||f.width===0||n.clipRect(r.parentElement).right<=s.width+1||r.parentElement.getBoundingClientRect().right+scrollX>s.width+1&&r.parentElement!==document.body||e.push({key:k(r),text:M(r,(r.textContent||"").trim())||r.tagName.toLowerCase(),right:Math.round(f.right+scrollX)})}c({rule:"page-overflow",keys:e.map(r=>r.key).sort().slice(0,1),elements:e,rect:null,measured:{pageWidth:d,viewport:s.width,by:d-s.width}})}for(let e of document.body.querySelectorAll(F)){if(!(e instanceof HTMLElement)||e.closest("[data-rl-overlay]"))continue;let o=n.cs(e);if(o.display==="none"||e.disabled||e.closest("[aria-hidden=true],[inert],[hidden]"))continue;let r=e.getBoundingClientRect();if(r.width<4||r.height<4)continue;let f={left:r.left+scrollX,top:r.top+scrollY,right:r.right+scrollX,bottom:r.bottom+scrollY};if(T(L(f,n.clipRect(e.parentElement)))<4)continue;let x=n.effectiveOpacity(e),b=x<.1&&o.visibility==="visible"&&o.pointerEvents!=="none";if(h.length<N+500&&h.push({key:k(e),kind:"control",text:M(e,(e.textContent||"").trim()),visible:!b,rect:f}),!b||e.matches("input[type=checkbox],input[type=radio],input[type=file],input[type=range]")&&(e.labels?.length||e.closest("label")))continue;let y=E(e);y.has("all")||y.has("hidden-control")||c({rule:"hidden-control",keys:[k(e)],elements:[{key:k(e),text:M(e,(e.textContent||"").trim())||e.tagName.toLowerCase()}],rect:f,measured:{opacity:+x.toFixed(2)}})}return{width:s.width,height:s.height,env:C(),findings:u,measures:h}}function V(l){if(!l.length)return[];let n=document.createElement("style");n.textContent="*{pointer-events:auto!important}",document.head.append(n);let s=scrollX,u=scrollY,c=[];try{for(let a of l){let h=(a.cut.left+a.cut.right)/2,m=(a.cut.top+a.cut.bottom)/2,w=a.ta.pinned&&a.tb.pinned,t=h-scrollX,i=m-scrollY;!w&&(t<0||i<0||t>=innerWidth||i>=innerHeight)&&(window.scrollTo({left:Math.max(0,h-innerWidth/2),top:Math.max(0,m-innerHeight/2),behavior:"instant"}),t=h-scrollX,i=m-scrollY),w&&(t=h-s,i=m-u);let p=document.elementsFromPoint(t,i),g=r=>p.findIndex(f=>f===r||r.contains(f)),d=g(a.ta.el),e=g(a.tb.el);if(d<0&&e<0)continue;let o=d<0?a.tb.el:e<0||d<=e?a.ta.el:a.tb.el;c.push({...a,top:D(o)})}}finally{n.remove(),(scrollX!==s||scrollY!==u)&&window.scrollTo({left:s,top:u,behavior:"instant"})}return c}function D(l){let n=l;for(let a=l;a&&a!==document.body;a=a.parentElement){let h=getComputedStyle(a);if(h.position!=="static"||h.zIndex!=="auto"||h.transform!=="none"){n=a;break}}let s=getComputedStyle(n),u=[s.position!=="static"?"position: "+s.position:"",s.zIndex!=="auto"?"z-index: "+s.zIndex:"",s.transform!=="none"?"transformed":""].filter(Boolean),c=(l.textContent||"").replace(/\s+/g," ").trim().slice(0,40);return{key:k(n),text:c,position:s.position,zIndex:s.zIndex,summary:`"${c}"`+(u.length?" ("+u.join(", ")+")":" (normal flow)")}}var Y="https://github.com/prajwalsouza/ResponsiveLint/blob/main/",W={"responsivelint-fix-overlap":{title:"Fix text drawn over other text",rules:["text-overlap"]},"responsivelint-fix-cramped-text":{title:"Fix text that is squeezed or cut off",rules:["squashed-text","clipped-text","width-outlier"]},"responsivelint-fix-overflow":{title:"Fix a page that scrolls sideways",rules:["page-overflow"]},"responsivelint-fix-controls":{title:"Fix controls that are invisible or go missing",rules:["hidden-control","disappears-in-band"]}},U=l=>{let n=Object.keys(W).find(u=>W[u].rules.includes(l))||"responsivelint-fix",s=`agents/skills/${n}/SKILL.md`;return{name:n,file:s,url:Y+s}},S={"text-overlap":{pack:"text",severity:"error",confidence:"high",title:"Text covers other text",why:"Two pieces of visible text are drawn in the same place, so neither can be read.",tries:["An element with position: absolute or fixed sits on text that wraps at this width: place it with flex or grid instead, or move it off the text. Changing z-index only swaps which text is hidden.","A box has a fixed height, so its text spills out when it wraps: remove height, or use min-height.","A negative margin or a transform pulls one element onto another: remove it at these widths.","A toast, tooltip or badge is placed on a toolbar: place it above or beside the toolbar."]},"squashed-text":{pack:"text",severity:"warning",confidence:"high",title:"Text squeezed to about one word per line",why:"The text has become so narrow that almost every word sits on its own line.",tries:["A neighbour in the same row does not wrap (white-space: nowrap, flex-shrink: 0, an auto grid column full of buttons): let it wrap with flex-wrap: wrap, or put it on its own line with grid-template-columns: 1fr.","The row keeps two columns at a width where one fits better: stack them below this width with a media or container query.","Nothing stops the text from shrinking: give it min-width: 12em (or similar)."]},"clipped-text":{pack:"text",severity:"warning",confidence:"medium",title:"Text cut off by its box",why:"A box with overflow hidden is smaller than the text inside it, so part of the text is not shown.",tries:["The box has a fixed width or height: remove it, or use min-width or min-height, so the box grows with its text.","The text is not allowed to wrap (white-space: nowrap): allow wrapping.","The cut is intended: add text-overflow: ellipsis and a title with the full text, so the finding becomes a note."]},"page-overflow":{pack:"overflow",severity:"error",confidence:"high",title:"The page scrolls sideways",why:"Something is wider than the screen, so the whole page can be dragged sideways.",tries:["The named element has a fixed width in pixels: use max-width: 100%, or a width in % or fr.","A row of controls or a long word or URL does not wrap: add flex-wrap: wrap, or overflow-wrap: anywhere for long words.","A wide table, code block or image: wrap it in a box with overflow-x: auto, or give images max-width: 100%.","Do not hide the problem with overflow-x: hidden on body or html; it cuts content off instead."]},"hidden-control":{pack:"visibility",severity:"warning",confidence:"medium",title:"A control takes space but cannot be seen",why:"A button, link or tab is laid out, clickable and focusable, but fully transparent in its resting state, so people do not know it is there.",tries:["It appears only on hover (opacity: 0 until :hover): show it at rest, perhaps quieter, because touch screens have no hover.","It should stay hidden until something happens: hide it properly with display: none, visibility: hidden or the hidden attribute until then, so it leaves the tab order too.","Keyboard users cannot find it: also show it on :focus-visible and :focus-within."]},"width-outlier":{pack:"sweep",severity:"warning",confidence:"high",title:"Breaks only in a narrow band of widths",why:"This element looks normal at the widths on both sides, but changes sharply inside this band, which is how layout bugs between breakpoints show up.",tries:["One part of the layout switches at a breakpoint before another does (a sidebar appears before the content stacks): line the two media queries up, or switch the content to a container query.","A neighbour stops wrapping inside the band and takes the width: let it wrap, or stack it below this width.","A fixed size takes over inside the band: replace it with min(), max() or clamp()."]},"disappears-in-band":{pack:"sweep",severity:"warning",confidence:"medium",title:"A control disappears in a narrow band of widths",why:"The control is visible at the widths on both sides but not inside this band.",tries:["Two media queries hand over at different widths (one hides the desktop control, the other shows the mobile one a few pixels later): use the same width for both, or one query.","max-width and min-width both use the same number, so one pixel shows neither: use max-width: 767px with min-width: 768px, or a range query.","The control is pushed out of its row and clipped: let the row wrap."]}};for(let l of Object.values(S))l.fix=l.tries[0];function G(l,n){let s=[...new Set(l)].sort((a,h)=>a-h),u=new Map(n.map((a,h)=>[a,h])),c=[];for(let a of s){let h=c[c.length-1];h&&u.get(a)===u.get(h[1])+1?h[1]=a:c.push([a,a])}return c}var B=l=>{let n=[...l].sort((s,u)=>s-u);return n.length?n[Math.floor(n.length/2)]:0};function Z(l,n,s){let u=[];for(let[c,a]of l){let h=n.map(i=>a.get(i));if(h.filter(Boolean).length<5)continue;let m=h.find(Boolean).kind,w=new Array(h.length).fill(!1);for(let i=0;i<h.length;i++){let p=h[i],g=[];for(let d=1;d<=3;d++)h[i-d]&&g.push(h[i-d]),h[i+d]&&g.push(h[i+d]);if(!(g.length<3)){if(m==="text"){if(!p)continue;let d=B(g.map(r=>r.lines)),e=B(g.map(r=>r.words/Math.max(1,r.lines))),o=p.words/Math.max(1,p.lines);w[i]=p.words>=3&&p.lines>=Math.max(3,2*d,d+2)&&o<=.5*e&&o<=2.5}else if(m==="control"){let d=g.filter(e=>e.visible).length;w[i]=(!p||!p.visible)&&d>=g.length-1}}}let t=0;for(;t<h.length;){if(!w[t]){t++;continue}let i=t;for(;i+1<h.length&&w[i+1];)i++;let p=h.slice(0,t).some((e,o)=>e&&!w[o]),g=h.slice(i+1).some((e,o)=>e&&!w[i+1+o]),d=i-t+1<=Math.max(1,Math.floor(.35*h.length));if(p&&g&&d){let e=h[t]||h.slice(t,i+1).find(Boolean),o=h.slice(0,t).reverse().find(Boolean),r=m==="text"?"width-outlier":"disappears-in-band";u.push({rule:r,keys:[c],state:s,widths:n.slice(t,i+1),elements:[{key:c,text:(e||o)?.text||""}],rect:e?.rect||o?.rect,goodWidth:n[n.indexOf(n[t])-1],measured:m==="text"&&e?{lines:e.lines,wordsPerLine:+(e.words/e.lines).toFixed(1)}:{visible:!1},expected:m==="text"&&o?{lines:o.lines,wordsPerLine:+(o.words/Math.max(1,o.lines)).toFixed(1)}:{visible:!0}})}t=i+1}}return u}function _(l,n={}){let s=[...new Set(l.map(t=>t.width))].sort((t,i)=>t-i),u=[];for(let t of l)for(let i of t.findings)u.push({...i,state:t.state,widths:[t.width]});let c=new Map;for(let t of l)c.has(t.state.id)||c.set(t.state.id,{state:t.state,snaps:[]}),c.get(t.state.id).snaps.push(t);for(let{state:t,snaps:i}of c.values()){if(i.length<5)continue;let p=new Map;for(let d of i)for(let e of d.measures)p.has(e.key+"|"+e.kind)||p.set(e.key+"|"+e.kind,new Map),p.get(e.key+"|"+e.kind).set(d.width,e);let g=new Map([...p].map(([d,e])=>[d.split("|")[0],e]));u.push(...Z(g,i.map(d=>d.width).sort((d,e)=>d-e),t))}let a=new Map;for(let t of u){let i=t.rule+"|"+t.keys.join("+");a.has(i)||a.set(i,{...t,widths:[],states:[],instances:[]});let p=a.get(i);p.widths.push(...t.widths),p.states.some(g=>g.id===t.state.id)||p.states.push(t.state),p.instances.push({state:t.state.id,width:t.widths[0],rect:t.rect,measured:t.measured})}Q(a);let h={error:0,warning:1,info:2},m={high:0,medium:1,low:2},w=[];for(let[t,i]of a){let p=S[i.rule];if(n.only&&!n.only.includes(p.pack)&&!n.only.includes(i.rule)||n.skip&&(n.skip.includes(p.pack)||n.skip.includes(i.rule)))continue;let g=p.severity,d=p.confidence;i.rule==="clipped-text"&&i.ellipsis&&(g="info");let e=[...new Set(i.widths)].sort((r,f)=>r-f),o=J(i,p);w.push({id:ee(t),rule:i.rule,pack:p.pack,severity:g,confidence:d,title:p.title,elements:i.elements,widths:e,bands:G(e,s),everyWidth:e.length===s.length,states:i.states.map(r=>r.label),measured:i.measured,expected:i.expected,why:p.why,fix:o[0],tries:o,guide:Y+"docs/rules/"+i.rule+".md",skill:U(i.rule),suppress:`data-rl-ignore="${i.rule}"`,instances:i.instances.slice(0,50),goodWidth:i.goodWidth})}return n.minConfidence&&w.splice(0,w.length,...w.filter(t=>m[t.confidence]<=m[n.minConfidence])),w.sort((t,i)=>h[t.severity]-h[i.severity]||m[t.confidence]-m[i.confidence]||i.widths.length-t.widths.length),{widths:s,findings:w}}function J(l,n){let s=[...n.tries],u=(a,h)=>{let[m]=s.splice(a,1);s.unshift(h||m)},c=l.measured||{};if(l.rule==="text-overlap"){let a=l.onTop;a&&["absolute","fixed","sticky"].includes(a.position)?u(0,`The text on top, ${a.summary}, is taken out of the normal layout: place it with flex or grid instead, or move it so it does not sit on the text. Changing z-index only swaps which text is hidden. (${a.key})`):a&&a.position==="static"&&u(1)}else l.rule==="clipped-text"&&(l.ellipsis?u(2,"The cut is marked with an ellipsis, so it looks intended: make sure a title or tooltip gives the full text."):c.contentWidth>c.boxWidth&&!(c.contentHeight>c.boxHeight)&&u(1));return s}function Q(l){let n=c=>c.includes(">")?c.slice(0,c.lastIndexOf(">")):c,s=new Map;for(let[c,a]of l){if(a.rule!=="text-overlap")continue;let[h,m]=a.keys;for(let[w,t]of[[h,m],[m,h]]){let i=w+"~"+n(t);s.has(i)||s.set(i,[]),s.get(i).push({id:c,shared:w,other:t})}}let u=new Set;for(let[c,a]of[...s].sort((h,m)=>m[1].length-h[1].length)){let h=a.filter(d=>!u.has(d.id)&&l.has(d.id));if(h.length<2)continue;let m=l.get(h[0].id),w=h[0].shared,t=n(h[0].other),i=m.elements.find(d=>d.key===w),p=h.map(d=>l.get(d.id).elements.find(e=>e.key===d.other)?.text).filter(Boolean),g={...m,keys:[w,t],widths:[],states:[],instances:[],elements:[i,{key:t,text:p.join(" \xB7 ").slice(0,60)}]};for(let d of h){let e=l.get(d.id);g.widths.push(...e.widths);for(let o of e.states)g.states.some(r=>r.id===o.id)||g.states.push(o);g.instances.push(...e.instances),l.delete(d.id),u.add(d.id)}l.set("text-overlap|"+w+"+"+t,g)}}function ee(l){let n=2166136261;for(let s=0;s<l.length;s++)n^=l.charCodeAt(s),n=Math.imul(n,16777619);return(n>>>0).toString(36)}var z="responsivelint-frame",j=document.currentScript,H=j?j.dataset:{};if(window.name===z)window.__ResponsiveLintFrame={checkNow:$};else{let l=/^(localhost|127\.0\.0\.1|\[::1\]|.+\.localhost|.+\.test)$/.test(location.hostname)||location.protocol==="file:",n=window.ResponsiveLint=te();if(l||"anywhere"in H){let s=()=>{n.check(),"ui"in H&&n.ui(!0),"sweep"in H&&n.sweep()};document.readyState==="complete"?setTimeout(s,50):addEventListener("load",()=>setTimeout(s,50))}}function te(){let l=new Set,n=new Set,s=[],u=[],c=!1,a=0,h=d=>n.forEach(e=>{try{e(d)}catch{}});function m(d){for(let e of d){if(l.has(e.id))continue;l.add(e.id),h(e);let o=e.severity==="error"?"#e5484d":e.severity==="warning"?"#d08a12":"#888";console.groupCollapsed(`%cResponsiveLint%c ${e.severity==="error"?"\u2716":"\u25B2"} ${e.rule}: ${e.title}`,"font-weight:700",`color:${o}`);for(let r of e.elements)console.log(r.text?`\u201C${r.text}\u201D`:r.key,document.querySelector(r.key)||r.key);console.log("where:",e.bands.map(([r,f])=>r===f?r:`${r}\u2013${f}`).join(", ")+" px",e.states.join(" \xB7 ")),e.measured&&console.log("measured:",e.measured,e.expected?["neighbours:",e.expected]:""),console.log("why:",e.why),console.log(`try:
|
|
2
|
+
`+e.tries.map((r,f)=>`${f+1}. ${r}`).join(`
|
|
3
|
+
`)),console.log("skill:",e.skill.name,e.skill.url),console.log("silence:",e.suppress),console.groupEnd()}}function w(){let d=$(),e=C();return s=_([{state:{id:"live",label:"live page"},width:d.width,findings:d.findings,measures:[]}]).findings,m(s),e.is3D&&!l.has("3d")&&(l.add("3d"),console.info("ResponsiveLint: 3D detected ("+(e.frameworks.join(", ")||"WebGL")+"). The 3D rule pack is not implemented yet.")),c&&g(),s}let t=()=>{clearTimeout(a),a=setTimeout(w,500)};addEventListener("resize",t),addEventListener("click",t,!0),new MutationObserver(d=>{d.some(e=>!(e.target instanceof Element&&e.target.closest("[data-rl-overlay]")))&&t()}).observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class","style","hidden","aria-expanded","open"]});async function i({from:d=320,to:e=1920,step:o=48}={}){let r=document.createElement("iframe");r.name=z,r.src=location.href,r.setAttribute("data-rl-overlay",""),r.style.cssText=`position:fixed;left:-20000px;top:0;height:${innerHeight}px;width:1280px;border:0;visibility:hidden`,document.body.append(r);try{await new Promise((b,y)=>{r.onload=b,setTimeout(()=>y(new Error("timeout")),2e4)});let f=r.contentWindow;if(!f.__ResponsiveLintFrame)throw new Error("the page does not load this script in a frame");let x=[];for(let b=d;b<=e;b+=o){r.style.width=b+"px",await new Promise(v=>f.requestAnimationFrame(()=>f.requestAnimationFrame(()=>setTimeout(v,120))));let y=f.__ResponsiveLintFrame.checkNow();x.push({state:{id:"sweep",label:"width sweep"},width:b,findings:y.findings,measures:y.measures})}return u=_(x).findings,m(u),c&&g(),u}catch(f){return console.info("ResponsiveLint: the width sweep could not run ("+f.message+"). Use the command line, npx responsivelint, for a full sweep."),[]}finally{r.remove()}}let p=null;function g(){if(p?.remove(),!c)return;p=document.createElement("div"),p.setAttribute("data-rl-overlay",""),p.style.cssText="position:absolute;left:0;top:0;width:0;height:0;z-index:2147483646;pointer-events:none";let d=[...s,...u.filter(o=>!s.some(r=>r.id===o.id))];for(let o of s)for(let r of o.instances){let f=r.rect;if(!f)continue;let x=document.createElement("div");x.style.cssText=`position:absolute;left:${f.left}px;top:${f.top}px;width:${f.right-f.left}px;height:${f.bottom-f.top}px;outline:2px solid ${o.severity==="error"?"#e5484d":"#d08a12"};outline-offset:1px;border-radius:2px`,x.title=o.title,p.append(x)}let e=document.createElement("div");e.style.cssText="position:fixed;right:12px;bottom:12px;max-width:360px;max-height:50vh;overflow:auto;pointer-events:auto;background:hsla(0,0%,100%,.97);color:#1d1f24;border-radius:10px;box-shadow:0 6px 24px hsla(0,0%,0%,.18);font:12px/1.45 system-ui,sans-serif;padding:10px 12px",e.innerHTML=`<div style="display:flex;justify-content:space-between;gap:8px;margin-bottom:6px"><b>ResponsiveLint \xB7 ${d.length} finding${d.length===1?"":"s"}</b><button type="button" style="border:0;background:none;cursor:pointer;font:inherit">\xD7</button></div>`,e.querySelector("button").onclick=()=>api.ui(!1);for(let o of d){let r=document.createElement("div");r.style.cssText="padding:5px 0;border-top:1px solid hsla(220,15%,90%,1);cursor:pointer";let f=o.bands.map(([b,y])=>b===y?b:`${b}\u2013${y}`).join(", ")+" px",x=b=>String(b).replace(/[&<>"]/g,y=>({"&":"&","<":"<",">":">",'"':"""})[y]);r.innerHTML=`<span style="color:${o.severity==="error"?"#e5484d":"#b37400"}">${o.severity==="error"?"\u2716":"\u25B2"}</span> ${x(o.title)}<br><span style="color:#6b7280">${x((o.elements[0]?.text||o.elements[0]?.key||"").slice(0,50))} \xB7 ${f}</span><br><span style="color:#374151">Try: ${x(o.tries[0])}</span> <a href="${x(o.skill.url)}" target="_blank" rel="noopener" style="color:hsla(220,70%,45%,1);text-decoration:none">${x(o.skill.name)}</a>`,r.onclick=()=>document.querySelector(o.elements[0]?.key)?.scrollIntoView({block:"center",behavior:"smooth"}),e.append(r)}p.append(e),document.body.append(p)}return{check:w,sweep:i,ui(d=!0){return c=!!d,g(),c},on(d,e){return d==="finding"&&n.add(e),()=>n.delete(e)},get findings(){return[...s,...u]},rules:S}}})();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# clipped-text: Text cut off by its box
|
|
2
|
+
|
|
3
|
+
## What it finds
|
|
4
|
+
|
|
5
|
+
A box with `overflow: hidden` or `clip` is smaller than its content and holds text, so part of the text is never shown. Boxes with `text-overflow: ellipsis` are reported as notes, because the cut is visible to the reader, and line clamping is treated as deliberate.
|
|
6
|
+
|
|
7
|
+
## Common causes
|
|
8
|
+
|
|
9
|
+
A fixed `width` or `height` on a label, badge or button; `white-space: nowrap` inside a narrow box.
|
|
10
|
+
|
|
11
|
+
## How to fix it
|
|
12
|
+
|
|
13
|
+
Let the box grow with its content, allow wrapping, or, if the cut is intended, add `text-overflow: ellipsis` and put the full text in a `title` or an accessible name.
|
|
14
|
+
|
|
15
|
+
## Fix it with an agent
|
|
16
|
+
|
|
17
|
+
Load the [`responsivelint-fix-cramped-text`](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-cramped-text/SKILL.md) skill. Each finding also lists the usual causes in `tries`, most likely first.
|
|
18
|
+
|
|
19
|
+
## When it is intended
|
|
20
|
+
|
|
21
|
+
Add `data-rl-ignore="clipped-text"` to the element or a container to stop this rule there. Use `data-rl-ignore` without a value to stop every rule. Prefer fixing the layout: an ignored finding is still a problem for readers.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# disappears-in-band: A control disappears in a narrow band of widths
|
|
2
|
+
|
|
3
|
+
## What it finds
|
|
4
|
+
|
|
5
|
+
A control is visible at the widths on both sides of a band but missing or invisible inside it.
|
|
6
|
+
|
|
7
|
+
## Common causes
|
|
8
|
+
|
|
9
|
+
Two media queries that hand over at different widths, for example a mobile button hidden from 760 px while its desktop replacement appears only from 840 px.
|
|
10
|
+
|
|
11
|
+
## How to fix it
|
|
12
|
+
|
|
13
|
+
Align the queries so that one layout's control appears exactly where the other's disappears, or use a single query for both.
|
|
14
|
+
|
|
15
|
+
## Fix it with an agent
|
|
16
|
+
|
|
17
|
+
Load the [`responsivelint-fix-controls`](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-controls/SKILL.md) skill. Each finding also lists the usual causes in `tries`, most likely first.
|
|
18
|
+
|
|
19
|
+
## When it is intended
|
|
20
|
+
|
|
21
|
+
Add `data-rl-ignore="disappears-in-band"` to the element or a container to stop this rule there. Use `data-rl-ignore` without a value to stop every rule. Prefer fixing the layout: an ignored finding is still a problem for readers.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# hidden-control: A control takes space but cannot be seen
|
|
2
|
+
|
|
3
|
+
## What it finds
|
|
4
|
+
|
|
5
|
+
A button, link, tab or other focusable control is laid out and can be clicked or focused, but is fully transparent (`opacity` below 0.1) in its resting state. Controls hidden with `visibility: hidden` or `pointer-events: none` are not reported, because they cannot be used either. A native checkbox or radio hidden behind a styled label is a common deliberate pattern and is also skipped.
|
|
6
|
+
|
|
7
|
+
## Common causes
|
|
8
|
+
|
|
9
|
+
A control that is meant to appear on hover (`opacity: 0` until `:hover`), which leaves touch and keyboard users with an invisible control.
|
|
10
|
+
|
|
11
|
+
## How to fix it
|
|
12
|
+
|
|
13
|
+
Show the control at rest. If it should appear only on hover, take it out of the layout and the tab order until then (`visibility: hidden`), and make sure touch and keyboard users have another way to reach it.
|
|
14
|
+
|
|
15
|
+
## Fix it with an agent
|
|
16
|
+
|
|
17
|
+
Load the [`responsivelint-fix-controls`](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-controls/SKILL.md) skill. Each finding also lists the usual causes in `tries`, most likely first.
|
|
18
|
+
|
|
19
|
+
## When it is intended
|
|
20
|
+
|
|
21
|
+
Add `data-rl-ignore="hidden-control"` to the element or a container to stop this rule there. Use `data-rl-ignore` without a value to stop every rule. Prefer fixing the layout: an ignored finding is still a problem for readers.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# page-overflow: The page scrolls sideways
|
|
2
|
+
|
|
3
|
+
## What it finds
|
|
4
|
+
|
|
5
|
+
The document is wider than the viewport, so the whole page can be dragged sideways. The finding names the outermost elements that stick out past the right edge and are not inside a scrolling or clipping container.
|
|
6
|
+
|
|
7
|
+
## Common causes
|
|
8
|
+
|
|
9
|
+
A fixed `width` in pixels, a table or code block without a scrolling wrapper, a row of controls with `white-space: nowrap`, an image without `max-width: 100%`.
|
|
10
|
+
|
|
11
|
+
## How to fix it
|
|
12
|
+
|
|
13
|
+
Fix the named element: use `max-width: 100%`, let its content wrap, or wrap wide tables and code in a container with `overflow-x: auto`. Do not hide the problem with `overflow-x: hidden` on `body`, which also hides the content.
|
|
14
|
+
|
|
15
|
+
## Fix it with an agent
|
|
16
|
+
|
|
17
|
+
Load the [`responsivelint-fix-overflow`](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-overflow/SKILL.md) skill. Each finding also lists the usual causes in `tries`, most likely first.
|
|
18
|
+
|
|
19
|
+
## When it is intended
|
|
20
|
+
|
|
21
|
+
Add `data-rl-ignore="page-overflow"` to the element or a container to stop this rule there. Use `data-rl-ignore` without a value to stop every rule. Prefer fixing the layout: an ignored finding is still a problem for readers.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# squashed-text: Text squeezed to about one word per line
|
|
2
|
+
|
|
3
|
+
## What it finds
|
|
4
|
+
|
|
5
|
+
A text block of at least three words that wraps onto about one line per word. A neighbour has taken almost all of the row's width.
|
|
6
|
+
|
|
7
|
+
## Common causes
|
|
8
|
+
|
|
9
|
+
A grid row with `minmax(0, 1fr) auto` where the `auto` column holds controls that do not wrap; a flex row where a sibling has `flex-shrink: 0` or `white-space: nowrap`.
|
|
10
|
+
|
|
11
|
+
## How to fix it
|
|
12
|
+
|
|
13
|
+
Let the wide neighbour wrap onto its own line: switch the row to `grid-template-columns: 1fr` when the controls are many, or add `flex-wrap: wrap`. Giving the text a `min-width` (for example `12em`) also stops the squeeze.
|
|
14
|
+
|
|
15
|
+
## Fix it with an agent
|
|
16
|
+
|
|
17
|
+
Load the [`responsivelint-fix-cramped-text`](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-cramped-text/SKILL.md) skill. Each finding also lists the usual causes in `tries`, most likely first.
|
|
18
|
+
|
|
19
|
+
## When it is intended
|
|
20
|
+
|
|
21
|
+
Add `data-rl-ignore="squashed-text"` to the element or a container to stop this rule there. Use `data-rl-ignore` without a value to stop every rule. Prefer fixing the layout: an ignored finding is still a problem for readers.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# text-overlap: Text covers other text
|
|
2
|
+
|
|
3
|
+
## What it finds
|
|
4
|
+
|
|
5
|
+
Two pieces of visible text are drawn in the same place. ResponsiveLint reads the line boxes of each element's own text, cuts them to what their scrolling or clipping ancestors let show, and reports two elements whose lines cover a quarter or more of the smaller one. It ignores an element inside the other, and a pinned (fixed or sticky) element over scrolling content, because that depends on the scroll position rather than the layout.
|
|
6
|
+
|
|
7
|
+
## Common causes
|
|
8
|
+
|
|
9
|
+
An absolutely positioned element placed over text that wraps at narrow widths; a fixed height that stops a box from growing when its text wraps; a toast or tooltip placed over a toolbar.
|
|
10
|
+
|
|
11
|
+
## How to fix it
|
|
12
|
+
|
|
13
|
+
Let the content take its own space. Replace `position: absolute` with flex or grid placement, remove the fixed `height`, or move the overlay so it does not sit on the text. For a temporary message, place it above the toolbar rather than on it.
|
|
14
|
+
|
|
15
|
+
## Fix it with an agent
|
|
16
|
+
|
|
17
|
+
Load the [`responsivelint-fix-overlap`](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-overlap/SKILL.md) skill. Each finding also lists the usual causes in `tries`, most likely first.
|
|
18
|
+
|
|
19
|
+
## When it is intended
|
|
20
|
+
|
|
21
|
+
Add `data-rl-ignore="text-overlap"` to the element or a container to stop this rule there. Use `data-rl-ignore` without a value to stop every rule. Prefer fixing the layout: an ignored finding is still a problem for readers.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# width-outlier: Breaks only in a narrow band of widths
|
|
2
|
+
|
|
3
|
+
## What it finds
|
|
4
|
+
|
|
5
|
+
The self-comparison. ResponsiveLint measures each text block at every width of the sweep and compares it with the same block at the three widths on each side. A width is reported when the block has at least twice as many lines as its neighbours, at most half their words per line and no more than two and a half words per line, and when normal widths exist on both sides of the band. A designed breakpoint changes many elements and stays changed, so it is not reported.
|
|
6
|
+
|
|
7
|
+
## Common causes
|
|
8
|
+
|
|
9
|
+
A media query that switches one part of a layout before another; a sidebar that appears at a breakpoint and narrows the content column before the content layout adapts.
|
|
10
|
+
|
|
11
|
+
## How to fix it
|
|
12
|
+
|
|
13
|
+
Open the page at a width inside the band and at a width just outside it. Look for the neighbour that takes the width (often controls that stop wrapping, or a column that appears) and let it wrap or move below.
|
|
14
|
+
|
|
15
|
+
## Fix it with an agent
|
|
16
|
+
|
|
17
|
+
Load the [`responsivelint-fix-cramped-text`](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-cramped-text/SKILL.md) skill. Each finding also lists the usual causes in `tries`, most likely first.
|
|
18
|
+
|
|
19
|
+
## When it is intended
|
|
20
|
+
|
|
21
|
+
Add `data-rl-ignore="width-outlier"` to the element or a container to stop this rule there. Use `data-rl-ignore` without a value to stop every rule. Prefer fixing the layout: an ignored finding is still a problem for readers.
|
package/llms.txt
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# ResponsiveLint
|
|
2
|
+
|
|
3
|
+
> ResponsiveLint opens a web page in Chromium, finds layouts reachable in one click and checks a range of widths for each layout. It compares elements with themselves at nearby widths to find problems that appear only in a narrow range.
|
|
4
|
+
|
|
5
|
+
- [README](https://github.com/prajwalsouza/ResponsiveLint#readme) covers setup, command options, browser use and CI.
|
|
6
|
+
- [Run a check](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint/SKILL.md) explains how to run the command and read findings.
|
|
7
|
+
- [Fix findings](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix/SKILL.md) explains how to work through a report and which fix skill to load.
|
|
8
|
+
- [Fix overlapping text](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-overlap/SKILL.md): text-overlap.
|
|
9
|
+
- [Fix squeezed or cut-off text](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-cramped-text/SKILL.md): squashed-text, clipped-text, width-outlier.
|
|
10
|
+
- [Fix sideways scrolling](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-overflow/SKILL.md): page-overflow.
|
|
11
|
+
- [Fix invisible or missing controls](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-controls/SKILL.md): hidden-control, disappears-in-band.
|
|
12
|
+
|
|
13
|
+
## Run a check
|
|
14
|
+
|
|
15
|
+
- Use Node.js 20 or newer. Install Chromium with `npx playwright install chromium` if the command cannot find it. For ResponsiveLint 0.1.0 run via `npx` alone, use `npx --yes --package=playwright@1.59.1 playwright install chromium` to match its browser version.
|
|
16
|
+
- Start the site's dev server and run `npx responsivelint http://localhost:5173 --json report.json`.
|
|
17
|
+
- A built site folder also works, for example `npx responsivelint ./dist --html report.html`.
|
|
18
|
+
- Normal mode checks 320 to 1920 px in 48 px steps and up to eight extra states. Aggressive mode uses 24 px steps and up to 20 extra states. Quick mode checks four widths and the starting state only. Set `--step 1` to check every whole-pixel width in the selected range.
|
|
19
|
+
- Use `--route '#/settings'` to start from a hash route, `--only text` to run text rules or `--states 0` to skip click exploration. Repeat `--storage key=value` to set multiple localStorage values.
|
|
20
|
+
- Exit code `0` means no findings met the failure threshold. Code `1` means the run found errors, or warnings under `--strict`. Code `2` means the command failed or received an unknown option.
|
|
21
|
+
- For an in-page check, load `dist/responsivelint.js` from the npm package. The README has the script tag, `data-ui`, `data-sweep`, `data-anywhere` and `window.ResponsiveLint` examples.
|
|
22
|
+
- From Node, use `import {check} from 'responsivelint'; const report = await check(url)`.
|
|
23
|
+
|
|
24
|
+
## Read and fix findings
|
|
25
|
+
|
|
26
|
+
The report includes `widths`, `states` and `findings`. Each finding gives `rule`, `severity`, `confidence`, `elements` (selector in `key` and visible `text`), `bands` in pixels, `states`, `measured`, `why`, `tries` (the usual causes and fixes, most likely first), `skill` (the fix skill to load: `name`, `file`, `url`) and `guide`. Sweep findings may include nearby measurements in `expected`.
|
|
27
|
+
|
|
28
|
+
Open the page at a width inside the finding's band. Repeat the click named in the state and inspect the named element. Load the skill named in `skill`, check the causes in `tries` in order, fix the layout and run the check again. For an intentional layout, use `data-rl-ignore="rule-name"`.
|
|
29
|
+
|
|
30
|
+
- [text-overlap](https://github.com/prajwalsouza/ResponsiveLint/blob/main/docs/rules/text-overlap.md) finds visible text drawn over other text.
|
|
31
|
+
- [squashed-text](https://github.com/prajwalsouza/ResponsiveLint/blob/main/docs/rules/squashed-text.md) finds text with about one word per line.
|
|
32
|
+
- [clipped-text](https://github.com/prajwalsouza/ResponsiveLint/blob/main/docs/rules/clipped-text.md) finds text partly hidden by its box.
|
|
33
|
+
- [page-overflow](https://github.com/prajwalsouza/ResponsiveLint/blob/main/docs/rules/page-overflow.md) names the element that makes the page scroll sideways.
|
|
34
|
+
- [hidden-control](https://github.com/prajwalsouza/ResponsiveLint/blob/main/docs/rules/hidden-control.md) finds controls that are fully transparent at rest.
|
|
35
|
+
- [width-outlier](https://github.com/prajwalsouza/ResponsiveLint/blob/main/docs/rules/width-outlier.md) finds elements that break only in a narrow range of widths.
|
|
36
|
+
- [disappears-in-band](https://github.com/prajwalsouza/ResponsiveLint/blob/main/docs/rules/disappears-in-band.md) finds controls missing in a narrow range of widths.
|
|
37
|
+
|
|
38
|
+
## Scope and safety
|
|
39
|
+
|
|
40
|
+
The command accepts local and test hosts by default. `--allow-remote` allows another host. The runner blocks POST, PUT, PATCH and DELETE requests and navigation to other sites. It dismisses dialogs, avoids typing and skips form submit controls and names that suggest actions such as paying or deleting. Use `data-rl-never` on controls it should skip.
|
|
41
|
+
|
|
42
|
+
State discovery explores one click at a time from the starting state. It skips hover-only states. The rules measure the layout the browser renders and report when a 3D scene is detected. They do not check the layout inside that scene.
|
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "responsivelint",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Layout linter that checks every width and every state of a web UI against itself: overlapping text, overflow, squashed labels, hidden controls.",
|
|
5
|
+
"author": "Prajwal DSouza",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {"type": "git", "url": "git+https://github.com/prajwalsouza/ResponsiveLint.git"},
|
|
8
|
+
"homepage": "https://github.com/prajwalsouza/ResponsiveLint#readme",
|
|
9
|
+
"bugs": {"url": "https://github.com/prajwalsouza/ResponsiveLint/issues"},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"responsive", "layout", "lint", "linter", "overflow", "overlap", "breakpoints", "viewport",
|
|
12
|
+
"playwright", "accessibility", "testing", "ci"
|
|
13
|
+
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20"
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"responsivelint": "bin/responsivelint.mjs"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./src/index.js",
|
|
23
|
+
"./core": "./src/core/index.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"bin",
|
|
27
|
+
"src",
|
|
28
|
+
"dist",
|
|
29
|
+
"docs",
|
|
30
|
+
"agents",
|
|
31
|
+
"llms.txt"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "node scripts/build-browser.mjs",
|
|
35
|
+
"prepublishOnly": "npm run build",
|
|
36
|
+
"test": "npm run build && node --test test/*.test.js",
|
|
37
|
+
"lint:fixtures": "node bin/responsivelint.mjs fixtures/planted --json .responsivelint/planted.json"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"playwright": "1.59.1"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"esbuild": "0.28.2"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// The script-tag version.
|
|
2
|
+
// <script src="responsivelint.js"></script> console findings, re-checked as the page changes
|
|
3
|
+
// <script src="responsivelint.js" data-ui></script> also outline problems on the page
|
|
4
|
+
// <script src="responsivelint.js" data-sweep></script> also sweep widths in a hidden copy of the page
|
|
5
|
+
import {checkNow, detectEnvironment} from '../core/measure.js';
|
|
6
|
+
import {analyze, RULES} from '../core/analyze.js';
|
|
7
|
+
|
|
8
|
+
const FRAME = 'responsivelint-frame';
|
|
9
|
+
const script = document.currentScript;
|
|
10
|
+
const opts = script ? script.dataset : {};
|
|
11
|
+
|
|
12
|
+
if (window.name === FRAME) {
|
|
13
|
+
// Inside our own sweep frame: only measure when asked.
|
|
14
|
+
window.__ResponsiveLintFrame = {checkNow};
|
|
15
|
+
} else {
|
|
16
|
+
const local = /^(localhost|127\.0\.0\.1|\[::1\]|.+\.localhost|.+\.test)$/.test(location.hostname) || location.protocol === 'file:';
|
|
17
|
+
const api = window.ResponsiveLint = createApi();
|
|
18
|
+
if (local || 'anywhere' in opts) {
|
|
19
|
+
const start = () => {
|
|
20
|
+
api.check();
|
|
21
|
+
if ('ui' in opts) api.ui(true);
|
|
22
|
+
if ('sweep' in opts) api.sweep();
|
|
23
|
+
};
|
|
24
|
+
if (document.readyState === 'complete') setTimeout(start, 50); else addEventListener('load', () => setTimeout(start, 50));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function createApi() {
|
|
29
|
+
const logged = new Set();
|
|
30
|
+
const listeners = new Set();
|
|
31
|
+
let current = [], sweepFindings = [], uiOn = false, timer = 0;
|
|
32
|
+
|
|
33
|
+
const emit = (f) => listeners.forEach((fn) => { try { fn(f); } catch {} });
|
|
34
|
+
|
|
35
|
+
function report(findings) {
|
|
36
|
+
for (const f of findings) {
|
|
37
|
+
if (logged.has(f.id)) continue;
|
|
38
|
+
logged.add(f.id);
|
|
39
|
+
emit(f);
|
|
40
|
+
const color = f.severity === 'error' ? '#e5484d' : f.severity === 'warning' ? '#d08a12' : '#888';
|
|
41
|
+
console.groupCollapsed(`%cResponsiveLint%c ${f.severity === 'error' ? '✖' : '▲'} ${f.rule}: ${f.title}`, 'font-weight:700', `color:${color}`);
|
|
42
|
+
for (const e of f.elements) console.log(e.text ? `“${e.text}”` : e.key, document.querySelector(e.key) || e.key);
|
|
43
|
+
console.log('where:', f.bands.map(([a, b]) => (a === b ? a : `${a}–${b}`)).join(', ') + ' px', f.states.join(' · '));
|
|
44
|
+
if (f.measured) console.log('measured:', f.measured, f.expected ? ['neighbours:', f.expected] : '');
|
|
45
|
+
console.log('why:', f.why);
|
|
46
|
+
console.log('try:\n' + f.tries.map((t, i) => `${i + 1}. ${t}`).join('\n'));
|
|
47
|
+
console.log('skill:', f.skill.name, f.skill.url);
|
|
48
|
+
console.log('silence:', f.suppress);
|
|
49
|
+
console.groupEnd();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function check() {
|
|
54
|
+
const snap = checkNow();
|
|
55
|
+
const env = detectEnvironment();
|
|
56
|
+
current = analyze([{state: {id: 'live', label: 'live page'}, width: snap.width, findings: snap.findings, measures: []}]).findings;
|
|
57
|
+
report(current);
|
|
58
|
+
if (env.is3D && !logged.has('3d')) { logged.add('3d'); console.info('ResponsiveLint: 3D detected (' + (env.frameworks.join(', ') || 'WebGL') + '). The 3D rule pack is not implemented yet.'); }
|
|
59
|
+
if (uiOn) draw();
|
|
60
|
+
return current;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const recheck = () => { clearTimeout(timer); timer = setTimeout(check, 500); };
|
|
64
|
+
addEventListener('resize', recheck);
|
|
65
|
+
addEventListener('click', recheck, true);
|
|
66
|
+
new MutationObserver((m) => { if (m.some((r) => !(r.target instanceof Element && r.target.closest('[data-rl-overlay]')))) recheck(); })
|
|
67
|
+
.observe(document.documentElement, {subtree: true, childList: true, attributes: true, attributeFilter: ['class', 'style', 'hidden', 'aria-expanded', 'open']});
|
|
68
|
+
|
|
69
|
+
/** Sweep widths in a hidden same-origin copy of this page. */
|
|
70
|
+
async function sweep({from = 320, to = 1920, step = 48} = {}) {
|
|
71
|
+
const frame = document.createElement('iframe');
|
|
72
|
+
frame.name = FRAME; frame.src = location.href; frame.setAttribute('data-rl-overlay', '');
|
|
73
|
+
frame.style.cssText = `position:fixed;left:-20000px;top:0;height:${innerHeight}px;width:1280px;border:0;visibility:hidden`;
|
|
74
|
+
document.body.append(frame);
|
|
75
|
+
try {
|
|
76
|
+
await new Promise((r, x) => { frame.onload = r; setTimeout(() => x(new Error('timeout')), 20000); });
|
|
77
|
+
const win = frame.contentWindow;
|
|
78
|
+
if (!win.__ResponsiveLintFrame) throw new Error('the page does not load this script in a frame');
|
|
79
|
+
const snaps = [];
|
|
80
|
+
for (let w = from; w <= to; w += step) {
|
|
81
|
+
frame.style.width = w + 'px';
|
|
82
|
+
await new Promise((r) => win.requestAnimationFrame(() => win.requestAnimationFrame(() => setTimeout(r, 120))));
|
|
83
|
+
const s = win.__ResponsiveLintFrame.checkNow();
|
|
84
|
+
snaps.push({state: {id: 'sweep', label: 'width sweep'}, width: w, findings: s.findings, measures: s.measures});
|
|
85
|
+
}
|
|
86
|
+
sweepFindings = analyze(snaps).findings;
|
|
87
|
+
report(sweepFindings);
|
|
88
|
+
if (uiOn) draw();
|
|
89
|
+
return sweepFindings;
|
|
90
|
+
} catch (e) {
|
|
91
|
+
console.info('ResponsiveLint: the width sweep could not run (' + e.message + '). Use the command line, npx responsivelint, for a full sweep.');
|
|
92
|
+
return [];
|
|
93
|
+
} finally { frame.remove(); }
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ---- overlay ----
|
|
97
|
+
let layer = null;
|
|
98
|
+
function draw() {
|
|
99
|
+
layer?.remove();
|
|
100
|
+
if (!uiOn) return;
|
|
101
|
+
layer = document.createElement('div');
|
|
102
|
+
layer.setAttribute('data-rl-overlay', '');
|
|
103
|
+
layer.style.cssText = 'position:absolute;left:0;top:0;width:0;height:0;z-index:2147483646;pointer-events:none';
|
|
104
|
+
const all = [...current, ...sweepFindings.filter((f) => !current.some((c) => c.id === f.id))];
|
|
105
|
+
for (const f of current) {
|
|
106
|
+
for (const inst of f.instances) {
|
|
107
|
+
const r = inst.rect; if (!r) continue;
|
|
108
|
+
const box = document.createElement('div');
|
|
109
|
+
box.style.cssText = `position:absolute;left:${r.left}px;top:${r.top}px;width:${r.right - r.left}px;height:${r.bottom - r.top}px;outline:2px solid ${f.severity === 'error' ? '#e5484d' : '#d08a12'};outline-offset:1px;border-radius:2px`;
|
|
110
|
+
box.title = f.title;
|
|
111
|
+
layer.append(box);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const panel = document.createElement('div');
|
|
115
|
+
panel.style.cssText = 'position:fixed;right:12px;bottom:12px;max-width:360px;max-height:50vh;overflow:auto;pointer-events:auto;background:hsla(0,0%,100%,.97);color:#1d1f24;border-radius:10px;box-shadow:0 6px 24px hsla(0,0%,0%,.18);font:12px/1.45 system-ui,sans-serif;padding:10px 12px';
|
|
116
|
+
panel.innerHTML = `<div style="display:flex;justify-content:space-between;gap:8px;margin-bottom:6px"><b>ResponsiveLint · ${all.length} finding${all.length === 1 ? '' : 's'}</b><button type="button" style="border:0;background:none;cursor:pointer;font:inherit">×</button></div>`;
|
|
117
|
+
panel.querySelector('button').onclick = () => api.ui(false);
|
|
118
|
+
for (const f of all) {
|
|
119
|
+
const row = document.createElement('div');
|
|
120
|
+
row.style.cssText = 'padding:5px 0;border-top:1px solid hsla(220,15%,90%,1);cursor:pointer';
|
|
121
|
+
const where = f.bands.map(([a, b]) => (a === b ? a : `${a}–${b}`)).join(', ') + ' px';
|
|
122
|
+
const esc = (t) => String(t).replace(/[&<>"]/g, (ch) => ({'&': '&', '<': '<', '>': '>', '"': '"'}[ch]));
|
|
123
|
+
row.innerHTML = `<span style="color:${f.severity === 'error' ? '#e5484d' : '#b37400'}">${f.severity === 'error' ? '✖' : '▲'}</span> ${esc(f.title)}<br><span style="color:#6b7280">${esc((f.elements[0]?.text || f.elements[0]?.key || '').slice(0, 50))} · ${where}</span><br><span style="color:#374151">Try: ${esc(f.tries[0])}</span> <a href="${esc(f.skill.url)}" target="_blank" rel="noopener" style="color:hsla(220,70%,45%,1);text-decoration:none">${esc(f.skill.name)}</a>`;
|
|
124
|
+
row.onclick = () => document.querySelector(f.elements[0]?.key)?.scrollIntoView({block: 'center', behavior: 'smooth'});
|
|
125
|
+
panel.append(row);
|
|
126
|
+
}
|
|
127
|
+
layer.append(panel);
|
|
128
|
+
document.body.append(layer);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
check, sweep,
|
|
133
|
+
ui(on = true) { uiOn = !!on; draw(); return uiOn; },
|
|
134
|
+
on(event, fn) { if (event === 'finding') listeners.add(fn); return () => listeners.delete(fn); },
|
|
135
|
+
get findings() { return [...current, ...sweepFindings]; },
|
|
136
|
+
rules: RULES,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Reporters. Every finding answers: what is wrong, where, why we think so, how sure we are, how to fix or silence it.
|
|
2
|
+
|
|
3
|
+
const tty = process.stdout.isTTY;
|
|
4
|
+
const c = (code) => (s) => (tty ? `\x1b[${code}m${s}\x1b[0m` : s);
|
|
5
|
+
const red = c(31), yellow = c(33), dim = c(2), bold = c(1), cyan = c(36);
|
|
6
|
+
|
|
7
|
+
export const fmtBands = (bands) => bands.map(([a, b]) => (a === b ? `${a}` : `${a}–${b}`)).join(', ') + ' px';
|
|
8
|
+
|
|
9
|
+
export function terminalReport(r) {
|
|
10
|
+
const out = [];
|
|
11
|
+
const head = `ResponsiveLint · ${r.url} · ${r.widths.length} widths (${r.widths[0]}–${r.widths[r.widths.length - 1]} px) · ${r.states.length} state${r.states.length === 1 ? '' : 's'} · ${r.seconds}s`;
|
|
12
|
+
out.push(bold(head));
|
|
13
|
+
if (r.env?.is3D) out.push(cyan(`3D detected: ${r.env.frameworks.join(', ') || 'WebGL canvas'}${r.env.xr ? ' with WebXR' : ''}. The 3D rule pack is planned and not yet implemented, so the scene itself was not checked.`));
|
|
14
|
+
if (r.states.length > 1) out.push(dim('States: ' + r.states.map((s) => s.label).join(' · ')));
|
|
15
|
+
out.push('');
|
|
16
|
+
for (const f of r.findings) {
|
|
17
|
+
const mark = f.severity === 'error' ? red('✖') : f.severity === 'warning' ? yellow('▲') : dim('·');
|
|
18
|
+
const el = f.elements[0];
|
|
19
|
+
out.push(`${mark} ${bold(f.rule)} ${f.title}${f.everyWidth ? dim(' (at every width)') : ''} ${dim(f.confidence + ' confidence')}`);
|
|
20
|
+
out.push(` ${dim('element')} ${el.text ? `"${el.text}" ` : ''}${dim(el.key)}`);
|
|
21
|
+
if (f.elements[1]) out.push(` ${dim('and')} ${f.elements[1].text ? `"${f.elements[1].text}" ` : ''}${dim(f.elements[1].key)}`);
|
|
22
|
+
out.push(` ${dim('where')} ${fmtBands(f.bands)}${f.states.length ? ` · ${f.states.join(' · ')}` : ''}`);
|
|
23
|
+
if (f.measured) out.push(` ${dim('measured')} ${fmt(f.measured)}${f.expected ? ` ${dim('neighbours')} ${fmt(f.expected)}` : ''}`);
|
|
24
|
+
out.push(` ${dim('why')} ${f.why}`);
|
|
25
|
+
f.tries.forEach((t, i) => out.push(`${i ? ' ' : ' ' + dim('try') + ' '}${i + 1}. ${t}`));
|
|
26
|
+
out.push(` ${dim('skill')} ${f.skill.name} ${dim(f.skill.file)}`);
|
|
27
|
+
out.push(` ${dim('guide')} ${dim(f.guide)}`);
|
|
28
|
+
out.push(` ${dim('silence')} ${f.suppress}`);
|
|
29
|
+
out.push('');
|
|
30
|
+
}
|
|
31
|
+
const n = (s) => r.findings.filter((f) => f.severity === s).length;
|
|
32
|
+
const skills = new Map();
|
|
33
|
+
for (const f of r.findings) skills.set(f.skill.name, [f.skill, (skills.get(f.skill.name)?.[1] || 0) + 1]);
|
|
34
|
+
if (skills.size) {
|
|
35
|
+
out.push(bold('To fix with an AI agent, load these skills (in the package and the repository):'));
|
|
36
|
+
for (const [name, [sk, k]] of skills) out.push(` ${name} ${dim(`${k} finding${k === 1 ? '' : 's'} · ${sk.file}`)}`);
|
|
37
|
+
out.push('');
|
|
38
|
+
}
|
|
39
|
+
out.push(bold(`${n('error')} errors, ${n('warning')} warnings, ${n('info')} notes`) + (r.pageErrors?.length ? dim(` · the page logged ${r.pageErrors.length} error(s)`) : ''));
|
|
40
|
+
return out.join('\n');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const fmt = (o) => Object.entries(o).map(([k, v]) => `${k} ${v}`).join(', ');
|
|
44
|
+
|
|
45
|
+
const esc = (s) => String(s ?? '').replace(/[&<>"]/g, (ch) => ({'&': '&', '<': '<', '>': '>', '"': '"'}[ch]));
|
|
46
|
+
|
|
47
|
+
export function htmlReport(r) {
|
|
48
|
+
const min = r.widths[0], max = r.widths[r.widths.length - 1];
|
|
49
|
+
const pos = (w) => ((w - min) / Math.max(1, max - min)) * 100;
|
|
50
|
+
const ruler = (f) => f.bands.map(([a, b]) => `<i class="band ${f.severity}" style="left:${pos(a)}%;width:max(3px,${pos(b) - pos(a)}%)" title="${a}–${b} px"></i>`).join('');
|
|
51
|
+
const cards = r.findings.map((f) => `
|
|
52
|
+
<article class="card ${f.severity}">
|
|
53
|
+
<header><span class="sev">${f.severity}</span><b>${esc(f.title)}</b><code>${f.rule}</code><span class="conf">${f.confidence} confidence</span></header>
|
|
54
|
+
<div class="ruler">${ruler(f)}</div>
|
|
55
|
+
<dl>
|
|
56
|
+
<dt>Element</dt><dd>${f.elements.map((e) => `${e.text ? `“${esc(e.text)}” ` : ''}<code>${esc(e.key)}</code>`).join('<br>')}</dd>
|
|
57
|
+
<dt>Where</dt><dd>${esc(fmtBands(f.bands))}${f.states.length ? ' · ' + f.states.map(esc).join(' · ') : ''}</dd>
|
|
58
|
+
${f.measured ? `<dt>Measured</dt><dd>${esc(fmt(f.measured))}${f.expected ? ` <span class="muted">· neighbours ${esc(fmt(f.expected))}</span>` : ''}</dd>` : ''}
|
|
59
|
+
<dt>Why</dt><dd>${esc(f.why)}</dd>
|
|
60
|
+
<dt>Try</dt><dd><ol>${f.tries.map((t) => `<li>${esc(t)}</li>`).join('')}</ol></dd>
|
|
61
|
+
<dt>Skill</dt><dd><a href="${esc(f.skill.url)}">${esc(f.skill.name)}</a> · <a href="${esc(f.guide)}">rule guide</a></dd>
|
|
62
|
+
<dt>Silence</dt><dd><code>${esc(f.suppress)}</code></dd>
|
|
63
|
+
</dl>
|
|
64
|
+
${f.evidence?.length ? `<div class="shots">${f.evidence.map((e) => `<figure><img src="data:image/png;base64,${e.png}" alt=""><figcaption>${e.kind === 'bad' ? 'Problem' : 'Healthy'} at ${e.width} px</figcaption></figure>`).join('')}</div>` : ''}
|
|
65
|
+
</article>`).join('');
|
|
66
|
+
return `<!doctype html><meta charset="utf-8"><title>ResponsiveLint report</title>
|
|
67
|
+
<style>a{color:hsla(220,70%,45%,1);text-decoration:none}dd ol{margin:0;padding-left:1.2em}
|
|
68
|
+
:root{--bg:hsla(60,20%,98%,1);--ink:hsla(220,15%,15%,1);--muted:hsla(220,8%,45%,1);--line:hsla(220,15%,88%,1);--err:hsla(358,75%,59%,1);--warn:hsla(36,90%,50%,1);--info:hsla(220,10%,60%,1);--card:hsla(0,0%,100%,1)}
|
|
69
|
+
body{margin:0;background:var(--bg);color:var(--ink);font:14px/1.55 system-ui,-apple-system,sans-serif}
|
|
70
|
+
main{max-width:980px;margin:0 auto;padding:32px 20px}
|
|
71
|
+
h1{font-size:22px;margin:0 0 4px}.muted{color:var(--muted)}a{color:inherit;text-decoration:none}
|
|
72
|
+
.axis{display:flex;justify-content:space-between;color:var(--muted);font-size:11px;margin:18px 0 6px}
|
|
73
|
+
.card{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:16px 18px;margin:14px 0}
|
|
74
|
+
.card header{display:flex;gap:10px;align-items:baseline;flex-wrap:wrap}.card header code{color:var(--muted)}
|
|
75
|
+
.sev{font-size:11px;text-transform:uppercase;letter-spacing:.08em;font-weight:700}.error .sev{color:var(--err)}.warning .sev{color:var(--warn)}.info .sev{color:var(--info)}
|
|
76
|
+
.conf{margin-left:auto;color:var(--muted);font-size:12px}
|
|
77
|
+
.ruler{position:relative;height:8px;background:hsla(150,40%,45%,.18);border-radius:4px;margin:12px 0}
|
|
78
|
+
.band{position:absolute;top:0;bottom:0;border-radius:4px}.band.error{background:var(--err)}.band.warning{background:var(--warn)}.band.info{background:var(--info)}
|
|
79
|
+
dl{display:grid;grid-template-columns:90px 1fr;gap:4px 14px;margin:0}dt{color:var(--muted)}dd{margin:0;overflow-wrap:anywhere}
|
|
80
|
+
.shots{display:flex;gap:12px;flex-wrap:wrap;margin-top:12px}figure{margin:0;max-width:100%}img{max-width:100%;border:1px solid var(--line);border-radius:6px;display:block}figcaption{color:var(--muted);font-size:12px}
|
|
81
|
+
</style>
|
|
82
|
+
<main>
|
|
83
|
+
<h1>ResponsiveLint report</h1>
|
|
84
|
+
<div class="muted">${esc(r.url)} · ${r.widths.length} widths · ${r.states.length} states · ${r.seconds}s · ${esc(r.startedAt)}</div>
|
|
85
|
+
${r.env?.is3D ? `<p class="muted">3D detected: ${esc(r.env.frameworks.join(', ') || 'WebGL canvas')}. The 3D rule pack is not implemented yet.</p>` : ''}
|
|
86
|
+
<p class="muted">States checked: ${r.states.map((s) => esc(s.label)).join(' · ')}</p>
|
|
87
|
+
<div class="axis"><span>${min} px</span><span>each bar: green where it is fine, coloured where the problem is</span><span>${max} px</span></div>
|
|
88
|
+
${cards || '<p>No problems found.</p>'}
|
|
89
|
+
</main>`;
|
|
90
|
+
}
|