generated from Exabyte-io/template-definitions
-
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
Showing
8 changed files
with
87 additions
and
8 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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { enqueueSnackbar } from "notistack"; | ||
import { useCallback } from "react"; | ||
import { showSuccessAlert } from "../other/alerts"; | ||
import { copyToClipboard } from "../utils/clipboard"; | ||
export const useCopyToClipboard = () => { | ||
return useCallback((textToCopy, content) => { | ||
copyToClipboard(textToCopy, () => { | ||
enqueueSnackbar(content, { variant: "success" }); | ||
showSuccessAlert(content); | ||
}); | ||
}, []); | ||
}; |
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,5 @@ | ||
export declare function showSuccessAlert(message: string): void; | ||
export declare function showErrorAlert(message: string): void; | ||
export declare function showWarningAlert(message: string): void; | ||
export declare function showInfoAlert(message: string): void; | ||
export declare function showAlert(message: string, type: "info" | "warning" | "error" | "success"): void; |
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 { enqueueSnackbar } from "notistack"; | ||
const anchorOrigin = { | ||
vertical: "bottom", | ||
horizontal: "left", | ||
}; | ||
export function showSuccessAlert(message) { | ||
enqueueSnackbar(message, { variant: "success", anchorOrigin }); | ||
} | ||
export function showErrorAlert(message) { | ||
enqueueSnackbar(message, { variant: "error", anchorOrigin }); | ||
} | ||
export function showWarningAlert(message) { | ||
enqueueSnackbar(message, { variant: "warning", anchorOrigin }); | ||
} | ||
export function showInfoAlert(message) { | ||
enqueueSnackbar(message, { variant: "info", anchorOrigin }); | ||
} | ||
export function showAlert(message, type) { | ||
switch (type) { | ||
case "warning": | ||
showWarningAlert(message); | ||
break; | ||
case "error": | ||
showErrorAlert(message); | ||
break; | ||
case "success": | ||
showSuccessAlert(message); | ||
break; | ||
case "info": | ||
showInfoAlert(message); | ||
break; | ||
default: | ||
showInfoAlert(message); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { enqueueSnackbar } from "notistack"; | ||
import { useCallback } from "react"; | ||
|
||
import { showSuccessAlert } from "../other/alerts"; | ||
import { copyToClipboard } from "../utils/clipboard"; | ||
|
||
export const useCopyToClipboard = () => { | ||
return useCallback((textToCopy: string, content: string) => { | ||
copyToClipboard(textToCopy, () => { | ||
enqueueSnackbar(content, { variant: "success" }); | ||
showSuccessAlert(content); | ||
}); | ||
}, []); | ||
}; |
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,41 @@ | ||
import { enqueueSnackbar, SnackbarOrigin } from "notistack"; | ||
|
||
const anchorOrigin: SnackbarOrigin = { | ||
vertical: "bottom", | ||
horizontal: "left", | ||
}; | ||
|
||
export function showSuccessAlert(message: string) { | ||
enqueueSnackbar(message, { variant: "success", anchorOrigin }); | ||
} | ||
|
||
export function showErrorAlert(message: string) { | ||
enqueueSnackbar(message, { variant: "error", anchorOrigin }); | ||
} | ||
|
||
export function showWarningAlert(message: string) { | ||
enqueueSnackbar(message, { variant: "warning", anchorOrigin }); | ||
} | ||
|
||
export function showInfoAlert(message: string) { | ||
enqueueSnackbar(message, { variant: "info", anchorOrigin }); | ||
} | ||
|
||
export function showAlert(message: string, type: "info" | "warning" | "error" | "success") { | ||
switch (type) { | ||
case "warning": | ||
showWarningAlert(message); | ||
break; | ||
case "error": | ||
showErrorAlert(message); | ||
break; | ||
case "success": | ||
showSuccessAlert(message); | ||
break; | ||
case "info": | ||
showInfoAlert(message); | ||
break; | ||
default: | ||
showInfoAlert(message); | ||
} | ||
} |