Skip to content

Commit 9268638

Browse files
committed
feat(mosaic): mark provider icons with data-provider and nudge the Apple logo
1 parent b34c9c7 commit 9268638

9 files changed

Lines changed: 43 additions & 4 deletions
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { render } from '@testing-library/react';
2+
import { describe, expect, it } from 'vitest';
3+
4+
import { UserProfileProviderMedia } from '../user-profile-provider-media';
5+
6+
describe('UserProfileProviderMedia', () => {
7+
it.each([
8+
['an image logo', { iconUrl: 'https://img.clerk.com/static/okx_wallet.svg' }],
9+
['a masked logo', { iconUrl: 'https://img.clerk.com/static/okx_wallet.svg', monochromeIcon: true }],
10+
['the initial fallback', {}],
11+
])('marks %s with the kebab-cased provider id', (_, props) => {
12+
const { container } = render(
13+
<UserProfileProviderMedia
14+
provider='OKX Wallet'
15+
iconId='okx_wallet'
16+
{...props}
17+
/>,
18+
);
19+
20+
expect(container.querySelector('.cl-provider-icon')).toHaveAttribute('data-provider', 'okx-wallet');
21+
});
22+
});

‎packages/mosaic/src/features/user-profile/user-profile-connected-accounts-section/user-profile-connected-account-row.view.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export function UserProfileConnectProviderRowView({
3636
<Section.Item>
3737
<UserProfileProviderMedia
3838
provider={provider.provider}
39+
iconId={provider.iconId}
3940
iconUrl={provider.iconUrl}
4041
monochromeIcon={provider.monochromeIcon}
4142
/>
@@ -104,6 +105,7 @@ export function UserProfileConnectedAccountRowView({
104105
<Section.Item>
105106
<UserProfileProviderMedia
106107
provider={account.provider}
108+
iconId={account.iconId}
107109
iconUrl={account.iconUrl}
108110
monochromeIcon={account.monochromeIcon}
109111
/>

‎packages/mosaic/src/features/user-profile/user-profile-connected-accounts-section/user-profile-connected-accounts-section.model.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export function createProviderCatalog(
8888
enabled: enabled.has(strategy),
8989
display: {
9090
provider: name,
91+
iconId: provider,
9192
iconUrl: iconImageUrl(provider),
9293
monochromeIcon: isMonochromeProvider(provider),
9394
},
@@ -109,7 +110,7 @@ export function createProviderCatalog(
109110
strategy,
110111
provider,
111112
enabled: enabled.has(strategy),
112-
display: { provider: settings?.name || provider, iconUrl: settings?.logo_url || undefined },
113+
display: { provider: settings?.name || provider, iconId: provider, iconUrl: settings?.logo_url || undefined },
113114
});
114115
}
115116
return [

‎packages/mosaic/src/features/user-profile/user-profile-connected-accounts-section/user-profile-connected-accounts-section.types.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type ConnectedAccountActionResult = 'redirecting' | void;
88

99
export interface ConnectedAccountProviderDisplay {
1010
provider: string;
11+
iconId?: string;
1112
iconUrl?: string;
1213
monochromeIcon?: boolean;
1314
}

‎packages/mosaic/src/features/user-profile/user-profile-provider-media.styles.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ export const styles = stylex.create({
1313
height: space['5'],
1414
width: space['5'],
1515
},
16+
appleOffset: {
17+
translate: '0 -1px',
18+
},
1619
maskImage: (url: string) => ({ maskImage: `url(${JSON.stringify(url)})` }),
1720
fallback: {
1821
borderRadius: radiusVars['--cl-radius-sm'],

‎packages/mosaic/src/features/user-profile/user-profile-provider-media.tsx‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@ import * as stylex from '@stylexjs/stylex';
22

33
import { IconFrame } from '../../components/icon';
44
import { Section } from '../../components/section';
5+
import { mergeStyleProps, themeProps } from '../../props';
56
import { styles } from './user-profile-provider-media.styles';
67

78
export function UserProfileProviderMedia({
89
provider,
10+
iconId,
911
iconUrl,
1012
monochromeIcon,
1113
}: {
1214
provider: string;
15+
iconId?: string;
1316
iconUrl?: string;
1417
monochromeIcon?: boolean;
1518
}) {
1619
const url = iconUrl?.trim();
20+
const slot = themeProps('provider-icon', { provider: iconId?.replaceAll('_', '-') });
21+
const offset = iconId === 'apple' && styles.appleOffset;
1722
return (
1823
<Section.Media size='lg'>
1924
<IconFrame
@@ -23,19 +28,19 @@ export function UserProfileProviderMedia({
2328
{url && monochromeIcon ? (
2429
<span
2530
aria-hidden
26-
{...stylex.props(styles.maskedIcon, styles.maskImage(url))}
31+
{...mergeStyleProps(slot, stylex.props(styles.maskedIcon, styles.maskImage(url), offset))}
2732
/>
2833
) : url ? (
2934
<img
3035
src={url}
3136
alt=''
3237
aria-hidden
33-
{...stylex.props(styles.icon)}
38+
{...mergeStyleProps(slot, stylex.props(styles.icon, offset))}
3439
/>
3540
) : (
3641
<span
3742
aria-hidden
38-
{...stylex.props(styles.fallback)}
43+
{...mergeStyleProps(slot, stylex.props(styles.fallback))}
3944
>
4045
{provider.trim().charAt(0).toUpperCase()}
4146
</span>

‎packages/mosaic/src/features/user-profile/user-profile-web3-wallets-section/user-profile-web3-wallet-row.view.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export function UserProfileWeb3WalletRowView({
5555
{wallet.provider ? (
5656
<UserProfileProviderMedia
5757
provider={wallet.provider}
58+
iconId={wallet.iconId}
5859
iconUrl={wallet.iconUrl}
5960
monochromeIcon={wallet.monochromeIcon}
6061
/>

‎packages/mosaic/src/features/user-profile/user-profile-web3-wallets-section/user-profile-web3-wallets-section.model.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export function projectWeb3Wallets({
8080
allowCreation &&
8181
wallet.verification.strategy !== null &&
8282
enabledStrategies.includes(wallet.verification.strategy),
83+
iconId: provider?.provider,
8384
iconUrl: provider ? iconImageUrl(provider.provider) : undefined,
8485
monochromeIcon: provider ? isMonochromeProvider(provider.provider) : false,
8586
isPrimary: wallet.id === primaryId,
@@ -93,6 +94,7 @@ export function projectWeb3Wallets({
9394
id: provider.strategy,
9495
walletPicker: provider.provider === 'solana' ? 'solana' : undefined,
9596
provider: provider.name,
97+
iconId: provider.provider,
9698
iconUrl: iconImageUrl(provider.provider),
9799
monochromeIcon: isMonochromeProvider(provider.provider),
98100
}))

‎packages/mosaic/src/features/user-profile/user-profile-web3-wallets-section/user-profile-web3-wallets-section.types.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface UserProfileWeb3Provider {
99
id: Web3Strategy;
1010
walletPicker?: 'solana';
1111
provider: string;
12+
iconId?: string;
1213
iconUrl?: string;
1314
monochromeIcon?: boolean;
1415
connectError?: string;
@@ -21,6 +22,7 @@ export interface UserProfileWeb3Wallet {
2122
walletPicker?: 'solana';
2223
canVerify?: boolean;
2324
provider?: string;
25+
iconId?: string;
2426
iconUrl?: string;
2527
monochromeIcon?: boolean;
2628
isPrimary?: boolean;

0 commit comments

Comments
 (0)