From 515d77685d41db1df0457b134f696da2ac313653 Mon Sep 17 00:00:00 2001 From: Joe Bacal Date: Tue, 20 Aug 2024 15:06:49 -0400 Subject: [PATCH] set up about tab, tab effects --- src/assets/scss/App.scss | 14 +++--- src/assets/scss/about-tab.scss | 1 + src/assets/scss/header.scss | 79 ++++++++++++++++----------------- src/assets/scss/vars.scss | 3 +- src/components/App.tsx | 10 +++-- src/components/about-tab.tsx | 12 +++++ src/components/header.tsx | 59 +++++++++--------------- src/components/location-tab.tsx | 11 ++++- src/types.ts | 1 + 9 files changed, 102 insertions(+), 88 deletions(-) create mode 100644 src/assets/scss/about-tab.scss create mode 100644 src/components/about-tab.tsx diff --git a/src/assets/scss/App.scss b/src/assets/scss/App.scss index e73247a..a5b8ab3 100644 --- a/src/assets/scss/App.scss +++ b/src/assets/scss/App.scss @@ -1,7 +1,6 @@ @import "./vars"; .App { - padding: 10px; box-sizing: border-box; font-family: "Montserrat", sans-serif; font-size: 12px; @@ -25,19 +24,22 @@ } .tab-content { - //display: none; would be easier, but it somehow Seasons 3D view doesn't initialize itself properly + // note each .tab-content is a wrapper for tab.location, tab.simulation, tab.about + // eahc of which maintain their own static layout widths + // this is 100% wide to cover the space affored by CODAP window whose width can change + // display: none; would be easier, but it somehow Seasons 3D view doesn't initialize itself properly // when display: none; is used. visibility: hidden; width: 0; height: 0; position: absolute; - padding: 3px; - border-top: 1px solid #777777; + padding: 9px $edge-padding $edge-padding $edge-padding; &.active { + background-color: white; visibility: visible; - width: auto; - height: auto; + width: 100%; + height: 100%; } } } diff --git a/src/assets/scss/about-tab.scss b/src/assets/scss/about-tab.scss new file mode 100644 index 0000000..9da87cb --- /dev/null +++ b/src/assets/scss/about-tab.scss @@ -0,0 +1 @@ +@import "./vars.scss"; diff --git a/src/assets/scss/header.scss b/src/assets/scss/header.scss index 831e7fc..922f7b4 100644 --- a/src/assets/scss/header.scss +++ b/src/assets/scss/header.scss @@ -1,64 +1,63 @@ @import "./vars.scss"; -.header { - p { - margin: 0; - } - - .info-icon { - position: absolute; - 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-height: 26px; +$general-tab-width: 80px; +$location-tab-width: 74px; +$simulation-tab-width: 88px; +$about-tab-width: 60px; .tab-container { - display: flex; + background-color: white; + padding-top:$edge-padding + 4px; + padding-left: $edge-padding; + padding-right: $edge-padding; width: 100%; margin-bottom: 0; position: relative; z-index: 1; - justify-content: flex-start; + border-bottom:1px solid #222; + height: $tab-height; + display: flex; .tab { - flex: 0 0 auto; + position: absolute; text-align: center; - padding: 10px 20px; + padding: 5px 10px; cursor: pointer; - color: #666; - border: 1px solid $codap-teal; - border-bottom: none; + color: #222; + border: 1px solid #222; margin-right: -1px; - position: relative; - border-radius: 8px 8px 0 0; - background-color: #e9e9e9; + border-radius: 6px 6px 0 0; + background-color: white; + display:inline-block; + bottom:-1px; + background-color: #e0e0e0; &.active { background-color: white; - color: $codap-teal; border-bottom: 1px solid white; - z-index: 2; + font-weight: bold; + z-index: 3; + height: 18px; } &:hover:not(.active) { background-color: #e0e0e0; } + + &.location { + left: $edge-padding; + } + + &.simulation { + left: $edge-padding + $location-tab-width; + } + + &.about { + left: $edge-padding + $location-tab-width + $simulation-tab-width; + &.active { + left: $edge-padding + $location-tab-width + $simulation-tab-width - 1px; + } + } } } diff --git a/src/assets/scss/vars.scss b/src/assets/scss/vars.scss index 2a3839b..c45ca63 100644 --- a/src/assets/scss/vars.scss +++ b/src/assets/scss/vars.scss @@ -1,3 +1,4 @@ $codap-teal: #177991; $codap-teal-light: #72bfca; -$codap-teal-lightest: rgba(114, 191, 202, 0.25); \ No newline at end of file +$codap-teal-lightest: rgba(114, 191, 202, 0.25); +$edge-padding: 4px; \ No newline at end of file diff --git a/src/components/App.tsx b/src/components/App.tsx index 2414d79..47e1df6 100755 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1,12 +1,13 @@ import React, { useEffect, useState, useRef, useCallback } from "react"; import { clsx } from "clsx"; -import { ICurrentDayLocation, ILocation } from "../types"; +import { ICurrentDayLocation, ILocation, TabName } from "../types"; import { debounce } from "../grasp-seasons/utils/utils"; import { kInitialDimensions, kVersion, kPluginName, kDefaultOnAttributes, kSimulationTabDimensions, kDataContextName, kChildCollectionName } from "../constants"; import { initializePlugin, codapInterface, selectSelf, addDataContextChangeListener, ClientNotification, getCaseByID } from "@concord-consortium/codap-plugin-api"; 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 { locationsEqual } from "../utils/daylight-utils"; @@ -41,7 +42,7 @@ const debouncedUpdateRowSelectionInCodap = debounce(( }, 250); export const App: React.FC = () => { - const [activeTab, setActiveTab] = useState<"location" | "simulation">("location"); + const [activeTab, setActiveTab] = useState("location"); const [latitude, setLatitude] = useState(""); const [longitude, setLongitude] = useState(""); const [dayOfYear, setDayOfYear] = useState(171); @@ -141,7 +142,7 @@ export const App: React.FC = () => { }; }, [latitude, longitude, dayOfYear]); - const handleTabClick = (tab: "location" | "simulation") => { + const handleTabClick = (tab: TabName) => { setActiveTab(tab); codapInterface.sendRequest({ action: "update", @@ -211,6 +212,9 @@ export const App: React.FC = () => { handleGetDataClick={handleGetDataClick} /> +
+ +
); }; diff --git a/src/components/about-tab.tsx b/src/components/about-tab.tsx new file mode 100644 index 0000000..db39291 --- /dev/null +++ b/src/components/about-tab.tsx @@ -0,0 +1,12 @@ +import React from "react"; + +import "../assets/scss/about-tab.scss"; + +export const AboutTab: React.FC = () => { + return ( +
+

about

+
+ ); +}; + diff --git a/src/components/header.tsx b/src/components/header.tsx index 887c838..e3b5eb9 100644 --- a/src/components/header.tsx +++ b/src/components/header.tsx @@ -1,49 +1,34 @@ -import React, { useState } from "react"; -import InfoIcon from "../assets/images/icon-info.svg"; +import React from "react"; import "../assets/scss/header.scss"; +import { TabName } from "../types"; interface IHeaderProps { - activeTab: "location" | "simulation"; - onTabClick: (tab: "location" | "simulation") => void; + activeTab: TabName; + onTabClick: (tab: TabName) => void; } export const Header: React.FC = ({ activeTab, onTabClick }) => { - const [showInfo, setShowInfo] = useState(false); - - const handleInfoClick = () => { - setShowInfo(!showInfo); - }; - return ( - <> -
-

- How long is a day?
- Enter a location or coordinates to retrieve data -

- - - -
- plugin info -
+
+
onTabClick("location")} + > + Location +
+
onTabClick("simulation")} + > + Simulation
-
-
-
onTabClick("location")} - > - Location -
-
onTabClick("simulation")} - > - Simulation -
+
onTabClick("about")} + > + About
- +
); }; diff --git a/src/components/location-tab.tsx b/src/components/location-tab.tsx index 297f27a..e060e41 100644 --- a/src/components/location-tab.tsx +++ b/src/components/location-tab.tsx @@ -88,12 +88,21 @@ export const LocationTab: React.FC = ({ return (
+
+

+ How long is a day?
+ Enter a location or coordinates to retrieve data +

+
-
OR
+
+
+ OR +

diff --git a/src/types.ts b/src/types.ts index 515f92b..722537f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -38,3 +38,4 @@ export interface GeoNameSearchOptions { maxRows?: number; } +export type TabName = "location" | "simulation" | "about";