Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
63732ad
Refactor locale handling by introducing useLocale hook and updating c…
davidheyman May 22, 2025
a068b33
Refactor page.js for improved path handling and locale support
davidheyman May 22, 2025
f4f9963
Refactor page.js for improved path handling and locale support
davidheyman May 22, 2025
81e7821
Refactor iconography imports and streamline getStaticPaths function
davidheyman May 22, 2025
2167307
Refactor locale handling by exporting supportedLocales and updating i…
davidheyman May 22, 2025
2606b29
Refactor iconography component to use useLocale hook for locale manag…
davidheyman May 22, 2025
ec63a4c
Refactor iconography components and update imports for improved struc…
davidheyman May 22, 2025
c69f3da
Refactor components to use useLocale hook for consistent locale manag…
davidheyman May 22, 2025
3ce7f61
Refactor ImageRow component imports for improved structure and update…
davidheyman May 22, 2025
99666ee
Refactor index.js to import React and return a div instead of null
davidheyman May 22, 2025
dec20ae
Refactor index.js to streamline imports and include Image component f…
davidheyman May 22, 2025
4dc476a
Add cloudfrontLoader utility and integrate it into Image components f…
davidheyman May 22, 2025
3023096
Refactor ImageRow and index.js to streamline image handling and remov…
davidheyman May 22, 2025
f212e0d
Update link paths in index.js to include locale for improved routing
davidheyman May 22, 2025
9257a34
Add forum and narratives links with translations to index.js
davidheyman May 23, 2025
f92ff50
Update HomeRedirect to use browser language preferences for locale se…
davidheyman May 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/jsLinters/eslint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions .idea/misc.xml

This file was deleted.

4 changes: 4 additions & 0 deletions assets/config/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ const translation = {
en: 'Search by box',
pt: 'Pesquisar por área',
},
narratives: {
en: 'Narratives',
pt: 'Narrativas',
},
};

export default translation;
12 changes: 8 additions & 4 deletions components/AtlasController/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useState, useEffect } from 'react';
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import axios from 'axios';
import useSWR from 'swr';
import { useRouter } from 'next/router';
import { flatten } from 'lodash';
import { Atlas } from '@imaginerio/diachronic-atlas';
import { Box, HStack, Checkbox, Text } from '@chakra-ui/react';
import { Box, Checkbox, HStack, Text } from '@chakra-ui/react';

import Legend from '../Legend';
import Probe from '../Probe';
Expand All @@ -18,6 +18,7 @@ import mapStyle from '../../assets/style/style.json';
import { useImages } from '../../providers/ImageContext';
import useDebouncedEffect from '../../utils/useDebouncedEffect';
import translation from '../../assets/config/translations';
import { useLocale } from '../../hooks/useLocale';

const fetcher = ssid => {
if (ssid) {
Expand Down Expand Up @@ -53,6 +54,7 @@ const AtlasController = ({ width, height, mobile }) => {
] = useImages();

const router = useRouter();
const { locale } = useLocale();
useEffect(() => {
const hash = router.asPath.split('#')[1];
if (hash) {
Expand Down Expand Up @@ -95,7 +97,9 @@ const AtlasController = ({ width, height, mobile }) => {
router.replace(`${router.basePath}#${selectedImage.ssid}`);
} else {
setViewCone(null);
router.replace(router.basePath);
if (router.basePath) {
router.replace(router.basePath);
}
}
}, [selectedImage]);

Expand Down Expand Up @@ -227,7 +231,7 @@ const AtlasController = ({ width, height, mobile }) => {
cursor="pointer"
>
<Checkbox isChecked={searchMove} pointerEvents="none" />
<Text>{translation.searchMoves[router.locale]}</Text>
<Text>{translation.searchMoves[locale]}</Text>
</HStack>
)}
<ViewControl
Expand Down
4 changes: 2 additions & 2 deletions components/Breadcrumbs/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import PropTypes from 'prop-types';
import Link from 'next/link';
import { useRouter } from 'next/router';
import { Box, Text } from '@chakra-ui/react';
import { ChevronRightIcon } from '@chakra-ui/icons';
import { useLocale } from '../../hooks/useLocale';

const Breadcrumbs = ({ collection, title }) => {
const { locale } = useRouter();
const { locale } = useLocale();
return (
<Box>
<Link href={`/${locale}/iconography`}>Iconography</Link>
Expand Down
8 changes: 4 additions & 4 deletions components/Footer/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { useRouter } from 'next/router';
import { Container, Grid, Box, Heading, Text, Stack, Image, Link } from '@chakra-ui/react';
import { Box, Container, Grid, Heading, Image, Link, Stack, Text } from '@chakra-ui/react';

import pages from '../../assets/config/pages';
import translations from '../../assets/config/translations';
import { useLocale } from '../../hooks/useLocale';

const ContactColumn = () => (
<Box>
Expand All @@ -23,7 +23,7 @@ const ContactColumn = () => (
);

const NavigationColumn = () => {
const { locale } = useRouter();
const { locale } = useLocale();
return (
<Box>
<Heading size="md">Menu</Heading>
Expand All @@ -48,7 +48,7 @@ const NavigationColumn = () => {
};

const Footer = () => {
const { locale } = useRouter();
const { locale } = useLocale();
return (
<Box as="section" backgroundColor="#F7F9FC" py={[5, 50]}>
<Container>
Expand Down
4 changes: 3 additions & 1 deletion components/Head/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import NextHead from 'next/head';
import { useRouter } from 'next/router';

import translations from '../../assets/config/translations';
import { useLocale } from '../../hooks/useLocale';

const Head = ({ title }) => {
const { asPath, locale } = useRouter();
const { asPath } = useRouter();
const { locale } = useLocale();
return (
<NextHead>
<meta charSet="UTF-8" />
Expand Down
20 changes: 13 additions & 7 deletions components/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,25 @@ import { useRouter } from 'next/router';
import {
Container,
Flex,
Spacer,
Stack,
HStack,
Link,
IconButton,
Link,
Menu,
MenuButton,
MenuList,
Spacer,
Stack,
} from '@chakra-ui/react';
import { HamburgerIcon } from '@chakra-ui/icons';

import pages from '../../assets/config/pages';
import translations from '../../assets/config/translations';
import { useLocale } from '../../hooks/useLocale';

const HeaderLinks = () => {
const { locale, asPath } = useRouter();
const { asPath } = useRouter();
const { locale } = useLocale();

return (
<>
<Link
Expand All @@ -40,8 +43,11 @@ const HeaderLinks = () => {
{pages[locale][page].title}
</Link>
))}
<Link variant="header" href="https://narratives.imaginerio.org">
Narratives
<Link variant="header" href="https://forum.imaginerio.org" target="_blank">
{translations.forum[locale]}
</Link>
<Link variant="header" href="https://narratives.imaginerio.org" target="_blank">
{translations.narratives[locale]}
</Link>
<Link
variant="header"
Expand All @@ -58,7 +64,7 @@ const HeaderLinks = () => {
};

const Header = () => {
const { locale } = useRouter();
const { locale } = useLocale();
return (
<Container maxW="6xl">
<Flex h="90px" alignItems="center">
Expand Down
8 changes: 4 additions & 4 deletions components/ImageController/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react';
import PropTypes from 'prop-types';
import { useRouter } from 'next/router';
import dynamic from 'next/dynamic';
import Link from 'next/link';
import { FiXCircle, FiExternalLink } from 'react-icons/fi';
import { Grid, Container, Box, Tooltip } from '@chakra-ui/react';
import { FiExternalLink, FiXCircle } from 'react-icons/fi';
import { Box, Container, Grid, Tooltip } from '@chakra-ui/react';

import ImageSearch from '../ImageSearch';
import ImageFilter from '../ImageFilter';
Expand All @@ -14,11 +13,12 @@ import ImageViewer from '../ImageViewer';
import translations from '../../assets/config/translations';

import { useImages } from '../../providers/ImageContext';
import { useLocale } from '../../hooks/useLocale';

const Mirador = dynamic(() => import('../Mirador'), { ssr: false });

const ImageController = ({ imageWidth, height }) => {
const { locale } = useRouter();
const { locale } = useLocale();
const [{ selectedImage }, dispatch] = useImages();

return (
Expand Down
20 changes: 11 additions & 9 deletions components/ImageFilter/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
import React, { useState, useRef, useEffect } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import PropTypes from 'prop-types';
import { useRouter } from 'next/router';
import { FiFilter } from 'react-icons/fi';
import {
Stack,
Box,
Text,
IconButton,
Heading,
Radio,
RadioGroup,
HStack,
IconButton,
Input,
Radio,
RadioGroup,
Stack,
Text,
Tooltip,
} from '@chakra-ui/react';

import { useImages } from '../../providers/ImageContext';
import translation from '../../assets/config/translations';
import { useLocale } from '../../hooks/useLocale';

const CollectionFilter = () => {
const { locale, query } = useRouter();
const { query } = useRouter();
const { locale } = useLocale();
const [{ categories, collection }, dispatch] = useImages();

useEffect(() => {
Expand Down Expand Up @@ -52,7 +54,7 @@ const CollectionFilter = () => {
};

const FilterMenu = ({ xPos }) => {
const { locale } = useRouter();
const { locale } = useLocale();
const [{ dates }, dispatch] = useImages();
const [tempDates, setTempDates] = useState(dates);
const [isError, setIsError] = useState(false);
Expand Down Expand Up @@ -122,7 +124,7 @@ FilterMenu.propTypes = {
};

const ImageFilter = () => {
const { locale } = useRouter();
const { locale } = useLocale();
const buttonRef = useRef(null);
const [isOpen, setIsOpen] = useState();
const [{ collection }] = useImages();
Expand Down
24 changes: 16 additions & 8 deletions components/ImageGrid/index.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
import React from 'react';
import PropTypes from 'prop-types';
import { useRouter } from 'next/router';
import dynamic from 'next/dynamic';
import Image from 'next/image';
import {
Box,
Heading,
Text,
Popover,
PopoverTrigger,
PopoverContent,
PopoverBody,
PopoverArrow,
PopoverBody,
PopoverContent,
PopoverTrigger,
Text,
} from '@chakra-ui/react';

import { ImageLink, MetaLinks } from '../ImageList/RowComponents';
import translation from '../../assets/config/translations';
import { useLocale } from '../../hooks/useLocale';

const FixedSizeGrid = dynamic(() => import('react-window').then(mod => mod.FixedSizeGrid), {
ssr: false,
});

const ImageGrid = ({ width, height, activeImages }) => {
const { locale } = useRouter();
const { locale } = useLocale();
const numColumns = Math.floor(width / 185);
const gridWidth = (width - 40) / numColumns;

Expand All @@ -40,7 +39,16 @@ const ImageGrid = ({ width, height, activeImages }) => {
<Popover trigger="hover">
<PopoverTrigger>
<Box pos="relative" w={`${gridWidth - 40}px`} h="150px" mx="20px" userSelect="none">
{thumbnail && <Image src={thumbnail} layout="fill" objectFit="contain" />}
{thumbnail && (
<Box
bgImage={`url(${thumbnail})`}
bgSize="contain"
w="full"
h="full"
bgPosition="center"
bgRepeat="no-repeat"
/>
)}
</Box>
</PopoverTrigger>
<PopoverContent>
Expand Down
13 changes: 3 additions & 10 deletions components/ImageList/ImageRow.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import Image from 'next/image';
import { Container, Grid, Flex } from '@chakra-ui/react';
import { Container, Flex, Grid, Image } from '@chakra-ui/react';

import { ImageMeta, ImageTitle, ImageLink } from './RowComponents';
import { ImageLink, ImageMeta, ImageTitle } from './RowComponents';

const calcImageSize = ({ rawWidth, rawHeight, rowWidth, rowHeight }) => {
let imgHeight = rowHeight;
Expand Down Expand Up @@ -55,13 +54,7 @@ const ImageRow = ({
<Flex align="center" justify="flex-end">
{thumbnail && (
<ImageLink w={`${imgWidth}px`} h={`${imgHeight}px`} cursor="pointer" ssid={ssid}>
<Image
src={thumbnail}
height={imgHeight}
width={imgWidth}
layout="responsive"
ssid={ssid}
/>
<Image src={thumbnail} h={`${imgHeight}px`} w={`${imgWidth}px`} ssid={ssid} />
</ImageLink>
)}
</Flex>
Expand Down
6 changes: 3 additions & 3 deletions components/ImageList/ImageRowSmall.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import { useRouter } from 'next/router';
import { Container, Box, Text } from '@chakra-ui/react';
import { Box, Container, Text } from '@chakra-ui/react';

import { ImageTitle, MetaLinks } from './RowComponents';
import translation from '../../assets/config/translations';
import { useLocale } from '../../hooks/useLocale';

const ImageRowSmall = ({ style, ssid, title, creator }) => {
const { locale } = useRouter();
const { locale } = useLocale();

return (
<div style={style}>
Expand Down
7 changes: 4 additions & 3 deletions components/ImageList/RowComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Box, Heading, Text } from '@chakra-ui/react';

import { useImages } from '../../providers/ImageContext';
import translation from '../../assets/config/translations';
import { useLocale } from '../../hooks/useLocale';

export const MetaLinks = ({ source }) => {
let links;
Expand Down Expand Up @@ -48,7 +49,7 @@ MetaLinks.propTypes = {
};

export const ImageMeta = ({ creator, date, source }) => {
const { locale } = useRouter();
const { locale } = useLocale();

return (
<Box>
Expand Down Expand Up @@ -106,11 +107,11 @@ ImageTitle.propTypes = {
};

export const ImageLink = ({ children, ssid, ...rest }) => {
const { asPath, locale } = useRouter();
const { asPath } = useRouter();
const [{ useLinks, allImages }, dispatch] = useImages();
if (useLinks)
return (
<Link href={`/${locale}${asPath}/${ssid}`}>
<Link href={`${asPath}/${ssid}`}>
<a style={{ width: '100%', height: '100%' }}>{children}</a>
</Link>
);
Expand Down
Loading