Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 7 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"extends": [
"airbnb-typescript",
"airbnb/hooks",
"react-app",
"prettier/react",
"plugin:jest/recommended",
"plugin:react/recommended",
Expand All @@ -40,7 +39,12 @@
// last configuration in the extends array.
"plugin:prettier/recommended"
],
"ignorePatterns": ["scratch", "src/serviceWorker.ts", "build"],
"ignorePatterns": [
"scratch",
"build",
"src/**/*.test.ts",
"src/**/*.test.tsx"
],
"rules": {
"array-bracket-newline": [
"error",
Expand Down Expand Up @@ -178,6 +182,6 @@
"import/newline-after-import": "error",
"import/extensions": 0,
"import/prefer-default-export": 0,
"@typescript-eslint/no-unused-vars": ["error"]
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }]
}
}
22 changes: 7 additions & 15 deletions public/index.html → index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<!-- End Google Tag Manager -->
<meta charset="utf-8" />
<!-- CRED: favicon stuff: https://realfavicongenerator.net/ -->
<link rel="icon" type="image/png" sizes="32x32" href="%PUBLIC_URL%/favicon-32x32.png?v=2.1">
<link rel="icon" type="image/png" sizes="16x16" href="%PUBLIC_URL%/favicon-16x16.png?v=2.1">
<link rel="icon" href="%PUBLIC_URL%/favicon.ico?v=2.1" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png?v=2.1">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png?v=2.1">
<link rel="icon" href="/favicon.ico?v=2.1" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#ffffff" />
<meta name="apple-mobile-web-app-title" content="Languages of NYC">
Expand All @@ -29,7 +29,7 @@
name="description"
content="An interactive language diversity map of New York City"
/>
<link rel="apple-touch-icon" sizes="180x180" href="%PUBLIC_URL%/apple-touch-icon.png?v=2.2">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=2.2">
<meta property="og:title" content="Languages of New York City Map" />
<meta property="og:site_name" content="Languages of New York City Map" />
<meta property="og:url" content="https://languagemap.nyc/" />
Expand All @@ -56,17 +56,8 @@
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json?v=2.1" />
<link rel="mask-icon" href="%PUBLIC_URL%/safari-pinned-tab.svg?v=2.1" color="#379587">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<link rel="manifest" href="/manifest.json?v=2.1" />
<link rel="mask-icon" href="/safari-pinned-tab.svg?v=2.1" color="#379587">
<title>Languages of New York City</title>
</head>
<body>
Expand All @@ -82,6 +73,7 @@
<!-- End Google Tag Manager (noscript) -->
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
<script>
const earlyAccessPath = 'https://fonts.googleapis.com/earlyaccess/'
Expand Down
26 changes: 12 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,33 @@
"jest-canvas-mock": "^2.2.0",
"match-sorter": "^4.2.0",
"material-table": "1.68.1",
"react": "^16.13.1",
"react": "^16.14.0",
"react-device-detect": "^1.17.0",
"react-dom": "^16.13.1",
"react-dom": "^16.14.0",
"react-icons": "^4.2.0",
"react-map-gl": "^5.2.7",
"react-map-gl-geocoder": "^2.0.16",
"react-markdown": "^5.0.3",
"react-query": "^2.12.1",
"react-query-devtools": "^2.6.3",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1",
"react-share": "^4.2.1",
"react-swipeable-views": "^0.13.9",
"react-transition-group": "^4.4.1",
"react-window": "^1.8.5",
"simple-statistics": "^7.3.2",
"typescript": "3.9.5",
"typescript": "4.9.5",
"webfontloader": "^1.6.28"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^3.6.0",
"@typescript-eslint/parser": "^3.6.0",
"@vitejs/plugin-react": "^4.3.4",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-airbnb-typescript": "^8.0.2",
"eslint-config-prettier": "^6.11.0",
"eslint-config-react-app": "^5.2.1",
"eslint-import-resolver-typescript": "^2.0.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-flowtype": "^5.2.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^23.18.0",
Expand All @@ -64,18 +63,17 @@
"lint-staged": "^10.2.11",
"prettier": "^2.0.5",
"prettier-eslint": "^11.0.0",
"prettier-eslint-cli": "^5.0.0"
"prettier-eslint-cli": "^5.0.0",
"vite": "^6.0.7",
"vite-plugin-svgr": "^4.3.0",
"vite-tsconfig-paths": "^5.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jest-environment-jsdom-sixteen",
"eject": "react-scripts eject",
"start": "vite",
"build": "tsc --noEmit && vite build",
"preview": "vite preview",
"lint": "eslint '*/**/*.{js,ts,tsx}' --quiet"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
Expand Down
3 changes: 2 additions & 1 deletion src/components/config/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { RouteLocation } from './types'

export const AIRTABLE_API_KEY = process.env.REACT_APP_AIRTABLE_API_KEY as string
export const AIRTABLE_API_KEY = import.meta.env
.REACT_APP_AIRTABLE_API_KEY as string
export const AIRTABLE_BASE = 'applPEl3BsnpuszQu'
export const AIRTABLE_CENSUS_BASE = 'appjb6Qnp4lTNz7Gn'

Expand Down
2 changes: 1 addition & 1 deletion src/components/details/DetailedIntro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const useStyles = makeStyles((theme: Theme) =>
export const DetailedIntro: FC<DetailedIntroProps> = (props) => {
const { data, shareNoun, isInstance, langDescripID, children } = props
const classes = useStyles()
const [anchorEl, setAnchorEl] = useState<HTMLDivElement | null>(null)
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null)

return (
<Grow in timeout={500} style={{ transformOrigin: 'top center' }}>
Expand Down
12 changes: 4 additions & 8 deletions src/components/details/LocationLink.tsx
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ankit0504 while this does work, I'd prefer to just use a legit solution since there are 6 instances of this.

    <Button
      color="secondary"
      // ...other props...
    >
       some text
    </Button>

I'm not sure why I used Link for this (maybe for styling?), but it's definitely not a link so let's go with Button (here and in the other 5 spots) unless you see any reason not to.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { FC } from 'react'
import { Link as RouterLink } from 'react-router-dom'
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles'
import { Link, Popover } from '@material-ui/core'
import { Button, Popover } from '@material-ui/core'
import { BiMapPin } from 'react-icons/bi'

import { NeighborhoodList } from 'components/details'
Expand Down Expand Up @@ -42,7 +42,7 @@ export const LocationLink: FC<LocationLinkProps> = (props) => {
const id = open ? 'neighbs-menu-popover' : undefined
const handleClose = () => setAnchorEl(null)

const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
event.preventDefault()
setAnchorEl(event.currentTarget)
}
Expand Down Expand Up @@ -77,18 +77,14 @@ export const LocationLink: FC<LocationLinkProps> = (props) => {
onClose={() => handleClose()}
/>
</Popover>
<Link
href="#"
role="button"
<Button
className={classes.link}
title="Show neighborhood or town options"
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore // TODO: mas tarde...
onClick={handleClick}
>
<BiMapPin />
{linkText}
</Link>
</Button>
</>
)
}
4 changes: 2 additions & 2 deletions src/components/details/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export type DetailedIntroProps = TonsOfData & {
}

export type LocationLinkProps = TonsOfData & {
anchorEl: HTMLDivElement | null
setAnchorEl: React.Dispatch<HTMLDivElement | null>
anchorEl: HTMLElement | null
setAnchorEl: React.Dispatch<HTMLElement | null>
}

export type DetailsProps = {
Expand Down
10 changes: 8 additions & 2 deletions src/components/explore/hooks.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { useQuery } from 'react-query'
import Airtable from 'airtable'

import { AIRTABLE_BASE, reactQueryDefaults } from 'components/config'
import {
AIRTABLE_API_KEY,
AIRTABLE_BASE,
reactQueryDefaults,
} from 'components/config'
import {
AirtableOptions,
TonsOfFields,
Expand All @@ -10,7 +14,9 @@ import {
} from './types'

const airtableQuery = async (tableName: string, options: AirtableOptions) => {
const base = new Airtable().base(options?.baseID || AIRTABLE_BASE)
const base = new Airtable({ apiKey: AIRTABLE_API_KEY }).base(
options?.baseID || AIRTABLE_BASE
)

// CRED: github.com/Airtable/airtable.js/issues/69#issuecomment-414394657
return base(tableName).select(options).all()
Expand Down
2 changes: 1 addition & 1 deletion src/components/generic/Logo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { FC } from 'react'
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles'
import { ReactComponent as ProjectLogo } from '../../img/logo.svg'
import ProjectLogo from '../../img/logo.svg?react'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion, not related to this pr, but TS does have a nice way to use absolute imports so we're not stuck with lots of ../../ like this. If it's set up properly, we could do img/logo.svg?react from anywhere in the repo.

Just a wishlist thing for later though.


type LogoProps = {
darkTheme?: boolean
Expand Down
10 changes: 4 additions & 6 deletions src/components/generic/ReadMore.tsx
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment for here and the others, regarding Link -> Button

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { FC, useState } from 'react'
import { isMobile } from 'react-device-detect'
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles'
import { Link } from '@material-ui/core'
import { Button } from '@material-ui/core'

import { ToggleableSection, MarkdownWithRouteLinks } from 'components/generic'

Expand Down Expand Up @@ -69,18 +69,16 @@ export const ReadMore: FC<ReadMoreProps> = (props) => {
})

const ToggleDescription = (
<Link
href="#"
<Button
className={classes.link}
onClick={(e: React.MouseEvent) => {
e.preventDefault()
onClick={() => {
setShowDescrip(!showDescrip)
}}
>
<span className={classes.innerText}>{`Read ${
showDescrip ? 'less' : 'more'
}`}</span>
</Link>
</Button>
)

return (
Expand Down
11 changes: 4 additions & 7 deletions src/components/home/FiltersWarning.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { FC, useContext } from 'react'
import { Link as RouterLink } from 'react-router-dom'
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles'
import { Link } from '@material-ui/core'
import { Button, Link } from '@material-ui/core'

import { GlobalContext } from 'components/context'
import { Explanation } from 'components/generic'
Expand Down Expand Up @@ -36,18 +36,15 @@ export const FiltersWarning: FC = () => {
const BadgeDot = <div className={classes.badgeDot} />

const ClearFilters = (
<Link
<Button
title="Clear table filters"
href="#"
color="primary"
onClick={(e: React.MouseEvent) => {
e.preventDefault()

onClick={() => {
dispatch({ type: 'CLEAR_FILTERS', payload: 555 }) // TODO: fix, obvi
}}
>
clear
</Link>
</Button>
)

const TableLink = (
Expand Down
10 changes: 4 additions & 6 deletions src/components/legend/WorldRegionMap.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { FC, useState } from 'react'
import { Link } from '@material-ui/core'
import { Button } from '@material-ui/core'
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles'

import { ToggleableSection, Explanation } from 'components/generic'
Expand Down Expand Up @@ -27,15 +27,13 @@ export const WorldRegionMap: FC = () => {
const [showWorldMap, setShowWorldMap] = useState<boolean>(false)

const WorldMapToggle = (
<Link
href="#"
onClick={(e: React.MouseEvent) => {
e.preventDefault()
<Button
onClick={() => {
setShowWorldMap(!showWorldMap)
}}
>
{showWorldMap ? 'Hide' : 'Show'} world map
</Link>
</Button>
)

const WorldMapTip = (
Expand Down
2 changes: 1 addition & 1 deletion src/components/map/MapCtrlBtns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const ctrlBtnsConfig = [
export const MapCtrlBtns: FC<MapCtrlBtnsProps> = (props) => {
const { onMapCtrlClick, isMapTilted } = props
const classes = useStyles()
const [anchorEl, setAnchorEl] = useState<HTMLDivElement | null>(null)
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null)

const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {
setAnchorEl(event.currentTarget)
Expand Down
11 changes: 5 additions & 6 deletions src/components/map/MapOptionsMenu.tsx
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { FC } from 'react'
import { Link as RouterLink } from 'react-router-dom'
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'
import { Link, Button, Popover, Typography } from '@material-ui/core'
import { Button, Popover, Typography } from '@material-ui/core'

import { DialogCloseBtn } from 'components/generic/modals'
import { useMapToolsState, useMapToolsDispatch } from 'components/context'
Expand All @@ -10,8 +10,8 @@ import { routes } from 'components/config/api'
import { BaseLayerToggles } from './BaseLayerToggles'

type MapOptionsMenuProps = {
anchorEl: HTMLDivElement | null
setAnchorEl: React.Dispatch<HTMLDivElement | null>
anchorEl: HTMLElement | null
setAnchorEl: React.Dispatch<HTMLElement | null>
}

const useStyles = makeStyles((theme: Theme) =>
Expand Down Expand Up @@ -131,8 +131,7 @@ export const MapOptionsMenu: FC<MapOptionsMenuProps> = (props) => {
>
View options
</Button>
<Link
component={Button}
<Button
size="small"
className={classes.censusLink}
color="secondary"
Expand All @@ -141,7 +140,7 @@ export const MapOptionsMenu: FC<MapOptionsMenuProps> = (props) => {
onClick={() => mapToolsDispatch({ type: 'CLEAR_CENSUS_FIELD' })}
>
Clear selection
</Link>
</Button>
</div>
<BaseLayerToggles />
<DialogCloseBtn tooltip="Close map menu" onClose={() => handleClose()} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/map/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { nonCensusPolygonConfig } from './config.non-census-poly'

export * from './config.points'

export const MAPBOX_TOKEN = process.env.REACT_APP_MB_TOKEN
export const MAPBOX_TOKEN = import.meta.env.REACT_APP_MB_TOKEN
export const NYC_LAT_LONG = { latitude: 40.7128, longitude: -74.006 }
export const initialMapState = { ...NYC_LAT_LONG, zoom: 8.5 }
export const POINT_ZOOM_LEVEL = 13 // clicked point or single-result filter
Expand Down
Loading