From 44a1c5b7e62e83af4d670e011f5998b9b8aedfef Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Mon, 29 Aug 2022 10:24:51 +0300 Subject: Update all .tsx files and remove unused --- src/config.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/config.tsx (limited to 'src/config.tsx') diff --git a/src/config.tsx b/src/config.tsx new file mode 100644 index 0000000..f74382c --- /dev/null +++ b/src/config.tsx @@ -0,0 +1,17 @@ +const hostname = window && window.location && window.location.hostname; + +const PRODUCTION = hostname.includes("geshem"); + +const IMAGES_BASE_URL = PRODUCTION ? "https://imgs.geshem.space" : ""; + +const MAPBOX_ACCESS_TOKEN = + "pk.eyJ1IjoieXV2YWRtIiwiYSI6ImNpcnMxbzBuaTAwZWdoa25oczlzZmkwbHcifQ.UHtLngbKm9O8945pJm23Nw"; + +const IMAGE_COORDINATES = [ + [31.7503896894, 34.4878044232], + [37.8574239563, 34.5078463729], + [37.7157066403, 29.4538271687], + [31.9347389087, 29.4373462909] +]; + +module.exports = { IMAGES_BASE_URL, MAPBOX_ACCESS_TOKEN, IMAGE_COORDINATES }; -- cgit v1.3.1 From b0a54e38d777ca233b6e42e57d7e603c20f0e5c1 Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Mon, 29 Aug 2022 10:27:10 +0300 Subject: Fix config exports --- src/config.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/config.tsx') diff --git a/src/config.tsx b/src/config.tsx index f74382c..0a79239 100644 --- a/src/config.tsx +++ b/src/config.tsx @@ -2,16 +2,14 @@ const hostname = window && window.location && window.location.hostname; const PRODUCTION = hostname.includes("geshem"); -const IMAGES_BASE_URL = PRODUCTION ? "https://imgs.geshem.space" : ""; +export const IMAGES_BASE_URL = PRODUCTION ? "https://imgs.geshem.space" : ""; -const MAPBOX_ACCESS_TOKEN = +export const MAPBOX_ACCESS_TOKEN = "pk.eyJ1IjoieXV2YWRtIiwiYSI6ImNpcnMxbzBuaTAwZWdoa25oczlzZmkwbHcifQ.UHtLngbKm9O8945pJm23Nw"; -const IMAGE_COORDINATES = [ +export const IMAGE_COORDINATES = [ [31.7503896894, 34.4878044232], [37.8574239563, 34.5078463729], [37.7157066403, 29.4538271687], [31.9347389087, 29.4373462909] ]; - -module.exports = { IMAGES_BASE_URL, MAPBOX_ACCESS_TOKEN, IMAGE_COORDINATES }; -- cgit v1.3.1 From ea1670f6e05d22c516d364072b7dde9bf3ebb5ae Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Thu, 1 Sep 2022 11:18:13 +0300 Subject: Extract playback slots to config --- src/Geshem.tsx | 7 ++++--- src/Slider.tsx | 3 ++- src/config.tsx | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/config.tsx') diff --git a/src/Geshem.tsx b/src/Geshem.tsx index 5210622..6e88f19 100644 --- a/src/Geshem.tsx +++ b/src/Geshem.tsx @@ -5,7 +5,7 @@ import { Map } from "./Map"; import { Slider } from "./Slider"; import { DateTime } from "./Datetime"; -import { IMAGES_BASE_URL } from "./config"; +import { IMAGES_BASE_URL, PLAYBACK_HOURS, PLAYBACK_SLOTS } from "./config"; import "./Geshem.css"; import "rc-slider/assets/index.css"; @@ -25,6 +25,7 @@ interface GeshemProps { date?: string } + export function Geshem({ date }: GeshemProps) { const [images, setImages] = useState([]); const [playback] = useState( @@ -32,7 +33,7 @@ export function Geshem({ date }: GeshemProps) { new URL(window.location.toString()).searchParams.get("history") || undefined ); - const [slider, setSlider] = useState(playback ? 143 : 9); + const [slider, setSlider] = useState(playback ? PLAYBACK_SLOTS : 9); useEffect(() => { const fetchImages = async () => @@ -43,7 +44,7 @@ export function Geshem({ date }: GeshemProps) { const buildPlayback = async () => { const date = playback; - const hours = Array.from(Array(24).keys()).map( + const hours = Array.from(Array(PLAYBACK_HOURS).keys()).map( h => `${String(h).padStart(2, "0")}` ); const minutes = Array.from(Array(6).keys()).map( diff --git a/src/Slider.tsx b/src/Slider.tsx index 4d287a2..50223fc 100644 --- a/src/Slider.tsx +++ b/src/Slider.tsx @@ -1,5 +1,6 @@ import React from "react"; import RcSlider, { SliderProps, SliderRef } from 'rc-slider/lib/Slider'; +import { PLAYBACK_SLOTS } from "./config"; // use workaround from: https://github.com/react-component/slider/issues/835#issuecomment-1201805736 const CustomSlider = RcSlider as React.ForwardRefExoticComponent & React.RefAttributes>; @@ -32,7 +33,7 @@ export function Slider({ playback, slider, setSlider }: GeshemSliderProps) {