-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
💄 (smpl): Select and list device in a drawer
- Loading branch information
1 parent
cee6a89
commit 9258f6e
Showing
8 changed files
with
233 additions
and
80 deletions.
There are no files selected for viewing
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
45 changes: 45 additions & 0 deletions
45
apps/sample/src/components/MainView/DeviceSelectionDrawer.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,45 @@ | ||
import { StyledDrawer } from "@/components/StyledDrawer"; | ||
import React from "react"; | ||
import { Text } from "@ledgerhq/react-ui"; | ||
import { ConnectDeviceActions } from "@/components/MainView/ConnectDeviceActions"; | ||
import { SdkError } from "@ledgerhq/device-management-kit"; | ||
import { useDeviceSessionsContext } from "@/providers/DeviceSessionsProvider"; | ||
import { Device } from "@/components/Device"; | ||
|
||
export const DeviceSelectionDrawer: React.FC<{ | ||
isOpen: boolean; | ||
onClose: () => void; | ||
onError: (error: SdkError | null) => void; | ||
}> = ({ isOpen, onClose, onError }) => { | ||
const { | ||
state: { deviceById }, | ||
} = useDeviceSessionsContext(); | ||
return ( | ||
<StyledDrawer isOpen={isOpen} onClose={onClose} big title="Select a device"> | ||
<Text variant="body" fontWeight="regular" color="opacityDefault.c60"> | ||
Connect another device | ||
</Text> | ||
<ConnectDeviceActions onError={onError} /> | ||
<Text | ||
variant="body" | ||
fontWeight="regular" | ||
color="opacityDefault.c60" | ||
mt={5} | ||
> | ||
Available devices | ||
</Text> | ||
<div data-testid="container_devices"> | ||
{Object.entries(deviceById).map(([sessionId, device]) => ( | ||
<Device | ||
key={sessionId} | ||
sessionId={sessionId} | ||
name={device.name} | ||
model={device.modelId} | ||
type={device.type} | ||
showActiveIndicator | ||
/> | ||
))} | ||
</div> | ||
</StyledDrawer> | ||
); | ||
}; |
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
Oops, something went wrong.