Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotBraem committed Jan 27, 2025
1 parent 62cc211 commit 05af262
Show file tree
Hide file tree
Showing 13 changed files with 283 additions and 17 deletions.
8 changes: 0 additions & 8 deletions .devcontainer/devcontainer.json

This file was deleted.

5 changes: 0 additions & 5 deletions .devcontainer/post-create.sh

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ yarn-error.log*

# vercel
.vercel
.turbo

# typescript
*.tsbuildinfo
Expand Down
Empty file added bos.config.json
Empty file.
12 changes: 12 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Profile Module</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/index.jsx"></script>
</body>
</html>
29 changes: 25 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
{
"name": "project-template",
"name": "@efiz.near/profile",
"version": "0.0.1",
"homepage": "/",
"type": "module",
"private": false,
"publishConfig": {
"access": "public"
},
"files": [
"dist"
],
"scripts": {
"dev": "cat welcome.txt && rsbuild dev",
"build": "rsbuild build",
"preview": "rsbuild preview",
"fmt": "prettier --write '**/*.{js,jsx,ts,tsx,json}'",
"fmt:check": "prettier --check '**/*.{js,jsx,ts,tsx,json}'",
"test": "bunx playwright test",
"test:ui": "bunx playwright test --ui",
"dev": "cat welcome.txt"
"test:ui": "bunx playwright test --ui"
},
"browserslist": {
"production": [
Expand All @@ -21,9 +31,20 @@
"last 1 safari version"
]
},
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-markdown": "^9.0.1"
},
"devDependencies": {
"@playwright/test": "^1.46.1",
"@types/node": "^20.11.0",
"prettier": "^3.3.3"
"prettier": "^3.3.3",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.16",
"@module-federation/enhanced": "^0.8.7",
"@rsbuild/core": "^1.2.3",
"@rsbuild/plugin-node-polyfill": "^1.2.0",
"@rsbuild/plugin-react": "^1.1.0"
}
}
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: {}
}
};
36 changes: 36 additions & 0 deletions rsbuild.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';
import { defineConfig } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';


export default defineConfig({
server: {
port: 5170,
},
output: {
distPath: {
root: 'dist'
},
},
tools: {
rspack: {
plugins: [new ModuleFederationPlugin({
name: 'profile',
filename: 'profile/remoteEntry.js',
exposes: {
'./App': './src/App.jsx'
},
experiments: {
federationRuntime: 'hoisted'
},
shared: {
'react': { singleton: true, eager: true, requiredVersion: '^18.0.0' },
'react-dom': { singleton: true, eager: true, requiredVersion: '^18.0.0' }
},
})]
}
},
plugins: [
pluginReact()
]
});
85 changes: 85 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import React from "react";
import ReactMarkdown from "react-markdown";
import "./index.css";

const fallbackUrl =
"https://ipfs.near.social/ipfs/bafkreibmiy4ozblcgv3fm3gc6q62s55em33vconbavfd2ekkuliznaq3zm";

const getImageUrl = (image) => {
if (image?.url) return image.url;
if (image?.ipfs_cid) return `https://ipfs.near.social/ipfs/${image.ipfs_cid}`;
return fallbackUrl;
};

function getSocialLink(platform, username) {
const links = {
github: `https://github.com/${username}`,
telegram: `https://t.me/${username}`,
linkedin: `https://linkedin.com/in/${username}`,
twitter: `https://twitter.com/${username}`,
website: `https://${username}`
};
return links[platform] || "#";
}

function getSocialIcon(platform) {
const icons = {
github: "📂",
telegram: "📞",
linkedin: "💼",
twitter: "🐦",
website: "🌐"
};
return icons[platform] || "🔗";
}

export default ({ accountId, profile }) => {
if (!profile) {
return (
<div className="p-8 text-center text-xl text-red-500">
Profile not found
</div>
);
}

return (
<div
className="margin-auto relative flex min-h-screen w-full flex-col items-center justify-center bg-cover bg-center py-16"
style={{
backgroundImage: `url(${getImageUrl(profile?.backgroundImage) || ""})`
}}
>
<div className="z-10 w-full max-w-2xl rounded-xl bg-white bg-opacity-95 p-8 text-center shadow-2xl backdrop-blur-sm lg:max-w-[1024px]">
<div className="w-full">
<img
src={getImageUrl(profile?.image)}
alt={profile?.name}
className="mx-auto mb-4 h-32 w-32 rounded-full object-cover shadow-lg"
/>
<h1 className="mb-1 text-5xl font-bold text-gray-800">
{profile?.name}
</h1>
<p className="text-gray-600 mb-4">@{accountId}</p>
<div className="markdown-content mb-6 rounded-lg bg-gray-50 p-4 text-left text-gray-700 shadow-inner">
<ReactMarkdown>{profile?.description || ""}</ReactMarkdown>
</div>
<div className="mt-6 flex flex-wrap justify-center gap-3">
{Object.entries(profile?.linktree || {}).map(
([platform, username]) => (
<a
key={platform}
href={getSocialLink(platform, username)}
target="_blank"
rel="noopener noreferrer"
className="bg-opacity-600 hover:bg-opacity-700 flex h-10 w-10 items-center justify-center rounded-full bg-white p-2 text-white shadow-md transition-all duration-300 hover:bg-white hover:shadow-lg"
>
{getSocialIcon(platform)}
</a>
)
)}
</div>
</div>
</div>
</div>
);
}
11 changes: 11 additions & 0 deletions src/bootstrap.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import * as ReactDOMClient from 'react-dom/client';
import App from './App';

const render = App => {
const root = document.getElementById('root');

ReactDOMClient.createRoot(root, <App />);
};

render(App);
95 changes: 95 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

.markdown-content {
line-height: 1.6;
}
.markdown-content h1 {
font-size: 1.8em;
margin-top: 0.5em;
margin-bottom: 0.5em;
font-weight: bold;
}
.markdown-content h2 {
font-size: 1.5em;
margin-top: 0.6em;
margin-bottom: 0.6em;
font-weight: bold;
}
.markdown-content h3 {
font-size: 1.3em;
margin-top: 0.7em;
margin-bottom: 0.7em;
font-weight: bold;
}
.markdown-content h4, .markdown-content h5, .markdown-content h6 {
font-size: 1.1em;
margin-top: 0.8em;
margin-bottom: 0.8em;
font-weight: bold;
}
.markdown-content p {
margin-top: 0.5em;
margin-bottom: 0.5em;
}
.markdown-content ul, .markdown-content ol {
padding-left: 1.5em;
margin-top: 0.5em;
margin-bottom: 0.5em;
}
.markdown-content ul {
list-style-type: disc;
}
.markdown-content ol {
list-style-type: decimal;
}
.markdown-content li {
margin-bottom: 0.3em;
}
.markdown-content a {
color: #4a22a5;
text-decoration: underline;
}
.markdown-content a:hover {
color: #3a1a84;
}
.markdown-content blockquote {
border-left: 3px solid #ccc;
margin: 0.5em 0;
padding-left: 1em;
font-style: italic;
}
.markdown-content code {
background-color: #f0f0f0;
padding: 0.2em 0.4em;
border-radius: 3px;
font-family: monospace;
}
.markdown-content pre {
background-color: #f0f0f0;
padding: 0.8em;
overflow-x: auto;
border-radius: 5px;
}
.markdown-content pre code {
background-color: transparent;
padding: 0;
}
.markdown-content hr {
border: 0;
border-top: 1px solid #ccc;
margin: 0.5em 0;
}
.markdown-content table {
border-collapse: collapse;
margin: 0.5em 0;
}
.markdown-content th, .markdown-content td {
border: 1px solid #ccc;
padding: 0.3em;
}
.markdown-content img {
max-width: 100%;
height: auto;
}
1 change: 1 addition & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import('./bootstrap');
11 changes: 11 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}

0 comments on commit 05af262

Please sign in to comment.