-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding toaster, dynamically checking pewpewVersion (#201)
* adding files to dynamically show latest pewpew version on Toaster * cleaning up code for lintter to pass * refactoring code to use tags in S3 * removing files from tsconfig * fixing lint rules * fixing spacing as local linter didnt catch those but the build did * missed one space * adding tests, cleaning up files * removing trailing spaces failing on build * adding DS_Store - make specific file to gitignore * updating storybook to show pewpew latest version output
- Loading branch information
1 parent
00bfbdb
commit a8bee2d
Showing
11 changed files
with
196 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,4 @@ testmerge.json | |
.env.development.local* | ||
.env.test.local* | ||
.env.production.local* | ||
|
||
.DS_Store |
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,49 @@ | ||
import React, { useEffect } from "react"; | ||
import styled, { keyframes } from "styled-components"; | ||
import { Info } from "../Alert"; | ||
|
||
interface ToasterProps { | ||
message: string; // Ensure message prop is of type string | ||
duration?: number; | ||
id: string; // Unique ID for the toaster | ||
} | ||
|
||
// Fade-in animation | ||
const fadeIn = keyframes` | ||
from { opacity: 0; } | ||
to { opacity: 1; } | ||
`; | ||
|
||
// Fade-out animation | ||
const fadeOut = keyframes` | ||
from { opacity: 1; } | ||
to { opacity: 0; } | ||
`; | ||
|
||
const Container = styled(Info)` | ||
position: fixed; | ||
bottom: 20px; | ||
right: 20px; | ||
width: 30%; | ||
font-size: 17px; | ||
animation: ${fadeIn} 0.3s ease-in-out forwards; | ||
&.fade-out { animation: ${fadeOut} 0.3s ease-in-out forwards; } | ||
`; | ||
|
||
const Toaster: React.FC<ToasterProps> = ({ id, message, duration = 7000 }) => { | ||
useEffect(() => { | ||
setTimeout(() => { | ||
const toasterElement = document.getElementById(id); | ||
if (toasterElement) { | ||
toasterElement.classList.add("fade-out"); | ||
setTimeout(() => { | ||
toasterElement.remove(); | ||
}, 300); // Wait for fade-out animation to complete before removing element | ||
} | ||
}, duration); | ||
}, [id, duration]); | ||
return <Container id={id}>{message}</Container>; | ||
}; | ||
|
||
export default Toaster; |
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,16 @@ | ||
import type { Meta, StoryFn } from "@storybook/react"; | ||
import { GlobalStyle } from "../Layout"; | ||
import React from "react"; | ||
import Toaster from "./index"; | ||
|
||
export default { | ||
title: "Toaster", | ||
component: Toaster | ||
} as Meta<typeof Toaster>; | ||
|
||
export const Default: StoryFn = () => ( | ||
<React.Fragment> | ||
<GlobalStyle /> | ||
<Toaster id="toaster" message={"Type your message here: "}/> | ||
</React.Fragment> | ||
); |
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
Oops, something went wrong.