Skip to content

Commit

Permalink
BitBabble DChat
Browse files Browse the repository at this point in the history
  • Loading branch information
wpdas committed Apr 9, 2024
0 parents commit 088fabf
Show file tree
Hide file tree
Showing 64 changed files with 4,769 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/deploy-mainnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Deploy DApp to Mainnet
on:
push:
branches: [main]
jobs:
deploy-mainnet:
uses: wpdas/alem/.github/workflows/deploy.yml@main
with:
signer-account-address: wendersonpires.near
signer-public-key: ed25519:9jDaFsG11jftUEQbccjUMsT39rZ3dzWJcDLoyT2qJvzb
secrets:
SIGNER_PRIVATE_KEY: ${{ secrets.SIGNER_PRIVATE_KEY }}
12 changes: 12 additions & 0 deletions .github/workflows/deploy-testnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Deploy DApp to Testnet
on:
push:
branches: [staging]
jobs:
deploy-testnet:
uses: wpdas/alem/.github/workflows/deploy-testnet.yml@main
with:
signer-account-address: wendersonpires.testnet
signer-public-key: ed25519:8NTXtouT5r4g18XJTErBeqEgDbDXsNxysVgD7DjUnL2N
secrets:
SIGNER_PRIVATE_KEY: ${{ secrets.TESTNET_SIGNER_PRIVATE_KEY }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/build
/node_modules
.env

# misc
.DS_Store
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.0.0
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
"singleQuote": false,
"printWidth": 120
}
Empty file added README.md
Empty file.
32 changes: 32 additions & 0 deletions alem.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"isIndex": false,
"mainnetAccount": "wendersonpires.near",
"testnetAccount": "wendersonpires.testnet",
"name": "Bit Babble",
"description": "App description",
"linktree": {
"website": "github.com/wpdas/alem"
},
"image": {
"ipfs_cid": "bafkreicjdgat5xsw7vxbosoyygermawhkfi2by3ovg7c6tumrayn4rimty"
},
"tags": [
"alem",
"dapp",
"near",
"bos"
],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@app/": "src/",
"@services/": "src/services/",
"@components/": "src/components/",
"@contexts/": "src/contexts/"
}
},
"options": {
"keepRoute": true,
"hideAlemBar": false
}
}
3 changes: 3 additions & 0 deletions alem.modules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"javascript-time-ago": "https://unpkg.com/javascript-time-ago@2.5.9/bundle/javascript-time-ago.js"
}
25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "bitbabble",
"version": "1.0.0",
"description": "The base template for Create Alem dApp",
"repository": "git@github.com:wpdas/create-alem-dapp.git",
"license": "MIT",
"scripts": {
"start": "MINIFY=false NODE_ENV=development alem dev --network testnet",
"start:mainnet": "MINIFY=false NODE_ENV=development alem dev",
"build": "alem build",
"deploy:mainnet": "npm run build; alem deploy",
"deploy:testnet": "npm run build; alem deploy --network testnet"
},
"dependencies": {
"alem": "^1.0.0-beta.12"
},
"devDependencies": {
"@types/styled-components": "^5.1.26",
"lint-staged": "^13.2.1",
"prettier": "^2.8.8"
},
"lint-staged": {
"**/*.{js,jsx,ts,tsx}": "prettier --write --ignore-unknown"
}
}
28 changes: 28 additions & 0 deletions src/Main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Routes from "./screens/Routes";
import TopBar from "@components/TopBar";
import BottomBar from "@components/BottomBar";
import { useRoutes, context, useMemo } from "alem";
import routesPath from "./screens/routesPath";
import CenterMessage from "./components/CenterMessage";

const Main = () => {
const { activeRoute } = useRoutes();
const accountId = context.accountId;

const Content = useMemo(
() => () => accountId ? <Routes /> : <CenterMessage message="You need to Sign in before using this chat." />,
[accountId, activeRoute],
);

return (
<div className="main-container">
<div className="top-bar-margin" />
<TopBar />
<Content />
{activeRoute !== routesPath.CHAT && accountId && <BottomBar />}
<div className="bottom-bar-margin" />
</div>
);
};

export default Main;
20 changes: 20 additions & 0 deletions src/components/Avatar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// TODO: Criar lib de Componentes?

type Props = {
name?: string;
image?: string;
};

// TODO: usar imagem do amigo
const Avatar = ({ name, image }: Props) => {
const nameParts = name ? name?.split(" ") : [""];
const finalName = `${nameParts[0][0]}${nameParts[1] ? nameParts[1][0] : ""}`;

return (
<div className="avatar">
{!image ? <p className="avatar-text">{finalName}</p> : <img src={image} alt={`Image of user ${name}`} />}
</div>
);
};

export default Avatar;
22 changes: 22 additions & 0 deletions src/components/Avatar/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.avatar {
display: flex;
/* background-color: #e2e8f0; */
border: 2px solid #103144;
border-radius: 9999px;
width: 32px;
height: 32px;
justify-content: center;
align-items: center;

img {
width: 32px;
height: 32px;
border-radius: 9999px;
}
}

.avatar-text {
color: #4a5568;
font-size: 0.9rem;
font-weight: 600;
}
46 changes: 46 additions & 0 deletions src/components/BottomBar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import routesPath from "@app/screens/routesPath";
import { navigate, useRoutes } from "alem";

const BottomBar = () => {
const routes = useRoutes();

// Items
const Items = ({
children,
name,
to,
active,
}: {
children: JSX.Element;
name: string;
to: string;
active?: boolean;
}) => {
const onClick = () => {
navigate.to(to, { previous: routes.activeRoute });
};

return (
<button className={`item ${active ? "active" : ""}`} onClick={onClick}>
{children}
<p className="item-text">{name}</p>
</button>
);
};

return (
<div className="bottombar">
<Items name="Chats" to={routesPath.CHATS_LIST} active={routes.activeRoute === routesPath.CHATS_LIST}>
<span className="material-symbols-outlined">forum</span>
</Items>
{/* <Items name="Groups" to={routesPath.GROUPS_LIST} active={routes.activeRoute === routesPath.GROUPS_LIST}>
<span className="material-symbols-outlined">group</span>
</Items> */}
<Items name="Contacts" to={routesPath.CONTACTS_LIST} active={routes.activeRoute === routesPath.CONTACTS_LIST}>
<span className="material-symbols-outlined">list_alt</span>
</Items>
</div>
);
};

export default BottomBar;
45 changes: 45 additions & 0 deletions src/components/BottomBar/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.bottombar {
bottom: 0px;
left: 0px;
width: 100%;
position: fixed;
display: flex;
background-color: #103144;
padding: 1rem 2.5rem;
justify-content: space-around;

.active {
p, span {
color: #EEFFFB;
}

span {
background-color: #1f5574;
border-radius: 0.5rem;
}
}

.item {
background-color: transparent;
border: none;
display: flex;
flex-direction: column;
align-items: center;
}

.item-text {
margin-top: 0.2rem;
font-weight: 600;
color: #bbc9c5;
}

span {
padding: 0.15rem 1rem;
color: #bbc9c5;
}
}

.bottom-bar-margin {
width: 100%;
height: 90px;
}
19 changes: 19 additions & 0 deletions src/components/CenterMessage/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
type Props = {
message: string;
};

const CenterMessage = ({ message }: Props) => (
<div style={{ margin: "auto", paddingTop: "236px", width: "100%" }}>
<div
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
}}
>
<p className="loading-message">{message}</p>
</div>
</div>
);

export default CenterMessage;
4 changes: 4 additions & 0 deletions src/components/CenterMessage/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.loading-message {
color: #1031449a;
font-weight: 600;
}
20 changes: 20 additions & 0 deletions src/components/ChatItem/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Avatar from "@components/Avatar";

type Props = {
name: string;
onSelectChat?: (chatId: string) => void;
};

const ChatItem = ({ name, onSelectChat }: Props) => {
return (
<div className="chat-item">
<div className="left">
<Avatar name={name} />
<p className="text">{name}</p>
</div>
<span className="material-symbols-outlined">arrow_forward_ios</span>
</div>
);
};

export default ChatItem;
28 changes: 28 additions & 0 deletions src/components/ChatItem/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.chat-item {
cursor: pointer;
display: flex;
padding: 16px 8px;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid #c9dad5;

:hover {
background-color: #D9F3EB;
}

:active {
background-color: #c2e9de;
}

.left {
display: flex;
align-items: flex-start;
align-items: center;
}

.text {
color: #103144;
font-weight: bold;
margin-left: 1rem;
}
}
Loading

0 comments on commit 088fabf

Please sign in to comment.