Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: group connectors between native and external #271

Merged
merged 28 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1089f61
feat: add info circle icon component
arthurgeron Sep 20, 2024
9df65ea
feat: separate connectors between native and external
arthurgeron Sep 20, 2024
b1b424d
chore: changeset
arthurgeron Sep 20, 2024
c81ad78
chore: include bako as native
arthurgeron Sep 20, 2024
50272da
fix: group titles
arthurgeron Sep 21, 2024
5a66d19
chore: hide info icons for now
arthurgeron Sep 21, 2024
e939d37
chore: include burner as native
arthurgeron Sep 21, 2024
76bd136
fix: hide info circles
arthurgeron Sep 21, 2024
c496c69
chore: adjust padding bottom
arthurgeron Sep 21, 2024
8914143
chore: minor design adjustments
arthurgeron Sep 21, 2024
951921e
feat: add request validation
luizstacio Sep 22, 2024
ea70c25
chore: add changesetts
luizstacio Sep 22, 2024
055811c
feat: add connecting screen
luizstacio Sep 22, 2024
813a1db
feat: add detect install and change screen
luizstacio Sep 23, 2024
62d5bc8
feat: return value on ping connector
luizstacio Sep 23, 2024
d2eb053
chore: remove unecesary change
luizstacio Sep 23, 2024
b472b04
feat: add bridge if balance zero
luizstacio Sep 23, 2024
371a76f
feat: make it work with metamask popup
luizstacio Sep 23, 2024
6273f27
feat: add disclaimer for non-native wallets
luizstacio Sep 23, 2024
16512dd
feat: mark connectors as external or native
arthurgeron Sep 22, 2024
8c56736
feat: improve filtering logic
arthurgeron Sep 22, 2024
a023d7b
fix: render connect modal using portal (#270)
helciofranco Sep 21, 2024
05e11df
feat: remove commented code
arthurgeron Sep 23, 2024
a4ba8ab
chore: changeset to patch
arthurgeron Sep 23, 2024
8ecd221
feat: use native list to detect external connector
arthurgeron Sep 23, 2024
cda25c4
Merge branch 'main' of github.com:FuelLabs/fuel-connectors into ls/fe…
arthurgeron Sep 23, 2024
5ed466c
Merge branch 'ls/feat/add-disclaimer' of github.com:FuelLabs/fuel-con…
arthurgeron Sep 23, 2024
a38b06f
Merge branch 'main' of github.com:FuelLabs/fuel-connectors into ag/fe…
arthurgeron Sep 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tender-games-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuels/react": minor
---

Group connectors between native and external
119 changes: 91 additions & 28 deletions packages/react/src/ui/Connect/components/Connectors/Connectors.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,54 @@
import { useConnectUI } from '../../../../providers/FuelUIProvider';
import { useMemo, useState } from 'react';
import {
type FuelUIContextType,
useConnectUI,
} from '../../../../providers/FuelUIProvider';
import { ConnectorIcon } from '../ConnectorIcon';
import { ConnectorBadge } from './ConnectorBadge';

import type { FuelConnector } from 'fuels';
// import { InfoCircleIcon } from '../../icons/InfoCircleIcon';
import { ConnectorsLoader } from './ConnectorsLoader';
arthurgeron marked this conversation as resolved.
Show resolved Hide resolved
import { ConnectorItem, ConnectorList, ConnectorName } from './styles';
import {
ConnectorItem,
ConnectorList,
ConnectorName,
GroupFirstTitleContainer,
GroupLastTitle,
GroupLastTitleContainer,
} from './styles';

const renderConnector = (
connect: FuelUIContextType['dialog']['connect'],
theme: FuelUIContextType['theme'],
connector: FuelConnector,
index: number,
) => (
<ConnectorItem
tabIndex={index + 1}
key={connector.name}
aria-label={`Connect to ${connector.name}`}
data-installed={connector.installed}
data-connected={connector.connected}
onClick={(e) => {
e.preventDefault();
connect(connector);
}}
>
<ConnectorIcon
connectorMetadata={connector.metadata}
connectorName={connector.name}
size={32}
theme={theme}
/>
<ConnectorName>{connector.name}</ConnectorName>
<ConnectorBadge
name={connector.name}
connected={connector.connected}
installed={connector.installed}
/>
</ConnectorItem>
);

export function Connectors() {
const {
Expand All @@ -14,34 +59,52 @@ export function Connectors() {
dialog: { connect },
} = useConnectUI();

const [renderConnectorItem] = useState(() =>
renderConnector.bind(null, connect, theme),
);

const { native, external } = useMemo(
() =>
connectors.reduce(
(acc, curr) => {
if (
curr.name.startsWith('Fuel') ||
curr.name === 'Bako Safe' ||
curr.name === 'Burner Wallet'
) {
acc.native.push(curr);
} else {
acc.external.push(curr);
}

arthurgeron marked this conversation as resolved.
Show resolved Hide resolved
return acc;
},
{
native: [] as Array<FuelConnector>,
external: [] as Array<FuelConnector>,
},
),
[connectors],
);

const shouldTitleGroups = !isLoading && !!native.length && !!external.length;

return (
<ConnectorList>
{connectors.map((connector, index) => (
<ConnectorItem
tabIndex={index + 1}
key={connector.name}
aria-label={`Connect to ${connector.name}`}
data-installed={connector.installed}
data-connected={connector.connected}
onClick={(e) => {
e.preventDefault();
connect(connector);
}}
>
<ConnectorIcon
connectorMetadata={connector.metadata}
connectorName={connector.name}
size={32}
theme={theme}
/>
<ConnectorName>{connector.name}</ConnectorName>
<ConnectorBadge
name={connector.name}
connected={connector.connected}
installed={connector.installed}
/>
</ConnectorItem>
))}
{shouldTitleGroups && (
<GroupFirstTitleContainer>
<GroupLastTitle>Fuel Native Wallets</GroupLastTitle>
{/* <InfoCircleIcon size={12} /> */}
</GroupFirstTitleContainer>
)}
{!isLoading && native.map(renderConnectorItem)}
{shouldTitleGroups && (
<GroupLastTitleContainer>
<GroupLastTitle>Non-Native Wallets</GroupLastTitle>
{/* <InfoCircleIcon size={12} /> */}
</GroupLastTitleContainer>
)}
{!isLoading && external.map(renderConnectorItem)}
{isLoading && (
<ConnectorsLoader items={fuelConfig.connectors?.length || 2} />
)}
Expand Down
31 changes: 31 additions & 0 deletions packages/react/src/ui/Connect/components/Connectors/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const ConnectorList = styled.div`
align-items: center;
gap: var(--fuel-items-gap);
padding: 0px 14px;
margin-top: 23px;
`;

export const ConnectorName = styled.div`
Expand Down Expand Up @@ -56,3 +57,33 @@ export const BadgeSuccess = styled(Badge)`;
background-color: var(--fuel-green-3);
color: var(--fuel-green-11);
`;

export const GroupLastTitle = styled.p`
color: #797979;
helciofranco marked this conversation as resolved.
Show resolved Hide resolved
font-family: Inter;
font-size: 13px;
font-style: normal;
font-weight: 400;
line-height: 20px;
letter-spacing: -0.13px;
`;

export const GroupFirstTitleContainer = styled.div`
display: flex;
align-items: center;
gap: 4px;
justify-content: flex-start;
width: 100%;
padding-left: 3px;
margin-bottom: 7px;
`;

export const GroupLastTitleContainer = styled.div`
display: flex;
align-items: center;
gap: 4px;
justify-content: flex-start;
width: 100%;
padding-left: 3px;
margin: 14px 0px 7px 0px;
`;
45 changes: 45 additions & 0 deletions packages/react/src/ui/Connect/icons/InfoCircleIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import type { SvgIconProps } from '../../../ui/types';

export function InfoCircleIcon({
theme,
size,
stroke = '#797979',
...props
}: SvgIconProps & { stroke?: string }) {
return (
<svg
width={size}
height={size}
viewBox="0 0 12 12"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<title>Info Circle Icon</title>
<g clip-path="url(#clip0_2341_25997)">
<path
d="M5.375 5.5H6L6 8.125M10.625 6C10.625 8.55432 8.55432 10.625 6 10.625C3.44568 10.625 1.375 8.55432 1.375 6C1.375 3.44568 3.44568 1.375 6 1.375C8.55432 1.375 10.625 3.44568 10.625 6Z"
stroke={stroke}
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
<rect
x="5.625"
y="3.625"
width="0.75"
height="0.75"
rx="0.375"
fill={stroke}
stroke={stroke}
stroke-width="0.25"
/>
</g>
<defs>
<clipPath id="clip0_2341_25997">
<rect width="12" height="12" fill="white" />
</clipPath>
</defs>
</svg>
);
}
Loading