adobe / aem-guides-wknd

Tutorial Code companion for Getting Started Developing with AEM Sites WKND Tutorial
https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-wknd-tutorial-develop/overview.html
MIT License
288 stars 569 forks source link

Target xf css issue #418

Closed knennigtri closed 1 year ago

knennigtri commented 1 year ago

When using the WKND XFs in Target on a WKND page, the HTML imported into Target contains:

<body class="xf-web-container">
 <div class="container">
    <div class="root container responsivegrid">
      <div id="container-d5e81cbcff" class="cmp-container">
         ...

WKND's css library uses body .root { to set spacing at the top of the WKND site with elements.scss:

body {
 ...
  .root {
     max-width: $max-body-width;
     margin: 0 auto;
     padding-top:$header-height;
     ...

When a WKND XF is added to a WKND page using the VEC with an imported XF from AEM, the css above is applied to the XF and therefore the component padding-top is set to $header-height.

image

This can be fixed by fixing the template-type and template for the WKND experience fragment template.

Description

Under ui.content.sample and ui.content the root nodes are updated to xf-root:

This allows the WKND XFs to be imported into Target without the root class and therefor, the padding is not applied:

<body class="xf-web-container">
 <div class="container">
    <div class="xf-root container responsivegrid">
      <div id="container-d5e81cbcff" class="cmp-container">
         ...

image

Motivation and Context

This allows anyone to use WKND as a reference website for the AEM XF and Adobe Target integration flawlessly.

Someone can now use the pre-created XF content in WKND and apply it successfully and beautifully to the WKND site using Adobe Target without the components 'jumping around' on the page.

How Has This Been Tested?

All tested locally on 2023.06 SDK

Checklist:

davidjgonzalez commented 1 year ago

@knennigtri Couldnt we just add CSS?:

body.xf-web-container .root { 
    all: unset;
}

(...or whatever needs to be unset/zero'd out)

my concern is that AEM OOTB the node name is called root, so i think you'd have to go in there and change the node names everything manually (in template and any existing nodes).

knennigtri commented 1 year ago

This is probably a simpler/more elegant solution. Let me investigate.

knennigtri commented 1 year ago

It looks like when an XF is imported into Target the HTML is different:

<div class="teaser cmp-teaser--featured aem-GridColumn aem-GridColumn--default--12">
  <div id="featured-article-magazine" class="cmp-teaser at-element-marker">
    <div>
      js/css for XF loaded
      <div class="container">
         <div class="root container responsivegrid">
            .....

Based on this snippet and @davidjgonzalez suggestion, I've updated this PR to update only elements.scss