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

Add Typings for Classes #37

Merged
merged 1 commit into from
Dec 10, 2018

Conversation

martinmckenna
Copy link
Contributor

@martinmckenna martinmckenna commented Dec 9, 2018

Purpose

Add typings for classes prop, so that the user can use both MUI classes and notistack classes.

Look no red squiggly lines!!!

screen shot 2018-12-09 at 2 45 58 am

And with intellisense working

screen shot 2018-12-09 at 2 47 13 am

@martinmckenna
Copy link
Contributor Author

martinmckenna commented Dec 9, 2018

I would also love to be notified when the next release goes live if possible so I can leverage this

@iamhosseindhv
Copy link
Owner

iamhosseindhv commented Dec 9, 2018

@martinmckenna thanks. next release will be published as soon as we merge this into master. I'll tag you here.

Regarding the PR, do you think we should do the same for OptionsObject? since all material-ui props and notistack classes can also be passed there. lmk what you think

@martinmckenna
Copy link
Contributor Author

martinmckenna commented Dec 9, 2018

Does including the classes in the Options object actually do anything though? I just tested a bit and can't figure out a way to apply styles that way.

Here's my code

import {
  StyleRulesCallback,
  withStyles,
  WithStyles,
} from '@material-ui/core/styles';
import * as React from 'react';
import { compose } from 'recompose';

import { InjectedNotistackProps, withSnackbar } from 'notistack';

type ClassNames = 'root';

const styles: StyleRulesCallback<ClassNames> = (theme) => ({
  root: {
    padding: '10em',
    color: 'yellow',
    backgroundColor: 'blue'
  },
});

type CombinedProps = WithStyles<ClassNames> & InjectedNotistackProps;

const MyComponent: React.StatelessComponent<CombinedProps> = (props) => {

  props.enqueueSnackbar('Hello world', {
    variant: 'warning',
    classes: {
      root: props.classes.root,
      variantWarning: props.classes.root
    } as any
  })

  return (<div>Hello world</div>);
};

const styled = withStyles(styles);

export default compose<CombinedProps, {}>(
  styled,
  withSnackbar
)(MyComponent)

And here's how it looks, No blue background color or yellow text

screen shot 2018-12-09 at 3 22 06 pm

If anything we should be omitting the classes props no?

@iamhosseindhv iamhosseindhv merged commit 5dd6588 into iamhosseindhv:master Dec 10, 2018
@iamhosseindhv
Copy link
Owner

iamhosseindhv commented Dec 10, 2018

@martinmckenna Thanks for your contribution ❤️

And new version (v0.4.1) is published.

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.

2 participants