Skip to content

Commit

Permalink
add tailwind and upgrade dao-haus packages
Browse files Browse the repository at this point in the history
  • Loading branch information
growindiedev committed May 14, 2024
1 parent 19d3f44 commit dc37587
Show file tree
Hide file tree
Showing 9 changed files with 569 additions and 165 deletions.
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"preview": "vite preview"
},
"dependencies": {
"@daohaus/keychain-utils": "^0.4.4",
"@daohaus/moloch-v3-data": "^0.4.4",
"@daohaus/moloch-v3-hooks": "^0.4.4",
"@daohaus/utils": "^0.4.4",
"@daohaus/keychain-utils": "^0.5.0",
"@daohaus/moloch-v3-data": "^0.5.0",
"@daohaus/moloch-v3-hooks": "^0.5.0",
"@daohaus/utils": "^0.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-markdown": "^9.0.1",
Expand All @@ -27,9 +27,12 @@
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.19",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.3",
"typescript": "^5.2.2",
"vite": "^5.2.0"
}
Expand Down
6 changes: 6 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
27 changes: 14 additions & 13 deletions src/components/layout/HomeContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@

import { Outlet } from "react-router-dom";
import styled from "styled-components";
//import styled from "styled-components";

const BlogContainerLayout = styled.div`
display: flex;
flex-direction: column;
align-items: left;
justify-content: center;
margin-top: 2rem;
max-width: 800px;
`;
// const BlogContainerLayout = styled.div`
// display: flex;
// flex-direction: column;
// align-items: left;
// justify-content: center;
// margin-top: 2rem;
// max-width: 800px;
// `;

export const HomeContainer = () => {

return (
<BlogContainerLayout>
// <BlogContainerLayout>
<div className="flex flex-col items-start justify-center mt-8 max-w-xl">
<Outlet />
</BlogContainerLayout>
</div>

// </BlogContainerLayout>
);
};
4 changes: 4 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
Expand Down
8 changes: 3 additions & 5 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@ import ReactDOM from "react-dom/client";
import { HashRouter } from "react-router-dom";
import { QueryClient, QueryClientProvider } from "react-query";


import { App } from "./App";

import "./App.css";

import "./index.css";

const queryClient = new QueryClient();

ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<HashRouter>
<QueryClientProvider client={queryClient}>
<App />
<App />
</QueryClientProvider>
</HashRouter>
</React.StrictMode>
);
);
171 changes: 88 additions & 83 deletions src/pages/BlogDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,106 +1,111 @@

import { Link, useParams } from 'react-router-dom'
import '../App.css'
import { useRecords } from '../hooks/UseRecords';
import { Link, useParams } from "react-router-dom";
// import '../App.css'
import { useRecords } from "../hooks/UseRecords";
import { ValidNetwork } from "@daohaus/keychain-utils";
import { useDaoData } from '@daohaus/moloch-v3-hooks';
import { BlogPost } from '../utils/types';
import { useDaoData } from "@daohaus/moloch-v3-hooks";
import { BlogPost } from "../utils/types";

import styled from "styled-components";
import ReactMarkdown from "react-markdown";



const ReactMarkdownWrapper = styled.div`
margin-top: 2rem;
margin-bottom: 2rem;
font-size: 1.5rem;
`;

const BlogDetailTitleBlock = styled.div`
margin-top: 2rem;
margin-bottom: 2rem;
font-size: 1.5rem;
`;

`
const BlogDetailTitleBlock = styled.div``;

const BlogDetailInfo = styled.div`
display: flex;
justify-content: space-between;
`
display: flex;
justify-content: space-between;
`;

const StyledLink = styled(Link)`
color: hsl(226, 70.0%, 55.5%);
color: hsl(226, 70%, 55.5%);
text-decoration: none;
&:hover {
color: #888;
}
`;


function BlogDetail() {
const { chainId, daoId, contentId } = useParams()
const { dao } = useDaoData({
daoId: daoId || "",
daoChain: chainId as ValidNetwork,
});

let { records } = useRecords({
daoId: daoId,
chainId: chainId as ValidNetwork,
recordType: "DUCEREF",
hash: contentId
});

const { records: comment } = useRecords({
daoId: daoId,
chainId: chainId as ValidNetwork,
recordType: "DUCE",
hash: contentId
});

if (records?.length === 0) {
records = comment;
}

const getBlogURL = (URI: string) => {
// TODO: this is very fagile
// example: https://dinhaus.github.io/din-admin/#/molochv3/0xaa36a7/0x738e841225bef5059640591f453eb7e9074c42c2/articles/0x53621709eb82041098d03fdd421cf0b78cd4dca68ee294084bff16ca9c66c689
// format molochV3/chainId/daoId/articles/contentId
// blog example: http://localhost:5173/din-blog/#/content/0xaa36a7/0x738e841225bef5059640591f453eb7e9074c42c2/0x53621709eb82041098d03fdd421cf0b78cd4dca68ee294084bff16ca9c66c689
// new format content/chainId/daoId/contentId
const parts = URI.split("/");
return `/content/${parts[6]}/${parts[7]}/${parts[9]}`;
}

return (
<>
<h1>{dao?.name || "Not Found"}</h1>
const { chainId, daoId, contentId } = useParams();
const { dao } = useDaoData({
daoId: daoId || "",
daoChain: chainId as ValidNetwork,
});

let { records } = useRecords({
daoId: daoId,
chainId: chainId as ValidNetwork,
recordType: "DUCEREF",
hash: contentId,
});

const { records: comment } = useRecords({
daoId: daoId,
chainId: chainId as ValidNetwork,
recordType: "DUCE",
hash: contentId,
});

if (records?.length === 0) {
records = comment;
}

<div>
{records?.map((record) => {
const parsedContent: BlogPost = record.parsedContent as BlogPost;
const date = new Date(Number(record.createdAt) * 1000);
const formattedDate = `${date.getFullYear()} ${date.toLocaleString('default', { month: 'short' })} ${date.getDate()}`;
return (
<div key={record.id}>
<BlogDetailTitleBlock>
<h2>{parsedContent.title}</h2>
{(record.parsedContent as BlogPost)?.contentURI && <StyledLink to={`${getBlogURL((record.parsedContent as BlogPost)?.contentURI)}`}>See original post</StyledLink>}
<BlogDetailInfo>
<p>{formattedDate}</p>
<StyledLink to={`/blog/${chainId}/${daoId}`}>See all posts</StyledLink>
</BlogDetailInfo>
</BlogDetailTitleBlock>
<ReactMarkdownWrapper>
<ReactMarkdown>{parsedContent?.content}</ReactMarkdown>
</ReactMarkdownWrapper>
</div>
)
})}
const getBlogURL = (URI: string) => {
// TODO: this is very fagile
// example: https://dinhaus.github.io/din-admin/#/molochv3/0xaa36a7/0x738e841225bef5059640591f453eb7e9074c42c2/articles/0x53621709eb82041098d03fdd421cf0b78cd4dca68ee294084bff16ca9c66c689
// format molochV3/chainId/daoId/articles/contentId
// blog example: http://localhost:5173/din-blog/#/content/0xaa36a7/0x738e841225bef5059640591f453eb7e9074c42c2/0x53621709eb82041098d03fdd421cf0b78cd4dca68ee294084bff16ca9c66c689
// new format content/chainId/daoId/contentId
const parts = URI.split("/");
return `/content/${parts[6]}/${parts[7]}/${parts[9]}`;
};

return (
<>
<h1>{dao?.name || "Not Found"}</h1>

<div>
{records?.map((record) => {
const parsedContent: BlogPost = record.parsedContent as BlogPost;
const date = new Date(Number(record.createdAt) * 1000);
const formattedDate = `${date.getFullYear()} ${date.toLocaleString(
"default",
{ month: "short" }
)} ${date.getDate()}`;
return (
<div key={record.id}>
<BlogDetailTitleBlock>
<h2>{parsedContent.title}</h2>
{(record.parsedContent as BlogPost)?.contentURI && (
<StyledLink
to={`${getBlogURL(
(record.parsedContent as BlogPost)?.contentURI
)}`}
>
See original post
</StyledLink>
)}
<BlogDetailInfo>
<p>{formattedDate}</p>
<StyledLink to={`/blog/${chainId}/${daoId}`}>
See all posts
</StyledLink>
</BlogDetailInfo>
</BlogDetailTitleBlock>
<ReactMarkdownWrapper>
<ReactMarkdown>{parsedContent?.content}</ReactMarkdown>
</ReactMarkdownWrapper>
</div>


</>
)
);
})}
</div>
</>
);
}

export default BlogDetail
export default BlogDetail;
14 changes: 5 additions & 9 deletions src/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@

import '../App.css'

function Home() {

// get params from url path


return (
<>
<h1>Din Blog</h1>

<h1 className="text-3xl font-bold underline text-red-500">
Hello world!
</h1>
</>
)
);
}

export default Home
export default Home;
8 changes: 8 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('tailwindcss').Config} */
export default {
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
};
Loading

0 comments on commit dc37587

Please sign in to comment.