Skip to content

Commit

Permalink
complete
Browse files Browse the repository at this point in the history
  • Loading branch information
kailasnadh790 committed Jan 12, 2024
1 parent f2a43d5 commit 1865c68
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 31 deletions.
132 changes: 106 additions & 26 deletions cigaradvisor/blocks/author/author.css
Original file line number Diff line number Diff line change
@@ -1,66 +1,63 @@
.author.block{
.author.block {
display: flex;
padding: 20px 0;
}

.author.block > div{
.author.block>div {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: 20px;
width: 100%;
margin-left: auto;
margin-right: auto;
max-width: 1080px;
}

.author.block .image-wrapper{
.author.block .image-wrapper {
text-align: center;
display: flex;
align-items: center;
justify-content: center;
padding: 0;
width: 25%;
float: left;
}

.author.block .image-wrapper img{
.author.block .image-wrapper img {
width: 100%;
max-width: 300px;
border: 1px solid #8e7b5c;
}

.author.block .author-details{
.author.block .author-details {
display: flex;
flex-direction: column;
align-items: left;
border-top: 2px solid #141414;
border-bottom: 2px solid #141414;
text-align: left;
width: 75%;
margin-top: 0;
padding: 0;
margin-left: 60px;
float: left;
align-items: center;
border-top: 2px solid #141414;
border-bottom: 2px solid #141414;
text-align: center;
width: 100%;
margin-top: 20px;
padding: 10px 0;
}

.author.block .author-details .author-heading-wrapper{
.author.block .author-details .author-heading-wrapper {
display: flex;
text-align: left;
margin-top: 5px;
}

.author.block .author-details .author-heading{
.author.block .author-details .author-heading {
display: flex;
flex-direction: column;
align-items: center;
}

.author.block .author-details .author-heading h2{
.author.block .author-details .author-heading h2 {
font-size: 24px;
text-align: center;
font-family: montserrat,sans-serif;
font-family: montserrat, sans-serif;
font-weight: 900;
color: #141414;
}

.author.block .author-details .author-heading h3{
.author.block .author-details .author-heading h3 {
margin: 0 0 0 10px;
position: relative;
bottom: 2px;
Expand All @@ -73,6 +70,89 @@
}


.author.block .author-details p{
.author.block .author-details p {
font-weight: bolder;
}

.author.block .author-details a {
color: #1e90ff;
font-weight: bolder;
margin-bottom: 5px;
}

.author.block .author-details ul {
display: flex;
margin: 10px 0;
}

.author.block .author-details ul li {
margin-right: 20px;
}

.author.block .author-details ul li a::before {
font-family: var(--ff-fontawesome);
font-style: normal;
font-weight: bolder;
text-decoration: inherit;
font-size: 20px;
color: #141414
}

.author.block .author-details ul li.social-twitter a::before {
content: "\f099";
}

.author.block .author-details ul li.social-facebook a::before {
content: "\f39e";
}

.author.block .author-details ul li.social-instagram a::before {
content: "\f16d";
}

.author.block .author-details ul li.social-youtube a::before {
content: "\f167";
}

/* media queries */
@media screen and (min-width: 900px) {
.author.block>div {
display: flex;
flex-direction: row;
margin-top: 20px;
width: 100%;
margin-left: auto;
margin-right: auto;
max-width: 1080px;
}

.author.block .image-wrapper {
text-align: center;
display: flex;
align-items: center;
justify-content: center;
padding: 0;
width: 25%;
float: left;
}

.author.block .author-details {
align-items: flex-start;
display: flex;
flex-direction: column;
border-top: 2px solid #141414;
border-bottom: 2px solid #141414;
text-align: left;
width: 75%;
margin-top: 0;
padding: 0;
margin-left: 60px;
float: left;
}

.author.block .author-details .author-heading {
display: flex;
flex-direction: row;
align-items: left;
}
}
39 changes: 34 additions & 5 deletions cigaradvisor/blocks/author/author.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { decorateExternalLink } from '../../scripts/scripts.js';

/**
* Loads an author.
* @param {string} path The path to the author
Expand All @@ -20,6 +22,7 @@ export default async function decorate(block) {
const path = link ? link.getAttribute('href') : block.textContent.trim();
block.innerHTML = '';
const author = await loadAuthor(path);
decorateExternalLink(author);
if (author) {
// add updated link to all author articles
const imageWrapper = document.createElement('div');
Expand All @@ -33,17 +36,43 @@ export default async function decorate(block) {
authorHeadingWrapper.classList.add('author-heading-wrapper');
const authorHeading = document.createElement('div');
authorHeading.classList.add('author-heading');
authorHeading.append(author.querySelector('h2'));
authorHeading.append(author.querySelector('h3'));
if (author.querySelector('h2')) {
authorHeading.append(author.querySelector('h2'));
}
if (author.querySelector('h3')) {
authorHeading.append(author.querySelector('h3'));
}
authorHeadingWrapper.append(authorHeading);
authorDetails.append(authorHeadingWrapper);
const authorP = author.querySelectorAll('p');
const authorPCount = authorP.length;
const authorPIndex = authorPCount - 1;
const authorPContent = authorP[authorPIndex];
authorDetails.append(authorPContent);
link.textContent = `Show all ${authorName}'s Articles`;
authorDetails.append(link);
if (authorPContent) {
authorDetails.append(authorPContent);
}
const socilaLinks = author.querySelector('ul');
if (socilaLinks) {
const socialItems = socilaLinks.querySelectorAll('li');
socialItems.forEach((item) => {
const textNode = item.childNodes[0];
if (textNode && textNode.textContent !== '') {
const text = `social-${textNode.textContent.trim()}`;
textNode.innerText = '';
const textToClass = text.toLowerCase().replace(/\s/g, '-');
item.className = textToClass;
}
});

authorDetails.append(socilaLinks);
} else {
const emptySocialLinks = document.createElement('ul');
authorDetails.append(emptySocialLinks);
}
if (authorName) {
link.textContent = `Show all ${authorName}'s Articles`;
authorDetails.append(link);
}
author.replaceChildren(imageWrapper);
author.append(authorDetails);
block.append(author);
Expand Down

0 comments on commit 1865c68

Please sign in to comment.