Skip to content

Commit ac83453

Browse files
max width for main content, generate grid on css instead of context variable
1 parent 22ef91b commit ac83453

File tree

2 files changed

+6
-37
lines changed

2 files changed

+6
-37
lines changed

src/components/skeleton/SkeletonFeed.tsx

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
import { useContext } from 'react'
21
import SkeletonChannelInfo from './SkeletonChannelInfo'
32
import SkeletonProfilePicture from './SkeletonProfilePicture'
43
import SkeletonThumbnail from './SkeletonThumbnail'
5-
import { ContextScreenWidth } from '../../App'
64

75
const SkeletonFeed = () => {
8-
const contextScreenWidth = useContext(ContextScreenWidth)
9-
if (!contextScreenWidth) {
10-
throw new Error(
11-
'ContextScreenWidth must be used within a ContextScreenWidth.Provider'
12-
)
13-
}
14-
156
const skeletonArray = Array.from({ length: 20 }, (_, i) => i)
167
return (
17-
<>
8+
<div className="max-w-[2048px] mx-auto">
189
<div className="w-full lg:w-4/5 max-w-6xl m-auto pt-4">
1910
<div
2011
className="bg-zinc-50 rounded-full h-6 animate-pulse my-2"
@@ -28,15 +19,7 @@ const SkeletonFeed = () => {
2819
className="bg-zinc-50 rounded-full h-5 animate-pulse my-4 mx-4"
2920
style={{ width: 'min(85vw, 320px)' }}
3021
></div>
31-
<article
32-
className={`p-4 gap-4 ${
33-
contextScreenWidth === 'MOBILE'
34-
? 'grid grid-cols-1'
35-
: contextScreenWidth === 'TABLET_SMALL'
36-
? 'grid grid-cols-2'
37-
: 'grid grid-cols-auto-fill-284'
38-
}`}
39-
>
22+
<article className="p-4 gap-4 grid grid-cols-1 min-[384px]:grid-cols-2 sm:grid-cols-auto-fill-284">
4023
{skeletonArray.map((item) => {
4124
return (
4225
<article key={item} className="max-w-[440px]">
@@ -51,7 +34,7 @@ const SkeletonFeed = () => {
5134
)
5235
})}
5336
</article>
54-
</>
37+
</div>
5538
)
5639
}
5740

src/components/streamFeed/StreamFeed.tsx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
ContextFocusInput,
2121
ContextLanguage,
2222
ContextSEOSearchText,
23-
ContextScreenWidth,
2423
ContextSearchText,
2524
ContextStreamData,
2625
} from '../../App'
@@ -75,13 +74,6 @@ const StreamFeed = () => {
7574
const [filteredStreamData, setFilteredStreamData] =
7675
contextFilteredStreamData
7776

78-
const contextScreenWidth = useContext(ContextScreenWidth)
79-
if (!contextScreenWidth) {
80-
throw new Error(
81-
'ContextScreenWidth must be used within a ContextScreenWidth.Provider'
82-
)
83-
}
84-
8577
const contextSearchText = useContext(ContextSearchText)
8678
if (!contextSearchText) {
8779
throw new Error(
@@ -188,7 +180,7 @@ const StreamFeed = () => {
188180
}
189181

190182
return (
191-
<>
183+
<div className="max-w-[2048px] mx-auto">
192184
{filteredStreamData && filteredStreamData.data.length > 0 ? (
193185
<>
194186
{!seoSearchText && (
@@ -247,13 +239,7 @@ const StreamFeed = () => {
247239
</>
248240
)}
249241
<article
250-
className={`p-4 gap-4 ${
251-
contextScreenWidth === 'MOBILE'
252-
? 'grid grid-cols-1'
253-
: contextScreenWidth === 'TABLET_SMALL'
254-
? 'grid grid-cols-2'
255-
: 'grid grid-cols-auto-fill-284'
256-
}`}
242+
className="p-4 gap-4 grid grid-cols-1 min-[384px]:grid-cols-2 sm:grid-cols-auto-fill-284"
257243
data-testid="streamfeed-container"
258244
>
259245
{filteredStreamData.data.map((item, index) => {
@@ -345,7 +331,7 @@ const StreamFeed = () => {
345331
) : (
346332
<StreamNoResults />
347333
)}
348-
</>
334+
</div>
349335
)
350336
}
351337

0 commit comments

Comments
 (0)