Skip to content

Support Theming#35

Merged
lttb merged 9 commits intomasterfrom
feature/theming
Mar 2, 2018
Merged

Support Theming#35
lttb merged 9 commits intomasterfrom
feature/theming

Conversation

@lttb
Copy link
Copy Markdown
Member

@lttb lttb commented Jul 18, 2017

@iamstarkov @kof

There is some basic support for theming out of the box.

So do we need to use themed-functions for styled-jss?

TODO:

  • update docs about theming in styled-jss

@lttb lttb force-pushed the feature/theming branch from bb481d1 to 386f756 Compare July 18, 2017 20:41
@cssinjs cssinjs deleted a comment from coveralls Jul 18, 2017
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling f1458d3 on feature/theming into ac3b05b on master.

@cssinjs cssinjs deleted a comment from coveralls Jul 18, 2017
@lttb lttb force-pushed the feature/theming branch from f1458d3 to f5f73c1 Compare July 18, 2017 20:51
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling f5f73c1 on feature/theming into ac3b05b on master.

Comment thread src/styled.js
static style: ComponentStyleType = elementStyle
static contextTypes = {
[channel]: PropTypes.object
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do smth like this instead static contextTypes = themeListener.contextTypes;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a problem with themeListener.contextTypes, because it's required, so user required to provide that channel in the context. but I don't think that styled-jss should be used only with ThemeProvider

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can add a variant with optional types into themeListner?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its not a problem

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to check if it themed styles creator, then you can add themeListener.contextTypes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's an open question for me - do we really need styles creator for styled-jss, because I don't see performance issues for the current solution (we have an 'overhead' with Object.assign in update, but it's fast enough I think)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its not performant, please use themed styles creator instead

Copy link
Copy Markdown
Member Author

@lttb lttb Jul 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lttb do you have 100+ components and tried to quickly change theme several times in a row?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and it also confusing part: theme is not dynamic part of the styles. its still static. so, when you debug style tags in the head, it gives you wrong sense of static/dynamic styles

Comment thread src/styled.js Outdated
this.dynamicTagName = availableDynamicTagNames.pop() || generateTagName(tagName)
}

this.state = context[channel] ? {theme: themeListener.initial(context)} : {}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{} should be a noTheme variable defined outside of constructor

Comment thread src/styled.js
import {Component, createElement} from 'react'
import PropTypes from 'prop-types'
import {themeListener, channel} from 'theming'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you probably want to use SheetManager from jss

@lttb
Copy link
Copy Markdown
Member Author

lttb commented Jul 31, 2017

@iamstarkov I need to refactor it with using theming function instead of props, so I hope I finish it this week

@lttb lttb mentioned this pull request Oct 23, 2017
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.5%) to 99.524% when pulling de6235f on feature/theming into 5adf8db on master.

@coveralls
Copy link
Copy Markdown

coveralls commented Jan 19, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling 802f620 on feature/theming into 5adf8db on master.

Comment thread README.md Outdated

const Button = styled('button')((props, {theme}) => ({
color: theme.color,
'background-color': theme.backgroundColor,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use consistent style, I would rather go for camel case

@jmadson
Copy link
Copy Markdown

jmadson commented Feb 5, 2018

@kof What's needed before this can merge?

@kof
Copy link
Copy Markdown
Member

kof commented Feb 6, 2018

We discussed to pass theme as a prop in order to stay consistent with cases where user can pass a theme over component prop, so we don't have a situation with 2 theme objects

@lttb lttb force-pushed the feature/theming branch from ad72f45 to 802f620 Compare March 2, 2018 00:27
@lttb lttb merged commit f2c3912 into master Mar 2, 2018
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

Successfully merging this pull request may close these issues.

5 participants