-
Notifications
You must be signed in to change notification settings - Fork 12
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 Notification Type to Snack Messaging #2884
Conversation
@fabian-bizfactory please let me know once you've looked through the diff and you think this is ready for review |
Sorry, about the PR pull. Found a potential issue after creating it |
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.
Looks good overall, I've got a couple of suggestions, would be happy if you could take a look at those!
const resetMessage = () => dispatch(setMessage({ message: null })); | ||
const resetMessage = () => | ||
dispatch( | ||
setMessage({ |
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.
Let's use the resetMessage
action instead here
@@ -4,12 +4,19 @@ import { Action } from "../app/actions"; | |||
|
|||
import { resetMessage, setMessage } from "./actions"; | |||
|
|||
export enum SnackMessageTypeT { |
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.
Ending types with aT
is something we're trying to slowly move away from, I'd suggest calling it SnackMessageType
|
||
const Root = styled("div")` | ||
const colorLookupTable: { [key in SnackMessageTypeT]: string } = { |
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.
Let's avoid calling variables by their "data structure" ("lookup table") and instead describe what they contain. Also Record
is useful here:
const colorLookupTable: { [key in SnackMessageTypeT]: string } = { | |
const bgColorByType: Record<SnackMessageType, string> = { |
export type SnackMessageActions = ActionType< | ||
typeof setMessage | typeof resetMessage | ||
>; | ||
|
||
export const setMessage = createAction("snack-message/SET")<{ | ||
message: string | null; | ||
notificationType: SnackMessageTypeT; |
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.
how about just calling it type
?
notificationType: SnackMessageTypeT; | |
type: SnackMessageType; |
const Root = styled("div")` | ||
const colorLookupTable: { [key in SnackMessageTypeT]: string } = { | ||
[SnackMessageTypeT.ERROR]: "rgba(0, 0, 0, 0.75)", | ||
[SnackMessageTypeT.SUCCESS]: "rgba(12, 100, 39, 0.75)", // #0C6427 |
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.
Have you tested what it looks like? I think with the green, it's actually too transparent, how about using 0.9
?
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 liked it that way. Took a look at 0.9, you are right, that looks better
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.
Nice! Looks good to me
No description provided.