Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[template/angular-xmcloud] Fix SXA component styles for basic site #1910

Closed
wants to merge 4 commits into from

Conversation

addy-pathania
Copy link
Contributor

@addy-pathania addy-pathania commented Aug 28, 2024

Description / Motivation

  • Fix styles issues caused by extra Angular selector tags in DOM tree.
  • Fix double inclusion of bootstrap styles in bundle.

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@addy-pathania addy-pathania requested a review from a team August 28, 2024 00:48
@@ -4,5 +4,22 @@ import { SxaComponent } from '../sxa.component';
@Component({
selector: 'app-promo',
templateUrl: './promo.component.html',
styles: [
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we create a separate SCSS file to store the styles?

import { Field } from '@sitecore-jss/sitecore-jss-angular';
import { SxaComponent } from '../sxa.component';

@Component({
selector: 'app-richtext',
templateUrl: './richtext.component.html',
styles: [
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above regarding SCSS file

import { Field } from '@sitecore-jss/sitecore-jss-angular';
import { SxaComponent } from '../sxa.component';

@Component({
selector: 'app-richtext',
templateUrl: './richtext.component.html',
styles: [
`
:host(.footer-richtext) {
Copy link
Contributor

@illiakovalenko illiakovalenko Aug 28, 2024

Choose a reason for hiding this comment

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

Inside all of these styles I see a lot of "magic" numbers
e.g. "width: 17%", "nth-child(2)", "max-width: 992px"
to me it means that here is kind of "hack" applied to this component, so the solution is not reliable

Copy link
Contributor

@yavorsk yavorsk Aug 28, 2024

Choose a reason for hiding this comment

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

maybe we can explore using attribute selectors for components instead type selectors? that could possibly remove the additional markup generated by angular

let parent = this.el.nativeElement.parentElement;

while (parent) {
if (parent.id === 'footer') {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can't use such condition and rely on specific parent component
it's a "hack", what will happen if id of the parent element is changed but it's actually the same "footer" placeholder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants