Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

PageTitle.tsx 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import React from 'react';
  2. import { Typography, Flex, Button } from 'antd';
  3. import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
  4. import { faArrowLeft } from '@fortawesome/free-solid-svg-icons';
  5. import { useRouter } from 'next/navigation';
  6. const { Title } = Typography;
  7. type PageTitleProps = {
  8. children?: React.ReactNode;
  9. position?: 'left' | 'center' | 'right';
  10. backButton?: boolean;
  11. };
  12. const PageTitle: React.FC<PageTitleProps> = ({
  13. children = <></>,
  14. position = 'center',
  15. backButton = false,
  16. }) => {
  17. const router = useRouter();
  18. const justifyMap: Record<string, 'flex-start' | 'center' | 'flex-end'> = {
  19. left: 'flex-start',
  20. center: 'center',
  21. right: 'flex-end',
  22. };
  23. return (
  24. <Flex
  25. align="center"
  26. justify="space-between"
  27. className="!bg-[#602FD0] !py-3 !px-5"
  28. >
  29. {/* Back Button */}
  30. {backButton ? (
  31. <Button
  32. type="text"
  33. icon={<FontAwesomeIcon icon={faArrowLeft} />}
  34. onClick={() => router.back()}
  35. style={{ fontSize: 20 }}
  36. className="!text-white"
  37. />
  38. ) : (
  39. <div style={{ width: 40 }} /> // Placeholder to keep spacing
  40. )}
  41. {/* Title */}
  42. <Flex style={{ flex: 1 }} justify={justifyMap[position]}>
  43. <Title level={4} style={{ margin: 0, color: 'white' }}>
  44. {children}
  45. </Title>
  46. </Flex>
  47. {/* Right Spacer to balance layout */}
  48. <div style={{ width: 40 }} />
  49. </Flex>
  50. );
  51. };
  52. export default PageTitle;