增加外链

This commit is contained in:
myf 2022-05-05 11:13:58 +08:00
parent 016f948610
commit 7d8ea94e43
4 changed files with 71 additions and 26 deletions

View File

@ -75,7 +75,10 @@ const Menu: React.FC<NavProps> = ({
profile, profile,
children, children,
inviteUrl, inviteUrl,
outLink,
}) => { }) => {
console.log("outLink-----:", outLink);
const { isXl } = useMatchBreakpoints(); const { isXl } = useMatchBreakpoints();
const isMobile = isXl === false; const isMobile = isXl === false;
const [isPushed, setIsPushed] = useState(!isMobile); const [isPushed, setIsPushed] = useState(!isMobile);
@ -143,6 +146,7 @@ const Menu: React.FC<NavProps> = ({
cakePriceUsd={cakePriceUsd} cakePriceUsd={cakePriceUsd}
pushNav={setIsPushed} pushNav={setIsPushed}
links={links} links={links}
outLink={outLink}
/> />
<Inner isPushed={isPushed} showMenu={showMenu}> <Inner isPushed={isPushed} showMenu={showMenu}>
{children} {children}

View File

@ -8,6 +8,9 @@ import CakePrice from "./CakePrice";
import ThemeSwitcher from "./ThemeSwitcher"; import ThemeSwitcher from "./ThemeSwitcher";
import SocialLinks from "./SocialLinks"; import SocialLinks from "./SocialLinks";
import LangSelector from "./LangSelector"; import LangSelector from "./LangSelector";
import Text from "../../../components/Text/Text";
import Dropdown from "../../../components/Dropdown/Dropdown";
import Link from "../../../components/Link/Link";
interface Props extends PanelProps, PushedProps {} interface Props extends PanelProps, PushedProps {}
@ -33,6 +36,11 @@ const SocialEntry = styled.div`
height: ${MENU_ENTRY_HEIGHT}px; height: ${MENU_ENTRY_HEIGHT}px;
padding: 0 16px; padding: 0 16px;
`; `;
const Image = styled.img`
width: 30px;
height: 30px;
border-radius: 50%;
`;
const PanelFooter: React.FC<Props> = ({ const PanelFooter: React.FC<Props> = ({
isPushed, isPushed,
@ -43,6 +51,7 @@ const PanelFooter: React.FC<Props> = ({
currentLang, currentLang,
langs, langs,
setLang, setLang,
outLink,
}) => { }) => {
if (!isPushed) { if (!isPushed) {
return ( return (
@ -53,12 +62,26 @@ const PanelFooter: React.FC<Props> = ({
</Container> </Container>
); );
} }
let covers = "";
if (outLink && outLink.length > 0) {
covers = outLink[0].cover;
}
return ( return (
<Container> <Container>
<SocialEntry> <SocialEntry>
<CakePrice cakePriceUsd={cakePriceUsd} /> <CakePrice cakePriceUsd={cakePriceUsd} />
<SocialLinks /> <Dropdown position="top-right" target={<Image src={covers} />}>
{outLink && outLink.length > 0
? outLink?.map((item) => {
return (
<Link href={item.link} color="textSubtle" key={item.id}>
<Image src={item.cover} />
</Link>
);
})
: ""}
</Dropdown>
{/* <SocialLinks outLink={outLink} /> */}
</SocialEntry> </SocialEntry>
<SettingsEntry> <SettingsEntry>
<ThemeSwitcher isDark={isDark} toggleTheme={toggleTheme} /> <ThemeSwitcher isDark={isDark} toggleTheme={toggleTheme} />

View File

@ -1,37 +1,45 @@
import React from "react"; import React from "react";
import styled from "styled-components";
import { SvgProps } from "../../../components/Svg"; import { SvgProps } from "../../../components/Svg";
import Flex from "../../../components/Box/Flex"; import Flex from "../../../components/Box/Flex";
import Dropdown from "../../../components/Dropdown/Dropdown"; import Dropdown from "../../../components/Dropdown/Dropdown";
import Link from "../../../components/Link/Link"; import Link from "../../../components/Link/Link";
import Text from "../../../components/Text/Text";
import * as IconModule from "../icons"; import * as IconModule from "../icons";
import { socials } from "../config"; import { socials } from "../config";
import { LinkLabel } from "./MenuEntry";
import { OutLink } from "../types";
const Icons = IconModule as unknown as { [key: string]: React.FC<SvgProps> }; const Icons = IconModule as unknown as { [key: string]: React.FC<SvgProps> };
interface Props {
outLink?: OutLink[];
}
const SocialLinks: React.FC = () => ( const Image = styled.img`
<Flex> width: 30px;
{socials.map((social, index) => { height: 30px;
const Icon = Icons[social.icon]; border-radius: 50%;
const iconProps = { width: "24px", color: "textSubtle", style: { cursor: "pointer" } }; `;
const mr = index < socials.length - 1 ? "24px" : 0;
if (social.items) { const SocialLinks: React.FC<Props> = ({ outLink }) => {
return ( let covers = "";
<Dropdown key={social.label} position="top" target={<Icon {...iconProps} mr={mr} />}> if (outLink && outLink.length > 0) {
{social.items.map((item) => ( covers = outLink[0].cover;
<Link external key={item.label} href={item.href} aria-label={item.label} color="textSubtle"> }
{item.label}
return (
<Dropdown position="top-right" target={<Image src={covers} />}>
{outLink && outLink.length > 0
? outLink?.map((item) => {
return (
<Link href={item.link} color="textSubtle" key={item.id}>
<Image src={item.cover} />
</Link> </Link>
))} );
</Dropdown> })
); : ""}
} </Dropdown>
return ( );
<Link external key={social.label} href={social.href} aria-label={social.label} mr={mr}> };
<Icon {...iconProps} />
</Link>
);
})}
</Flex>
);
export default React.memo(SocialLinks, () => true); export default React.memo(SocialLinks, () => true);

View File

@ -54,6 +54,7 @@ export interface PanelProps {
langs: Language[]; langs: Language[];
setLang: (lang: Language) => void; setLang: (lang: Language) => void;
links: Array<MenuEntry>; links: Array<MenuEntry>;
outLink?: OutLink[];
} }
export interface NavProps extends PanelProps { export interface NavProps extends PanelProps {
@ -62,4 +63,13 @@ export interface NavProps extends PanelProps {
login?: Login; login?: Login;
profile?: Profile; profile?: Profile;
logout?: () => void; logout?: () => void;
outLink?: OutLink[];
}
export interface OutLink {
id: string;
englishName: string;
name: string;
cover: string;
link: string;
} }