-
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.
- Loading branch information
1 parent
eeaba9c
commit 0eb9f43
Showing
6 changed files
with
128 additions
and
13 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@project44-manifest/react': minor | ||
--- | ||
|
||
toast position support |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { Toast } from './Toast'; | ||
export type { ToastOptions, ToastProps, ToastVariant } from './Toast.types'; | ||
export type { ToastOptions, ToastPosition, ToastProps, ToastVariant } from './Toast.types'; | ||
export { toast } from './utils'; |
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,55 @@ | ||
export const getPositionStyle = (position: string, offset: number): React.CSSProperties => { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
const styles: React.CSSProperties = { | ||
position: 'absolute', | ||
transition: 'all 200ms cubic-bezier(0.4, 0.14, 0.3, 1)', | ||
} as React.CSSProperties; | ||
|
||
switch (position) { | ||
case 'top-left': | ||
return { | ||
...styles, | ||
top: 0, | ||
left: 0, | ||
transform: `translateY(${offset}px)`, | ||
}; | ||
|
||
case 'top-center': | ||
return { | ||
...styles, | ||
top: 0, | ||
left: '50%', | ||
transform: `translate(-50%,${offset}px)`, | ||
}; | ||
case 'top-right': | ||
return { | ||
...styles, | ||
top: 0, | ||
right: 0, | ||
transform: `translateY(${offset}px)`, | ||
}; | ||
case 'bottom-left': | ||
return { | ||
...styles, | ||
bottom: 0, | ||
left: 0, | ||
transform: `translateY(${-offset}px)`, | ||
}; | ||
case 'bottom-center': | ||
return { | ||
...styles, | ||
bottom: 0, | ||
left: '50%', | ||
transform: `translate(-50%, ${-offset}px)`, | ||
}; | ||
case 'bottom-right': | ||
return { | ||
...styles, | ||
bottom: 0, | ||
right: 0, | ||
transform: `translateY(${-offset}px)`, | ||
}; | ||
default: | ||
return styles; | ||
} | ||
}; |