HeinrichApfelmus / threepenny-gui

GUI framework that uses the web browser as a display.
https://heinrichapfelmus.github.io/threepenny-gui/
Other
437 stars 77 forks source link

Simplified loading of static content #160

Closed jerbaroo closed 7 years ago

jerbaroo commented 7 years ago

To include a single CSS file we currently need to write a HTML file e.g. /samples/static/chat.html and serve the CSS file from our static folder. This is a lot of code for a single CSS file and also requires users to remember to include:

<script src="haskell.js"></script>
<script type="text/javascript" charset="utf-8">
    Haskell.initFFI();
</script>

(At least I'm not aware of a more simple way)

Suggestion is to add a way of importing CSS files that doesn't require so much wiring. Perhaps:

main = startGUI defaultConfig { includeCSS = ["/static/css/chat.css"] } setup

In the above case we edit the default served HTML by adding a stylesheet import pointing to "/static/css/chat.css".

Could also extend this mechanism for including scripts:

config = defaultConfig { includeScripts = [
    "/static/js/chat.js",
    "https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"] }
main = startGUI config setup
HeinrichApfelmus commented 7 years ago

Well, for CSS stylesheets, there is the addStyleSheet function. Does that help?

jerbaroo commented 7 years ago

Perfect, I dont know how I missed it.