Skip to content

Commit

Permalink
replace <line>s with <path>
Browse files Browse the repository at this point in the history
  • Loading branch information
HectorVilas committed Apr 29, 2023
1 parent 9e0ce79 commit 3b87781
Showing 1 changed file with 7 additions and 43 deletions.
50 changes: 7 additions & 43 deletions modules/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,52 +90,16 @@ function nav() {

function menuBtn() {
const menuBtn = document.createElementNS(svgNs, 'svg');
const lineColor = '#1f604a';
const lineWidth = 4;
const lineLeft = 5;
const lineRight = 35;
const lineCap = 'round';
const lineAttributes = [
{
x1: lineLeft,
y1: 12,
x2: lineRight,
y2: 12,
stroke: lineColor,
'stroke-width': lineWidth,
'stroke-linecap': lineCap,
},
{
x1: lineLeft,
y1: 20,
x2: lineRight,
y2: 20,
stroke: lineColor,
'stroke-width': lineWidth,
'stroke-linecap': lineCap,
},
{
x1: lineLeft,
y1: 28,
x2: lineRight,
y2: 28,
stroke: lineColor,
'stroke-width': lineWidth,
'stroke-linecap': lineCap,
},
const lineDraw = [
'M 5 10 L 35 10',
'M 5 20 L 35 20',
'M 5 30 L 35 30',
];

for (let i = 0; i < lineAttributes.length; i += 1) {
const line = document.createElementNS(svgNs, 'line');
const attributes = [];

for (const attr in lineAttributes[i]) attributes.push(attr);

attributes.forEach(attr => {
const value = lineAttributes[i][attr];
line.setAttribute(attr, value);
});
for (let i = 0; i < lineDraw.length; i += 1) {
const line = document.createElementNS(svgNs, 'path');

line.setAttribute('d', lineDraw[i]);
line.classList.add(`menu-button-line-${i}`);

menuBtn.append(line);
Expand Down

0 comments on commit 3b87781

Please sign in to comment.