-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
92 additions
and
36 deletions.
There are no files selected for viewing
Binary file modified
BIN
+12 KB
(120%)
...hain/__image_snapshots__/components-connect-createsession--default-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-26 KB
(56%)
.../__image_snapshots__/components-connect-createsession--with-preset-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
packages/keychain/src/components/session/ExpirationCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { ClockIcon } from "@cartridge/ui-next"; | ||
import { AccordionCard } from "./AccordionCard"; | ||
import { | ||
Select, | ||
SelectContent, | ||
SelectItem, | ||
SelectTrigger, | ||
SelectValue, | ||
} from "@cartridge/ui-next"; | ||
|
||
interface ExpirationCardProps { | ||
duration: bigint; | ||
onDurationChange: (duration: bigint) => void; | ||
isExpanded?: boolean; | ||
} | ||
|
||
export function ExpirationCard({ | ||
duration, | ||
onDurationChange, | ||
}: ExpirationCardProps) { | ||
return ( | ||
<AccordionCard | ||
icon={<ClockIcon variant="solid" />} | ||
title="Session Expiration" | ||
trigger={ | ||
<div className="text-xs text-muted-foreground"> | ||
Expires in | ||
<span className="text-accent-foreground font-bold"> | ||
{formatDuration(duration)} | ||
</span> | ||
</div> | ||
} | ||
> | ||
<div className="flex flex-col gap-4 p-3 text-xs"> | ||
<div className="flex items-center justify-between"> | ||
<div className="text-muted-foreground">Duration</div> | ||
<Select | ||
value={duration.toString()} | ||
onValueChange={(val) => onDurationChange(BigInt(val))} | ||
> | ||
<SelectTrigger className="w-28"> | ||
<SelectValue placeholder="1 HR" /> | ||
</SelectTrigger> | ||
<SelectContent> | ||
<SelectItem value={(60 * 60).toString()}>1 HR</SelectItem> | ||
<SelectItem value={(60 * 60 * 24).toString()}>24 HRS</SelectItem> | ||
<SelectItem value={(60 * 60 * 24 * 7).toString()}> | ||
1 WEEK | ||
</SelectItem> | ||
</SelectContent> | ||
</Select> | ||
</div> | ||
</div> | ||
</AccordionCard> | ||
); | ||
} | ||
|
||
function formatDuration(seconds: bigint): string { | ||
const hours = Number(seconds) / 3600; | ||
if (hours === 1) return "1 hour"; | ||
if (hours === 24) return "24 hours"; | ||
if (hours === 168) return "1 week"; | ||
return `${hours} hours`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters