5 ms·
Nice, but it does not look practical considering it appears to be replacing the whole DOM with every update. However, thumbs up on the idea of UI components tha
by tobr 3y ago
Nice, but it does not look practical considering it appears to be replacing the whole DOM with every update. However, thumbs up on the idea of UI components that aren’t implemented as a framework, but rather as a convention that different frameworks could support.
It would be so nice to just have a way to specify which part of the markup is owned by which component, and the basic life cycle events they need to agree on to work together, but then allow the internal considerations of each component to be handled by any framework or even plain JS if you prefer.
- danielvaughn 3y agoI’m actually working on something like that, but it isn’t a framework necessarily. I’ve described it as a “programming language for designers”. The idea is to allow designers to specify the graphical layer of apps, without specifying any behavior. The core language itself is platform-agnostic, with platform-specific dialects. So you could use it to spec out a web/iOS/android/etc app. And the cool thing about it is that it compiles to an intermediate representation, which will be a JSON data structure. So you could use it to generate a React component library, or Vue, or Angular, or web components, etc etc.
- 20after4 3y agoTo me this sounds a lot like reinventing CSS.
- danielvaughn 3y agoNo no, not at all. The web dialect just uses CSS under the hood, and maps properties 1:1. There’s no magic, no abstraction.
- boris_m 3y agoThis is a reference implementation, you can easily implement it by using React or any other virtual DOM lib. All components would work as well.
- tobr 3y agoNot sure I see how. Components appear to return DOM nodes, but as far as I can see they’re not provided an existing DOM structure to inspect. So they can’t be sure how to safely reuse existing DOM, as they don’t control what the parent will do with the nodes they return.
- boris_m 3y agoNo, I mean to reimplement the "framework". 1. Change the "div" "span" etc. to be just "createElement('div'..." 2. At the "render" function, do "reactDOM.render" instead of "replaceChildren"
- tobr 3y agoI think I misunderstood what you’re trying to do, in that case. This is a pattern for how to handle state updates, rather than a framework that happens to not have any code.
- boris_m 3y agoIt was mainly a demonstration of a pattern, yes, implementation was a secondary consideration. But there are ways to make this approach work as well.