generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MWPW-137717 | New block - Basic Brick & Masonry #1515
Merged
Merged
Changes from 45 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
03c54fe
Basic brick and masonry block block
aishwaryamathuria 2808e51
latest update
aishwaryamathuria 8a7a095
Cleanup
aishwaryamathuria 0a8f105
Cleanup
aishwaryamathuria 7692a52
Masonry brick height
aishwaryamathuria 81fec4b
Unit tests
aishwaryamathuria 2db10d7
Cleanup
aishwaryamathuria 8111224
Cleanup
aishwaryamathuria 3903c0a
CHanginf block name
aishwaryamathuria ceb0ac9
Target non empty p tags only
aishwaryamathuria 54bacb5
Merge branch 'main' into masonry
aishwaryamathuria 8f7025b
Merge branch 'adobecom:main' into masonry
aishwaryamathuria 39d2189
Reduce line of code for button
aishwaryamathuria 123152c
Fixing font-weight
aishwaryamathuria a57fa29
Fixing font-weight
aishwaryamathuria d1d74d7
Merge branch 'adobecom:main' into masonry
aishwaryamathuria e33f62c
Review comments
aishwaryamathuria f2853e7
Fixing object fit issue
aishwaryamathuria a23048f
Merge branch 'main' into masonry
Blainegunn c37d820
Merge branch 'stage' into masonry
Blainegunn bdb7448
Adding brick block
aishwaryamathuria 568a475
Merge branch 'masonry' of github.com:aishwaryamathuria/milo into masonry
aishwaryamathuria c76ee95
Merge branch 'main' into masonry
Blainegunn 58b0bc1
Merge branch 'main' into masonry
aishwaryamathuria 637fbc8
Filter the p tag to remove empty and whitespace ones
aishwaryamathuria 05fa9bb
MWPW-139392
aishwaryamathuria 7371093
MWPW-139392
aishwaryamathuria 29f825b
MWPW-139392
aishwaryamathuria d98a06f
MWPW-139812
aishwaryamathuria 00c7de2
Tmp change
aishwaryamathuria 9f124d5
revert Tmp change
aishwaryamathuria 93bdb67
Merge branch 'main' into masonry
aishwaryamathuria b06dd28
Merge branch 'main' into masonry
aishwaryamathuria 361dc77
Merge branch 'main' into masonry
aishwaryamathuria 0ca3f71
Review comments
aishwaryamathuria 76a3bb8
Review comments
aishwaryamathuria d0b2b05
Unit tests
aishwaryamathuria 161b0dd
Fix
aishwaryamathuria 03fd7f1
Fix
aishwaryamathuria 2a8fd33
Fix
aishwaryamathuria 9a7e0d7
Merge branch 'main' into masonry
aishwaryamathuria 222479d
Fix
aishwaryamathuria 157e30e
Fix
aishwaryamathuria 091adb9
Align bricks
aishwaryamathuria edc9a16
Unit tests
aishwaryamathuria 546055f
Remove extra span 12
aishwaryamathuria c4a4c95
Merge branch 'main' into masonry
aishwaryamathuria 4bcf8f1
Update class name
aishwaryamathuria 3e8ac98
Merge branch 'masonry' of github.com:aishwaryamathuria/milo into masonry
aishwaryamathuria 500f610
Merge branch 'main' into masonry
aishwaryamathuria fe3e823
fixing lint error
aishwaryamathuria File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,245 @@ | ||
.brick { | ||
position: relative; | ||
display: flex; | ||
text-size-adjust: none; | ||
min-height: 300px; | ||
} | ||
|
||
.brick, | ||
.brick.click a.foreground { | ||
color: inherit; | ||
} | ||
|
||
.brick.light, | ||
.brick.light.click a.foreground { | ||
color: var(--text-color); | ||
} | ||
|
||
.brick.dark, | ||
.dark.brick.click a.foreground { | ||
color: var(--color-white); | ||
} | ||
|
||
.brick .foreground a:not([class]), | ||
.brick .foreground span.first-link { | ||
font-weight: 700; | ||
} | ||
|
||
.brick.rounded-corners, | ||
.brick.rounded-corners .background, | ||
.brick.rounded-corners .foreground { | ||
border-radius: var(--spacing-xs); | ||
} | ||
|
||
.brick .background { | ||
position: absolute; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
top: 0; | ||
overflow: hidden; | ||
} | ||
|
||
.brick .foreground { | ||
position: relative; | ||
display: flex; | ||
flex-grow: 1; | ||
padding: var(--spacing-m); | ||
} | ||
|
||
.brick.align-center .foreground, | ||
.brick.align-center .foreground .action-area, | ||
.brick.center .foreground, | ||
.brick.center .foreground .action-area { | ||
align-items: center; | ||
text-align: center; | ||
justify-content: center; | ||
} | ||
|
||
.brick.center .foreground { | ||
align-items: flex-start; | ||
} | ||
|
||
.brick .background div, | ||
.brick .background p, | ||
.brick .background picture { | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.brick .background p, | ||
.brick .background picture { | ||
display: block; | ||
} | ||
|
||
.brick .background img { | ||
object-fit: contain; | ||
object-position: bottom center; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
.brick .mobile-only, | ||
.brick .tablet-only, | ||
.brick .desktop-only { | ||
display: none; | ||
} | ||
|
||
.brick .foreground .icon-area picture { | ||
display: flex; | ||
} | ||
|
||
.brick .foreground p { | ||
padding: 0; | ||
margin: 0; | ||
} | ||
|
||
.brick .foreground div > * { | ||
margin-top: var(--spacing-xs); | ||
} | ||
|
||
.brick .foreground p:first-child, | ||
.brick .foreground p.icon-area, | ||
.brick .foreground p.icon-area + p { | ||
margin-top: 0; | ||
} | ||
|
||
.brick .foreground p.icon-area { | ||
display: inline-block; | ||
margin-bottom: var(--spacing-s); | ||
} | ||
|
||
.brick .foreground p.action-area { | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: 24px; | ||
margin-top: var(--spacing-s); | ||
} | ||
|
||
.brick .icon-stack-area li picture { | ||
display: flex; | ||
margin: 0; | ||
padding: 0; | ||
flex-shrink: 0; | ||
} | ||
|
||
.brick .icon-stack-area li img { | ||
width: var(--icon-size-s); | ||
height: auto; | ||
} | ||
|
||
.brick .foreground .icon-area img { | ||
height: var(--icon-size-l); | ||
width: auto; | ||
} | ||
|
||
.brick.click > a { | ||
text-decoration: none; | ||
} | ||
|
||
.brick .icon-stack-area { | ||
display: flex; | ||
flex-flow: row wrap; | ||
flex-direction: column; | ||
gap: var(--spacing-xs); | ||
width: 100%; | ||
margin: 0; | ||
padding: 0; | ||
list-style-type: none; | ||
} | ||
|
||
.brick.center .icon-stack-area, | ||
.brick.align-center .icon-stack-area { | ||
display: inline-flex; | ||
width: auto; | ||
} | ||
|
||
.brick .icon-stack-area li, | ||
.brick .icon-stack-area li a { | ||
display: flex; | ||
align-items: center; | ||
gap: var(--spacing-xs); | ||
text-align: left; | ||
} | ||
|
||
[dir="rtl"] .brick .icon-stack-area li, | ||
[dir="rtl"] .brick .icon-stack-area li a { | ||
text-align: right; | ||
} | ||
|
||
.brick.click a.foreground .first-link:not([class*="button"]) { | ||
color: var(--link-color); | ||
text-decoration: none; | ||
} | ||
|
||
.brick.click:hover a.foreground .first-link:not([class*="button"]) { | ||
text-decoration: underline; | ||
color: var(--link-hover-color); | ||
} | ||
|
||
.static-links .brick.click a.foreground .first-link:not([class*="button"]), | ||
.static-links .brick.click a.foreground a:not([class*="button"]), | ||
.brick.static-links.click a.foreground .first-link:not([class*="button"]), | ||
.brick.static-links.click a.foreground a:not([class*="button"]) { | ||
color: inherit; | ||
text-decoration: underline; | ||
} | ||
|
||
.brick.click:hover .first-link.con-button.blue, | ||
.brick.click:active .first-link.con-button.blue { | ||
background: var(--color-accent-hover); | ||
border-color: var(--color-accent-hover); | ||
color: var(--color-white); | ||
} | ||
|
||
.brick.click:hover .first-link.con-button, | ||
.brick.click:active .first-link.con-button, | ||
.brick.light.click:hover .first-link.con-button, | ||
.brick.light.click:active .first-link.con-button, | ||
.light .brick.click:hover .first-link.con-button, | ||
.light .brick.click:active .first-link.con-button { | ||
background-color: var(--color-black); | ||
border-color: var(--color-black); | ||
color: var(--color-white); | ||
} | ||
|
||
.dark .brick.click:hover .first-link.con-button, | ||
.brick.dark.click:active .first-link.con-button { | ||
background-color: var(--color-white); | ||
color: var(--color-black); | ||
text-decoration: none; | ||
} | ||
|
||
|
||
@media screen and (max-width: 600px) { | ||
.brick .mobile-only { | ||
display: block; | ||
} | ||
} | ||
|
||
@media screen and (min-width: 600px) { | ||
.brick { | ||
min-height: 384px; | ||
} | ||
|
||
.brick .foreground { | ||
padding: var(--spacing-l); | ||
} | ||
} | ||
|
||
@media screen and (min-width: 600px) and (max-width: 1199px) { | ||
.brick .tablet-only { | ||
display: block; | ||
} | ||
} | ||
|
||
@media screen and (min-width: 1200px) { | ||
.brick .desktop-only { | ||
display: block; | ||
} | ||
|
||
.brick.large { | ||
min-height: 500px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { decorateTextOverrides, decorateBlockText, decorateBlockBg, decorateIconStack, decorateButtons } from '../../utils/decorate.js'; | ||
import { createTag } from '../../utils/utils.js'; | ||
|
||
const blockTypeSizes = { | ||
large: ['xxl', 'm', 'l'], | ||
default: ['xl', 'm', 'l'], | ||
}; | ||
const objFitOptions = ['fill', 'contain', 'cover', 'none', 'scale-down']; | ||
|
||
function getBlockSize(el) { | ||
const sizes = Object.keys(blockTypeSizes); | ||
const size = sizes.find((s) => el.classList.contains(`${s}`)) || 'default'; | ||
return blockTypeSizes[size]; | ||
} | ||
|
||
function handleSupplementalText(foreground) { | ||
if (!foreground.querySelector('.action-area')) return; | ||
const nextP = foreground.querySelector('.action-area + p'); | ||
const lastP = foreground.querySelector('.action-area ~ p:last-child'); | ||
if (nextP) nextP.className = ''; | ||
if (lastP) lastP.className = 'supplemental-text'; | ||
} | ||
|
||
function setObjectFitAndPos(text, pic, bgEl) { | ||
const backgroundConfig = text.split(',').map((c) => c.toLowerCase().trim()); | ||
const fitOption = objFitOptions.filter((c) => backgroundConfig.includes(c)); | ||
const focusOption = backgroundConfig.filter((c) => !fitOption.includes(c)); | ||
if (fitOption) [pic.querySelector('img').style.objectFit] = fitOption; | ||
bgEl.innerHTML = ''; | ||
bgEl.append(pic); | ||
bgEl.append(document.createTextNode(focusOption.join(','))); | ||
} | ||
|
||
function handleObjectFit(bgRow) { | ||
const bgConfig = bgRow.querySelectorAll('div'); | ||
[...bgConfig].forEach((r) => { | ||
const pic = r.querySelector('picture'); | ||
if (!pic) return; | ||
let text = ''; | ||
const pchild = [...r.querySelectorAll('p:not(:empty)')].filter((p) => p.innerHTML.trim() !== ''); | ||
if (pchild.length > 2) text = pchild[1]?.textContent.trim(); | ||
if (!text && r.textContent) text = r.textContent; | ||
if (!text) return; | ||
setObjectFitAndPos(text, pic, r); | ||
}); | ||
} | ||
|
||
function handleClickableBrick(el, foreground) { | ||
if (!el.classList.contains('click')) return; | ||
const links = foreground.querySelectorAll('a'); | ||
if (links.length !== 1) { el.classList.remove('click'); return; } | ||
const a = links[0]; | ||
const linkDiv = createTag('span', { class: [...a.classList, 'first-link'].join(' ') }, a.innerHTML); | ||
a.replaceWith(linkDiv, a); | ||
a.className = 'foreground'; | ||
el.appendChild(a); | ||
a.innerHTML = foreground.innerHTML; | ||
foreground.remove(); | ||
} | ||
|
||
function decorateSupplementalText(el) { | ||
const supplementalEl = el.querySelector('.foreground p.supplemental-text'); | ||
if (!supplementalEl) return; | ||
supplementalEl.className = 'body-xs supplemental-text'; | ||
} | ||
|
||
function decorateBricks(el) { | ||
if (!el.classList.contains('light')) el.classList.add('dark'); | ||
const elems = el.querySelectorAll(':scope > div'); | ||
if (elems.length > 1) { | ||
handleObjectFit(elems[elems.length - 2]); | ||
decorateBlockBg(el, elems[elems.length - 2], { useHandleFocalpoint: true }); | ||
} | ||
if (elems.length > 2) { | ||
el.querySelector('.background').style.background = elems[0].textContent; | ||
elems[0].remove(); | ||
} | ||
const foreground = elems[elems.length - 1]; | ||
foreground.classList.add('foreground'); | ||
const hasIconArea = foreground.querySelector('p')?.querySelector('img'); | ||
if (hasIconArea) foreground.querySelector('p').classList.add('icon-area'); | ||
const blockFormatting = getBlockSize(el); | ||
decorateButtons(foreground, 'button-l'); | ||
decorateBlockText(foreground, blockFormatting); | ||
decorateIconStack(el); | ||
el.querySelector('.icon-stack-area')?.classList.add('body-xs'); | ||
handleSupplementalText(foreground); | ||
handleClickableBrick(el, foreground); | ||
return foreground; | ||
} | ||
|
||
export default async function init(el) { | ||
decorateBricks(el); | ||
decorateTextOverrides(el); | ||
decorateSupplementalText(el); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think along the same lines as the
basic-brick
conversation from Chris M, I thinkmasonry-layout
can be simplified to justmasonry
. Layout is implied unless there are more options related tomasonry
.This makes authoring much easier too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rgclayton Adding the update to the comment - masonry-layout is a polyfill and the authoring does not require the authors to add this as a style. As per the latest authoring format this would only need new masonry key row in the section-metadata with layout info.