-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe70904
commit b24b94f
Showing
8 changed files
with
245 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import styled from "@emotion/styled" | ||
import { theme } from "theme" | ||
|
||
export const SWarningMessageContainer = styled.div` | ||
background: ${theme.gradients.primaryGradient}; | ||
width: 100%; | ||
cursor: pointer; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 8px; | ||
padding: 8px; | ||
z-index: ${theme.zIndices.header}; | ||
color: ${theme.colors.black}; | ||
` | ||
|
||
export const SWarningMessageContent = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
gap: 8px; | ||
align-items: center; | ||
justify-content: center; | ||
` | ||
|
||
export const SSecondaryItem = styled.div` | ||
display: flex; | ||
flex: 1 1 0%; | ||
flexbasis: 0; | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { ReactComponent as CrossIcon } from "assets/icons/CrossIcon.svg" | ||
import { Modal } from "components/Modal/Modal" | ||
import { ReactNode, useState } from "react" | ||
import { useTranslation } from "react-i18next" | ||
import { TWarningsType, useWarningsStore } from "./WarningMessage.utils" | ||
import { | ||
SSecondaryItem, | ||
SWarningMessageContainer, | ||
SWarningMessageContent, | ||
} from "./WarningMessage.styled" | ||
|
||
export const WarningMessage = (props: { | ||
type: TWarningsType | ||
text: ReactNode | ||
modalContent?: ReactNode | ||
}) => { | ||
const [open, setOpen] = useState(false) | ||
const { t } = useTranslation() | ||
|
||
const warnings = useWarningsStore() | ||
|
||
return ( | ||
<> | ||
{open && ( | ||
<Modal | ||
open | ||
onClose={() => setOpen(false)} | ||
title={t("depeg.modal.title")} | ||
width={450} | ||
> | ||
{props.modalContent} | ||
</Modal> | ||
)} | ||
<SWarningMessageContainer | ||
onClick={() => props.modalContent && setOpen(true)} | ||
> | ||
<SSecondaryItem /> | ||
<SWarningMessageContent> | ||
<svg | ||
width="18" | ||
height="15" | ||
viewBox="0 0 18 15" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000.svg?react" | ||
css={{ flexShrink: 0 }} | ||
> | ||
<path | ||
fillRule="evenodd" | ||
clipRule="evenodd" | ||
d="M8.75753 0.707031L16.7104 14.4818H0.804688L8.75753 0.707031ZM8.01068 10.5323H9.50752V12.0291H8.01068V10.5323ZM9.50752 5.99067H8.01068V9.48331H9.50752V5.99067Z" | ||
fill="url(#paint0_linear_21027_167880)" | ||
/> | ||
<defs> | ||
<linearGradient | ||
id="paint0_linear_21027_167880" | ||
x1="8.75753" | ||
y1="1.38726" | ||
x2="8.75753" | ||
y2="14.4818" | ||
gradientUnits="userSpaceOnUse" | ||
> | ||
<stop offset="0.448929" stopColor="black" /> | ||
<stop offset="1" stopColor="black" stopOpacity="0.27" /> | ||
</linearGradient> | ||
</defs> | ||
</svg> | ||
|
||
{props.text} | ||
</SWarningMessageContent> | ||
|
||
<SSecondaryItem | ||
css={{ | ||
justifyContent: "flex-end", | ||
}} | ||
> | ||
<CrossIcon | ||
onClick={(e) => { | ||
e.stopPropagation() | ||
warnings.setWarnings(props.type, false) | ||
}} | ||
/> | ||
</SSecondaryItem> | ||
</SWarningMessageContainer> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { create } from "zustand" | ||
import { persist } from "zustand/middleware" | ||
|
||
type TWarningStore = { | ||
warnings: { | ||
depeg: { visible?: boolean } | ||
} | ||
setWarnings: (key: TWarningsType, isOpen: boolean) => void | ||
} | ||
|
||
export type TWarningsType = keyof TWarningStore["warnings"] | ||
|
||
export const useWarningsStore = create( | ||
persist<TWarningStore>( | ||
(set) => ({ | ||
warnings: { | ||
depeg: { | ||
visible: true, | ||
}, | ||
}, | ||
setWarnings: (key, isOpen) => | ||
set(({ warnings }) => ({ | ||
warnings: { | ||
...warnings, | ||
[key]: { ...warnings[key], visible: isOpen }, | ||
}, | ||
})), | ||
}), | ||
{ | ||
name: "warnings", | ||
version: 0.1, | ||
getStorage: () => window.sessionStorage, | ||
}, | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters