react-notification-system icon indicating copy to clipboard operation
react-notification-system copied to clipboard

Overridden "Containers.DefaultStyle.width" must be coercible to a number

Open begincalendar opened this issue 8 years ago • 7 comments

Due to this line, if you override the container width, you must provide a value that is coercible to the Number type (e.g. 4 or "56.56", etc.).

This is problematic for the following reasons:

  • The TypeScript definition file does not enforce this restriction, please see this line.
  • Widths are constrained to pixel units.

It would be handy to be able to specify the width in other units (e.g. percentages, em, etc.), but I realise (being naive to the implementation of this package), that it might not be a simple fix.

How feasible would it be to allow for units (other than pixels), when specifying an overriding width?

begincalendar avatar Mar 28 '17 00:03 begincalendar

@igorprado

bump

begincalendar avatar Apr 08 '17 01:04 begincalendar

We are also running into an issue with this from a slightly different angle. We wanted to be able to gain control of the notification width through CSS so we could more easily leverage media queries. To do this without turning off inline styles and having to reimplement them in CSS, we are setting Containers.DefaultStyle.width to inherit and then setting the width using the notifications-wrapper class. This yields the expected results, but throws the following warning:

'Warning: NaN is an invalid value for the marginLeft css style property.'

Would we be able to work this case in as well? I would be willing to raise a PR if we could come up with a suitable solution.

nlrowe avatar May 14 '17 07:05 nlrowe

Same as me. I want to make this notification has an auto width which is decided screen size. If there is a type check before calculating the marginLeft, it will get rid of this warning.

yunlong-tang avatar Sep 22 '17 00:09 yunlong-tang

same error, i want to use width: 100% , but in here,

-(this.props.getStyles.overrideWidth / 2);

NaN is an invalid value for the marginLeft css style property

geminiyellow avatar Apr 03 '18 06:04 geminiyellow

@igorprado could you fix this ?

geminiyellow avatar Apr 04 '18 02:04 geminiyellow

Same here, has this been fixed?

darrendahl avatar Aug 17 '20 19:08 darrendahl

My 2 cents here, indeed using this as a screen wide bar notification, and overriding container with 100%, causes a warning in the notification center. I a simple PR would be just to avoid setting marginLeft when typeof width === string.

P.S: In 4 months this ticket issue will be 4 years old! We need a cake and a celebration here 🍰 🎉

constantin-melniciuc avatar Dec 21 '20 09:12 constantin-melniciuc