Bluesky app fork with some witchin' additions 馃挮
at main 50 lines 1.1 kB view raw
1import * as toast from '#/components/Toast' 2import {type ToastType} from '#/components/Toast/types' 3 4/** 5 * @deprecated use {@link ToastType} and {@link toast} instead 6 */ 7export type LegacyToastType = 8 | 'xmark' 9 | 'exclamation-circle' 10 | 'check' 11 | 'clipboard-check' 12 | 'circle-exclamation' 13 14export const convertLegacyToastType = ( 15 type: ToastType | LegacyToastType, 16): ToastType => { 17 switch (type) { 18 // these ones are fine 19 case 'default': 20 case 'success': 21 case 'error': 22 case 'warning': 23 case 'info': 24 return type 25 // legacy ones need conversion 26 case 'xmark': 27 return 'error' 28 case 'exclamation-circle': 29 return 'warning' 30 case 'check': 31 return 'success' 32 case 'clipboard-check': 33 return 'success' 34 case 'circle-exclamation': 35 return 'warning' 36 default: 37 return 'default' 38 } 39} 40 41/** 42 * @deprecated use {@link toast} instead 43 */ 44export function show( 45 message: string, 46 type: ToastType | LegacyToastType = 'default', 47): void { 48 const convertedType = convertLegacyToastType(type) 49 toast.show(message, {type: convertedType}) 50}