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

Create a Status Alert #42

Merged
merged 2 commits into from
Oct 16, 2017
Merged

Create a Status Alert #42

merged 2 commits into from
Oct 16, 2017

Conversation

fysheets
Copy link
Contributor

@fysheets fysheets commented Oct 3, 2017

Create a new component for StatusAlert that is accessible and reusable.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 98.537% when pulling efa09a564d4a4e6b058ccccf5bdc46be10d4f585 on fsheets/status-alert into 35d2bf8 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 98.537% when pulling 169b6f97869f2e7287d543c090e2609077cde8bc on fsheets/status-alert into 35d2bf8 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 98.537% when pulling 9e137c82aa5555e41d0fad4b1ecb18f9c8c0a9f5 on fsheets/status-alert into 35d2bf8 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 98.537% when pulling 5a400a98155f7243376a840238380216a25ce3cb on fsheets/status-alert into 35d2bf8 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.7%) to 99.251% when pulling eda87287af292b23076e8b92ccfba714f1caa05f on fsheets/status-alert into 35d2bf8 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-6.6%) to 91.892% when pulling 059141eea65da7446ef59ab1558864382108041c on fsheets/status-alert into 35d2bf8 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-6.6%) to 91.892% when pulling 059141eea65da7446ef59ab1558864382108041c on fsheets/status-alert into 35d2bf8 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-7.2%) to 91.275% when pulling e39c0111f59eb89daefb2eb12335380071b30b41 on fsheets/status-alert into 35d2bf8 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-7.004%) to 91.503% when pulling 7533e1425789d8154f9ce80049fce995ba832b40 on fsheets/status-alert into 35d2bf8 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-6.5%) to 92.027% when pulling 72509e5a49163cb68baf55f260d330d9c1c9c857 on fsheets/status-alert into 35d2bf8 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-6.2%) to 92.308% when pulling 6a507569232dfcc317098d39fa29b08132fbf8f1 on fsheets/status-alert into 35d2bf8 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 99.038% when pulling 49426ed7f1212d1d8a22e48401bafc8edc17d1d8 on fsheets/status-alert into 35d2bf8 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.038% when pulling 69ca19b308870eac1394dafeb2fd1ed437dfe000 on fsheets/status-alert into fd4b1bd on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 99.353% when pulling f276c63b6e9559b4acf70644c39411c22dde536c on fsheets/status-alert into fd4b1bd on master.

@fysheets fysheets changed the title WIP: Create a Status Alert Create a Status Alert Oct 5, 2017
Copy link
Contributor

@arizzitano arizzitano left a comment

Choose a reason for hiding this comment

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

This looks pretty good overall! Two main things: 1) I think onClose shouldn't be required if dismissible is false, 2) could you import and use the existing Paragon Button instead of the native <button />? The rest is just style suggestions.

className: PropTypes.arrayOf(PropTypes.string),
dialog: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired,
dismissible: PropTypes.bool,
onClose: PropTypes.func.isRequired,
Copy link
Contributor

Choose a reason for hiding this comment

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

So I'm team onClose required for the standard use case, but it should probably not be required if this is a dismissible alert. This would be a good place to use a custom prop validator -- maybe this package would be helpful? https://www.npmjs.com/package/react-proptype-conditional-require

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That totally makes sense and that package looks interesting! I will read up and see if we can leverage it.


if (dismissible) {
className.push(styles['alert-dismissible']);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to inline this below within the classNames call (same way you did with the other conditional styles)? e.g. { [styles['alert-dismissible']]: dismissable }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah - the answer is most likely yes :) thanks!

rel="noopener noreferrer"
>
Click me!
</a>
Copy link
Contributor

Choose a reason for hiding this comment

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

Really loving Paragon's quality cat content 😼

let dismissButton = (<div />);
if (dismissible) {
dismissButton = (
<button
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use the Paragon Button component here instead of the native one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noting down our discussion -- the dismissible button formatting is generated from both the alert & close SASS files in order to render properly -- Will try to include the close partial into Button to see if it will continue to render correctly.


renderDismissible() {
const { dismissible } = this.props;
let dismissButton = (<div />);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why render this empty div if dismissible is false? Could we do something more along the lines of

return (dismissible) ? null : (
  <Button
    // button props...
  />
);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can definitely give this a go -- it didn't cross my mind that null was a valid thing that could be returned as part of a render.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@arizzitano I updated this to be null instead of the empty div. When I made my first attempt to turn it into a ternary operator it didn't render happily with the spanning over multiple lines. I will revisit this though when I test out the options to switch to the paragon Button from the above comment.

open
/>
))
.add('modal invoked via a button', () => (
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you mean alert here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you Michael :)

dialog="Success! You triggered the alert!"
/>
))
.add('modal with a link', () => (
Copy link
Contributor

Choose a reason for hiding this comment

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

Alert here, too!

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 99.344% when pulling f820498b9cb7e191d09789a44d4b998ed31a29c1 on fsheets/status-alert into fd4b1bd on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 99.344% when pulling bc15656e7ba29f96f7a8177bc6c5a34e5d9e99e4 on fsheets/status-alert into ece2748 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 99.344% when pulling 7a2235c1e531358aa056059808650962f197b91f on fsheets/status-alert into 4ebc1ab on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 99.344% when pulling d07c6964123dc14c0e57978f285eb1a79960de2c on fsheets/status-alert into a4e492b on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 99.34% when pulling a4650511bbebd252643611f4b9c94eec4bc5ceb9 on fsheets/status-alert into a4e492b on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 99.34% when pulling 88edd5a9644f15633c28d439b34b26299202d936 on fsheets/status-alert into a4e492b on master.


exports[`Storyshots StatusAlert alert invoked via a button 1`] = `
<div>
<div
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@arizzitano while playing with the screenreader yesterday, I think that I need to add an aria-hidden on the status alert that is tied with the "open" state field, but when I did my first attempt it didn't appear to work as I had expected. Advice on the logic that should go here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Spoke with Mark -- he noted that we could leverage display: 'none' and display: 'block' for this instead of aria-hidden so I am looking into how to correctly integrate that logic into classNames

@fysheets fysheets mentioned this pull request Oct 12, 2017
@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 99.34% when pulling d828a7b084e0a2015ebb926ff0fa9ad6211b993b on fsheets/status-alert into a4e492b on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 99.34% when pulling ff9a435e2c33a57150217be280c6d84f52412d5f on fsheets/status-alert into a4e492b on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 99.34% when pulling ff9a435e2c33a57150217be280c6d84f52412d5f on fsheets/status-alert into a4e492b on master.

Copy link
Contributor

@arizzitano arizzitano left a comment

Choose a reason for hiding this comment

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

One request re: README but otherwise this looks great! 🚢

### `dismissible` (boolean; optional)
`dismissible` specifies if the status alert will include the dismissible X button to close the alert. It defaults to true.

### `onClose` (function; required)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a note about onClose not being required if dismissible is true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For sure -- how does this look:

onClose (function; conditionally required)

onClose is a function that is called on close. It can be used to perform actions upon closing of the status alert, such as restoring focus to the previous logical focusable element. It is only required if dismissible is set to true and not required if the alert if not dismissible.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect!

[styles.show]: this.state.open,
})}
role="alert"
hidden={!this.state.open}
Copy link
Contributor

Choose a reason for hiding this comment

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

Great find re: hidden! 👏👏👏

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 99.34% when pulling ef19327c55078653fd423f72683462a9783caaa3 on fsheets/status-alert into a4e492b on master.

@coveralls
Copy link

coveralls commented Oct 13, 2017

Coverage Status

Coverage decreased (-7.004%) to 91.503% when pulling 7533e1425789d8154f9ce80049fce995ba832b40 on fsheets/status-alert into 35d2bf8 on master.

@fysheets fysheets merged commit c046e63 into master Oct 16, 2017
@fysheets fysheets deleted the fsheets/status-alert branch October 16, 2017 13:27
PKulkoRaccoonGang pushed a commit to raccoongang/paragon that referenced this pull request Sep 20, 2022
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.

4 participants