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

Multiple class not working #90

Open
DavidHenri008 opened this issue May 18, 2018 · 5 comments
Open

Multiple class not working #90

DavidHenri008 opened this issue May 18, 2018 · 5 comments

Comments

@DavidHenri008
Copy link

DavidHenri008 commented May 18, 2018

Hi,
I am using the React-Toolbox and I understood that it uses the react-css-themr behind the scene.
I am trying to add a class dynamically to do the styling but it is not working as expected.

My react code:

import React from 'react';
import PropTypes from 'prop-types';
import { AppBar } from 'react-toolbox/lib/app_bar';
import theme from './AppBar.css';

const PurpleAppBar = props => (
<AppBar theme={theme} className="disabled"> App Example </AppBar>
);
export default PurpleAppBar;

My css file:

.appBar {
background-color: blue;
}
.appBar.disabled {
background-color: gray;
}
.appBar:hover {
opacity: 0.5;
}

The AppBar is blue and the hover is working. However since the disabled class is added I would expect the color to be gray.

Thanks.

@palashkaria
Copy link

palashkaria commented May 18, 2018

did you pass the theme to you appBar?

what is the 'App Example'?

<AppBar theme={props.theme} /> should work

EDIT: if AppBar has a 'disabled' class defined, that is. Otherwise what you want to do is
<AppBar className={disabled ? theme.disabled : null} />

@DavidHenri008
Copy link
Author

Yes. I just updated my question since I did not see that my code was not showing properly.

@palashkaria
Copy link

palashkaria commented May 18, 2018

in your example you are not using themr at all. This is a question for react-toolbox. You need to pass theme.disabled, check their docs http://react-toolbox.io/#/components/app_bar

do
<AppBar theme={theme} className={theme.disabled}>

@palashkaria
Copy link

palashkaria commented May 18, 2018

Also, you need to configure sassLoader
https://github.com/react-toolbox/react-toolbox/tree/master#using-sass-loader

sassLoader: {
  data: '@import "' + path.resolve(__dirname, 'theme/_theme.scss') + '";'
}

@DavidHenri008
Copy link
Author

Thanks. I understand I do not use themr, but React-Toolbox is using it. May question was really about why adding the disabled className manually was not working as expected. I was able to make it work by using className={theme.disabled} but I had to declare the .disable class separately in the css.

I appreciate your time.

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

2 participants