by mg · 3y ago · 0 comments
I'm also never sure what magic gets wrapped around the html I type. Does this thing add a DOCTYPE? A header? Or can I define my own header? Etc.
So I made this one, where you edit just a raw html page and see the output right away:
https://no-gravity.github.io/html_editor/
The code is here:
https://github.com/no-gravity/html_editor
One way I often use it is that I copy the whole source (via view source) of a page, paste it into the html_editor, add a <base href="url_of_the_page"> to it and then I can try realtime changes with all the external CSS and JS being loaded just as it is on the original page.
I think it's for this reason you often see those languages split out in code playgrounds. And I also think it's a big part of the initial pushback against css-in-JS libraries such as styled-components or Emotion.
This is why I absolutely love Vue single-file components. AFAIK, there’s no elegant substitute for these in React.
If I want to create a reusable component I need to control the layout tightly, and use media queries for display size.
The user of the component needs to control the colour and cosmetic stuff, while also using media queries, but for dark/light mode.
All four use cases use the same bloody input - CSS! Which means all of the different parties are stepping on each others toes because they may accidentally set a property that needs to be set by a different party.
It's not designed for separation of concerns.
All of the four mentioned use cases are stylistic. So it is desirable to accomplish them in a domain-specific styling language.
Used correctly, conflicting regressions are greatly minified.
It's just the problem with CSS that the vast number of developers don't know about its fundamentals, such as "CSS Specifity"
https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity
This collective lack of knowledge leads to the kind of "monkey patching until it works for me (and breaks for you)" many lament about.
Feel free to give an concrete minimum viable example (including code) where you are struggling with CSS, and I will try to give suggestions.
I respectfully disagree.
CSS controls layout of child components within a container, which is not a stylistic use case.
I've used Qt, WxWidgets, Tk, Delphi, VB and more, and none of them treat layout as a characteristic identical in nature to (for example) background-color.
Finagling the layout manager in any UI toolkit uses a very different mechanism from specifying the colors to use.
> Used correctly, conflicting regressions are greatly minified.
Maybe. I dunno if it is reasonable that the human reader can know all the CSS styles and files, and still not be able to tell which style will eventually be applied, because all of them have a '!' somewhere. > Feel free to give an concrete minimum viable example (including code) where you are struggling with CSS, and I will try to give suggestions.
I'm not really struggling; I find it weird, that is all - I think it is a mixing of concerns when the mechanism used to specify the location of (for example) the major page elements (menubar, leftnav, maincontent, rightnav)is the same as the mechanism to specify the background-color.
That is what the web was built as. We were supposed to browse documents like we browsed magazines. Your React monstrosities were hacked on top of that model, turning the browser into an application runtime - which it wasn't meant to be.
It says,
> MOUNTAIN VIEW, Calif. (December 4, 1995) -- Netscape Communications Corporation (NASDAQ: NSCP) and Sun Microsystems, Inc. (NASDAQ:SUNW), today announced JavaScript, an open, cross-platform object scripting language for the creation and customization of applications on enterprise networks and the Internet.
(Emphasis mine)
JavaScript was always meant for building applications.
Think Outlook Web, Google Maps, and all the smaller apps built with frameworks of their time such as Dojo, YUI etc
There also are monstrosities with the server at the center...
applications with hundreds of hidden form fields per page, required server sessions for anonymous users, DSLs in half-baked server-side templating languages, server code generating and injecting opaque JS to sync state with the client, the list goes on.
And these things all have ups and downs themselves I guess, just like React has.
In fact animation is one of my least favorite uses of JS, the more I can do in CSS, the better.
As a user sometimes I enjoy complex animations but only when it serves a purpose.
However, my own personal guidelines are::
* A small project lives all in one file.
* A medium project is organized by what the files are (markup, images, etc).
* A large project is organized by its major components, and how those components are themselves organized depends on _their_ size and what they do.
* Never be afraid to reorganize a project if (and only if) it makes sense.
Video: https://rt.ht/yt (multi-device, live sync without reloads)
Home: https://elefunc.com/#rtcode_io
Playground: https://rtcode.io
Network: https://rtedge.net
---
To import from CodePen:
• https://codepen.io/jkantner/pen/NWEgzoK (original)
• https://rt.ht/codepen.io/jkantner/pen/NWEgzoK (import)
• https://rtcode.io/jkantner/pen/NWEgzoK (import)
Besides that, I like it. Thanks for the links.
Is this a commercial product?
• https://new.rt.ht (try starting fresh here)
If you cannot save your code, just save the URL which encodes the complete state down to the selected text ranges.
Saving/deployed to 275+ Cloudflare locations may not be available globally yet.
It is will be a free playground with commercial features, such as edge-deployed workers which can be developed in-editor:
• https://sw.rt.ht/? (in-editor)
• https://sw.rt.ht (edge-deployed)
Does it matter? (Serious question) Not for a full website where it matters for duplication / caching / performance, but in this context - for the playground.
There is one little quirky js thing you can do to get the script element from inside the script but I doubt many people are doing that.
<div>…</div><script>document.currentScript.previousSibling.…</script>
Provided you care even vaguely about code size (and are ending up with handfuls of kilobytes at most, not multiple megabytes), inlining everything is excellent for performance (seriously, unreasonably effective, way more than most expect), and if it’s stuff that must be done before the document is fully interactive, then doing it immediately like this rather than messing around with DOMContentLoaded event handlers and querying and such is likewise excellent for performance.Now you *have* to elaborate. And what's the problem it solves?
I used it years ago because we had an XML based templating engine and some "components" needed to inject little scripts to add functionality. I could have given everything unique IDs but this was more fun. Forget what I did with it but I need to know where it was in the DOM or something.
Tbh I also never liked it, for all those reasons you listed.
Ideally it would be a left panel with a treeview list of files with the selected file displayed on the right panel in an editable element.
Output should be a different window which updates on every change.