mirror of
https://github.com/logto-io/logto.git
synced 2025-02-24 22:05:56 -05:00
refactor(console): use switch-case to make the select aligment logic more readable (#812)
This commit is contained in:
parent
c6b44eea87
commit
b14a705bd3
1 changed files with 25 additions and 10 deletions
|
@ -42,20 +42,35 @@ const selectVerticalAlignment = ({
|
||||||
const isTopAllowed = verticalTop >= minY;
|
const isTopAllowed = verticalTop >= minY;
|
||||||
const isBottomAllowed = verticalBottom + overlayHeight <= maxY;
|
const isBottomAllowed = verticalBottom + overlayHeight <= maxY;
|
||||||
|
|
||||||
if (verticalAlign === 'top') {
|
switch (verticalAlign) {
|
||||||
if (isTopAllowed) {
|
case 'top': {
|
||||||
return 'top';
|
if (isTopAllowed) {
|
||||||
|
return 'top';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isBottomAllowed) {
|
||||||
|
return 'bottom';
|
||||||
|
}
|
||||||
|
|
||||||
|
return verticalAlign;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isBottomAllowed ? 'bottom' : 'top';
|
case 'bottom': {
|
||||||
}
|
if (isBottomAllowed) {
|
||||||
|
return 'bottom';
|
||||||
|
}
|
||||||
|
|
||||||
// Mark: VerticalAlign === 'bottom'
|
if (isTopAllowed) {
|
||||||
if (isBottomAllowed) {
|
return 'top';
|
||||||
return 'bottom';
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return isTopAllowed ? 'top' : 'bottom';
|
return verticalAlign;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
return verticalAlign;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectHorizontalAlignment = ({
|
const selectHorizontalAlignment = ({
|
||||||
|
|
Loading…
Add table
Reference in a new issue