MCPcopy Create free account
hub / github.com/dailydotdev/apps / next

Function next

packages/shared/src/lib/feedHighlightColSpan.ts:190–250  ·  view source on GitHub ↗
(
      item,
      { fullRowBefore = false, maxColSpan = Infinity } = {},
    )

Source from the content-addressed store, hash-verified

188
189 return {
190 next(
191 item,
192 { fullRowBefore = false, maxColSpan = Infinity } = {},
193 ): FeedItemPlacement {
194 if (!layoutEnabled) {
195 const shifted = itemIdx + safeFirstSlotOffset;
196 const placement: FeedItemPlacement = {
197 colSpan: 1,
198 row: Math.floor(shifted / safeNumCards),
199 column: shifted % safeNumCards,
200 };
201 itemIdx += 1;
202 return placement;
203 }
204
205 if (fullRowBefore) {
206 if (col !== 0) {
207 row += 1;
208 }
209 row += 1;
210 col = 0;
211 }
212
213 const requested = requestedColSpan(item, widenableTypes);
214 const actual = ((): number => {
215 if (requested === 1) {
216 return 1;
217 }
218 if (itemIdx < startIndex) {
219 return 1;
220 }
221 if (row < minWideCardRow) {
222 return 1;
223 }
224 if (itemIdx - lastLargeIndex < minSpacing) {
225 return 1;
226 }
227 const clampedToGrid = Math.min(requested, numCards);
228 const remainingInRow = numCards - col;
229 return Math.max(1, Math.min(clampedToGrid, remainingInRow, maxColSpan));
230 })();
231
232 const placement: FeedItemPlacement = {
233 colSpan: actual,
234 row,
235 column: col,
236 };
237
238 if (actual > 1) {
239 lastLargeIndex = itemIdx;
240 }
241
242 col += actual;
243 if (col >= numCards) {
244 row += 1;
245 col = 0;
246 }
247 itemIdx += 1;

Callers

nothing calls this directly

Calls 1

requestedColSpanFunction · 0.85

Tested by

no test coverage detected