Skip to content

Commit

Permalink
set up for about tab and location tab styling
Browse files Browse the repository at this point in the history
  • Loading branch information
bacalj committed Aug 19, 2024
1 parent 6efc8c8 commit dd6f43c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 37 deletions.
1 change: 1 addition & 0 deletions src/assets/scss/about-tab.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "./vars.scss";
17 changes: 0 additions & 17 deletions src/assets/scss/header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,6 @@
top: 7px;
right: 7px;
}

.plugin-info-popup {
display: flex;
transform: translateX(-50px);
position: absolute;
background-color: white;
box-shadow: 0px 2px 4px rgba(silver, 0.4);
padding: 10px;
border-radius: 4px;
border: 1.5px solid rgba($codap-teal, 0.3);
width: 150px;
top: 30px;
right: -20px;
&.hidden {
display: none;
}
}
}

.tab-container {
Expand Down
3 changes: 1 addition & 2 deletions src/assets/scss/location-tab.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,15 @@
background-color: white;
list-style: none;
margin:3px;
color: #222;

&.on {
background-color: $codap-teal-lightest;
color: $codap-teal;
border: 1px solid $codap-teal;
}

&.off {
background-color: white;
color: #aaa;
border: 1px solid $codap-teal;
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { initializePlugin, codapInterface, addDataContextChangeListener, ClientN
import { useCodapData } from "../hooks/useCodapData";
import { LocationTab } from "./location-tab";
import { SimulationTab } from "./simulation-tab";
import { AboutTab } from "./about-tab";
import { Header } from "./header";

import "../assets/scss/App.scss";
Expand All @@ -16,7 +17,7 @@ const updateRowSelectionInCodap = (latitude: string, longitude: string, day: num
}

export const App: React.FC = () => {
const [activeTab, setActiveTab] = useState<"location" | "simulation">("location");
const [activeTab, setActiveTab] = useState<"location" | "simulation" | "about">("location");
const [latitude, setLatitude] = useState("");
const [longitude, setLongitude] = useState("");
const [dayOfYear, setDayOfYear] = useState(171);
Expand Down Expand Up @@ -85,7 +86,7 @@ export const App: React.FC = () => {
initialize();
}, []);

const handleTabClick = (tab: "location" | "simulation") => {
const handleTabClick = (tab: "location" | "simulation" | "about") => {
setActiveTab(tab);
// Update dimensions of the plugin window when switching tabs.
codapInterface.sendRequest({
Expand Down Expand Up @@ -132,6 +133,9 @@ export const App: React.FC = () => {
setLocations={setLocations}
/>
</div>
<div className={clsx("tab-content", { active: activeTab === "about" })}>
<AboutTab />
</div>
</div>
);
};
11 changes: 11 additions & 0 deletions src/components/about-tab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";

import "../assets/scss/about-tab.scss";

export const AboutTab: React.FC = () => {
return (
<div className="about-tab">
<p>about</p>
</div>
);
};
25 changes: 9 additions & 16 deletions src/components/header.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
import React, { useState } from "react";
import InfoIcon from "../assets/images/icon-info.svg";
import React from "react";

import "../assets/scss/header.scss";

interface IHeaderProps {
activeTab: "location" | "simulation";
onTabClick: (tab: "location" | "simulation") => void;
activeTab: "location" | "simulation" | "about";
onTabClick: (tab: "location" | "simulation" | "about") => void;
}

export const Header: React.FC<IHeaderProps> = ({ activeTab, onTabClick }) => {
const [showInfo, setShowInfo] = useState<boolean>(false);

const handleInfoClick = () => {
setShowInfo(!showInfo);
};

return (
<>
<div className="plugin-row header">
<p>
How long is a day?<br />
Enter a location or coordinates to retrieve data
</p>
<span title="Get further information about this CODAP plugin">
<InfoIcon className="info-icon" onClick={handleInfoClick}/>
</span>
<div className={`plugin-info-popup ${showInfo ? "showing" : "hidden"}`}>
plugin info
</div>
</div>
<hr />
<div className="tab-container">
Expand All @@ -43,6 +30,12 @@ export const Header: React.FC<IHeaderProps> = ({ activeTab, onTabClick }) => {
>
Simulation
</div>
<div
className={`tab ${activeTab === "about" ? "active" : ""}`}
onClick={() => onTabClick("about")}
>
About
</div>
</div>
</>
);
Expand Down

0 comments on commit dd6f43c

Please sign in to comment.