-
Notifications
You must be signed in to change notification settings - Fork 64
Add Snackbar #721
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 Snackbar #721
Conversation
Codecov Report
@@ Coverage Diff @@
## master #721 +/- ##
==========================================
+ Coverage 98.41% 98.42% +0.01%
==========================================
Files 44 46 +2
Lines 3273 3294 +21
Branches 970 973 +3
==========================================
+ Hits 3221 3242 +21
Misses 52 52
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #721 +/- ##
==========================================
+ Coverage 98.4% 98.42% +0.02%
==========================================
Files 44 47 +3
Lines 3257 3300 +43
Branches 968 976 +8
==========================================
+ Hits 3205 3248 +43
Misses 52 52
Continue to review full report at Codecov.
|
@@ -0,0 +1,54 @@ | |||
@import '../common/styles/variables.css'; | |||
|
|||
.root { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this should all be here or in the dojo theme?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomdye Good question. I added the minimum structure and positioning to this CSS, just so that it uses flex box and displays at the bottom of the window. Should this not be here?
src/snackbar/index.tsx
Outdated
export class Snackbar extends WidgetBase<SnackbarProperties> { | ||
protected render(): DNode { | ||
const { type, open, message, actionsRenderer } = this.properties; | ||
const classes = [css.root]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to make Widget themable
* make `open` property not optional * remove unnecessary manual typing * simplify adding classes, remove nested ternary
- Allow actions to be passed, which are buttons that will be rendered on the Snackbar - Replace `success` with `type?: 'success' | 'error'`
- type return value of render method - remove nls for Snackbar and use of I18nMixin
src/snackbar/index.tsx
Outdated
export class Snackbar extends ThemedMixin(WidgetBase)<SnackbarProperties> { | ||
protected render(): DNode { | ||
const { type, open, leading, stacked, message, actionsRenderer } = this.properties; | ||
const classes = [css.root]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason you didn't use ternary for adding conditional classes to the root here like we do elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this to be consistent with what we've done elsewhere. I originally did it this way because I'm not a fan of testing the placement of null
.
const successTemplate = template.setProperty('@root', 'classes', [
css.root,
css.open,
null,
null,
css.stacked
]);
src/snackbar/index.tsx
Outdated
<div key="label" classes={css.label} role="status" aria-live="polite"> | ||
{message} | ||
</div> | ||
<div key="actions" classes={css.actions}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure the actions
section should be rendered at all if there is no actionsRenderer
property passed
src/snackbar/index.tsx
Outdated
const { type, open, leading, stacked, message, actionsRenderer } = this.properties; | ||
const classes = [css.root]; | ||
|
||
if (open) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see previous comment re. ternary for these classes as we have done elsewhere.
Type: feature
The following has been addressed in the PR:
Description:
Add a Snackbar widget
Properties:
type?: 'success' | 'error'
- whether the Snackbar should display with its success or error stateopen?: boolean;
- Whether the Snackbar is openmessage: string;
- The title/text to display within the SnackbaractionsRenderer?: () => DNode | DNode[]
- Buttons to render in the actions portion of the SnackbarExample use:
Screenshot

Resolves #713