Skip to content

Commit acd8667

Browse files
authored
add files list details, mix padding bump dependencies (#2383)
1 parent 671583e commit acd8667

File tree

6 files changed

+103
-59
lines changed

6 files changed

+103
-59
lines changed

bun.lock

Lines changed: 45 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/Package/CodeBrowser/CodeBrowserContentHeader.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,36 @@ import { type PropsWithChildren } from 'react';
22
import { View } from 'react-native';
33

44
import { P } from '~/common/styleguide';
5+
import { WarningBlockquote } from '~/components/Icons';
6+
import Tooltip from '~/components/Tooltip';
7+
import { getFileWarning } from '~/util/codeBrowser';
58
import tw from '~/util/tailwind';
69

710
type Props = PropsWithChildren<{
811
filePath: string;
912
}>;
1013

1114
export default function CodeBrowserContentHeader({ filePath, children }: Props) {
15+
const warning = getFileWarning(filePath.split('/').at(-1));
1216
return (
1317
<View
1418
style={[
1519
tw`flex min-h-[45px] flex-row items-center justify-between gap-3 border-b border-palette-gray2 bg-default px-4 py-3 dark:border-default`,
1620
!children && tw`pr-20`,
1721
]}>
18-
<P style={[tw`font-mono text-[13px]`, { wordBreak: 'break-all' }]}>{filePath}</P>
22+
<P style={[tw`font-mono flex items-center gap-1.5 text-[13px]`, { wordBreak: 'break-all' }]}>
23+
{filePath}
24+
{warning && (
25+
<Tooltip
26+
trigger={
27+
<View style={tw`ml-auto`}>
28+
<WarningBlockquote style={tw`size-3.5 text-warning-dark dark:text-warning`} />
29+
</View>
30+
}>
31+
<P style={tw`text-[12px] font-light`}>{warning.message}</P>
32+
</Tooltip>
33+
)}
34+
</P>
1935
{children}
2036
</View>
2137
);

components/Package/CodeBrowser/CodeBrowserFileRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default function CodeBrowserFileRow({
5757
<WarningBlockquote style={tw`size-3.5 text-warning-dark dark:text-warning`} />
5858
</View>
5959
}>
60-
<span style={tw`text-[12px]`}>{warning.message}</span>
60+
<P style={tw`text-[12px] font-light`}>{warning.message}</P>
6161
</Tooltip>
6262
)}
6363
</>

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@
2121
"precommit": "simple-git-hooks && lint-staged"
2222
},
2323
"dependencies": {
24-
"@expo/html-elements": "^56.0.0-canary-20260414-e3dbafd",
24+
"@expo/html-elements": "^56.0.0-canary-20260417-141204f",
2525
"@expo/match-media": "^0.4.0",
2626
"@m2d/react-markdown": "^1.0.0",
2727
"@radix-ui/react-hover-card": "^1.1.15",
2828
"@radix-ui/react-tooltip": "^1.2.8",
2929
"@react-native-picker/picker": "^2.11.4",
3030
"@sentry/react": "^10.49.0",
31-
"@videojs/react": "^10.0.0-beta.21",
31+
"@videojs/react": "^10.0.0-beta.22",
3232
"@visx/gradient": "^3.12.0",
3333
"@visx/responsive": "^3.12.0",
3434
"@visx/xychart": "^3.12.0",
3535
"crypto-js": "^4.2.0",
3636
"es-toolkit": "^1.45.1",
37-
"expo": "^56.0.0-canary-20260414-e3dbafd",
38-
"expo-font": "^56.0.0-canary-20260414-e3dbafd",
37+
"expo": "^56.0.0-canary-20260417-141204f",
38+
"expo-font": "^56.0.0-canary-20260417-141204f",
3939
"next": "^16.2.4",
4040
"node-emoji": "^2.2.0",
4141
"postcss": "^8.5.10",
@@ -77,7 +77,7 @@
7777
"oxlint": "^1.60.0",
7878
"oxlint-tsgolint": "^0.21.1",
7979
"simple-git-hooks": "^2.13.1",
80-
"typescript": "^6.0.2",
80+
"typescript": "^6.0.3",
8181
"user-agent-data-types": "^0.4.3"
8282
},
8383
"simple-git-hooks": {

scenes/PackageCodeScene.tsx

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { type UnpkgMeta } from '~/types';
1616
import { type PackageCodePageProps } from '~/types/pages';
1717
import { buildCodeBrowserFileTree, getCodeBrowserFilePath } from '~/util/codeBrowser';
1818
import { TimeRange } from '~/util/datetime';
19+
import { formatBytes } from '~/util/formatBytes';
20+
import { pluralize } from '~/util/strings';
1921
import tw from '~/util/tailwind';
2022

2123
export default function PackageCodeScene({ apiData, packageName }: PackageCodePageProps) {
@@ -70,6 +72,11 @@ export default function PackageCodeScene({ apiData, packageName }: PackageCodePa
7072
[filteredFiles, data?.prefix]
7173
);
7274

75+
const totalFilesSize = useMemo(
76+
() => filteredFiles.reduce((total, file) => total + (file.size ?? 0), 0),
77+
[filteredFiles]
78+
);
79+
7380
if (!library) {
7481
return <NotFound />;
7582
}
@@ -147,19 +154,37 @@ export default function PackageCodeScene({ apiData, packageName }: PackageCodePa
147154
? tw`h-[320px] flex-grow-0 border-b`
148155
: tw`w-[320px] flex-grow border-r`,
149156
]}
150-
contentContainerStyle={tw`flex-0 py-2`}>
157+
contentContainerStyle={tw`pt-2`}>
151158
{filteredFiles.length > 0 ? (
152-
<CodeBrowserFileTree
153-
tree={fileTree}
154-
activeFile={activeFile}
155-
onSelectFile={setActiveFile}
156-
/>
159+
<>
160+
<CodeBrowserFileTree
161+
tree={fileTree}
162+
activeFile={activeFile}
163+
onSelectFile={setActiveFile}
164+
/>
165+
<View style={tw`h-2`} />
166+
</>
157167
) : (
158168
<View style={tw`px-3 py-2`}>
159169
<Label style={tw`text-center`}>No files match this search.</Label>
160170
</View>
161171
)}
162172
</ScrollView>
173+
{filteredFiles.length > 0 && (
174+
<View
175+
style={[
176+
tw`relative flex min-h-[26px] flex-row items-center justify-between gap-3 border-r border-t border-palette-gray2 bg-default px-3 pb-px dark:border-default`,
177+
isSmallScreen && tw`border-r-0`,
178+
]}>
179+
<Label style={tw`font-light text-secondary`}>
180+
<span style={tw`font-medium`}>{filteredFiles.length}</span>{' '}
181+
{pluralize('file', filteredFiles.length)}
182+
</Label>
183+
<Label style={tw`font-light text-secondary`}>
184+
<span style={tw`font-medium`}>{formatBytes(totalFilesSize)}</span>
185+
</Label>
186+
</View>
187+
)}
163188
</View>
164189
<View
165190
style={[

util/codeBrowser.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ const FILE_WARNING_MATCHERS = FILE_WARNINGS.map(warning => ({
9090
matchers: warning.fileNames.map(createFileWarningMatcher),
9191
}));
9292

93-
export function getFileWarning(fileName: string) {
93+
export function getFileWarning(fileName?: string) {
94+
if (!fileName) {
95+
return undefined;
96+
}
9497
return FILE_WARNING_MATCHERS.find(warning => warning.matchers.some(matcher => matcher(fileName)));
9598
}
9699

0 commit comments

Comments
 (0)