Skip to content

Commit 4f57af1

Browse files
authored
add: family connector (#456)
* locales * family support * add logo * Update CHANGELOG.md * clean up * cleanup
1 parent a28540a commit 4f57af1

File tree

36 files changed

+567
-191
lines changed

36 files changed

+567
-191
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# 1.9.0
2+
3+
We're thrilled to announce a major upgrade to ConnectKit—designed to make onboarding and navigating Ethereum simpler and safer than ever.
4+
5+
Introducing [Family Accounts](https://app.family.co), simplified onboarding for new users.
6+
7+
Learn more by reading the announcement [here](https://family.co/blog/family-accounts).
8+
9+
## New
10+
11+
- Support for [Family Accounts](https://app.family.co).
12+
13+
## Improved
14+
15+
- Updates chain logos for `zora`, `base`, `optimism` and `lens`.
16+
117
# 1.8.2
218

319
This update includes improvements to the `CoinbaseWalletSDK` connect popup and `MockConnector`.

examples/testbench/src/components/Web3Provider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const ckConfig = getDefaultConfig({
4141
appName: 'ConnectKit testbench',
4242
appIcon: '/app.png',
4343
walletConnectProjectId: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID!,
44+
//enableFamily: false,
4445
});
4546
const customConfig = {
4647
...ckConfig,

packages/connectkit/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"dependencies": {
4242
"buffer": "^6.0.3",
4343
"detect-browser": "^5.3.0",
44+
"family": "^0.1.1",
4445
"framer-motion": "^6.3.11",
4546
"qrcode": "^1.5.0",
4647
"react-transition-state": "^1.1.4",

packages/connectkit/src/assets/logos.tsx

Lines changed: 21 additions & 2 deletions
Large diffs are not rendered by default.

packages/connectkit/src/components/Common/ConnectorList/index.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,40 @@ import {
2222
} from '../../../utils';
2323
import { useLastConnector } from '../../../hooks/useLastConnector';
2424
import { useConnect } from '../../../hooks/useConnect';
25+
import {
26+
useFamilyAccountsConnector,
27+
useFamilyConnector,
28+
} from '../../../hooks/useConnectors';
29+
import { isFamily } from '../../../utils/wallets';
2530

2631
const ConnectorList = () => {
2732
const context = useContext();
2833
const isMobile = useIsMobile();
2934

3035
const wallets = useWallets();
3136
const { lastConnectorId } = useLastConnector();
37+
const familyConnector = useFamilyConnector();
38+
const familyAccountsConnector = useFamilyAccountsConnector();
39+
40+
let filteredWallets = wallets.filter(
41+
(wallet) => wallet.id !== familyAccountsConnector?.id
42+
);
43+
if (familyConnector && isFamily()) {
44+
filteredWallets = filteredWallets.filter(
45+
(wallet) => wallet.id !== familyConnector?.id
46+
);
47+
}
3248

3349
const walletsToDisplay =
3450
context.options?.hideRecentBadge || lastConnectorId === 'walletConnect' // do not hoist walletconnect to top of list
35-
? wallets
51+
? filteredWallets
3652
: [
3753
// move last used wallet to top of list
3854
// using .filter and spread to avoid mutating original array order with .sort
39-
...wallets.filter(
55+
...filteredWallets.filter(
4056
(wallet) => lastConnectorId === wallet.connector.id
4157
),
42-
...wallets.filter(
58+
...filteredWallets.filter(
4359
(wallet) => lastConnectorId !== wallet.connector.id
4460
),
4561
];
@@ -134,6 +150,7 @@ const ConnectorItem = ({
134150
<ConnectorIcon
135151
data-small={wallet.iconShouldShrink}
136152
data-shape={wallet.iconShape}
153+
data-background={redirectToMoreWallets}
137154
>
138155
{wallet.iconConnector ?? wallet.icon}
139156
</ConnectorIcon>

packages/connectkit/src/components/Common/ConnectorList/styles.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ const styles = {
212212
&[data-shape='square'] {
213213
border-radius: 0;
214214
}
215+
216+
&[data-background='true'] {
217+
border-radius: 22.5%;
218+
background: var(--ck-body-background-tertiary);
219+
padding: 8%;
220+
}
215221
`,
216222
},
217223
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import {
2+
ButtonContainer,
3+
InnerContainer,
4+
IconContainer,
5+
ButtonContainerInner,
6+
} from './styles';
7+
import FitText from '../FitText';
8+
import useLocales from '../../../hooks/useLocales';
9+
10+
const FamilyLogo = () => (
11+
<svg
12+
width="20"
13+
height="20"
14+
viewBox="0 0 20 20"
15+
fill="none"
16+
xmlns="http://www.w3.org/2000/svg"
17+
>
18+
<path
19+
fillRule="evenodd"
20+
clipRule="evenodd"
21+
d="M19.0204 1.00451C19.6474 1.63141 19.9997 2.4816 20 3.36818C20.0008 4.14967 19.726 4.90643 19.2239 5.50535C18.7218 6.10427 18.0246 6.50698 17.2549 6.64267V6.70894C18.019 6.85794 18.7076 7.26796 19.2026 7.86877C19.6976 8.46958 19.9683 9.2238 19.9683 10.0022C19.9683 10.7807 19.6976 11.5349 19.2026 12.1357C18.7076 12.7365 18.019 13.1465 17.2549 13.2955V13.3613C18.0719 13.5195 18.8007 13.9762 19.2994 14.6424C19.798 15.3086 20.0308 16.1365 19.9523 16.9649C19.8738 17.7933 19.4896 18.5628 18.8747 19.1234C18.2598 19.6841 17.4581 19.9958 16.626 19.9977C15.0203 19.9977 13.6632 18.8411 13.3487 17.3187H13.266C13.1161 18.0763 12.707 18.7581 12.1091 19.247C11.5112 19.7358 10.7617 20.0013 9.98928 19.9977C8.38358 19.9977 7.02654 18.8411 6.71207 17.3187H6.62934C6.5085 17.9135 6.22824 18.4642 5.81854 18.912C5.40885 19.3597 4.88513 19.6877 4.3034 19.8609C3.72166 20.034 3.1038 20.0458 2.5159 19.8949C1.92799 19.7441 1.39216 19.4362 0.965705 19.0044C0.539251 18.5726 0.238219 18.0329 0.0948058 17.4432C-0.0486071 16.8535 -0.0290062 16.2359 0.151512 15.6565C0.332031 15.0771 0.666676 14.5576 1.11966 14.1537C1.57264 13.7497 2.12691 13.4765 2.7232 13.3632V13.2974C1.95907 13.1484 1.27053 12.7384 0.775518 12.1376C0.280502 11.5368 0.0098111 10.7826 0.0098111 10.0041C0.0098111 9.22568 0.280502 8.47147 0.775518 7.87065C1.27053 7.26984 1.95907 6.85982 2.7232 6.71082V6.64455C2.12752 6.52895 1.57437 6.2539 1.12271 5.84872C0.671047 5.44354 0.337805 4.92342 0.158498 4.34378C-0.0208088 3.76414 -0.0394594 3.14672 0.104534 2.55732C0.248527 1.96792 0.549768 1.42863 0.976148 0.996935C1.40253 0.565238 1.93807 0.257312 2.52569 0.105976C3.11331 -0.0453591 3.73098 -0.0344317 4.31288 0.137594C4.89478 0.309619 5.41909 0.636296 5.82993 1.0828C6.24077 1.52931 6.52274 2.07892 6.64579 2.67304H6.72852C6.8865 1.9201 7.29921 1.24463 7.89713 0.760429C8.49504 0.276232 9.2416 0.0129149 10.011 0.0148468C10.7804 0.0167787 11.5257 0.283841 12.1211 0.771035C12.7166 1.25823 13.1259 1.93577 13.2801 2.68949H13.3629C13.6952 1.16716 15.0348 0.00860963 16.6565 0.0250597C17.5432 0.0253088 18.3935 0.377609 19.0204 1.00451ZM5.93783 5.07571C5.33116 5.0757 4.84252 5.57305 4.85166 6.17966C4.86836 7.28867 4.89073 9.01161 4.89073 10.2871C4.89073 11.5614 4.8684 13.2824 4.8517 14.3916C4.84255 14.9997 5.3327 15.4985 5.94094 15.4985H14.2263C14.8345 15.4985 15.3247 14.9997 15.3155 14.3916C15.2988 13.2824 15.2765 11.5614 15.2765 10.2871C15.2765 9.01161 15.2988 7.28867 15.3155 6.17966C15.3247 5.57305 14.8367 5.0757 14.23 5.07571L9.99998 5.07576L5.93783 5.07571Z"
22+
fill="currentColor"
23+
/>
24+
</svg>
25+
);
26+
27+
export const FamilyAccountsButton = ({ onClick }: { onClick: () => void }) => {
28+
const locales = useLocales();
29+
return (
30+
<ButtonContainer onClick={onClick}>
31+
<ButtonContainerInner>
32+
<IconContainer>
33+
<FamilyLogo />
34+
</IconContainer>
35+
<InnerContainer>
36+
<FitText>{locales.continueWithFamily}</FitText>
37+
</InnerContainer>
38+
</ButtonContainerInner>
39+
</ButtonContainer>
40+
);
41+
};
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { motion } from 'framer-motion';
2+
import styled from './../../../styles/styled';
3+
4+
export const ButtonContainerInner = styled(motion.div)`
5+
display: flex;
6+
align-items: center;
7+
justify-content: center;
8+
inset: 0;
9+
height: 100%;
10+
`;
11+
export const ButtonContainer = styled.button`
12+
--color: #ffffff;
13+
--background: var(--ck-family-accounts-brand);
14+
--box-shadow: var(--ck-primary-button-box-shadow);
15+
--border-radius: var(--ck-primary-button-border-radius);
16+
--font-weight: var(--ck-primary-button-font-weight, 500);
17+
18+
--hover-color: var(--ck-button-primary-hover-color, var(--color));
19+
--hover-background: var(
20+
--ck-primary-button-hover-background,
21+
var(--background)
22+
);
23+
--hover-box-shadow: var(
24+
--ck-primary-button-hover-box-shadow,
25+
var(--box-shadow)
26+
);
27+
--hover-border-radius: var(
28+
--ck-primary-button-hover-border-radius,
29+
var(--border-radius)
30+
);
31+
--hover-font-weight: var(--ck-primary-button-font-weight, var(--font-weight));
32+
33+
appearance: none;
34+
cursor: pointer;
35+
user-select: none;
36+
min-width: fit-content;
37+
width: 100%;
38+
display: block;
39+
text-align: center;
40+
height: 48px;
41+
margin: 18px 0 2px;
42+
line-height: 48px;
43+
padding: 0 4px;
44+
font-size: 16px;
45+
font-weight: var(--font-weight, 500);
46+
text-decoration: none;
47+
white-space: nowrap;
48+
transition: 100ms ease;
49+
transition-property: box-shadow, background-color;
50+
color: var(--color);
51+
background: var(--background);
52+
border-radius: var(--border-radius);
53+
box-shadow: var(--box-shadow);
54+
will-change: transform, box-shadow, background-color, color;
55+
`;
56+
57+
export const InnerContainer = styled.div`
58+
transform: translateZ(0); // Shifting fix
59+
position: relative;
60+
display: inline-block;
61+
vertical-align: middle;
62+
max-width: calc(100% - 42px);
63+
transition: opacity 300ms ease;
64+
`;
65+
66+
export const IconContainer = styled.div`
67+
position: relative;
68+
display: inline-block;
69+
vertical-align: middle;
70+
max-width: 20px;
71+
max-height: 20px;
72+
margin: 0 12px 0 0;
73+
svg {
74+
display: block;
75+
position: relative;
76+
max-width: 100%;
77+
height: auto;
78+
}
79+
`;

packages/connectkit/src/components/Common/Modal/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,10 +697,16 @@ const Page: React.FC<PageProps> = ({
697697
);
698698
};
699699

700-
export const OrDivider = ({ children }: { children?: React.ReactNode }) => {
700+
export const OrDivider = ({
701+
children,
702+
hideHr,
703+
}: {
704+
children?: React.ReactNode;
705+
hideHr?: boolean;
706+
}) => {
701707
const locales = useLocales();
702708
return (
703-
<TextWithHr>
709+
<TextWithHr $disableHr={hideHr}>
704710
<span>{children ?? locales.or}</span>
705711
</TextWithHr>
706712
);

packages/connectkit/src/components/Common/Modal/styles.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ export const PageContent = styled(motion.div)`
7171
padding-top: 48px;
7272
`;
7373

74-
export const TextWithHr = styled(motion.div)`
74+
export const TextWithHr = styled(motion.div)<{
75+
$disableHr?: boolean;
76+
}>`
7577
user-select: none;
7678
position: relative;
7779
display: block;
@@ -90,6 +92,9 @@ export const TextWithHr = styled(motion.div)`
9092
background: var(--ck-body-background);
9193
transition: background-color 200ms ease;
9294
}
95+
${(props) =>
96+
!props.$disableHr &&
97+
`
9398
&:before {
9499
z-index: 2;
95100
content: '';
@@ -102,6 +107,7 @@ export const TextWithHr = styled(motion.div)`
102107
background: var(--ck-body-divider);
103108
box-shadow: var(--ck-body-divider-box-shadow);
104109
}
110+
`}
105111
`;
106112
export const ModalHeading = styled(motion.div)`
107113
z-index: 3;

0 commit comments

Comments
 (0)