mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
More straitforward context transition relations declaration
This commit is contained in:
@ -232,20 +232,22 @@ class PanelTransition extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getDirection(next, prev) {
|
getDirection(next, prev) {
|
||||||
const not = (panelId) => ![prev, next].includes(panelId);
|
// transition between context will be Y (through heigh animation)
|
||||||
|
// transition inside context will be X (horizontal sliding animation)
|
||||||
|
const contexts = [
|
||||||
|
['login', 'password', 'forgotPassword', 'recoverPassword'],
|
||||||
|
['register', 'activation'],
|
||||||
|
['changePassword'],
|
||||||
|
['permissions']
|
||||||
|
];
|
||||||
|
|
||||||
const map = {
|
const prevPanelContext = contexts.filter((context) => context.includes(prev));
|
||||||
login: not('password') && not('forgotPassword') ? 'Y' : 'X',
|
|
||||||
password: not('login') && not('forgotPassword') ? 'Y' : 'X',
|
|
||||||
register: not('activation') ? 'Y' : 'X',
|
|
||||||
activation: not('register') ? 'Y' : 'X',
|
|
||||||
permissions: 'Y',
|
|
||||||
changePassword: 'Y',
|
|
||||||
forgotPassword: not('password') && not('login') ? 'Y' : 'X',
|
|
||||||
recoverPassword: not('password') && not('login') && not('forgotPassword') ? 'Y' : 'X'
|
|
||||||
};
|
|
||||||
|
|
||||||
return map[next];
|
if (prevPanelContext.length > 1) {
|
||||||
|
throw new Error(`${prev} panel exists more than in one context`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return prevPanelContext.pop().includes(next) ? 'X' : 'Y';
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdateHeight = (height, key) => {
|
onUpdateHeight = (height, key) => {
|
||||||
|
Reference in New Issue
Block a user