调整外链

This commit is contained in:
myf 2022-05-09 11:20:12 +08:00
parent 9a087424b1
commit 9fe17da09b
2 changed files with 66 additions and 42 deletions

View File

@ -0,0 +1,31 @@
import React from "react";
import styled from "styled-components";
import Flex from "../../../components/Box/Flex";
import Text from "../../../components/Text/Text";
import Dropdown from "../../../components/Dropdown/Dropdown";
import Link from "../../../components/Link/Link";
import MoreIcon from "../../../components/Svg/Icons/More";
interface ExternalLinkProps {
link?: string;
name?: string;
icon?: string;
}
const Image = styled.img`
width: 30px;
height: 30px;
border-radius: 50%;
cursor: pointer;
`;
const ExternalLink: React.FC<ExternalLinkProps> = ({ link = "", name = "", icon = "" }) => {
return (
<>
<Link external href={link} color="textSubtle">
{icon ? <Image src={icon} title={name} /> : <Text>{name}</Text>}
</Link>
</>
);
};
export default ExternalLink;

View File

@ -14,6 +14,7 @@ import Dropdown from "../../../components/Dropdown/Dropdown";
import Link from "../../../components/Link/Link";
import MoreIcon from "../../../components/Svg/Icons/More";
import ChevronRightIcon from "../../../components/Svg/Icons/ChevronRight";
import ExternalLink from "./ExternalLink";
interface Props extends PanelProps, PushedProps {}
@ -58,7 +59,7 @@ const ImageDiv = styled.div`
/* padding: 0 10px; */
border-radius: 10px;
position: absolute;
width: 100px;
width: 140px;
/* height: 400px; */
/* top: 0; */
right: 0px;
@ -86,7 +87,7 @@ const ImageItem = styled.div`
position: absolute;
width: 100px;
right: 0px;
left: 80px;
left: 130px;
z-index: 99999;
bottom: 0;
margin: 20px auto;
@ -116,6 +117,12 @@ const MoreIconSvg = styled(MoreIcon)`
width: 30px;
height: 30px;
`;
const TextDiv = styled(Text)`
width: 70px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
`;
const PanelFooter: React.FC<Props> = ({
isPushed,
@ -128,16 +135,17 @@ const PanelFooter: React.FC<Props> = ({
setLang,
socialLink,
}) => {
let defaultList: SocialLink[] | undefined;
let moreList: SocialLink[] | undefined;
if (socialLink && socialLink.length > 2) {
const list = JSON.parse(JSON.stringify(socialLink));
const listLink = JSON.parse(JSON.stringify(socialLink));
moreList = list.slice(2, socialLink.length);
defaultList = listLink.splice(0, 2);
} else {
defaultList = socialLink;
let defaultList = undefined;
let moreList = undefined;
if (socialLink && socialLink.length > 0) {
defaultList = socialLink.filter((item, index) => {
if (index < 2) return item;
});
moreList = socialLink.filter((item, index) => {
if (index >= 2) return item;
});
}
if (!isPushed) {
return (
<Container>
@ -151,32 +159,21 @@ const PanelFooter: React.FC<Props> = ({
<Container>
<SocialEntry>
<CakePrice cakePriceUsd={cakePriceUsd} />
<>
{defaultList && defaultList.length > 0
? defaultList.map((item) => {
return item.list && item.list.length > 1 ? (
<Dropdown position="top-right" target={<Image src={item.icon} title={item.name} />}>
{item.list && item.list.length > 0
? item.list?.map((childItem) => {
return (
<Link key={item.key} external href={childItem.link} color="textSubtle">
<Text>{childItem.name}</Text>
</Link>
);
})
: ""}
</Dropdown>
) : item.list && item.list.length > 0 ? (
<Link key={item.key} external href={item.list[0].link} color="textSubtle">
<Image src={item.icon} title={item.name} />
</Link>
) : (
""
);
})
: ""}
{moreList && moreList.length > 0 ? (
{defaultList?.map((item) => {
return item.list && item.list.length > 1 ? (
<Dropdown position="top-right" target={<Image src={item.icon} title={item.name} />}>
{item.list?.map((childItem) => {
return <ExternalLink link={childItem.link} name={childItem.name} />;
})}
</Dropdown>
) : item.list ? (
<ExternalLink link={item.list[0].link} icon={item.icon} name={item.name} />
) : (
""
);
})}
{moreList ? (
<ImageDiv>
<div className="moreText">
<MoreIconSvg />
@ -188,17 +185,13 @@ const PanelFooter: React.FC<Props> = ({
<Flex className="content-item" alignItems="center" justifyContent="space-between">
<>
<Image src={item.icon} title={item.name} />
<Text marginLeft="5px">{item.name}</Text>
<TextDiv marginLeft="5px">{item.name}</TextDiv>
</>
<ChevronRightIcon />
</Flex>
<div className="itemDiv">
{item.list?.map((childItem) => {
return (
<Link external href={childItem.link} color="textSubtle">
<Text>{childItem.name}</Text>
</Link>
);
return <ExternalLink link={childItem.link} name={childItem.name} />;
})}
</div>
</ImageItem>