generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,138 additions
and
44 deletions.
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
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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import { | ||
addCssVariables, | ||
} from '../../scripts/lib-franklin.js'; | ||
|
||
export default function decorate(block) { | ||
const cols = [...block.firstElementChild.children]; | ||
block.classList.add(`columns-${cols.length}-cols`); | ||
const columns = block.querySelectorAll(':scope > div > div'); | ||
const columnCount = columns.length; | ||
// following line regex matches partition sizes separated by dashes like 1-2-3 | ||
const columnPartionRegex = /^\d{1,}(?:-\d{1,})*$/; | ||
const columnPartions = [...block.classList].find((c) => columnPartionRegex.test(c))?.split('-') || []; | ||
|
||
// setup image columns | ||
[...block.children].forEach((row) => { | ||
[...row.children].forEach((col) => { | ||
const pic = col.querySelector('picture'); | ||
if (pic) { | ||
const picWrapper = pic.closest('div'); | ||
if (picWrapper && picWrapper.children.length === 1) { | ||
// picture is only content in column | ||
picWrapper.classList.add('columns-img-col'); | ||
} | ||
} | ||
}); | ||
}); | ||
const variables = {}; | ||
for (let i = 0; i < columnCount; i += 1) { | ||
const partition = columnPartions.length > i ? columnPartions[i] : 1; | ||
variables[`column${i}-flex`] = partition; | ||
} | ||
addCssVariables(block, variables); | ||
} |
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,30 @@ | ||
.section.grid { | ||
display: grid; | ||
grid-template-columns: var(--grid-template-columns, unset); | ||
grid-template-rows: var(--grid-template-rows, unset); | ||
} | ||
|
||
.section.grid .element { | ||
grid-column: var(--grid-column-start-position, auto) / var(--grid-column-end-position, auto); | ||
grid-row: var(--grid-row-start-position, auto) / var(--grid-row-end-position, auto); | ||
width: 100%; | ||
max-width: unset; | ||
background-color: var(--background-color, transparent); | ||
color: var(--text-color); | ||
margin: auto; | ||
} | ||
|
||
.section.grid .element .image-wrapper { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.section.grid .element img { | ||
width: 100%; | ||
height: auto; | ||
} | ||
|
||
.section.grid .element p { | ||
margin: 0; | ||
padding: var(--padding-vertical) var(--padding-horizontal); | ||
} |
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,29 @@ | ||
import { | ||
addCssVariables, | ||
} from '../../scripts/lib-franklin.js'; | ||
|
||
export default function decorate(block) { | ||
const elements = [...block.querySelectorAll(':scope > div')]; | ||
|
||
const columnTemplate = elements.find((e) => e.dataset.gridColumns)?.dataset.gridColumns; | ||
const rowTemplate = elements.find((e) => e.dataset.gridRows)?.dataset.gridRows; | ||
if (columnTemplate || rowTemplate) { | ||
addCssVariables(block, { | ||
'grid-template-columns': columnTemplate, | ||
'grid-template-rows': rowTemplate, | ||
}); | ||
} | ||
|
||
elements.forEach((e) => { | ||
e.classList.add('element'); | ||
|
||
const [[startColumnPosition, startRowPosition], [endColumnPosition, endRowPosition]] = e.dataset.gridPosition.split(/\s*\/\s*/).map((p) => p.split(/\s*-\s*/)); | ||
|
||
addCssVariables(e, { | ||
'grid-column-start-position': startColumnPosition, | ||
'grid-row-start-position': startRowPosition, | ||
'grid-column-end-position': endColumnPosition, | ||
'grid-row-end-position': endRowPosition, | ||
}); | ||
}); | ||
} |
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,19 @@ | ||
header a:any-link { | ||
color: inherit; | ||
} | ||
|
||
header p, | ||
header .section.grid .element p { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
a.button:any-link { | ||
background-color: transparent; | ||
color: inherit; | ||
font-weight: normal; | ||
} | ||
|
||
a.button:any-link .icon { | ||
vertical-align: middle; | ||
} |
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
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,5 @@ | ||
.navigation ul { | ||
list-style: none; | ||
display: flex; | ||
gap: var(--padding-horizontal); | ||
} |
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,3 @@ | ||
export default async function decorate(/* block */) { | ||
// nop | ||
} |
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.