Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

[DOCS] 558: Page Builder styling improvements. #15

Closed
wants to merge 13 commits into from
Closed

Conversation

bdenham
Copy link
Collaborator

@bdenham bdenham commented Nov 16, 2020

Description

This PR adds documentation for the new Page Builder CSS styling described in magento/magento2-page-builder#558.

Preview

You must be logged into Adobe's AnyConnect VPN to view the following previews:

Overview topic: https://devdocs.magedevteam.com/77/page-builder/docs/styling/how-pagebuilder-styles-content.html
How to override topic: https://devdocs.magedevteam.com/77/page-builder/docs/styling/how-to-add-custom-styles.html

@bdenham bdenham added documentation Improvements or additions to documentation enhancement New feature or request labels Nov 16, 2020
@bdenham bdenham self-assigned this Nov 16, 2020
@bdenham bdenham changed the base branch from master to 1.6.0-release November 17, 2020 23:20

1. **Html-body id**. The first thing to notice is the CSS `id=html-body` assigned to Magento storefront pages. Page Builder uses this `id` to construct all the CSS selectors it applies to its content types.

2. **Internal style block**. Page Builder adds all the unique `data-pb-style` attribute styles (one for each content type on the page) to a single `<style>` block. This creates what's called an internal stylesheet for the page. In this example, the page contains three content types. So Page Builder has added three CSS rulesets to the `<style>` block, one for each content type on the page. If the page contained 10 content types, the `<style>` block would contain 10 CSS rulesets.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be less specific about the count of rulesets because they are not aligned with a number of content types


2. **Internal style block**. Page Builder adds all the unique `data-pb-style` attribute styles (one for each content type on the page) to a single `<style>` block. This creates what's called an internal stylesheet for the page. In this example, the page contains three content types. So Page Builder has added three CSS rulesets to the `<style>` block, one for each content type on the page. If the page contained 10 content types, the `<style>` block would contain 10 CSS rulesets.

3. **Applied styles**. The dynamic `data-pb-style` attributes on the content types match their respective CSS styles in the `<style>` block, and the browser does the rest. For custom content types (and many native content types), Page Builder applies the `data-pb-style` attribute to the top-level container element. However, for some content types, like the Row shown in this example, the `data-pb-style` attribute is added to an inner element.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are adding data-pb-style to each element in content type which contains styles


![Page Builder style selector](../images/pagebuilder-style-override-selector.svg)

This CSS selector results in a CSS specificity value of 120, which overrides the 110 specificity for Page Builder styles, while keeping the specificity relatively low for any additional overrides, as needed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like that you are adding specificity value to make it more understandable!

@bdenham bdenham closed this Dec 16, 2020
@bdenham bdenham deleted the styling branch January 16, 2021 13:18
magento-devops-reposync-svc pushed a commit that referenced this pull request Jun 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants