Advertisement
Guest User

Ethan Gooding: Demo Login Animation

a guest
May 24th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // These code snippets are of a demo login animation
  2. // They are from my fLEXpx project, using React.js
  3. // To see how it works, head to this site and select "Demo profile":
  4. // http://flexpx.herokuapp.com/
  5. // GitHub repo: https://github.com/Eden12345/fLEXpx
  6.  
  7.  
  8.  
  9.  
  10.  
  11. // Clicking on the demo button in the Landing Page Component
  12. // triggers a Redux action that changes the demo UI slice of the
  13. // web application's Redux store's state
  14.  
  15. // GitHub: https://github.com/Eden12345/fLEXpx/blob/master/frontend/components/landing_page/landing_page.jsx
  16.  
  17. demoUser() {
  18.   this.props.switchLoginAnimation(true);
  19.   this.props.history.push('/login');
  20. }
  21.  
  22. render() {
  23.   return (
  24.     <main className="landing-page animated fadeIn">
  25.       <div className="greeting">
  26.         <p className="landing-page-text">Discover Photos and Upload Your Own</p>
  27.         <a className="button landing-page-demo" onClick={this.demoUser}>Demo profile</a>
  28.       </div>
  29.     </main>
  30.   );
  31. }
  32.  
  33.  
  34.  
  35. // By setting up my Session (login/sign-up) component to listen
  36. // to that demo UI slice of the Redux store's state, I can then
  37. // trigger a series of actions using timeouts and animations
  38. // to mimic the visual aspects of logging in as that user
  39.  
  40. // GitHub: https://github.com/Eden12345/fLEXpx/blob/master/frontend/components/session/session_form.jsx
  41.  
  42. componentDidMount() {
  43.   if (this.props.loginAnimation) {
  44.     setTimeout(() => {
  45.       this.demoUser();
  46.       this.props.switchLoginAnimation(false);
  47.     }, 750);
  48.   }
  49. }
  50.  
  51. demoUser() {
  52.   this.setState({
  53.     username: "eden",
  54.     password: "starwars"
  55.   });
  56.  
  57.   setTimeout(() => {
  58.     this.props.login({user: {username: "eden", password: "starwars"}});
  59.   }, 250);
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement