You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.5 KiB

  1. import icon_bluetooth from '../assets/icon_bluetooth.svg';
  2. import icon_arr_d from '../assets/icon_arr_down.svg';
  3. import './CustomNavBar.scss';
  4. import { useState } from 'react';
  5. export default function CustomNavBar({ title }: { title: string }) {
  6. const [showDetail, setShowDetail] = useState(false);
  7. return (
  8. <div className="relative bg-white h-[--navBarHeight] border-b border-[#D8D8D8]">
  9. {/** 温度,水平仪 */}
  10. <div
  11. className="absolute h-[30px] w-full bg-white border border-[#D8D8D8] flex items-center gap-2 px-4"
  12. style={{ top: showDetail ? '100%' : 0, transition: 'top 300ms' }}>
  13. <span className="flex-1">温度: 31.2°C</span>
  14. <span className="flex-1">X轴倾斜: -0.496</span>
  15. <span className="flex-1">Y轴倾斜: 3.005</span>
  16. </div>
  17. {/** 导航栏 */}
  18. <div className="absolute left-0 top-0 w-full h-full flex items-center px-3 bg-white">
  19. <h1 className="text-lg text-text ml-3">{title}</h1>
  20. <div className="ml-auto flex items-center" onClick={() => setShowDetail(!showDetail)}>
  21. <div className="bluetooth-battery flex justify-center items-center">78%</div>
  22. <img src={icon_bluetooth} alt="icon" className="mx-2" />
  23. <span></span>
  24. <img src={icon_arr_d} alt="arr" style={{
  25. transform: showDetail ? 'rotate(180deg)' : 'rotate(0deg)',
  26. transition: 'transform 300ms'
  27. }} />
  28. </div>
  29. </div>
  30. </div>
  31. );
  32. }