Skip to content

Commit 1febfca

Browse files
authored
Merge pull request #271 from medyo/develop
New version
2 parents 4a38bbb + 50dba0a commit 1febfca

File tree

13 files changed

+93
-102
lines changed

13 files changed

+93
-102
lines changed

src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const App = () => {
3535
} = useUserPreferences()
3636

3737
useLayoutEffect(() => {
38-
document.documentElement.style.setProperty('--max-visible-cards', maxVisibleCards.toString())
38+
document.documentElement.style.setProperty('--user-cards-count', maxVisibleCards.toString())
3939
}, [maxVisibleCards])
4040

4141
useEffect(() => {

src/assets/App.css

Lines changed: 46 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ a {
2929
display: flex;
3030
flex-direction: column;
3131
height: 100vh;
32+
max-width: 3000px;
3233
}
3334

3435
.errorMsg {
@@ -104,13 +105,17 @@ a {
104105
box-sizing: border-box;
105106
display: flex;
106107
flex: 1 1 auto;
107-
gap: 12px;
108+
gap: var(--cards-gap);
108109
height: 100%;
109-
justify-content: space-between;
110110
overflow-y: hidden;
111111
padding-top: 20px;
112112
position: relative;
113113
scroll-snap-type: x mandatory;
114+
flex-wrap: nowrap;
115+
}
116+
117+
.Cards > * {
118+
flex: 0 0 calc((100% - ((var(--visible-cards)) * var(--cards-gap))) / var(--visible-cards));
114119
}
115120

116121
.HorizontalScroll {
@@ -185,23 +190,16 @@ a {
185190
fill: var(--app-name-text-color);
186191
}
187192

188-
.cards {
189-
display: flex;
190-
align-items: flex-start;
191-
flex-direction: row;
192-
flex-wrap: wrap;
193-
}
194-
195193
.block {
196194
background-color: var(--card-background-color);
197195
border: 1px solid var(--card-border-color);
198196
flex-direction: column;
199-
flex: 0 0 auto;
200197
height: calc(100% - 54px);
201198
overflow: hidden;
202199
padding-bottom: 56px;
200+
box-sizing: border-box;
203201
scroll-snap-align: start;
204-
width: 100vw;
202+
width: 100%;
205203
}
206204

207205
.blockContent {
@@ -1345,8 +1343,43 @@ Producthunt item
13451343
}
13461344
}
13471345

1346+
@media (min-width: 768px) {
1347+
html {
1348+
--max-layout-cards-count: 2;
1349+
}
1350+
}
1351+
1352+
@media (min-width: 1200px) {
1353+
html {
1354+
--max-layout-cards-count: 4;
1355+
}
1356+
.App {
1357+
margin: 0 auto;
1358+
}
1359+
}
1360+
1361+
@media (min-width: 1800px) {
1362+
html {
1363+
--max-layout-cards-count: 5;
1364+
}
1365+
.App {
1366+
margin: 0 auto;
1367+
max-width: 1800px;
1368+
}
1369+
}
1370+
1371+
@media (min-width: 2048px) {
1372+
html {
1373+
--max-layout-cards-count: 6;
1374+
}
1375+
.App {
1376+
margin: 0 auto;
1377+
max-width: 3000px;
1378+
}
1379+
}
1380+
13481381
/* Small devices (portrait tablets and large phones, 600px and up) */
1349-
@media only screen and (min-width: 768px) {
1382+
@media (min-width: 768px) {
13501383
.floatingFilter {
13511384
display: none;
13521385
}
@@ -1355,7 +1388,6 @@ Producthunt item
13551388
border-radius: 10px;
13561389
height: 100%;
13571390
padding-bottom: 0;
1358-
width: calc(95vw / min(2, var(--max-visible-cards)));
13591391
}
13601392

13611393
.blockContent {
@@ -1390,7 +1422,7 @@ Producthunt item
13901422
}
13911423

13921424
/* Medium devices (landscape tablets, 768px and up) */
1393-
@media only screen and (min-width: 768px) {
1425+
@media (min-width: 768px) {
13941426
.AppHeader {
13951427
height: auto;
13961428
}
@@ -1400,10 +1432,6 @@ Producthunt item
14001432
width: auto;
14011433
}
14021434

1403-
.block {
1404-
width: calc(96vw / min(3, var(--max-visible-cards)));
1405-
}
1406-
14071435
.searchBar {
14081436
width: auto;
14091437
}
@@ -1416,41 +1444,6 @@ Producthunt item
14161444
}
14171445
}
14181446

1419-
/* Large devices (desktops, 992px and up)*/
1420-
@media only screen and (min-width: 992px) {
1421-
.block {
1422-
width: calc(96vw / min(3, var(--max-visible-cards)));
1423-
}
1424-
}
1425-
1426-
/* X-Large devices (large desktops, 1200px and up)*/
1427-
@media only screen and (min-width: 1200px) {
1428-
.block {
1429-
width: calc(96vw / min(4, var(--max-visible-cards)));
1430-
}
1431-
}
1432-
1433-
/* XX-Large devices (larger desktops, 1400px and up)*/
1434-
@media only screen and (min-width: 1400px) {
1435-
.block {
1436-
width: calc(95vw / min(4, var(--max-visible-cards)));
1437-
}
1438-
}
1439-
1440-
@media (min-width: 1800px) {
1441-
.App {
1442-
width: 1800px;
1443-
margin: 0 auto;
1444-
padding: 0;
1445-
}
1446-
1447-
.block {
1448-
width: calc(
1449-
(1800px - 20px * min(5, var(--max-visible-cards))) / min(5, var(--max-visible-cards))
1450-
);
1451-
}
1452-
}
1453-
14541447
/***** PAGE ****/
14551448
.Page {
14561449
max-width: 1024px;

src/assets/variables.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
}
1212

1313
html {
14-
--max-visible-cards: 4;
14+
--user-cards-count: 4;
15+
--max-layout-cards-count: 1;
16+
--visible-cards: min(var(--max-layout-cards-count), var(--user-cards-count, 1));
17+
--cards-gap: 12px;
1518
}
1619

1720
html.dark {

src/components/Elements/CardWithActions/CardItemWithActions.tsx

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import React, { useCallback, useEffect, useState } from 'react'
22
import { BiBookmarkMinus, BiBookmarkPlus, BiShareAlt } from 'react-icons/bi'
3-
import { MdBugReport } from 'react-icons/md'
4-
import { reportLink } from 'src/config'
53
import { ShareModal } from 'src/features/shareModal'
64
import { ShareModalData } from 'src/features/shareModal/types'
75
import { Attributes, trackLinkBookmark, trackLinkUnBookmark } from 'src/lib/analytics'
86
import { useBookmarks } from 'src/stores/bookmarks'
9-
import { useUserPreferences } from 'src/stores/preferences'
107

118
type CardItemWithActionsProps = {
129
item: {
@@ -72,14 +69,6 @@ export const CardItemWithActions = ({
7269
const onShareModalClicked = useCallback(() => {
7370
setShareModalData({ title: item.title, link: item.url, source: source })
7471
}, [item.title, item.url, source])
75-
76-
const onReportClicked = useCallback(() => {
77-
const tags = useUserPreferences
78-
.getState()
79-
.userSelectedTags.map((tag) => tag.label.toLocaleLowerCase())
80-
window.open(`${reportLink}?tags=${tags.join(',')}&url=${item.url}`, '_blank')
81-
}, [item.url])
82-
8372
return (
8473
<div key={item.id} className="blockRow">
8574
<ShareModal
@@ -89,14 +78,6 @@ export const CardItemWithActions = ({
8978
/>
9079
{cardItem}
9180
<div className={`blockActions ${isBookmarked ? 'active' : ''} `}>
92-
{source === 'ai' && (
93-
<button
94-
className={`blockActionButton `}
95-
onClick={onReportClicked}
96-
aria-label="Report item">
97-
<MdBugReport />
98-
</button>
99-
)}
10081
<button
10182
className={`blockActionButton `}
10283
onClick={onShareModalClicked}

src/features/adv/api/getAd.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,8 @@ import { axios } from 'src/lib/axios'
33
import { ExtractFnReturnType, QueryConfig } from 'src/lib/react-query'
44
import { Ad } from '../types'
55

6-
const getAd = async (
7-
keywords: string[],
8-
feed: boolean = false,
9-
aditionalAdQueries: { [key: string]: string } | undefined
10-
): Promise<Ad | null> => {
6+
const getAd = async (keywords: string[], feed: boolean = false): Promise<Ad | null> => {
117
let params = { keywords: keywords.join(','), feed: feed ? 'true' : 'false' }
12-
if (aditionalAdQueries) {
13-
params = { ...params, ...aditionalAdQueries }
14-
}
158
return axios.get('/engine/ads/', { params })
169
}
1710

@@ -21,12 +14,11 @@ type UseGetAdOptions = {
2114
keywords: string[]
2215
feed?: boolean
2316
config?: QueryConfig<QueryFnType>
24-
aditionalAdQueries: { [key: string]: string } | undefined
2517
}
26-
export const useGetAd = ({ keywords, feed, config, aditionalAdQueries }: UseGetAdOptions) => {
18+
export const useGetAd = ({ keywords, feed, config }: UseGetAdOptions) => {
2719
return useQuery<ExtractFnReturnType<QueryFnType>>({
2820
...config,
2921
queryKey: ['ad', keywords.join(',')],
30-
queryFn: () => getAd(keywords, feed, aditionalAdQueries),
22+
queryFn: () => getAd(keywords, feed),
3123
})
3224
}

src/features/adv/components/AdvBanner.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { useEffect, useState } from 'react'
1+
import { useEffect } from 'react'
22
import { AdPlaceholder } from 'src/components/placeholders'
3+
import { useRemoteConfigStore } from 'src/features/remoteConfig'
34
import { useUserPreferences } from 'src/stores/preferences'
45
import { useGetAd } from '../api/getAd'
6+
import { useDelayedFlag } from '../hooks/useDelayedFlag'
57
import { Ad } from '../types'
68
import './AdvBanner.css'
79

@@ -13,10 +15,9 @@ type AdvBannerProps = {
1315

1416
export const AdvBanner = ({ feedDisplay = false, loadingState, onAdLoaded }: AdvBannerProps) => {
1517
const { userSelectedTags } = useUserPreferences()
18+
const adsFetchDelayMs = useRemoteConfigStore((s) => s.adsFetchDelayMs)
19+
const isReady = useDelayedFlag(adsFetchDelayMs)
1620

17-
const [aditionalAdQueries, setAditionalAdQueries] = useState<
18-
{ [key: string]: string } | undefined
19-
>()
2021
const {
2122
isSuccess,
2223
data: ad,
@@ -25,18 +26,11 @@ export const AdvBanner = ({ feedDisplay = false, loadingState, onAdLoaded }: Adv
2526
} = useGetAd({
2627
keywords: userSelectedTags.map((tag) => tag.label.toLocaleLowerCase()),
2728
feed: true,
28-
aditionalAdQueries: aditionalAdQueries,
2929
config: {
3030
cacheTime: 0,
3131
staleTime: 0,
32+
enabled: isReady,
3233
useErrorBoundary: false,
33-
refetchInterval(data) {
34-
if (data?.nextAd) {
35-
setAditionalAdQueries(data.nextAd.queries)
36-
return data.nextAd.interval
37-
}
38-
return false
39-
},
4034
},
4135
})
4236

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { useEffect, useState, useTransition } from 'react'
2+
3+
export const useDelayedFlag = (ms: number | undefined) => {
4+
const [ready, setReady] = useState(false)
5+
const [, startTransition] = useTransition()
6+
useEffect(() => {
7+
if (ms === undefined || ms <= 0) {
8+
setReady(true)
9+
return
10+
}
11+
const t = setTimeout(() => startTransition(() => setReady(true)), ms)
12+
return () => clearTimeout(t)
13+
}, [ms])
14+
15+
return ready
16+
}

src/features/cards/components/githubCard/RepoItem.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ const RepoItem = ({
2222
return (
2323
<CardItemWithActions
2424
source={analyticsTag}
25-
item={item}
25+
item={{
26+
title: `${item.owner}/${item.name}`,
27+
url: item.url,
28+
id: item.id.toString(),
29+
}}
2630
cardItem={
2731
<>
2832
<CardLink

src/features/onboarding/components/steps/HelloTab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const OCCUPATIONS: Occupation[] = [
1414
value: 'frontend',
1515
icon: FaPaintBrush,
1616
sources: ['devto', 'github', 'medium', 'hashnode'],
17-
tags: ['frontend', 'javascript', 'typescript', 'css', 'react', 'vue', 'angular'],
17+
tags: ['frontend', 'javascript', 'typescript', 'css', 'react', 'vue.js', 'angularjs'],
1818
},
1919
{
2020
title: 'Back-End Engineer',

src/features/remoteConfig/api/getRemoteConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type UseGetRemoteConfigOptions = {
1515
export const useGetRemoteConfig = ({ config }: UseGetRemoteConfigOptions = {}) => {
1616
return useQuery<ExtractFnReturnType<QueryFnType>>({
1717
...config,
18-
queryKey: ['remote-config', 'v2'],
18+
queryKey: ['remote-config', 'v3'],
1919
queryFn: () => getRemoteConfig(),
2020
})
2121
}

0 commit comments

Comments
 (0)