Re: [elm-discuss] Re: Adding CSS produced by a view function to the document's

2017-06-08 Thread Francesco Orsenigo

The idea is to keep a set of all the rules added to the header, add only 
those that are missing and never remove any.
This will not work for for rules whose definitions are changed dynamically, 
but seems like an acceptable trade off.

The ability to calculate all the styles that *might* appear would have the 
same limitation.


On Friday, June 9, 2017 at 2:41:32 PM UTC+10, Aaron VonderHaar wrote:
>
> I experimented with some ways to have view functions that return both Html 
> and the necessary styles.  I found I could make it work, but I ultimately 
> abandoned the idea because of a fundamental problem:
>
> view model =
> if model.showWidget then
> Widget.view model.widgetData
> else
> text ""
>
> In the code above, depending on the model, you may or may not call 
> Widget.view.  If your view functions are some new type that includes the 
> necessary styles, then you now have a problem that you will only know about 
> the styles for views that are currently visible, which means that your 
> final stylesheet will constantly be changing as the model changes.
>
> What we really want is to get all the styles for all Html that *might* 
> appear, not for all Html that currently appears.  I suspect an API could be 
> designed that would allow such Html+styles views to be composed in a way 
> that could provide *all*possible*styles*, but I expect it would probably be 
> a significant departure from how Html-only views work, so I haven't pursued 
> that idea further.
>
> At NoRedInk, we have an idea for a way to look at an entry point Elm file 
> and traverse all of the imported modules, collect all of the top-level 
> Stylesheets (similar to what the latest elm-test does for Test 
> definitions), and compile a .css file that we can reference in the  
> (but this would be done outside of Elm).  However, that idea is also 
> currently in a state of haven't-yet-pursued-further.
>
> On Thu, Jun 8, 2017 at 4:38 AM, Kevin Yank  > wrote:
>
>> The style-elements 
>>  
>> package introduced at Elm Europe today needs to solve this problem too. For 
>> now, it too is just rendering an invalid 

Re: [elm-discuss] Re: Adding CSS produced by a view function to the document's

2017-06-08 Thread Aaron VonderHaar
I experimented with some ways to have view functions that return both Html
and the necessary styles.  I found I could make it work, but I ultimately
abandoned the idea because of a fundamental problem:

view model =
if model.showWidget then
Widget.view model.widgetData
else
text ""

In the code above, depending on the model, you may or may not call
Widget.view.  If your view functions are some new type that includes the
necessary styles, then you now have a problem that you will only know about
the styles for views that are currently visible, which means that your
final stylesheet will constantly be changing as the model changes.

What we really want is to get all the styles for all Html that *might*
appear, not for all Html that currently appears.  I suspect an API could be
designed that would allow such Html+styles views to be composed in a way
that could provide *all*possible*styles*, but I expect it would probably be
a significant departure from how Html-only views work, so I haven't pursued
that idea further.

At NoRedInk, we have an idea for a way to look at an entry point Elm file
and traverse all of the imported modules, collect all of the top-level
Stylesheets (similar to what the latest elm-test does for Test
definitions), and compile a .css file that we can reference in the 
(but this would be done outside of Elm).  However, that idea is also
currently in a state of haven't-yet-pursued-further.

On Thu, Jun 8, 2017 at 4:38 AM, Kevin Yank  wrote:

> The style-elements
> 
> package introduced at Elm Europe today needs to solve this problem too. For
> now, it too is just rendering an invalid 

[elm-discuss] Re: Adding CSS produced by a view function to the document's

2017-06-08 Thread Kevin Yank
The style-elements 
 
package introduced at Elm Europe today needs to solve this problem too. For 
now, it too is just rendering an invalid 

[elm-discuss] Re: Adding CSS produced by a view function to the document's

2017-06-05 Thread 'Jonas Schürmann' via Elm Discuss
I am unsure what your goal is, but perhaps elm-css 
 can help you. If you want to 
generate styles dynamically, it is probably best to use inline styles.

Am Montag, 5. Juni 2017 12:46:47 UTC+2 schrieb Francesco Orsenigo:
>
> I am experimenting with view functions that produce both html content and 
> the style that should be applied to that markup, as in
>
> myView : Model -> ( Html msg, List CssRule )
>
> So far, I have been rendering the above by creating a