Skip to content

Commit

Permalink
prevent styles from escaping shadow dom and add warning
Browse files Browse the repository at this point in the history
  • Loading branch information
fpbrault committed Feb 14, 2025
1 parent d5dd436 commit 76f94d2
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 9 deletions.
17 changes: 16 additions & 1 deletion packages/atomic/dev/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const getCurrentExample = () =>

const makeLinks = () => {
return links
.filter((link) => link.href !== window.location.pathname)
.map(
(link) =>
`<li>
Expand All @@ -41,7 +40,20 @@ const example = getCurrentExample();
const styleTag = document.createElement('style');
styleTag.innerHTML = `
html {
@layer base {
.styles-error {
display: none;
}
}
body{
margin: 0;}
header {
min-height: 130px;
}
nav {
padding: 10px 20px;
font-family: var(--atomic-font-family);
span {
Expand All @@ -64,7 +76,10 @@ styleTag.innerHTML = `
styleTag.setAttribute('nonce', '1234567890');

header.innerHTML = `
<span class="styles-error block font-bold text-error">If you can see this, our styles have escaped shadow DOM
</span>
<nav>
<span>${example ? example.label : ''} example</span>
<ul>
${makeLinks()}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {CommerceBindings as Bindings} from '../../atomic-commerce-interface/atom
*/
@Component({
tag: 'atomic-commerce-facets',
styleUrl: 'atomic-commerce-facets.pcss',
shadow: false,
})
export class AtomicCommerceFacets implements InitializableComponent<Bindings> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
@apply set-font-size-base;

margin-top: 1.25rem;
max-height: 2.5rem;
@apply line-clamp-2;
}

Expand Down Expand Up @@ -145,7 +144,6 @@
@apply set-font-size-base;

margin-top: 1rem;
max-height: 2.5rem;
@apply line-clamp-2;
}

Expand Down Expand Up @@ -226,7 +224,6 @@
@apply set-font-size-base;

margin-top: 0.75rem;
max-height: 1.25rem;
@apply line-clamp-1;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {Bindings} from '../../atomic-search-interface/atomic-search-interface';
*/
@Component({
tag: 'atomic-automatic-facet-generator',
styleUrl: 'atomic-automatic-facet-generator.pcss',
shadow: false,
})
export class AtomicAutomaticFacetGenerator implements InitializableComponent {
Expand Down
1 change: 1 addition & 0 deletions packages/atomic/src/themes/coveo.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
--animate-scale-up-modal: scaleUp 0.5s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;

--spacing: 0.25rem;
--tw-leading: 1.5;
}

@property --tw-ring-offset-shadow {
Expand Down
2 changes: 1 addition & 1 deletion packages/atomic/src/utils/coveo.tw.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@theme inline static {
@theme static {
/* Primary colors */
--atomic-primary: #126ce0;
--atomic-primary-light: #399ffe;
Expand Down

0 comments on commit 76f94d2

Please sign in to comment.