Skip to content

Commit

Permalink
merge main resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Lakshmishri committed Aug 19, 2024
2 parents ca370ea + c26b4d5 commit 9a06a6b
Show file tree
Hide file tree
Showing 7 changed files with 252 additions and 11 deletions.
137 changes: 133 additions & 4 deletions blocks/columns/columns.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* stylelint-disable no-descending-specificity */
.columns > div {
display: flex;
flex-direction: column;
Expand All @@ -12,13 +13,15 @@
order: 1;
}

.columns > div > div:not(.columns-img-col) {
.columns > div > div:not(.columns-img-col, .columns.locations > div > div) {
max-width: 750px;
margin-left: auto;
margin-right: auto;
}

.columns > div > .columns-img-col:not(.columns.image-no-order > div > .columns-img-col) {
.columns
> div
> .columns-img-col:not(.columns.image-no-order > div > .columns-img-col) {
order: 0;
}

Expand All @@ -37,13 +40,107 @@
}

.columns.download em {
color: var(--link-color)
color: var(--link-color);
}

.download .secondary:any-link {
padding: 0;
}

/* styles for column gallery variant */
.columns.gallery {
display: flex;
flex-direction: column;
gap: 30px;
}

.columns.gallery > div {
flex-direction: row;
}

.columns.gallery .columns-img-col {
position: relative;
width: calc((100% - 90px) / 4);
}

.columns.gallery .columns-img-col::after {
content: "";
transition: 0.3s ease-out;
transition-property: opacity;
opacity: 0;
width: 100%;
height: 100%;
display: block;
top: 0;
position: absolute;
left: 0;
background: rgb(34 34 34 / 80%);
}

.columns.gallery .columns-img-col:hover::after,
.columns.gallery .columns-img-col:hover:active {
opacity: 1;
}

.columns.gallery img {
aspect-ratio: 1 / 1;
}

/* styles for columns location variant */
.columns.locations {
display: flex;
flex-direction: column;
}

.columns.locations,
.columns.locations > div {
gap: 60px;
}

.columns.locations > div > div {
gap: 60px;
margin: 0;
position: relative;
text-wrap: wrap;
overflow-wrap: anywhere;
}

.columns.locations > div > div::after {
content: "";
position: absolute;
border-top: 1px solid #e5e5e5;
left: 0;
width: 100%;
bottom: -30px;
}

.columns.locations > div:last-of-type > div:last-of-type {
padding-bottom: 30px;
}

.columns.locations > div:last-of-type > div:last-of-type::after {
border: unset;
}

/* styles for produsts variant */
.columns.products .icon {
max-width: 400px;
aspect-ratio: 106 / 75;
width: auto;
height: auto;
display: block;
margin: auto;
}

.columns.products p > picture img {
aspect-ratio: 10 / 7;
}

/* ratio variants */
.columns.ratio > div > div {
margin: unset;
}

@media (width >= 640px) {
/* styles for column grid variant */
.columns.grid > div {
Expand Down Expand Up @@ -84,8 +181,40 @@
padding-top: 0;
}

.columns.grid > div .col-wide,
.columns.grid > div .col-wide,
.columns.grid > div .col-narrow {
flex-basis: 0;
}

/* styles for column gallery variant */
.columns.gallery {
gap: 40px;
}

.columns.locations {
padding-bottom: 40px;
}

.columns.locations > div {
align-items: stretch;
}

.columns.locations > div > div::after {
border-top: unset;
border-right: 1px solid #e5e5e5;
height: 100%;
right: -20px;
top: 0;
width: 1px;
left: unset;
}

.columns.locations > div > div:last-of-type::after {
display: none;
}

/* ratio variants */
.columns.ratio > div {
display: grid;
}
}
34 changes: 34 additions & 0 deletions blocks/columns/columns.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { createOptimizedPicture } from '../../scripts/aem.js';

const borderClassName = 'border-top';

export default function decorate(block) {
Expand All @@ -13,9 +15,25 @@ export default function decorate(block) {
const isDownloadVariant = block.classList.contains('download');

const isGridVariant = block.classList.contains('grid');
const isGalleryVariant = block.classList.contains('gallery');
const ratioClass = [...block.classList].find((cl) => cl.startsWith('ratio-'));
let rationNumbers;

if (ratioClass) {
const regex = /(\d+)/g;

rationNumbers = [...ratioClass.matchAll(regex).map((match) => parseInt(match[1], 10))];
block.classList.add('ratio');
}

// setup image columns
[...block.children].forEach((row) => {
const rows = [...row.children];

if (rationNumbers) {
row.style.gridTemplateColumns = rationNumbers.map((v) => `${v}fr`).join(' ');
}

rows.forEach((col, index) => {
const pic = col.querySelector('picture');
if (pic) {
Expand Down Expand Up @@ -47,6 +65,22 @@ export default function decorate(block) {
col.classList.add('col-narrow');
}
}

// handel gallery variant
if (isGalleryVariant) {
const imageSrc = pic.querySelector('img').src;
const breakpoints = [
{ media: '(min-width: 1800px)', width: '620' },
{ media: '(min-width: 1500px)', width: '460' },
{ media: '(min-width: 1200px)', width: '345' },
{ media: '(min-width: 960px)', width: '238' },
{ media: '(min-width: 640px)', width: '218' },
{ width: '138' },
];
const newPic = createOptimizedPicture(imageSrc, '', false, breakpoints);

pic.replaceWith(newPic);
}
});
});
}
2 changes: 1 addition & 1 deletion blocks/footer/footer.css
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ footer {

@media (width >= 768px) {
.footer .section {
padding: 10px 30px 40px;
padding: 40px 30px;
}

.footer .columns > div {
Expand Down
4 changes: 3 additions & 1 deletion blocks/text/text.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
max-width: 750px;
}

/* centering by variant */
.text.center > div {
margin: auto;
}

/* centering by set the text aling in the document */
.section-center .text {
text-align: center;
}
}
20 changes: 20 additions & 0 deletions icons/kb4.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions icons/kb4rc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ blockquote {
margin-bottom: 1em;
}

ul {
padding-left: 30px;
}

address, dl, fieldset, figure, ol, p, pre, ul {
margin: 0 0 20px;
}

ul {
padding: 0 30px;
}

code {
padding: 0.125em;
}
Expand Down Expand Up @@ -256,7 +256,7 @@ main .section:first-child {
}

main .section:last-child,
main .section.padding-bottom-0 {
main .section.padding-bottom-0 {
padding-bottom: 0;
}

Expand Down

0 comments on commit 9a06a6b

Please sign in to comment.