Profile: hide email pagination controls when no other pages (#1764)

* make add email button small

* hide pagination when only one page of emails

* add autohide to paginationcontrols
This commit is contained in:
Kerry
2023-09-14 10:07:47 +12:00
committed by GitHub
parent 6729429630
commit 51581ea27e
3 changed files with 17 additions and 7 deletions

View File

@@ -17,6 +17,8 @@ import { Button } from "@vector-im/compound-web";
type Props = {
onNext: (() => void) | null;
onPrev: (() => void) | null;
// automatically hide the component when there are no onNext/onPrev
autoHide?: boolean;
count?: number;
disabled?: boolean;
};
@@ -24,9 +26,13 @@ type Props = {
const PaginationControls: React.FC<Props> = ({
onNext,
onPrev,
autoHide,
count,
disabled,
}) => {
if (autoHide && !onNext && !onPrev) {
return null;
}
return (
<div className="grid items-center grid-cols-3 gap-2">
<Button

View File

@@ -113,7 +113,9 @@ const AddEmailForm: React.FC<{
<Label>Add email</Label>
<Control disabled={pending} inputMode="email" ref={fieldRef} />
</Field>
<Submit disabled={pending}>Add</Submit>
<Submit size="sm" disabled={pending}>
Add
</Submit>
</Root>
</>
);

View File

@@ -160,12 +160,6 @@ const UserEmailList: React.FC<{
return (
<BlockList>
<H3>Emails</H3>
<PaginationControls
count={result.data?.user?.emails?.totalCount ?? 0}
onPrev={prevPage ? (): void => paginate(prevPage) : null}
onNext={nextPage ? (): void => paginate(nextPage) : null}
disabled={pending}
/>
{showNoPrimaryEmailAlert && (
<Alert type="critical" title="No primary email address" />
)}
@@ -178,6 +172,14 @@ const UserEmailList: React.FC<{
onRemove={onRemove}
/>
))}
<PaginationControls
autoHide
count={result.data?.user?.emails?.totalCount ?? 0}
onPrev={prevPage ? (): void => paginate(prevPage) : null}
onNext={nextPage ? (): void => paginate(nextPage) : null}
disabled={pending}
/>
<AddEmailForm userId={userId} onAdd={onAdd} />
</BlockList>
);