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

Fixed Algolia search box styling #1488

Merged
merged 1 commit into from
Aug 14, 2023
Merged

Fixed Algolia search box styling #1488

merged 1 commit into from
Aug 14, 2023

Conversation

r100-stack
Copy link
Member

@r100-stack r100-stack commented Aug 14, 2023

Changes

The broken Algolia styles were because of some unnecessary astro scoping in the Algolia styles. I fixed this by adding is:global.

Old New
image image
The problem was the unnecessary astro scoping

image


I am not sure why didn't this "missing styles" issue happen in the dev version. I suspect it has something to do with the bug in astro where importing styles into a layer also duplicates those styles outside the layer (as mentioned in #1365 (comment)).

But what I'm confused about is why when running yarn dev before this PR shows this order of styles/stylesheets in the browser inspect pane:

  • body in no layer
  • :root in no layer
  • :root in the thirdparty.algolia layer

i.e., what surprises me is that even though body has a lower specificity ((0, 0, 1)) than :root ((0, 1, 0)), body's styles get preference over :root.

screenshots

image
image


Regardless, making sure the Algolia styles are global solves the styling issue in the prod and dev builds. So this PR is good as-is.

Testing

Ran yarn build and yarn preview in the website workspace to confirm that the styles show up correctly in the production build.

Docs

N/A

@r100-stack r100-stack self-assigned this Aug 14, 2023
@r100-stack r100-stack marked this pull request as ready for review August 14, 2023 16:36
@r100-stack r100-stack requested review from a team as code owners August 14, 2023 16:36
@r100-stack r100-stack requested review from gretanausedaite and mayank99 and removed request for a team August 14, 2023 16:36
Copy link
Contributor

@mayank99 mayank99 left a comment

Choose a reason for hiding this comment

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

LGTM. nice work finding the issue!


what surprises me is that even though body has a lower specificity ((0, 0, 1)) than :root ((0, 1, 0)), body's styles get preference over :root

i've explained this in #1365 (comment) - specificity doesn't matter, position in the dom does.

<html> // <- :root
  <body> // lower in dom
    ...
  </body>
</html>

@r100-stack
Copy link
Member Author

LGTM. nice work finding the issue!

Thanks!

what surprises me is that even though body has a lower specificity ((0, 0, 1)) than :root ((0, 1, 0)), body's styles get preference over :root

i've explained this in #1365 (comment) - specificity doesn't matter, position in the dom does.

<html> // <- :root
  <body> // lower in dom
    ...
  </body>
</html>

Ohh, right, this concept of which CSS variable definition to use often confuses me. I played around with this codesandbox to understand this concept. I will keep this in mind for the next time.

@mayank99 mayank99 merged commit e778cf8 into dev Aug 14, 2023
12 of 14 checks passed
@mayank99 mayank99 deleted the rohan/algolia-styles branch August 14, 2023 16:58
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.

2 participants