Wrap indent
Wrapped lines in code blocks keep their indent, capped so deep lines don't squeeze into a sliver on a phone.
Deep nesting
export function pyramid(a: unknown) {
if (a) {
if (Array.isArray(a)) {
for (const b of a) {
if (typeof b === "object" && b !== null) {
for (const [key, value] of Object.entries(b)) {
if (value) {
try {
if (typeof value === "function") {
return value(() => {
return new Promise((resolve) => {
setTimeout(() => {
resolve({ key, nested: { deeper: { deepest: { stillGoing: "yes, still going" } } } });
}, 0);
});
});
}
} catch {}
}
}
}
}
}
}
}export function pyramid(a: unknown) {
if (a) {
if (Array.isArray(a)) {
for (const b of a) {
if (typeof b === "object" && b !== null) {
for (const [key, value] of Object.entries(b)) {
if (value) {
try {
if (typeof value === "function") {
return value(() => {
return new Promise((resolve) => {
setTimeout(() => {
resolve({ key, nested: { deeper: { deepest: { stillGoing: "yes, still going" } } } });
}, 0);
});
});
}
} catch {}
}
}
}
}
}
}
}JSX
export default function SettingsPage({ user, workspaces }: Props) {
return (
<PageLayout>
<section className={styles.section}>
{workspaces.map((workspace) => (
<Card key={workspace.id} className={cn(styles.card, workspace.archived && styles.archived)}>
<CardHeader>
<CardTitle>{workspace.name} · {workspace.members.length} members · created {formatDate(workspace.createdAt)}</CardTitle>
</CardHeader>
<CardContent>
<NotificationPreferences userId={user.id} workspaceId={workspace.id} defaults={workspace.notificationDefaults} />
</CardContent>
</Card>
))}
</section>
</PageLayout>
);
}export default function SettingsPage({ user, workspaces }: Props) {
return (
<PageLayout>
<section className={styles.section}>
{workspaces.map((workspace) => (
<Card key={workspace.id} className={cn(styles.card, workspace.archived && styles.archived)}>
<CardHeader>
<CardTitle>{workspace.name} · {workspace.members.length} members · created {formatDate(workspace.createdAt)}</CardTitle>
</CardHeader>
<CardContent>
<NotificationPreferences userId={user.id} workspaceId={workspace.id} defaults={workspace.notificationDefaults} />
</CardContent>
</Card>
))}
</section>
</PageLayout>
);
}Python
def build_report(rows, *, include_archived=False, group_by="workspace"):
groups = {}
for row in rows:
if row.archived and not include_archived:
continue
for key in (row.workspace_id, row.project_id, row.environment_name):
if key is not None:
groups.setdefault(key, []).append({"id": row.id, "title": row.title, "updated": row.updated_at.isoformat(), "owner": row.owner.email})
if len(groups[key]) > 1000:
raise ValueError(f"group {key} has more than 1000 rows; narrow the query with a date range or a project filter before building the report")
return groupsdef build_report(rows, *, include_archived=False, group_by="workspace"):
groups = {}
for row in rows:
if row.archived and not include_archived:
continue
for key in (row.workspace_id, row.project_id, row.environment_name):
if key is not None:
groups.setdefault(key, []).append({"id": row.id, "title": row.title, "updated": row.updated_at.isoformat(), "owner": row.owner.email})
if len(groups[key]) > 1000:
raise ValueError(f"group {key} has more than 1000 rows; narrow the query with a date range or a project filter before building the report")
return groupsNarrow the window to see the cap kick in: on a phone, deep lines stop at 40% instead of squeezing into a sliver.
Related
- Layouts with route groups
The plan to give each kind of page its own layout with Next.js route groups: (site), (notes) with a left notes aside, (bare), and (artifacts) for self-contained HTML files.
- Highlight
The Highlight text component: a faint blue tint with square corners, whose side padding repeats on every line it wraps across.
- UI stress test
Nested components stacked inside each other, like bold and code inside links and tables inside lists, to find where the styles break.
- Route groups
An interactive explainer of Next.js route groups: how folders in parentheses leave the URL, share layouts, opt pages in and out, and isolate loading and error states.