Header.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import React from 'react';
  2. import { Button } from './Button';
  3. import './header.css';
  4. type User = {
  5. name: string;
  6. };
  7. interface HeaderProps {
  8. user?: User;
  9. onLogin: () => void;
  10. onLogout: () => void;
  11. onCreateAccount: () => void;
  12. }
  13. export const Header = ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => (
  14. <header>
  15. <div className="storybook-header">
  16. <div>
  17. <svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
  18. <g fill="none" fillRule="evenodd">
  19. <path
  20. d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
  21. fill="#FFF"
  22. />
  23. <path
  24. d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
  25. fill="#555AB9"
  26. />
  27. <path
  28. d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z"
  29. fill="#91BAF8"
  30. />
  31. </g>
  32. </svg>
  33. <h1>Acme</h1>
  34. </div>
  35. <div>
  36. {user ? (
  37. <>
  38. <span className="welcome">
  39. Welcome, <b>{user.name}</b>!
  40. </span>
  41. <Button size="small" onClick={onLogout} label="Log out" />
  42. </>
  43. ) : (
  44. <>
  45. <Button size="small" onClick={onLogin} label="Log in" />
  46. <Button primary size="small" onClick={onCreateAccount} label="Sign up" />
  47. </>
  48. )}
  49. </div>
  50. </div>
  51. </header>
  52. );