Skip to content

Commit 0921fc1

Browse files
committed
move constants to config
1 parent 8821a96 commit 0921fc1

18 files changed

Lines changed: 105 additions & 97 deletions

File tree

src/components/AppContentLayout.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from 'react'
2-
import { SUPPORTED_CARDS } from '../Constants'
2+
import { SUPPORTED_CARDS } from 'src/config'
33
import BottomNavigation from './BottomNavigation'
44
import { isDesktop } from 'react-device-detect'
55
import { useUserPreferences } from 'src/stores/preferences'
@@ -25,7 +25,7 @@ function DesktopCards({ cards }) {
2525
label: constantCard.label,
2626
icon: constantCard.icon,
2727
analyticsTag: constantCard.analyticsTag,
28-
withAds: index == 0,
28+
withAds: index === 0,
2929
})
3030
})
3131
}

src/components/BottomNavigation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import { SUPPORTED_CARDS } from '../Constants'
2+
import { SUPPORTED_CARDS } from 'src/config'
33
import { useUserPreferences } from 'src/stores/preferences'
44
import { AiOutlineMenu } from 'react-icons/ai'
55

src/components/CardComponent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import React from 'react'
22
import { BsBoxArrowInUpRight } from 'react-icons/bs'
3-
import { APP } from '../Constants'
3+
import { ref } from 'src/config'
44
import { useUserPreferences } from 'src/stores/preferences'
55

66
function CardComponent({ icon, title, children, fullBlock = false, link }) {
77
const { openLinksNewTab } = useUserPreferences()
88

99
const handleHeaderLinkClick = (e) => {
1010
e.preventDefault()
11-
let url = `${link}?${APP.ref}`
11+
let url = `${link}?${ref}`
1212
window.open(url, openLinksNewTab ? '_blank' : '_self')
1313
}
1414

src/components/ClickableItem.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { trackLinkOpen } from 'src/lib/analytics'
22
import React from 'react'
3-
import { APP } from '../Constants'
3+
import { ref } from 'src/config'
44

55
import { useUserPreferences } from 'src/stores/preferences'
66

@@ -22,9 +22,9 @@ const ClickableItem = ({ link, className, children, analyticsAttributes, appendR
2222

2323
// Url has some query params
2424
if (url.search) {
25-
utmUrl += `&${APP.ref}`
25+
utmUrl += `&${ref}`
2626
} else {
27-
utmUrl += `?${APP.ref}`
27+
utmUrl += `?${ref}`
2828
}
2929

3030
window.open(utmUrl, openLinksNewTab ? '_blank' : '_self')

src/components/Elements/SearchBar/SearchBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useEffect, useRef } from 'react'
22
import { trackSearchEngineUse } from 'src/lib/analytics'
33
import { GoSearch } from 'react-icons/go'
4-
import { SUPPORTED_SEARCH_ENGINES } from 'src/Constants'
4+
import { SUPPORTED_SEARCH_ENGINES } from 'src/config'
55
import { useUserPreferences } from 'src/stores/preferences'
66
import { SearchEngine } from 'src/types'
77

src/components/Header.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { BsFillGearFill } from 'react-icons/bs'
33
import { CgTab } from 'react-icons/cg'
44
import { BsFillBookmarksFill } from 'react-icons/bs'
55
import { ReactComponent as HackertabLogo } from 'src/assets/logo.svg'
6-
import UserTags from './UserTags'
6+
import { UserTags } from './UserTags'
77
import { SettingsModal } from 'src/features/settings'
88
import { BsMoon } from 'react-icons/bs'
99
import { IoMdSunny } from 'react-icons/io'

src/components/Layout/Footer.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
11
import React from 'react'
2-
import { APP } from '../../Constants'
2+
import {
3+
repository,
4+
supportLink,
5+
privacyPolicyLink,
6+
termsAndConditionsLink,
7+
dataSourcesLink,
8+
} from 'src/config'
39
import { RiCodeSSlashFill } from 'react-icons/ri'
410
import { HiLightBulb } from 'react-icons/hi'
511
import { trackPageView } from 'src/lib/analytics'
612

713
export const Footer = () => {
814
const onSourceCodeClick = () => {
915
trackPageView('Source Code')
10-
window.open(APP.repository, '_blank')
16+
window.open(repository, '_blank')
1117
}
1218

1319
const onNewFeatureRequest = () => {
1420
trackPageView('Feature Request')
15-
window.open(APP.supportLink)
21+
window.open(supportLink)
1622
}
1723

1824
const onPrivacyPolicyClick = () => {
1925
trackPageView('Privacy Policy')
20-
window.open(APP.privacyPolicyLink)
26+
window.open(privacyPolicyLink)
2127
}
2228
const onTermsClick = () => {
2329
trackPageView('Terms And Conditions')
24-
window.open(APP.termsAndConditionsLink)
30+
window.open(termsAndConditionsLink)
2531
}
2632
const onDataSourcesClick = () => {
2733
trackPageView('Data Sources')
28-
window.open(APP.dataSourcesLink)
34+
window.open(dataSourcesLink)
2935
}
3036

3137
return (

src/components/ScrollCardsNavigator.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState, useEffect, useLayoutEffect, useRef } from 'react'
22
import { FiChevronLeft, FiChevronRight } from 'react-icons/fi'
3-
import { APP } from '../Constants'
3+
import { maxCardsPerRow } from 'src/config'
44
import { useUserPreferences } from 'src/stores/preferences'
55
import { trackPageScroll } from 'src/lib/analytics'
66

@@ -18,9 +18,9 @@ function ScrollCardsNavigator() {
1818
}
1919

2020
const handleKeyboardKeys = (e) => {
21-
if (e.keyCode == 37) {
21+
if (e.keyCode === 37) {
2222
scrollTo('left')
23-
} else if (e.keyCode == 39) {
23+
} else if (e.keyCode === 39) {
2424
scrollTo('right')
2525
}
2626
}
@@ -40,7 +40,7 @@ function ScrollCardsNavigator() {
4040

4141
useEffect(() => {
4242
setLeftButtonVisible(false)
43-
setRightButtonVisible(cards.length > APP.maxCardsPerRow)
43+
setRightButtonVisible(cards.length > maxCardsPerRow)
4444
}, [cards])
4545

4646
const scrollTo = (direction) => {

src/components/SelectableCard.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useLayoutEffect } from 'react'
22
import DropDownMenu from './DropDownMenu'
3-
import { GLOBAL_TAG, MY_LANGUAGES_TAG } from '../Constants'
3+
import { GLOBAL_TAG, MY_LANGUAGES_TAG } from 'src/config'
44
import { useUserPreferences } from 'src/stores/preferences'
55

66
function SelectableCard({
@@ -33,15 +33,15 @@ function SelectableCard({
3333
return null
3434
}
3535

36-
return mergedTags.find((t) => t.value == value)
36+
return mergedTags.find((t) => t.value === value)
3737
}
3838

3939
const findTagByLabel = (name) => {
4040
if (!name) {
4141
return null
4242
}
4343

44-
return mergedTags.find((t) => t.label == name)
44+
return mergedTags.find((t) => t.label === name)
4545
}
4646

4747
useLayoutEffect(() => {
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import React from 'react'
2-
import { TiPlus } from 'react-icons/ti';
2+
import { TiPlus } from 'react-icons/ti'
33
import { useUserPreferences } from 'src/stores/preferences'
44

5-
function UserTags({ onAddClicked }) {
5+
type UserTagsProps = {
6+
onAddClicked: () => void
7+
}
8+
9+
export const UserTags = ({ onAddClicked }: UserTagsProps) => {
610
const { userSelectedTags } = useUserPreferences()
711

812
return (
@@ -18,5 +22,3 @@ function UserTags({ onAddClicked }) {
1822
</nav>
1923
)
2024
}
21-
22-
export default UserTags

0 commit comments

Comments
 (0)