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

Function next

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

Source from the content-addressed store, hash-verified

205
206 return {
207 next(
208 item,
209 { fullRowBefore = false, maxColSpan = Infinity } = {},
210 ): FeedItemPlacement {
211 if (!layoutEnabled) {
212 const shifted = itemIdx + safeFirstSlotOffset;
213 const placement: FeedItemPlacement = {
214 colSpan: 1,
215 row: Math.floor(shifted / safeNumCards),
216 column: shifted % safeNumCards,
217 };
218 itemIdx += 1;
219 return placement;
220 }
221
222 if (fullRowBefore) {
223 if (col !== 0) {
224 row += 1;
225 }
226 row += 1;
227 col = 0;
228 }
229
230 const requested = requestedColSpan(item, widenableTypes);
231 const actual = ((): number => {
232 if (requested === 1) {
233 return 1;
234 }
235 // The reader placed it, so the hero rules (where, how often) do not
236 // apply; it only has to fit the row and stop short of an ad's cell,
237 // and narrows to one card where it does not.
238 if (isWideFeedWidgetItem(item)) {
239 return Math.max(1, Math.min(requested, numCards - col, maxColSpan));
240 }
241 if (!isEnabled) {
242 return 1;
243 }
244 if (itemIdx < startIndex) {
245 return 1;
246 }
247 if (row < minWideCardRow) {
248 return 1;
249 }
250 if (itemIdx - lastLargeIndex < minSpacing) {
251 return 1;
252 }
253 const clampedToGrid = Math.min(requested, numCards);
254 const remainingInRow = numCards - col;
255 return Math.max(1, Math.min(clampedToGrid, remainingInRow, maxColSpan));
256 })();
257
258 const placement: FeedItemPlacement = {
259 colSpan: actual,
260 row,
261 column: col,
262 };
263
264 if (actual > 1) {

Callers

nothing calls this directly

Calls 2

requestedColSpanFunction · 0.85
isWideFeedWidgetItemFunction · 0.85

Tested by

no test coverage detected