Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default theme #75

Open
therustmonk opened this issue Mar 16, 2017 · 4 comments
Open

Change default theme #75

therustmonk opened this issue Mar 16, 2017 · 4 comments

Comments

@therustmonk
Copy link

I couldn't find any guide how to attach a new theme.
I can change defaultTheme in https://github.com/gdotdesign/elm-ui/blob/development/source/Ui/Styles/Theme.elm directly, but I don't think it's a right way.
How to change it simpler?

Also we should add this information to the documentation.

@gdotdesign
Copy link
Owner

Unfortunately there is no proper way of changing the theme. I'm experimenting with some methods, I'll let you know when I have something to share.

@therustmonk
Copy link
Author

For theming in my projects I use var expression. It works in this fashion:

:root { --bg-color: white; --fg-color: black; }
.theme-noon { --bg-color: grey; --fg-color: blue; }
.theme-dark { --bg-color: black; --fg-color: green; }

component { display: block; background: var(--bg-color); color: var(--fg-color); }

The advantage of this approach is that you can mix themes in one layout using classes:

view =
    div [ class "component theme-dark" ]
        [ div [ class "component" ] [ text "This block uses Dark theme" ]
        , div [ class "component theme-noon" ] [ text "This block uses Noon theme" ]
        ]

What about to use this approach? It is compatible with all modern browsers and makes possible to change theme on-the-fly without redundancy of parameters trailing.

@gdotdesign
Copy link
Owner

This is one of the paths I'm experimenting with in this branch: https://github.com/gdotdesign/elm-ui/compare/theming-experiments It works as expected, the problem is that CSS variables according to can i use are not supported in IE or Edge: http://caniuse.com/#feat=css-variables

The other path is to use https://github.com/gdotdesign/elm-html-styles which also can be good. You can check some of the components already converted here: https://github.com/gdotdesign/elm-ui/compare/html-styles.

I like the second one more, but I'm still evaluating it in an other project.

@MartinKavik
Copy link

MartinKavik commented Jun 16, 2017

Hi,
I've just discovered Tachyons.io.
(Why it can be useful: github.com/dwyl/learn-tachyons + github.com/dwyl/technology-stack).

And I've written a basic prototype of a button component based on elm-ui repo: github.com/MartinKavik/tachyons-elm-ui-example = my experiment with theming components for maybe some inspiration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants