Skip to content

Commit

Permalink
breadcrumb
Browse files Browse the repository at this point in the history
  • Loading branch information
joanbeltran-cn committed Nov 7, 2024
1 parent 424f726 commit d2601e1
Show file tree
Hide file tree
Showing 9 changed files with 28,580 additions and 412 deletions.
81 changes: 65 additions & 16 deletions blocks/breadcrumb/breadcrumb.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@

.breadcrumb {
position: relative;

&:before {
top: 0;
bottom: 0;
left: 0;
width: 50%;
background: #002551;
content: "";
position: absolute;
z-index: -1;
}

h1 {
color: #fff;
margin: 0;
}
}

.breadcrumb-content {
Expand All @@ -15,7 +31,6 @@
margin-right: auto;
margin-left: auto;

/*this widths are for all the containers*/
@media (min-width: 768px) {
padding-block-start: 61px;
padding-block-end: 72px;
Expand All @@ -30,20 +45,54 @@
padding-inline-start: 190px;
max-width: 1140px;
}
}

.breadcrumb:before {
top: 0;
bottom: 0;
left: 0;
width: 50%;
background: #002551;
content: "";
position: absolute;
z-index: -1;
}
ul {
list-style: none;
margin-block: 0;
padding-inline-start: 0;
margin-bottom: 12px;
display: flex;
align-items: flex-start;
flex-wrap: wrap;
}

.breadcrumb h1 {
color: #fff;
margin: 0;
}
li {
position: relative;
white-space: nowrap;
margin-right: 16px;
color: #fff;
font-family: IBM Plex Sans, sans-serif;
font-weight: 400;
font-size: 16px;
line-height: 24px;

+ li {
padding-inline-start: 22px;

&:before {
font-family: Font Awesome\ 5 Pro;
content: "\F105";
position: absolute;
left: 0;
top: 1px;
color: #0097e6;
}
}
}

a {
color: #fff;
border-bottom: 1px solid #fff;
text-decoration: none;
transition: all .3s;
font-style: normal;


&:hover {
color: #fff;
border-bottom: 2px solid #fff;
text-shadow: 0 0 1px #fff;
padding-bottom: 2px;
}
}
}
37 changes: 33 additions & 4 deletions blocks/breadcrumb/breadcrumb.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
const getPath = () => {
const path = window.location.pathname

Check failure on line 2 in blocks/breadcrumb/breadcrumb.js

View workflow job for this annotation

GitHub Actions / build

Missing semicolon
if (path === '/') {
return ['Home', 'Services', 'Water', 'Water supply', 'Water pressure'];
}
return path.split('/').filter((item) => item !== '');
}

Check failure on line 7 in blocks/breadcrumb/breadcrumb.js

View workflow job for this annotation

GitHub Actions / build

Missing semicolon

export default function decorate(block) {
const title = block.querySelector('p');
block.innerHTML = `
<div class="breadcrumb-content">
<h1>${title?.innerText}</h1>
</div>`;
const breadcrumb = document.createElement('div');
const path = getPath();
const list = document.createElement('ul');

path.forEach((item, index) => {
const li = document.createElement('li');
const a = document.createElement('a');
if (index < path.length - 1) {
a.href = '#';
a.innerText = item;
li.append(a)

Check failure on line 21 in blocks/breadcrumb/breadcrumb.js

View workflow job for this annotation

GitHub Actions / build

Missing semicolon
} else {
li.innerText = item;
}


Check failure on line 26 in blocks/breadcrumb/breadcrumb.js

View workflow job for this annotation

GitHub Actions / build

More than 1 blank line not allowed
list.append(li);
});

breadcrumb.className = 'breadcrumb-content'

Check failure on line 30 in blocks/breadcrumb/breadcrumb.js

View workflow job for this annotation

GitHub Actions / build

Missing semicolon
breadcrumb.innerHTML = `<h1>${title?.innerText}</h1>`;

block.innerHTML = '';
breadcrumb.prepend(list);
block.append(breadcrumb);
}
Loading

0 comments on commit d2601e1

Please sign in to comment.