index.js:add maxWidth constraint,rearrange conditional