Skip to content

Commit

Permalink
refactor(cxl-lumo-styles): cxl-section - avoid !important, hide old b…
Browse files Browse the repository at this point in the history
…ackground-image
  • Loading branch information
freudFlintstone committed Dec 5, 2023
1 parent a19be96 commit ea5e829
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
13 changes: 6 additions & 7 deletions packages/cxl-lumo-styles/scss/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
@mixin wide-background {
position: relative;
overflow-x: hidden;
background-repeat: no-repeat !important;
background-size: auto clamp(65%, 40vw, 90%) !important;
background: unset !important;

&::before {
position: absolute;
Expand Down Expand Up @@ -90,7 +89,7 @@
}
}

// Use ::after pseudo element to add hero background image. url must be set to CSS custom property --hero-image
// Use ::after pseudo element to add hero background image. url must be set to CSS custom property --cxl-hero-image
@mixin wide-background-hero-image {
&::after {
content: "";
Expand All @@ -99,10 +98,10 @@
width: 100%;
height: clamp(calc(50% + 82px), calc(50% + var(--figure-height-factor)), calc(50% + var(--figure-height-factor)));
max-height: calc(50% + var(--figure-height-factor));
background-image: var(--hero-image);
background-repeat: no-repeat !important;
background-size: auto clamp(65%, 40vw, 100%) !important;
background-position-x: left !important;
background-image: var(--cxl-hero-image);
background-repeat: no-repeat;
background-size: auto clamp(65%, 40vw, 100%) ;
background-position-x: left;
background-position-y: bottom;
overflow: visible;
z-index: -1;
Expand Down
2 changes: 1 addition & 1 deletion packages/cxl-ui/scss/cxl-section.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
background-color: transparent !important; /* stylelint-disable-line declaration-no-important */
}

@media #{mq.$large} {
@media #{mq.$medium} {
:host(#view-hero) {
@include mixins.wide-background();
@include mixins.extend-background-right();
Expand Down
10 changes: 2 additions & 8 deletions packages/cxl-ui/scss/global/cxl-section.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
/* stylelint-disable selector-no-qualifying-type */
@use "~@conversionxl/cxl-lumo-styles/scss/mq";


// Use more specific selector to hide cxl-section background-image.
cxl-section.wp-block-group.wp-block-cxl-section#view-hero {
background: none !important;
}

cxl-section#view-hero, cxl-section[theme~="cxl-header"] {
cxl-section#view-hero, cxl-section[theme~="cxl-hero"] {
.column-1 {
@media #{mq.$large} {
@media #{mq.$medium} {
max-width: 45%;
}
}
Expand Down
10 changes: 6 additions & 4 deletions packages/storybook/cxl-ui/cxl-section/cxl-section.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ export default {
description: {
component: 'Use `<cxl-section theme="cxl-header">` to create a section header component. \
`cxl-section` components with id="view-hero" are automatically themed as hero headers. \
Additionally, it is necessary to add CSS code in wordpress block-editor: \
Additionally, it is necessary to custom CSS code on cxl-section element, for each page: \
\
\
`#view-hero::after { \
background-image: url([wpv-post-featured-image size="xx-large" output="url"]); \
}` \
<style> \
cxl-section { \
--cxl-hero-image: url([wpv-post-featured-image size="large" output="url"]) \
} \
</style> \
',
},
}
Expand Down

0 comments on commit ea5e829

Please sign in to comment.