a tool for shared writing and social publishing

added the publicaions nav to the mobile footer

+95 -107
-7
components/ActionBar/ActionButton.tsx
··· 86 86 </button> 87 87 ); 88 88 }; 89 - 90 - // ok currently in the middle of making the actions on home, looseleaf, and pub appear at the top by the page title 91 - // i then need to find a good place for the publication list in the footer 92 - // but first i really need to refactor action button 93 - // 1) make a primary variant 94 - // 2) make a secondary variant 95 - //
+84 -25
components/ActionBar/MobileNavigation.tsx
··· 22 22 import { Avatar } from "components/Avatar"; 23 23 import { useProfileFromDid } from "src/utils/getRecordFromDid"; 24 24 import { LoginActionButton } from "components/LoginButton"; 25 + import { ButtonPrimary } from "components/Buttons"; 25 26 26 27 export const MobileNavigation = (props: { 27 28 currentPage: navPages; ··· 33 34 let compactOnMobile = 34 35 props.currentPage === "home" || 35 36 props.currentPage === "looseleafs" || 36 - props.currentPage === "pub" 37 - ? false 38 - : true; 37 + props.currentPage === "pub"; 38 + function getPubIcons() { 39 + let hasLooseleafs = !!identity?.permission_token_on_homepage.find( 40 + (f) => 41 + f.permission_tokens.leaflets_to_documents && 42 + f.permission_tokens.leaflets_to_documents[0]?.document, 43 + ); 44 + 45 + if (identity && identity.publications.length >= 1) { 46 + return ( 47 + <div className="pubNav flex gap-2 font-bold"> 48 + Publications 49 + <div className="flex"> 50 + {identity.publications.map((pub, index) => { 51 + if (index <= 3) 52 + return ( 53 + <PubIcon 54 + key={pub.uri} 55 + record={normalizePublicationRecord(pub.record)} 56 + uri={pub.uri} 57 + className="-ml-4 first:ml-0" 58 + /> 59 + ); 60 + })} 61 + </div> 62 + </div> 63 + ); 64 + } 65 + if (identity && hasLooseleafs) { 66 + return ( 67 + <div className="bg-bg-leaflet rounded-full "> 68 + <LooseLeafSmall className="scale-[75%]" /> 69 + </div> 70 + ); 71 + } else 72 + return ( 73 + <ButtonPrimary compact className="text-sm!"> 74 + Create a Publication! 75 + </ButtonPrimary> 76 + ); 77 + } 39 78 40 79 return ( 41 80 <div 42 - className={`mobileNav flex justify-between gap-1 items-center text-secondary pl-1 ${compactOnMobile ? "w-full" : "w-fit"}`} 81 + className={`mobileNav flex justify-between gap-1 items-center text-secondary px-1 w-full `} 43 82 > 44 - <div className="flex gap-2"> 45 - <WriterButton 46 - compactOnMobile={compactOnMobile} 47 - currentPage={props.currentPage} 48 - currentPubUri={props.currentPublicationUri} 49 - /> 50 - <ReaderButton 51 - compactOnMobile={compactOnMobile} 52 - current={props.currentPage === "reader"} 53 - subs={ 54 - identity?.publication_subscriptions?.length !== 0 && 55 - identity?.publication_subscriptions?.length !== undefined 56 - } 57 - /> 83 + <div 84 + className={`flex gap-2 grow items-center ${compactOnMobile ? "justify-start" : "justify-between"}`} 85 + > 86 + <div className="flex gap-2 items-center justify-start"> 87 + <WriterButton 88 + compactOnMobile={compactOnMobile} 89 + currentPage={props.currentPage} 90 + currentPubUri={props.currentPublicationUri} 91 + /> 92 + <ReaderButton 93 + compactOnMobile={compactOnMobile} 94 + current={props.currentPage === "reader"} 95 + subs={ 96 + identity?.publication_subscriptions?.length !== 0 && 97 + identity?.publication_subscriptions?.length !== undefined 98 + } 99 + /> 100 + </div> 101 + {identity?.atp_did ? ( 102 + <> 103 + {compactOnMobile && <Separator classname="h-6!" />} 104 + <NotificationButton /> 105 + </> 106 + ) : ( 107 + <LoginActionButton /> 108 + )} 58 109 </div> 59 - {identity?.atp_did ? ( 60 - <> 61 - {!compactOnMobile && <Separator />} 62 - <NotificationButton /> 63 - </> 64 - ) : ( 65 - <LoginActionButton /> 110 + 111 + {compactOnMobile && ( 112 + <Popover trigger={getPubIcons()} className="pt-1 px-2!"> 113 + <HomeButton 114 + current={props.currentPage === "home"} 115 + className="flex-row-reverse! justify-end!" 116 + /> 117 + <hr className="my-1 border-border-light" /> 118 + <PublicationButtons 119 + currentPage={props.currentPage} 120 + currentPubUri={props.currentPublicationUri} 121 + className="justify-end!" 122 + optionClassName=" flex-row-reverse!" 123 + /> 124 + </Popover> 66 125 )} 67 126 </div> 68 127 );
+11 -75
components/ActionBar/NavigationButtons.tsx
··· 1 1 import { HomeSmall } from "components/Icons/HomeSmall"; 2 2 import { ActionButton } from "./ActionButton"; 3 3 import { useIdentityData } from "components/IdentityProvider"; 4 - import Link from "next/link"; 5 - import { DiscoverSmall } from "components/Icons/DiscoverSmall"; 6 - import { PubIcon, PublicationButtons } from "./Publications"; 4 + import { PublicationButtons } from "./Publications"; 7 5 import { ReaderUnreadSmall } from "components/Icons/ReaderSmall"; 8 6 import { 9 7 NotificationsReadSmall, ··· 12 10 import { SpeedyLink } from "components/SpeedyLink"; 13 11 import { Popover } from "components/Popover"; 14 12 import { WriterSmall } from "components/Icons/WriterSmall"; 15 - import { LooseLeafSmall } from "components/Icons/LooseleafSmall"; 16 - import { normalizePublicationRecord } from "src/utils/normalizeRecords"; 17 - import { theme } from "tailwind.config"; 18 - 19 13 export type navPages = 20 14 | "home" 21 15 | "reader" ··· 47 41 currentPubUri?: string; 48 42 compactOnMobile?: boolean; 49 43 }) => { 50 - let { identity } = useIdentityData(); 51 - 52 - let currentPub = identity?.publications?.find( 53 - (pub) => pub.uri === props.currentPubUri, 54 - ); 55 - let pubRecord = currentPub 56 - ? normalizePublicationRecord(currentPub.record) 57 - : null; 58 - 44 + console.log(props.currentPage); 59 45 let current = 60 46 props.currentPage === "home" || 61 47 props.currentPage === "looseleafs" || 62 48 props.currentPage === "pub"; 63 - console.log(current); 64 - 65 - let currentPubIcon = 66 - currentPub && pubRecord ? ( 67 - <PubIcon record={pubRecord} uri={currentPub.uri} /> 68 - ) : null; 69 - 70 - let currentIcon = 71 - props.currentPage === "home" ? ( 72 - <HomeSmall className="text-tertiary" /> 73 - ) : props.currentPage === "looseleafs" ? ( 74 - <LooseLeafSmall className="text-tertiary" /> 75 - ) : props.currentPage === "pub" ? ( 76 - currentPubIcon 77 - ) : null; 78 49 79 50 return ( 80 51 <Popover 81 52 className="p-2!" 82 53 asChild 83 54 trigger={ 84 - props.compactOnMobile ? ( 85 - <ActionButton 86 - nav 87 - labelOnMobile={true} 88 - icon={<WriterSmall />} 89 - label=<div className="flex flex-row gap-1">Write</div> 90 - className={current ? "bg-bg-page! border-border-light!" : ""} 91 - /> 92 - ) : ( 93 - <ActionButton 94 - nav 95 - labelOnMobile={false} 96 - icon={ 97 - <> 98 - <WriterSmall /> 99 - </> 100 - } 101 - label=<div className="flex flex-row gap-1">Writer</div> 102 - className={current ? "bg-bg-page! border-border-light!" : ""} 103 - /> 104 - ) 55 + <ActionButton 56 + nav 57 + labelOnMobile={!props.compactOnMobile} 58 + icon={<WriterSmall />} 59 + label="Write" 60 + className={` w-fit! ${current ? "bg-bg-page! border-border-light!" : ""}`} 61 + /> 105 62 } 106 63 > 107 64 <SpeedyLink href={"/home"} className="hover:!no-underline"> ··· 110 67 icon={<HomeSmall />} 111 68 label="Write" 112 69 className={ 113 - props.currentPage === "home" 114 - ? "bg-bg-page! border-border-light!" 115 - : "" 70 + props.currentPage === "home" ? "bg-bg-page! border-border!" : "" 116 71 } 117 72 /> 118 73 </SpeedyLink> ··· 135 90 <SpeedyLink href={"/reader"} className="hover:no-underline!"> 136 91 <ActionButton 137 92 nav 138 - labelOnMobile={props.compactOnMobile} 93 + labelOnMobile={!props.compactOnMobile} 139 94 icon={<ReaderUnreadSmall />} 140 95 label="Read" 141 96 className={props.current ? "bg-bg-page! border-border-light!" : ""} ··· 166 121 </SpeedyLink> 167 122 ); 168 123 } 169 - 170 - const Divider = () => { 171 - return ( 172 - <svg 173 - width="6" 174 - height="25" 175 - viewBox="0 0 6 25" 176 - fill="none" 177 - xmlns="http://www.w3.org/2000/svg" 178 - > 179 - <path 180 - d="M0.5 0.5V7.5L5 12.5L0.5 17.5L0.5 24.5" 181 - stroke={theme.colors["border-light"]} 182 - strokeLinecap="round" 183 - strokeLinejoin="round" 184 - /> 185 - </svg> 186 - ); 187 - };