Closed BryanWilhite closed 4 years ago
additionally these CSS revelations imply a system must be put in place to address normalizing shadow-DOM CSS:
style
elements used in renderah, this is quite a serious oversight: i need to review my entire configurable CSS strategy
:book: https://lit-element.polymer-project.org/guide/styles
i am pretty much using unsafe
(older) CSS patterns like this:
const cssWidthAndZIndexStyleBlock = html`
<style>
:host div {
width: ${this.cssWidth};
z-index: ${this.cssZIndexBase + 1};
}
:host div > ul {
z-index: ${this.cssZIndexBase + 2};
}
</style>`;
because cssWidth
is just a string
---which is unsafe
Use CSS variables and custom properties to make styles that can be configured at runtime
this sample is clearly showing me that CSS variables can penetrate the shadow DOM: https://stackblitz.com/edit/lit-element-example-sncrr7?file=index.html
<!doctype html>
<html>
<head>
<style>
:root {
--global-color: red;
}
</style>
<script src="./node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script>
<script src="./node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
</head>
<body>
<my-element></my-element>
</body>
</html>
this is great news but forces me to consider dropping the ability to enter arbitrary CSS (composing css
and html
assuming this is possible) or confusing end users with two different CSS customization systems
the ‘mouse-based story of selecting items’ aforementioned leads me to question the need for handling the blur event which occurs when clicking on a Suggestion (unlike the use of the up/down arrow keys which keeps focus)
the blur handler is only needed when suggestions are displayed and the mouse clicks away (apparently abandoning Suggestion selection)
the reason why i have no default CSS settings for
rx-input-autocomplete
was based on the incorrect assumption that light-DOM CSS styling might need to cascade downWeb Component CSS styling cannot be done from the document at all?
https://javascript.info/shadow-dom-style#summary
https://developer.mozilla.org/en-US/docs/Web/CSS/:host()
This CSS-Tricks article shows step by step that the answer is yes:
https://css-tricks.com/styling-a-web-component/