Improve toast messages (#184)

* Add styles for icons

* Add theme colors

* Improve toast message

Co-authored-by: Szymon Szlachtowicz <38212223+Szymx95@users.noreply.github.com>
This commit is contained in:
Maria Rushkova 2022-01-12 06:44:12 +01:00 committed by GitHub
parent 97535066e9
commit 78296b041d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 84 additions and 26 deletions

View File

@ -150,7 +150,7 @@ function ActivityMessage({
<FlexDiv> <FlexDiv>
<ContextHeading>{`Invited you to join a community `}</ContextHeading> <ContextHeading>{`Invited you to join a community `}</ContextHeading>
<Tag> <Tag>
<CommunityIcon /> <CommunityIcon width={17} height={16} />
<CommunityLogo <CommunityLogo
style={{ style={{
backgroundImage: activity.invitation?.icon backgroundImage: activity.invitation?.icon

View File

@ -37,7 +37,7 @@ const Icon = styled.svg`
fill: ${({ theme }) => theme.bodyBackgroundColor}; fill: ${({ theme }) => theme.bodyBackgroundColor};
} }
&.accept { &.green {
fill: ${({ theme }) => theme.greenColor}; fill: ${({ theme }) => theme.greenColor};
} }
`; `;

View File

@ -1,14 +1,25 @@
import React from "react"; import React from "react";
import styled from "styled-components"; import styled from "styled-components";
export const CommunityIcon = () => { type CommunityIconProps = {
width: number;
height: number;
className?: string;
};
export const CommunityIcon = ({
width,
height,
className,
}: CommunityIconProps) => {
return ( return (
<Icon <Icon
width="17" width={width}
height="16" height={height}
viewBox="0 0 17 16" viewBox="0 0 17 16"
fill="none" fill="none"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
className={className}
> >
<path <path
fillRule="evenodd" fillRule="evenodd"
@ -21,4 +32,12 @@ export const CommunityIcon = () => {
const Icon = styled.svg` const Icon = styled.svg`
fill: ${({ theme }) => theme.secondary}; fill: ${({ theme }) => theme.secondary};
&.green {
fill: ${({ theme }) => theme.greenColor};
}
&.red {
fill: ${({ theme }) => theme.redColor};
}
`; `;

View File

@ -38,8 +38,4 @@ export const ProfileIcon = () => {
const Icon = styled.svg` const Icon = styled.svg`
fill: ${({ theme }) => theme.tertiary}; fill: ${({ theme }) => theme.tertiary};
&:hover {
fill: ${({ theme }) => theme.bodyBackgroundColor};
}
`; `;

View File

@ -65,7 +65,7 @@ const EmojiReaction = styled.button`
} }
&.chosen { &.chosen {
background: ${({ theme }) => theme.reactionChosen}; background: ${({ theme }) => theme.blueBg};
border: 1px solid ${({ theme }) => theme.tertiary}; border: 1px solid ${({ theme }) => theme.tertiary};
color: ${({ theme }) => theme.tertiary}; color: ${({ theme }) => theme.tertiary};
} }

View File

@ -216,7 +216,8 @@ export const ProfileModal = () => {
...prev, ...prev,
{ {
id: id + request, id: id + request,
type: "request", type: "confirmation",
text: "Contact Request Sent",
}, },
]), ]),
setRequestCreation(false), setRequestCreation(false),

View File

@ -3,8 +3,11 @@ import styled, { keyframes } from "styled-components";
import { useToasts } from "../../contexts/toastProvider"; import { useToasts } from "../../contexts/toastProvider";
import { Toast } from "../../models/Toast"; import { Toast } from "../../models/Toast";
import { Column } from "../CommunityIdentity";
import { CheckSvg } from "../Icons/CheckIcon"; import { CheckSvg } from "../Icons/CheckIcon";
import { CommunityIcon } from "../Icons/CommunityIcon";
import { CrossIcon } from "../Icons/CrossIcon"; import { CrossIcon } from "../Icons/CrossIcon";
import { ProfileSvg } from "../Icons/ProfileIcon";
import { textSmallStyles } from "../Text"; import { textSmallStyles } from "../Text";
export function AnimationToastMessage() { export function AnimationToastMessage() {
@ -32,16 +35,31 @@ export function ToastMessage({ toast }: ToastMessageProps) {
return ( return (
<ToastWrapper> <ToastWrapper>
<ToastBlock> <ToastBlock>
{toast.type !== "verification" && ( {toast.type === "confirmation" && (
<CheckWrapper> <IconWrapper className="green">
<CheckSvg width={20} height={20} className="accept" /> <CheckSvg width={20} height={20} className="green" />
</CheckWrapper> </IconWrapper>
)} )}
<ToastText> {toast.type === "incoming" && (
{toast.type === "request" <IconWrapper className="blue">
? "Contact Request Sent" <ProfileSvg width={20} height={20} />
: "Verification Request Sent"} </IconWrapper>
</ToastText> )}
{(toast.type === "approvement" || toast.type === "rejection") && (
<IconWrapper
className={toast.type === "approvement" ? "green" : "red"}
>
<CommunityIcon
width={20}
height={19}
className={toast.type === "approvement" ? "green" : "red"}
/>
</IconWrapper>
)}
<Column>
<ToastText>{toast.text}</ToastText>
{toast.request && <ToastRequest>{toast.request}</ToastRequest>}
</Column>
</ToastBlock> </ToastBlock>
<CloseButton onClick={closeToast}> <CloseButton onClick={closeToast}>
<CrossIcon /> <CrossIcon />
@ -74,7 +92,15 @@ const ToastText = styled.p`
${textSmallStyles}; ${textSmallStyles};
`; `;
const CheckWrapper = styled.div` const ToastRequest = styled(ToastText)`
width: 243px;
color: ${({ theme }) => theme.secondary};
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
`;
const IconWrapper = styled.div`
width: 32px; width: 32px;
height: 32px; height: 32px;
display: flex; display: flex;
@ -82,7 +108,18 @@ const CheckWrapper = styled.div`
align-items: center; align-items: center;
border-radius: 50%; border-radius: 50%;
margin-right: 12px; margin-right: 12px;
background: rgba(78, 188, 96, 0.1);
&.green {
background: ${({ theme }) => theme.greenBg};
}
&.blue {
background: ${({ theme }) => theme.blueBg};
}
&.red {
background: ${({ theme }) => theme.buttonNoBg};
}
`; `;
const CloseButton = styled.button` const CloseButton = styled.button`

View File

@ -1,4 +1,6 @@
export type Toast = { export type Toast = {
id: string; id: string;
type: "request" | "incomeRequest" | "verification"; type: "confirmation" | "incoming" | "approvement" | "rejection";
text: string;
request?: string;
}; };

View File

@ -22,13 +22,14 @@ export type Theme = {
skeletonDark: string; skeletonDark: string;
redColor: string; redColor: string;
greenColor: string; greenColor: string;
greenBg: string;
mentionColor: string; mentionColor: string;
mentionHover: string; mentionHover: string;
mentionBg: string; mentionBg: string;
mentionBgHover: string; mentionBgHover: string;
shadow: string; shadow: string;
reactionBg: string; reactionBg: string;
reactionChosen: string; blueBg: string;
}; };
export const lightTheme: Theme = { export const lightTheme: Theme = {
@ -56,6 +57,7 @@ export const lightTheme: Theme = {
skeletonDark: "#E9EDF1", skeletonDark: "#E9EDF1",
redColor: "#FF2D55", redColor: "#FF2D55",
greenColor: "#4EBC60", greenColor: "#4EBC60",
greenBg: "rgba(78, 188, 96, 0.1)",
mentionColor: "#0DA4C9", mentionColor: "#0DA4C9",
mentionHover: "#BDE7F2", mentionHover: "#BDE7F2",
mentionBg: "#E5F8FD", mentionBg: "#E5F8FD",
@ -63,7 +65,7 @@ export const lightTheme: Theme = {
shadow: shadow:
"0px 2px 4px rgba(0, 34, 51, 0.16), 0px 4px 12px rgba(0, 34, 51, 0.08)", "0px 2px 4px rgba(0, 34, 51, 0.16), 0px 4px 12px rgba(0, 34, 51, 0.08)",
reactionBg: "#eceffc", reactionBg: "#eceffc",
reactionChosen: "rgba(67, 96, 223, 0.1)", blueBg: "rgba(67, 96, 223, 0.1)",
}; };
export const darkTheme: Theme = { export const darkTheme: Theme = {
@ -91,6 +93,7 @@ export const darkTheme: Theme = {
skeletonDark: "#141414", skeletonDark: "#141414",
redColor: "#FF5C7B", redColor: "#FF5C7B",
greenColor: "#60C370", greenColor: "#60C370",
greenBg: "rgba(96, 195, 112, 0.2)",
mentionColor: "#51D0F0", mentionColor: "#51D0F0",
mentionHover: "#004E60", mentionHover: "#004E60",
mentionBg: "#004050", mentionBg: "#004050",
@ -98,7 +101,7 @@ export const darkTheme: Theme = {
shadow: shadow:
"0px 2px 4px rgba(0, 34, 51, 0.16), 0px 4px 12px rgba(0, 34, 51, 0.08)", "0px 2px 4px rgba(0, 34, 51, 0.16), 0px 4px 12px rgba(0, 34, 51, 0.08)",
reactionBg: "#373737", reactionBg: "#373737",
reactionChosen: "rgba(134, 158, 255, 0.3)", blueBg: "rgba(134, 158, 255, 0.3)",
}; };
export default { lightTheme, darkTheme }; export default { lightTheme, darkTheme };