added preferences card

This commit is contained in:
2025-07-31 17:55:47 +02:00
parent 3ecac5a854
commit f4881be087
2 changed files with 83 additions and 17 deletions

View File

@@ -0,0 +1,13 @@
import React from "react";
const ChangePreferences: React.FC = () => {
return (
<div className="w-full">
<h2 className="text-2xl font-bold mb-2 text-blue-700">
Change Preferences
</h2>
</div>
);
};
export default ChangePreferences;

View File

@@ -1,11 +1,13 @@
import React from "react"; import React from "react";
import ChangeAPI from "./ChangeAPI"; import ChangeAPI from "./ChangeAPI";
import ChangePreferences from "./ChangePreferences";
import { useState } from "react"; import { useState } from "react";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import logo from "../assets/cloud-sun-fill.svg"; import logo from "../assets/cloud-sun-fill.svg";
const Header: React.FC = () => { const Header: React.FC = () => {
const [apiCard, setApiCard] = useState(false); const [apiCard, setApiCard] = useState(false);
const [preferencesCard, setPreferencesCard] = useState(false);
const apiKey = Cookies.get("apiKey") || ""; const apiKey = Cookies.get("apiKey") || "";
return ( return (
@@ -21,23 +23,59 @@ const Header: React.FC = () => {
Weather App Weather App
</h1> </h1>
</div> </div>
<button <div className="flex items-center gap-4">
className="bg-white text-blue-700 font-bold px-6 py-3 rounded-xl shadow-lg hover:bg-blue-100 transition-all border border-blue-200" {" "}
onClick={() => setApiCard(true)} {/* Added container for buttons */}
> <button
<span className="flex items-center gap-2"> className="bg-white text-blue-700 font-bold px-6 py-3 rounded-xl shadow-lg hover:bg-blue-100 transition-all border border-blue-200 flex items-center gap-2"
<svg onClick={() => setApiCard(true)}
className="w-5 h-5" >
fill="none" <span className="flex items-center gap-2">
stroke="currentColor" <svg
strokeWidth="2" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24" fill="none"
> viewBox="0 0 24 24"
<path d="M12 4v16m8-8H4" /> strokeWidth={1.5}
</svg> stroke="currentColor"
Set API Key className="size-6"
</span> >
</button> <path
strokeLinecap="round"
strokeLinejoin="round"
d="M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z"
/>
</svg>
Set API Key
</span>
</button>
<button
className="bg-white text-blue-700 font-bold px-6 py-3 rounded-xl shadow-lg hover:bg-blue-100 transition-all border border-blue-200 flex items-center gap-2"
onClick={() => setPreferencesCard(true)}
>
<span className="flex items-center gap-2">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
className="size-6"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 0 1 1.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.559.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.894.149c-.424.07-.764.383-.929.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 0 1-1.449.12l-.738-.527c-.35-.25-.806-.272-1.203-.107-.398.165-.71.505-.781.929l-.149.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 0 1-.12-1.45l.527-.737c.25-.35.272-.806.108-1.204-.165-.397-.506-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.108-1.204l-.526-.738a1.125 1.125 0 0 1 .12-1.45l.773-.773a1.125 1.125 0 0 1 1.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894Z"
/>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"
/>
</svg>
Preferences
</span>
</button>
</div>
</header> </header>
{apiCard && ( {apiCard && (
<div className="fixed inset-0 bg-gray-900 bg-opacity-60 flex items-center justify-center z-50 transition-all"> <div className="fixed inset-0 bg-gray-900 bg-opacity-60 flex items-center justify-center z-50 transition-all">
@@ -53,6 +91,21 @@ const Header: React.FC = () => {
</div> </div>
</div> </div>
)} )}
{preferencesCard && (
<div className="fixed inset-0 bg-gray-900 bg-opacity-60 flex items-center justify-center z-50 transition-all">
<div className="bg-white rounded-2xl shadow-2xl p-10 w-full max-w-md relative border-2 border-blue-200">
<button
className="absolute top-4 right-4 text-gray-400 hover:text-blue-600 text-2xl font-bold"
onClick={() => setPreferencesCard(false)}
aria-label="Close"
>
&times;
</button>
<ChangePreferences />
</div>
</div>
)}
</> </>
); );
}; };