Skip to content

Commit

Permalink
Merge pull request #5 from growindiedev/feat/QA-Audit
Browse files Browse the repository at this point in the history
ui fixes
  • Loading branch information
dekanbro authored May 9, 2024
2 parents 6eb5acb + 6cee1e7 commit 75c3a5e
Show file tree
Hide file tree
Showing 8 changed files with 1,833 additions and 227 deletions.
58 changes: 41 additions & 17 deletions src/components/DaoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,28 @@ const StyledLink = styled(Link)`
color: inherit;
`;

const StyledDaoCard = styled.div`
background-color: ${(props) => props.theme.secondary.step2};
const StyledDaoCard = styled.div<{ isPersonalHub?: boolean }>`
background-color: ${(props) =>
props.isPersonalHub
? props.theme.secondary.step4
: props.theme.secondary.step2};
display: flex;
flex-direction: column;
justify-content: space-between;
width: 100%;
// max-width: 34rem;
min-width: 26rem;
border: 1px solid ${(props) => props.theme.secondary.step5};
padding: 1rem;
padding: 1.5rem;
border-radius: ${(props) => props.theme.card.radius};
.top-row {
display: flex;
flex-direction: row;
justify-content: space-between;
> * {
margin: 1rem;
}
}
.top-box {
display: flex;
Expand All @@ -55,13 +61,16 @@ const StyledDaoCard = styled.div`
display: flex;
flex-direction: column;
margin-bottom: 2.4rem;
p {
margin-bottom: 0.6rem;
}
}
.tag-box {
font-size: 1.4rem;
margin-bottom: 2.4rem;
> * {
margin-block: 1rem;
}
div {
margin-right: 1.5rem;
}
Expand All @@ -70,7 +79,6 @@ const StyledDaoCard = styled.div`
display: flex;
flex-direction: row;
}
`;

export const DaoCard = ({
Expand All @@ -87,7 +95,10 @@ export const DaoCard = ({
const chainIdLocal = chainId;

return (
<StyledDaoCard className="dao-card">
<StyledDaoCard
className="dao-card"
isPersonalHub={tags?.includes("personal")}
>
<div className="top-row">
<div className="top-box">
<div className="alert-box">
Expand All @@ -107,17 +118,25 @@ export const DaoCard = ({
)}
</div>
</div>
<StyledLink to={`${ADMIN_URL}/#/molochv3/${chainIdLocal}/${id}/articles`}><ParLg className="dao-title">
{name ? charLimit(name, 31) : charLimit(id, 31)}{" "}
</ParLg></StyledLink>
<StyledLink
to={`${ADMIN_URL}/#/molochv3/${chainIdLocal}/${id}/articles`}
>
<ParLg className="dao-title">
{name ? charLimit(name, 31) : charLimit(id, 31)}{" "}
</ParLg>
</StyledLink>
<div className="stats-box">
{activeMemberCount && (
<ParMd>
<Bold>
{readableNumbers.toNumber({ value: (Number(activeMemberCount) - 1).toString() })}
{readableNumbers.toNumber({
value: (Number(activeMemberCount) - 1).toString(),
})}
</Bold>{" "}
{parseInt(
readableNumbers.toNumber({ value: (Number(activeMemberCount) - 1).toString() })
readableNumbers.toNumber({
value: (Number(activeMemberCount) - 1).toString(),
})
) === 1
? "Curator"
: "Curators"}
Expand All @@ -126,7 +145,8 @@ export const DaoCard = ({
{proposalCount && (
<ParMd>
<Bold>{readableNumbers.toNumber({ value: proposalCount })}</Bold>{" "}
{parseInt(readableNumbers.toNumber({ value: proposalCount })) === 1
{parseInt(readableNumbers.toNumber({ value: proposalCount })) ===
1
? "Curated Article"
: "Curated Articles"}
</ParMd>
Expand All @@ -137,17 +157,21 @@ export const DaoCard = ({
<Tag tagColor="red">{getNetworkName(chainIdLocal || DEFAULT_NETWORK_ID)}</Tag>
</div> */}
</div>
{description && (<div className="description-box">
<ReactMarkdown>{description}</ReactMarkdown>
</div>)}
{tags?.length && (<div class-name="tag-box">
{description && (
<div className="description-box">
<ReactMarkdown>{description}</ReactMarkdown>
</div>
)}
{tags?.length && (
<div className="tag-box">
<ParSm>Tags:</ParSm>
{tags.map((tag) => (
<Tag key={tag} tagColor="blue">
{tag}
</Tag>
))}
</div>)}
</div>
)}
{/* <div className="button-box">
<ButtonRouterLink
color="secondary"
Expand Down
102 changes: 48 additions & 54 deletions src/components/UserDaos.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { useDHConnect } from "@daohaus/connect";
import styled from "styled-components";
import { BiColumnLayout, Button, Link } from "@daohaus/ui";
Expand All @@ -24,62 +23,57 @@ const ExternalLinkButton = styled(Link)`
}
`;

const InsideConatiner = styled.div`
> * {
margin-bottom: 2rem;
}
`;

export const UserDaos = () => {
const { chainId, isConnected, address } = useDHConnect();
const [daoData, setDaoData] = useState<ListDaosQueryResDaos>([]);

const { chainId, isConnected, address } = useDHConnect();
const [daoData, setDaoData] = useState<ListDaosQueryResDaos>([]);


useEffect(() => {
if (!isConnected || !address) {
return;
}

const fetchDaos = async () => {
const query = await listDaos({
networkId: chainId as ValidNetwork,
filter: {
referrer: NFT_DAO_REFERRER,
createdBy: address,
},
});
setDaoData(query.items);
console.log("daos", daoData);
};

fetchDaos();
useEffect(() => {
if (!isConnected || !address) {
return;
}
, [chainId, isConnected, address]);


const hasPersonalHub = () => {
// check if tags array in all daos contain "personal"
return daoData.some(dao => dao.tags?.includes("personal") ?? false);
}

return (
<div>
<h2>Your Hubs</h2>

{daoData?.map(dao => (
<DaoCard
key={dao.id}

{...dao}
/>
))}
{(daoData.length == 0 || !hasPersonalHub()) && (<>
<h2>Create Personal Hub</h2>
<p>
The fun starts with your own personal hub.
</p>
<LinkButton to={`/summon/personal`} >
<Button variant="outline">Summon a Personal Hub</Button>
</LinkButton></>)}
</div>
)



const fetchDaos = async () => {
const query = await listDaos({
networkId: chainId as ValidNetwork,
filter: {
referrer: NFT_DAO_REFERRER,
createdBy: address,
},
});
setDaoData(query.items);
console.log("daos", daoData);
};

fetchDaos();
}, [chainId, isConnected, address]);

const hasPersonalHub = () => {
// check if tags array in all daos contain "personal"
return daoData.some((dao) => dao.tags?.includes("personal") ?? false);
};

return (
<InsideConatiner>
<h2>Your Hubs</h2>

{daoData?.map((dao) => (
<DaoCard key={dao.id} {...dao} />
))}
{(daoData.length == 0 || !hasPersonalHub()) && (
<>
<h2>Create Personal Hub</h2>
<p>The fun starts with your own personal hub.</p>
<LinkButton to={`/summon/personal`}>
<Button variant="outline">Summon a Personal Hub</Button>
</LinkButton>
</>
)}
</InsideConatiner>
);
};
98 changes: 98 additions & 0 deletions src/components/customFields/MDXEditorField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { useEffect, useRef, useState } from "react";
import { Buildable, Field } from "@daohaus/ui";
import { useFormContext } from "react-hook-form";

import {
MDXEditor,
headingsPlugin,
UndoRedo,
BoldItalicUnderlineToggles,
toolbarPlugin,
BlockTypeSelect,
quotePlugin,
listsPlugin,
ListsToggle,
MDXEditorMethods,
linkPlugin,
linkDialogPlugin,
CreateLink,
DiffSourceToggleWrapper,
diffSourcePlugin,
codeBlockPlugin,
} from "@mdxeditor/editor";

Check failure on line 22 in src/components/customFields/MDXEditorField.tsx

View workflow job for this annotation

GitHub Actions / deploy

Cannot find module '@mdxeditor/editor' or its corresponding type declarations.
import "@mdxeditor/editor/style.css";
import styled from "styled-components";
import { LinkStyles } from "@daohaus/ui";

const MarkDownContainer = styled.div`
padding: 10px;
margin-bottom: 5rem;
border-radius: 5px;
background-color: ${({ theme }) => theme.input.bg};
color: ${({ theme }) => theme.input.color};
font-size: ${({ theme }) => theme.field.fontSize};
font-weight: ${({ theme }) => theme.field.fontWeight};
font-family: ${({ theme }) => theme.field.inputFont};
min-height: 10vh;
max-height: 50vh;
overflow: auto;
a {
${LinkStyles};
}
`;

export const MDXEditorField = (props: Buildable<Field>) => {
const { setValue, watch } = useFormContext();
const [content, createdAt] = watch([props.id, "createdAt"]);

const ref = useRef<MDXEditorMethods>(null);

const handleOnChange = (value: string) => {
setValue(props.id, value);
};

// useEffect(() => {
// const drafts = localStorage.getItem("drafts") || ("{}" as string);
// const parsedDrafts = JSON.parse(drafts);

// if (parsedDrafts[createdAt]) {
// ref.current?.setMarkdown(parsedDrafts[createdAt]?.content || "");
// setValue(props.id, parsedDrafts[createdAt]?.content);
// }
// }, [createdAt, ref]);

return (
<MarkDownContainer>
<MDXEditor
ref={ref}
className="dark-theme dark-editor"
markdown={""}
plugins={[
diffSourcePlugin({
diffMarkdown: content || "",
viewMode: "rich-text",
}),
codeBlockPlugin(),
listsPlugin(),
quotePlugin(),
headingsPlugin(),
linkPlugin(),
linkDialogPlugin(),
toolbarPlugin({
toolbarContents: () => (
<>
<DiffSourceToggleWrapper>
<BoldItalicUnderlineToggles />
<CreateLink />
<ListsToggle /> <BlockTypeSelect />
<UndoRedo />
</DiffSourceToggleWrapper>
</>
),
}),
]}
onChange={handleOnChange}
/>
</MarkDownContainer>
);
};
Loading

0 comments on commit 75c3a5e

Please sign in to comment.