gdotdesign / elm-ui

UI library for making web applications with Elm
https://elm-ui.netlify.com
BSD 2-Clause "Simplified" License
920 stars 39 forks source link

relative main.css #29

Closed robashton closed 8 years ago

robashton commented 8 years ago

Hey, this is more of a dumbass query than an "issue" per se - but I don't see a way of overriding the location of main.css

https://github.com/gdotdesign/elm-ui/blob/0.2/source/Ui/App.elm#L123

I've got my elm app as a sub-path of one of my projects which means it's accessed via

/foo/index.html

and the initial load can't take place when I pull it up in an app. I notice in the kitchen sink and master branch it looks like this

https://github.com/gdotdesign/elm-ui/blob/master/source/Ui/App.elm#L99

So it works fine; I assume the kitchen sink wouldn't work under the current gh-pages set-up therefore.

( http://gdotdesign.github.io/elm-ui/ <-- sub-path)

Am I missing something? Happy to do this as my first ever PR if it's something that needs changing somehow :)

robashton commented 8 years ago

Although tbh, https://github.com/gdotdesign/elm-ui/blob/0.2/public/index.html#L5 doesn't work either if you do a make because it's Main.js and not main.js

I know this is small-fry but "muh website doesn't work" on 0.17.0 with 0.2 at present =)

gdotdesign commented 8 years ago

Thanks for bringing this up, I have run into this issue couple of time myself that is why it changed so many times.

I see a couple of solutions for this:

  1. move the loading of the main.css to the index.html and basically let everyone deal with it as they see fit, this could mean that we couldn't react to the loading as we do now
  2. modify Ui.App so it would receive an option for relative vs absolute main.css
  3. or find out a logic that works for every use case (this is what I was trying to do)

After changing the way how the Main.js is loaded now I think the best way would be to the 1., but I don't know if people would be OK with losing that particular feature (reacting to loading of the stylesheet https://github.com/gdotdesign/elm-ui/blob/0.2/source/Ui/App.elm#L137)

robashton commented 8 years ago

Okay cool - I haven't gotten the wrong end of the stick!

1) Seems legit 2) Seems like a rabbit hole 3) Also a rabbit hole unless you simply just allow the URL to main.css to be passed in somewhere

The default behaviour of wanting to react to stylesheet loading doesn't have to change as it can happen out in user-land anyway (we have loadStylesheet and the hooks from that, and making that a user decision isn't the worse thing in the world).

If the default scaffold generates an index.html with a relative main.css as part of the html (if the two are side by side in the 'dist' folder this should work in most cases?), and then the user decides to load it programmatically and react to it loading then that's a simple (documented) step.

Maybe this is for the best anyway; an application not working because some CSS is missing/unloadable for some reason isn't ideal anyway (It took me a small moment to work out this is why I couldn't see any errors or anything on my screen haha)

gdotdesign commented 8 years ago

Yes you are right thanks for the input :+1: I'll make the changes soon-ish (in a couple of days)

gdotdesign commented 8 years ago

Here is the commit for the change https://github.com/gdotdesign/elm-ui/commit/90b199f56bab59c98e8e98a2360e687a1e539764

And I released a new version (0.2.0-alpha3) under the alpha tag, you can install it via npm install elm-ui@alpha -g