Skip to content

Commit

Permalink
Patches2 (#652)
Browse files Browse the repository at this point in the history
* fix(): social bar avatars

* feat(): tag subscriptions

* feat(): add share modal to profile pages

* feat(): add qr code to profile card

* chore(): circle

* chore(): circle
  • Loading branch information
quininez committed Feb 10, 2021
1 parent 60ba70e commit aed004d
Show file tree
Hide file tree
Showing 17 changed files with 442 additions and 103 deletions.
28 changes: 21 additions & 7 deletions apps/akasha/src/widgets/trending-widget/trending-widget-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import * as React from 'react';
import DS from '@akashaproject/design-system';
import { RootComponentProps, IAkashaError } from '@akashaproject/ui-awf-typings';
import { useTranslation } from 'react-i18next';
import { useTrendingData, useLoginState, useFollow } from '@akashaproject/ui-awf-hooks';
import {
useTrendingData,
useLoginState,
useFollow,
useTagSubscribe,
} from '@akashaproject/ui-awf-hooks';

const { TrendingWidgetCard } = DS;

Expand Down Expand Up @@ -33,24 +38,33 @@ const TrendingWidget: React.FC<RootComponentProps> = props => {
},
});

const [tagSubscriptionState, tagSubscriptionActions] = useTagSubscribe({
globalChannel,
profileService: sdkModules.profiles.profileService,
onError: (errorInfo: IAkashaError) => {
logger.error(errorInfo.error.message, errorInfo.errorKey);
},
});

React.useEffect(() => {
if (loginState.ethAddress) {
trendingData.profiles.slice(0, 4).forEach(async (profile: any) => {
if (loginState.ethAddress && profile.ethAddress) {
followActions.isFollowing(loginState.ethAddress, profile.ethAddress);
}
});
tagSubscriptionActions.getTagSubscriptions();
}
}, [trendingData.profiles, loginState.ethAddress]);
}, [trendingData, loginState.ethAddress]);

const handleTagClick = () => {
// todo
};
const handleTagSubscribe = () => {
// todo
const handleTagSubscribe = (tagName: string) => {
tagSubscriptionActions.toggleTagSubscription(tagName);
};
const handleTagUnsubscribe = () => {
// todo
const handleTagUnsubscribe = (tagName: string) => {
tagSubscriptionActions.toggleTagSubscription(tagName);
};
const handleProfileClick = (ethAddress: string) => {
singleSpa.navigateToUrl(`/profile/${ethAddress}`);
Expand All @@ -75,7 +89,7 @@ const TrendingWidget: React.FC<RootComponentProps> = props => {
tags={trendingData.tags}
profiles={trendingData.profiles}
followedProfiles={followedProfiles}
subscribedTags={[]}
subscribedTags={tagSubscriptionState}
onClickTag={handleTagClick}
handleSubscribeTag={handleTagSubscribe}
handleUnsubscribeTag={handleTagUnsubscribe}
Expand Down
1 change: 1 addition & 0 deletions apps/moderation/src/components/entry-data-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const EntryDataCard: React.FC<IEntryDataCardProps> = props => {
onUpdateClick={() => null}
onENSChangeClick={() => null}
hideENSButton={true}
handleShareClick={() => null}
/>
)}
</>
Expand Down
26 changes: 26 additions & 0 deletions ui/design/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion ui/design/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"@vx/scale": "0.0.199",
"@vx/shape": "0.0.199",
"@vx/tooltip": "0.0.199",
"@types/qrcode.react": "1.0.1",
"d3-array": "2.8.0",
"dayjs": "1.9.6",
"is-hotkey": "0.1.7",
Expand All @@ -108,7 +109,8 @@
"slate-history": "0.59.0",
"slate-react": "0.59.0",
"lodash.isequal": "4.5.0",
"react-dropzone": "11.2.4"
"react-dropzone": "11.2.4",
"qrcode.react": "1.0.1"
},
"peerDependencies": {
"react": "16.14.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const mockProfileData = {

const createBaseComponent = (props: any) => (
<ProfileCard
handleShareClick={() => null}
loggedEthAddress={null}
profileData={mockProfileData}
onClickFollowers={props.onClickFollowers}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { Box, Drop, Text } from 'grommet';
import React from 'react';
import { TextIcon } from '../../../TextIcon';
import QRCode from 'qrcode.react';

interface IProfileEditMenuProps {
target: {};
onClose: () => void;
ensName?: string;
ethAddress: string;
// labels
ethereumAddressLabel?: string;
ethereumNameLabel?: string;
copyLabel?: string;
showQRCodeLabel?: string;
}

const EthereumIdDrop = (props: IProfileEditMenuProps) => {
const {
onClose,
target,
ethAddress,
ensName,
ethereumAddressLabel,
ethereumNameLabel,
showQRCodeLabel,
copyLabel,
} = props;

const [QRCodeValue, setQRCodeValue] = React.useState<string | null>(null);

const handleCopy = (data: string) => {
navigator.clipboard.writeText(data);
handleClose();
};

const handleClose = () => {
onClose();
setQRCodeValue(null);
};

const handleShowQR = (value: string) => {
setQRCodeValue(value);
};

const renderText = () => (
<>
{ensName && (
<Box gap="xsmall" pad={{ bottom: 'small' }}>
<Text size="small" color="secondaryText">
{ethereumNameLabel}
</Text>
<TextIcon
iconType="copy"
fontSize="small"
label={copyLabel}
onClick={() => handleCopy(ensName)}
clickable={true}
/>
<TextIcon
iconType="copy"
fontSize="small"
label={showQRCodeLabel}
onClick={() => handleShowQR(ensName)}
clickable={true}
/>
</Box>
)}
<Box gap="xsmall">
<Text size="small" color="secondaryText">
{ethereumAddressLabel}
</Text>
<TextIcon
iconType="copy"
fontSize="small"
label={copyLabel}
onClick={() => handleCopy(ethAddress)}
clickable={true}
/>
<TextIcon
iconType="copy"
fontSize="small"
label={showQRCodeLabel}
onClick={() => handleShowQR(ethAddress)}
clickable={true}
/>
</Box>
</>
);
return (
<Drop
overflow="hidden"
target={target}
align={{ top: 'bottom', right: 'right' }}
onClickOutside={handleClose}
onEsc={handleClose}
>
<Box
round="xxsmall"
pad="small"
border={{ size: 'xsmall', color: 'border', side: 'all', style: 'solid' }}
>
{QRCodeValue && <QRCode value={QRCodeValue} />}
{!QRCodeValue && renderText()}
</Box>
</Drop>
);
};

export default EthereumIdDrop;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Box, Text, Drop } from 'grommet';
import { Box, Text } from 'grommet';
import * as React from 'react';
import { IProfileData } from '../profile-widget-card';
import { Icon } from '../../../Icon';
import { TextIcon } from '../../../TextIcon';
import EthereumIdDrop from './ethereum-id-drop';

export interface IProfileCardEthereumIdProps {
ethereumAddressLabel?: string;
Expand Down Expand Up @@ -33,73 +33,6 @@ const ProfileCardEthereumId: React.FC<IProfileCardEthereumIdProps> = props => {
setPopoverOpen(false);
};

const handleCopy = (data: string) => {
navigator.clipboard.writeText(data);
closePopover();
};

const handleShowQR = () => {
return;
};

const renderPopover = () => (
<Drop
overflow="hidden"
target={popoverRef.current}
align={{ top: 'bottom', right: 'right' }}
onClickOutside={closePopover}
onEsc={closePopover}
>
<Box
round="xxsmall"
pad="small"
gap="xsmall"
border={{ size: 'xsmall', color: 'border', side: 'all', style: 'solid' }}
>
{profileData.ensName && (
<Box gap="xsmall">
<Text size="small" color="secondaryText">
{ethereumNameLabel}
</Text>
<TextIcon
iconType="copy"
fontSize="small"
label={copyLabel}
onClick={() => handleCopy(profileData.ensName!)}
clickable={true}
/>
<TextIcon
iconType="copy"
fontSize="small"
label={showQRCodeLabel}
onClick={handleShowQR}
clickable={true}
/>
</Box>
)}
<Box gap="xsmall">
<Text size="small" color="secondaryText">
{ethereumAddressLabel}
</Text>
<TextIcon
iconType="copy"
fontSize="small"
label={copyLabel}
onClick={() => handleCopy(profileData.ethAddress)}
clickable={true}
/>
<TextIcon
iconType="copy"
fontSize="small"
label={showQRCodeLabel}
onClick={handleShowQR}
clickable={true}
/>
</Box>
</Box>
</Drop>
);

return (
<>
<Box direction="column" pad="medium" gap="medium">
Expand All @@ -113,7 +46,18 @@ const ProfileCardEthereumId: React.FC<IProfileCardEthereumIdProps> = props => {
<Icon type="copy" clickable={true} onClick={togglePopover} ref={popoverRef} />
</Box>
</Box>
{popoverOpen && popoverRef.current && renderPopover()}
{popoverOpen && popoverRef.current && (
<EthereumIdDrop
onClose={closePopover}
target={popoverRef.current}
copyLabel={copyLabel}
showQRCodeLabel={showQRCodeLabel}
ethAddress={profileData.ethAddress}
ensName={profileData.userName}
ethereumAddressLabel={ethereumAddressLabel}
ethereumNameLabel={ethereumNameLabel}
/>
)}
</>
);
};
Expand Down
7 changes: 2 additions & 5 deletions ui/design/src/components/Cards/profile-cards/profile-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface IProfileCardProps extends IProfileWidgetCard {
getProfileProvidersData?: () => void;
onUpdateClick: () => void;
onENSChangeClick: () => void;
handleShareClick: () => void;
updateProfileLabel?: string;
changeENSLabel?: string;
hideENSButton?: boolean;
Expand Down Expand Up @@ -82,6 +83,7 @@ const ProfileCard: React.FC<IProfileCardProps> = props => {
onClickPosts,
handleFollow,
handleUnfollow,
handleShareClick,
isFollowing,
profileData,
descriptionLabel,
Expand All @@ -104,11 +106,6 @@ const ProfileCard: React.FC<IProfileCardProps> = props => {
const followersTitle = `${profileData.totalFollowers} ${followersLabel}`;
const followingTitle = `${profileData.totalFollowing} ${followingLabel}`;

const handleShareClick = () => {
// to be implemented
return;
};

const [editable /* , setEditable */] = useState(false);
const [menuDropOpen, setMenuDropOpen] = React.useState(false);
const [editMenuOpen, setEditMenuOpen] = React.useState(false);
Expand Down
Loading

0 comments on commit aed004d

Please sign in to comment.