Guide.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import React, { useEffect, useLayoutEffect } from 'react';
  2. import Navbar from '@/src/components/Navbar.tsx';
  3. import Sidebar from '@/src/components/Sidebar.tsx';
  4. import Footer from '@/src/components/Footer.tsx';
  5. import TipsCategory from '@/src/components/TipsCategory.tsx';
  6. import FAQItem from '@/src/components/FAQItem.tsx';
  7. import { CONTENT } from '../constants.ts';
  8. import { useLanguage } from '@/src/contexts/LanguageContext.tsx';
  9. import { useTheme } from '@/src/contexts/ThemeContext.tsx';
  10. import { useLocation } from 'react-router-dom';
  11. const Guide: React.FC = () => {
  12. const { language } = useLanguage();
  13. const { guideHeroImage } = useTheme();
  14. const location = useLocation();
  15. const t = CONTENT[language];
  16. useLayoutEffect(() => {
  17. const params = new URLSearchParams(location.search);
  18. const section = params.get('section');
  19. let elementId = '';
  20. if (section === 'tips') {
  21. elementId = 'guide-tips';
  22. } else if (section === 'faq') {
  23. elementId = 'guide-faq';
  24. }
  25. if (elementId) {
  26. const element = document.getElementById(elementId);
  27. if (element) {
  28. element.scrollIntoView({ behavior: 'smooth' });
  29. }
  30. }
  31. }, [location.search]);
  32. return (
  33. <div className="min-h-screen bg-white font-sans text-vista-darkblue overflow-x-hidden">
  34. <Navbar />
  35. <Sidebar />
  36. {/* Hero Section */}
  37. <section className="relative h-[50vh] w-full overflow-hidden">
  38. <div className="absolute inset-0 z-0">
  39. <img
  40. src={guideHeroImage || "https://images.unsplash.com/photo-1578474843222-9593bc88d8b0?q=80&w=1920&auto=format&fit=crop"}
  41. alt="Travel Guide"
  42. className="w-full h-full object-cover object-center"
  43. onError={(e) => {
  44. const target = e.target as HTMLImageElement;
  45. target.src = "https://images.unsplash.com/photo-1578474843222-9593bc88d8b0?q=80&w=1920&auto=format&fit=crop";
  46. }}
  47. />
  48. <div className="absolute inset-0 bg-black/40 pointer-events-none"></div>
  49. </div>
  50. <div className="relative z-10 h-full flex flex-col justify-center items-center text-center px-4 drop-shadow-md">
  51. <h1 className="text-white text-4xl md:text-6xl font-serif leading-tight italic">
  52. {t.guide.hero.title}
  53. </h1>
  54. <p className="text-white text-xl md:text-2xl mt-4 max-w-2xl">
  55. {t.guide.hero.subtitle}
  56. </p>
  57. </div>
  58. </section>
  59. {/* Main Content */}
  60. <main className="py-20">
  61. {/* Travel Tips Section */}
  62. <section id="guide-tips" className="max-w-7xl mx-auto px-6 mb-24">
  63. <div className="text-center mb-16">
  64. <span className="text-vista-gold uppercase tracking-widest text-sm font-bold">{t.guide.tips.sectionTitle}</span>
  65. <h2 className="text-4xl font-serif text-vista-darkblue mt-3">{t.guide.tips.sectionSubtitle}</h2>
  66. </div>
  67. <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
  68. {t.guide.tips.categories.map((category) => (
  69. <TipsCategory
  70. key={category.title}
  71. icon={category.icon}
  72. title={category.title}
  73. items={category.items}
  74. />
  75. ))}
  76. </div>
  77. </section>
  78. {/* FAQ Section */}
  79. {/*<section id="guide-faq" className="py-24 bg-vista-teal">*/}
  80. <section id="guide-faq" className="py-24 bg-gray-500">
  81. <div className="max-w-7xl mx-auto px-6">
  82. <div className="text-center mb-16">
  83. <span className="text-white uppercase tracking-widest text-sm font-bold">{t.guide.faq.sectionTitle}</span>
  84. <h2 className="text-4xl font-serif text-white mt-3">{t.guide.faq.sectionSubtitle}</h2>
  85. </div>
  86. <div className="max-w-3xl mx-auto space-y-6">
  87. {t.guide.faq.items.map((faq) => (
  88. <FAQItem
  89. key={faq.question}
  90. question={faq.question}
  91. answer={faq.answer}
  92. />
  93. ))}
  94. </div>
  95. </div>
  96. </section>
  97. </main>
  98. <Footer />
  99. </div>
  100. );
  101. };
  102. export default Guide;