-
Notifications
You must be signed in to change notification settings - Fork 0
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
4dbe573
commit af63d75
Showing
18 changed files
with
156 additions
and
31 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
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,22 @@ | ||
import React from "react"; | ||
import { Banner, Stack } from "@biom3/react"; | ||
import { useMessageProvider } from "@/app/context"; | ||
|
||
export default function Banners() { | ||
const { messages, removeMessage } = useMessageProvider(); | ||
|
||
return ( | ||
<> | ||
{messages ? ( | ||
<Stack gap="base.spacing.x2"> | ||
{messages.map((message, index) => ( | ||
<Banner key={index} variant={message.status}> | ||
<Banner.Caption>{message.message}</Banner.Caption> | ||
<Banner.RightButton onClick={() => removeMessage(index)}>Close</Banner.RightButton> | ||
</Banner> | ||
))} | ||
</Stack> | ||
) : null} | ||
</> | ||
); | ||
} |
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
File renamed without changes.
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,42 @@ | ||
import { createContext, useContext } from "react"; | ||
import { Message } from "../types"; | ||
import React from "react"; | ||
|
||
const MessageContext = createContext<{ | ||
messages: Message[]; | ||
removeMessage: (index: number) => void; | ||
addMessage: (message: Message) => void; | ||
}>({ | ||
messages: [], | ||
removeMessage: () => {}, | ||
addMessage: () => {}, | ||
}); | ||
|
||
export function MessageProvider({ children }: { children: React.ReactNode }) { | ||
const [messages, setMessages] = React.useState<Message[]>([]); | ||
|
||
const removeMessage = (index: number) => { | ||
const newMessages = [...messages]; | ||
newMessages.splice(index, 1); | ||
setMessages(newMessages); | ||
}; | ||
|
||
const addMessage = (message: Message) => { | ||
setMessages([...messages, message]); | ||
}; | ||
|
||
return ( | ||
<MessageContext.Provider value={{ messages, removeMessage, addMessage }}> | ||
{children} | ||
</MessageContext.Provider> | ||
); | ||
} | ||
|
||
export function useMessageProvider() { | ||
const { messages, removeMessage, addMessage } = useContext(MessageContext); | ||
return { | ||
messages, | ||
removeMessage, | ||
addMessage, | ||
}; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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 |
---|---|---|
|
@@ -1894,7 +1894,19 @@ | |
resolved "https://registry.yarnpkg.com/@rive-app/canvas-lite/-/canvas-lite-2.20.0.tgz#2ff253e0c59560ca03a75551721368adb39af5ac" | ||
integrity sha512-tvZokI/oZh1PLyMn4v7YQXlKz8MkrHQuoQ6upVcNwOxWxXnfwL5zeE/fguUEbPYZ22d1oKQ7pO5Imr5fjk8KjQ== | ||
|
||
"@rive-app/react-canvas-lite@^4.13.8", "@rive-app/react-canvas-lite@^4.9.0": | ||
"@rive-app/[email protected]": | ||
version "2.20.2" | ||
resolved "https://registry.yarnpkg.com/@rive-app/canvas-lite/-/canvas-lite-2.20.2.tgz#e9b2c63b16476129bbdbd2410c4c46ddb14a5256" | ||
integrity sha512-Eqy9D1qFI7jOESFtLJMDOiiRUSGOMeERsVVJC33xkQXySxaJ9sgvLUzN6RPdgwFlOjEmOhy5QWyQ/8B6r1xJ+w== | ||
|
||
"@rive-app/react-canvas-lite@^4.13.10": | ||
version "4.13.10" | ||
resolved "https://registry.yarnpkg.com/@rive-app/react-canvas-lite/-/react-canvas-lite-4.13.10.tgz#6d8f4b07ea8ef828bbdb7431197be58fa0104c0e" | ||
integrity sha512-JXbBfRimZUtlAtr5tXM22CmMYwnqNjqEEH7bfnJ3VgS6FUHv+Lw1BeoMPdam4vRMm1guuZu8HsvQn91U08fr5g== | ||
dependencies: | ||
"@rive-app/canvas-lite" "2.20.2" | ||
|
||
"@rive-app/react-canvas-lite@^4.9.0": | ||
version "4.13.8" | ||
resolved "https://registry.yarnpkg.com/@rive-app/react-canvas-lite/-/react-canvas-lite-4.13.8.tgz#e6665207dac1c665c79fd130cfd9bbbb955d1968" | ||
integrity sha512-0InycO7Eon03++Z4HfkqTOFLU2fIcw2GUZFz5k6GPjIeF3bhBIG9jfULcFVLpac94Ce/VuVfsq38+9qoq9HWUA== | ||
|