Luc Girardin
01/12/2024, 5:15 PMNick
01/12/2024, 8:35 PMNick
02/06/2024, 5:18 AMLuc Girardin
02/06/2024, 6:30 AMNick
02/06/2024, 6:47 AMLuc Girardin
02/06/2024, 7:14 AMNick
02/06/2024, 7:52 AMView
that will have an embedded HtmlElement
.
public interface ForeignViewFactory {
// creates a View that holds element (scaling it to 100%)
public operator fun invoke(element: HTMLElement): View
}
the new View class itself could be really simple:
internal class ForeignViewInternal(htmlFactory: HtmlFactory, private val element: HTMLElement): View() {
private val root = htmlFactory.create<HTMLIFrameElement>().apply {
this.className = "FOREIGN" // This would change to be some known class used to avoid styling children
style.setWidthPercent (100.0)
style.setHeightPercent(100.0)
element.style.setWidthPercent (100.0)
element.style.setHeightPercent(100.0)
add(element)
}
override fun render(canvas: Canvas) {
if (canvas is NativeCanvas) {
canvas.addData(listOf(root))
}
}
}
then the next step would be to ensure the styles set in SystemStylerImpl don't affect anything within such a View
, hence the class
to tag things.
let me know if this sounds like it would allow the right level of flexibility to embed React components.Luc Girardin
02/06/2024, 2:42 PMLuc Girardin
02/06/2024, 2:42 PMNick
02/06/2024, 3:16 PMall: initial
be used? i know you can reset the CSS properties to their defaults with this short-cut. but wondering how to target this so it only undoes Doodle's styles for these sub components, while letting them use their own styles (inline or via CSS).
i assumed i'd need to modify the styles applied in SystemStylerImpl
so they ignore the sub-children (maybe via some wizardry with not()). but you think all: initial
can work?Luc Girardin
02/06/2024, 3:20 PMLuc Girardin
02/06/2024, 5:52 PMall: initial
should do the trick. Libraries are usually well-behaved these days and they will inject appropriate class names and styles from the element they are instructed to start with, without need to have definitions further up the hierarchy. Thus, my recommendation would be to do nothing on the Doodle side: just allow for creating an HTML element (typically a div) and populate it through a function call (typically createRoot(div).render(NestedApp.create())
when using React). It would be recommended to set the all: initial
property to the div element, but there may be people who would rather prefer to inherit from the Doodle CSS style. You could for exemple imagine to where people who want to use the logic of MUI Base but have a style that match the Doodle style. The only reason I could foresee where it would be beneficial that Doodle create that initial div element is if you want to have it sized based on Doodle layout system. I wrote this quickly because I am cooking at the same time, so let me know if something doesn't make any sense!Nick
02/07/2024, 5:42 AM* {all:initial}
, for child elements) inline.Nick
02/07/2024, 9:01 AM${prefix("body")} div { display:inline }
, which win b/c they target an element type instead of *
. back to the drawing board 😔.Luc Girardin
02/07/2024, 9:04 AMLuc Girardin
02/07/2024, 9:05 AMLuc Girardin
02/07/2024, 9:08 AMall
property in CSS affects all individual properties, but its impact on the display
property may not always be straightforward. The display
property controls how an element is rendered in the document, and its behavior can be affected by other properties as well as the context of the element.
When you use the all: unset;
rule, it resets all properties to their initial values or inherits them from the parent. However, the impact on the display
property might not be as obvious, and it won’t necessarily change the display
value back to its initial state.
For example, if you have an element with a specific display
value, such as block
or inline
, applying all: unset;
won’t necessarily revert the display
property to its default value. The display
property is often determined by the default styling associated with the HTML element, and the all
property might not directly affect it.
To reset the display
property to its initial state, you can explicitly set it in your CSS. For example:
css
div { all: unset; display: initial; /* or display: block; or display: inline; depending on your needs */ }
This will explicitly set the display
property to its initial value for the selected element(s).
In summary, while the all
property can unset many individual properties, its impact on the display
property may require additional, explicit styling to achieve the desired result.Nick
02/08/2024, 4:01 AMLuc Girardin
02/08/2024, 6:51 AMNick
02/08/2024, 7:55 AMwhen()
selector to lower specificity for another rule. then i had to use a class (i.e. what FOREIGN
was the placeholder for) and do .className * { all:revert }
. this seemed to do the trick. but i can't guarantee there aren't some other edge cases.
is this something you would be willing to also test out if i published another snapshot build? i don't do React or anything else in the web ecosystem. so my basic testing might miss some edge case(s).Luc Girardin
02/08/2024, 10:34 AMNick
02/09/2024, 8:46 AM0.10.0-SNAPSHOT
). you can try out hosting html elements by injecting the HtmlElementViewFactory
(available in the Modules._HtmlElementViewModule
), and constructing a View as follows:_
val view = htmlElementViewFactory(element = htmlElement)
Luc Girardin
02/09/2024, 8:47 AMNick
02/14/2024, 3:06 PMLuc Girardin
02/14/2024, 3:10 PMLuc Girardin
02/14/2024, 3:11 PMLuc Girardin
02/14/2024, 3:12 PMLuc Girardin
02/14/2024, 3:13 PMLuc Girardin
02/14/2024, 3:17 PMLuc Girardin
02/14/2024, 3:25 PMLuc Girardin
02/14/2024, 3:28 PMNick
02/14/2024, 4:28 PMLuc Girardin
02/14/2024, 4:32 PMNick
02/14/2024, 4:38 PMLuc Girardin
02/14/2024, 4:42 PMLuc Girardin
02/14/2024, 5:50 PMLuc Girardin
02/14/2024, 5:57 PMLuc Girardin
02/15/2024, 12:52 PMLuc Girardin
02/15/2024, 4:07 PM