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.
Merge pull request #23 from hlxsites/config-sheet
#464411 - Add external components config excel sheet
- Loading branch information
Showing
15 changed files
with
627 additions
and
455 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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,27 +1,30 @@ | ||
import { collectAttributes } from '../../scripts/libs.js'; | ||
import ComponentBase from '../../scripts/component-base.js'; | ||
import { stringToArray } from '../../scripts/libs.js'; | ||
|
||
// TODO the block for this component should not have content, the values should come only form class attribute as for any other component | ||
// as for any other block. should replace the this.parentElement | ||
export default class SectionMetadata extends ComponentBase { | ||
async ready() { | ||
const classes = [...this.querySelectorAll(':scope > div > div:first-child')].map( | ||
(keyCell) => `${keyCell.textContent.trim()}-${keyCell.nextElementSibling.textContent.trim()}`, | ||
); | ||
static observedAttributes = ['class']; | ||
|
||
const { currentAttributes } = collectAttributes( | ||
'section-metadata', | ||
classes, | ||
SectionMetadata.observedAttributes, | ||
this, | ||
); | ||
const section = this.parentElement; | ||
Object.keys(currentAttributes).forEach((key) => { | ||
if (key === 'class') { | ||
section.setAttribute(key, currentAttributes[key]); | ||
} else { | ||
section.setAttribute(`data-${key}`, currentAttributes[key]); | ||
} | ||
}); | ||
extendConfig() { | ||
return [ | ||
...super.extendConfig(), | ||
{ | ||
classes: { | ||
section: 'section', | ||
}, | ||
}, | ||
]; | ||
} | ||
|
||
ready() { | ||
this.parentElement.classList.add(this.config.classes.section, ...this.classList.values()); | ||
} | ||
|
||
onAttributeClassChanged({ oldValue, newValue }) { | ||
if (!this.initialized) return; | ||
if (oldValue === newValue) return; | ||
|
||
const opts = { divider: ' ' }; | ||
this.parentElement.classList.remove(...stringToArray(oldValue, opts)); | ||
this.parentElement.classList.add(...stringToArray(newValue, opts)); | ||
} | ||
} |
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
Oops, something went wrong.