This commit is contained in:
Jorijn van der Graaf 2025-11-12 21:24:23 +01:00
commit 02c07ceaa2
6 changed files with 575 additions and 31 deletions

78
README.md Normal file
View file

@ -0,0 +1,78 @@
# catcrafts.net
A modern, responsive website built with C++ using Crafter.CppDOM and compiled to WebAssembly.
## Features
- Modern, clean design with gradient colors and smooth animations
- Fully responsive layout that works on mobile and desktop
- Blog functionality with multiple posts
- Smooth navigation and transitions
- Semantic HTML structure
- Custom CSS with modern styling techniques
## Project Structure
```
catcrafts.net/
├── interfaces/ # Interface definitions
│ ├── Catcrafts.cppm
│ ├── Catcrafts-Views.cppm
│ ├── Catcrafts-Component.cppm
│ └── Catcrafts-Blog.cppm
├── implementations/ # Implementation files
│ ├── Catcrafts-Blog.cpp
│ └── main.cpp
├── styles.css # Modern CSS styling
├── project.json # Build configuration
├── run.sh # Development server script
└── build.sh # Build script
```
## Building and Running
### Prerequisites
- C++ compiler with WebAssembly support
- Caddy server for serving files
### Quick Start
1. Make the scripts executable:
```bash
chmod +x run.sh build.sh
```
2. Run the development server:
```bash
./run.sh
```
The website will be available at `http://localhost:8085`
### Building Manually
```bash
./build.sh
```
## Technologies Used
- **C++**: Core application logic
- **Crafter.CppDOM**: DOM manipulation library
- **WebAssembly**: Runtime environment
- **CSS3**: Modern styling with animations and gradients
- **HTML5**: Semantic markup
## Customization
To add new blog posts:
1. Edit `interfaces/Catcrafts-Blog.cppm`
2. Add new entries to the `posts` vector
To modify styling:
1. Edit `styles.css`
2. Adjust colors, fonts, and layout as needed
## License
This project is licensed under the MIT License - see the LICENSE file for details.

View file

@ -14,9 +14,17 @@ namespace Catcrafts {
std::string RenderBlog() { std::string RenderBlog() {
std::string html = ""; std::string html = "";
for(const BlogPost& post : *posts) { for(const BlogPost& post : *posts) {
html += std::format("{}<br>{}<br><br>{}", post.name, post.date, post.content); html += std::format(R"(
<div class="post fade-in">
<div class="post-header">
<h2 class="post-title">{}</h2>
<span class="post-date">{}</span>
</div>
<div class="post-content">
{}
</div>
</div>)", post.name, post.date, post.content);
} }
return html; return html;
} }
} }

View file

@ -17,33 +17,23 @@ HtmlElementView* blogButton;
void RenderRoot(const std::string_view route) { void RenderRoot(const std::string_view route) {
std::string pageContent; std::string pageContent;
if(route == "/blog") { //currently pointless if but for adding more pages in the future if(route == "/blog") {
pageContent = RenderBlog(); pageContent = RenderBlog();
} else { } else {
pageContent = RenderBlog(); //default route pageContent = RenderBlog(); //default route
} }
// Set body content
main->SetInnerHTML(pageContent);
body->SetInnerHTML(std::format(R"( // Update active nav link
Catcrafts.net // auto navLinks = document->GetElementsByClassName("nav-container")[0]->GetElementsByTagName("a");
<nav> // for(auto link : navLinks) {
<ul> // if(link->GetAttribute("id") == "blog-nav-button") {
<li><a id="blog-nav-button" style="cursor: pointer;">Blog</a></li> // link->SetAttribute("class", "active");
<li><a href="https://forgejo.catcrafts.net/">Forgejo</a></li> // } else {
</ul> // link->SetAttribute("class", "");
</nav> // }
//}
{}
<footer>Powered by Crafter.CppDOM, Running near native with WASM!, <a href="https://forgejo.catcrafts.net/Catcrafts/catcrafts.net">View source</a></footer>)", pageContent));
if(blogButton) {
delete blogButton;
}
blogButton = new HtmlElementView("blog-nav-button");
blogButton->AddClickListener([](Crafter::MouseEvent e) {
PushState("{}", "", "/blog");
RenderRoot("blog");
});
} }
int main() { int main() {
@ -51,5 +41,11 @@ int main() {
RenderRoot(GetPathNameString()); RenderRoot(GetPathNameString());
}); });
blogButton = new HtmlElementView("blog-nav-button");
blogButton->AddClickListener([](Crafter::MouseEvent e) {
PushState("{}", "", "/blog");
RenderRoot("blog");
});
RenderRoot("/"); RenderRoot("/");
} }

View file

@ -11,10 +11,37 @@ import Crafter.CppDOM;
using namespace Crafter; using namespace Crafter;
export namespace Catcrafts { export namespace Catcrafts {
HtmlElementView* body = new HtmlElementView("body"); HtmlElementView* body = new HtmlElementView("body", R"(
HtmlElementView* head = new HtmlElementView("head", R"( <header>
<style> <div class="nav-container">
<a href="/" class="logo">🐱 Catcrafts</a>
<nav>
<ul>
<li><a id="blog-nav-button" style="cursor: pointer;" class="active">Blog</a></li>
<li><a href="https://forgejo.catcrafts.net/">Forgejo</a></li>
</ul>
</nav>
</div>
</header>
</style> <main id="main"></main>
)");//add style here
<footer>
<div class="footer-content">
<div class="footer-links">
Powered by Crafter.CppDOM, Running near native with WASM!
<a href="https://forgejo.catcrafts.net/Catcrafts/catcrafts.net">View source</a>
</div>
<p>&copy; 2025 Catcrafts®. All rights reserved. Crafter® and Catcrafts® are registered trademarks with the EUIPO</p>
</div>
</footer>)");
HtmlElementView* head = new HtmlElementView("head", R"(
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Catcrafts.net</title>
<link rel="stylesheet" href="/styles.css">
)");
HtmlElementView* main = new HtmlElementView("main");
} }

435
styles.css Normal file
View file

@ -0,0 +1,435 @@
/* Modern CSS for catcrafts.net */
/* Base styles */
:root {
--primary-color: #4361ee;
--secondary-color: #3a0ca0;
--accent-color: #f72585;
--light-color: #f8f9fa;
--dark-color: #212529;
--success-color: #4cc9f0;
--border-radius: 12px;
--box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
--transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6;
color: var(--dark-color);
background: linear-gradient(135deg, #f5f7ff 0%, #e6e9ff 100%);
min-height: 100vh;
display: flex;
flex-direction: column;
font-size: 16px;
}
/* Header and Navigation */
header {
background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
color: white;
padding: 1rem 0;
box-shadow: var(--box-shadow);
position: sticky;
top: 0;
z-index: 100;
backdrop-filter: blur(10px);
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}
.nav-container {
max-width: 1200px;
margin: 0 auto;
padding: 0 1.5rem;
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
font-size: 1.8rem;
font-weight: 700;
text-decoration: none;
color: white;
display: flex;
align-items: center;
gap: 0.5rem;
transition: var(--transition);
}
.logo:hover {
opacity: 0.9;
transform: scale(1.05);
}
nav ul {
display: flex;
list-style: none;
gap: 1.5rem;
}
nav a {
color: white;
text-decoration: none;
font-weight: 500;
padding: 0.5rem 1rem;
border-radius: var(--border-radius);
transition: var(--transition);
position: relative;
overflow: hidden;
}
nav a:hover,
nav a.active {
background-color: rgba(255, 255, 255, 0.2);
}
/* Add underline effect for active nav items */
nav a::after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
width: 0;
height: 2px;
background-color: var(--accent-color);
transition: var(--transition);
transform: translateX(-50%);
}
nav a:hover::after,
nav a.active::after {
width: 80%;
}
/* Main Content */
main {
flex: 1;
max-width: 1200px;
margin: 2rem auto;
padding: 0 1.5rem;
}
.hero {
text-align: center;
padding: 3rem 2rem;
margin-bottom: 2rem;
background: linear-gradient(135deg, #e0f7fa, #bbdefb);
border-radius: var(--border-radius);
box-shadow: var(--box-shadow);
border: 1px solid rgba(255, 255, 255, 0.5);
animation: fadeInUp 0.8s ease-out;
}
.hero h1 {
font-size: 2.8rem;
margin-bottom: 1rem;
color: var(--secondary-color);
background: linear-gradient(to right, var(--primary-color), var(--accent-color));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.hero p {
font-size: 1.3rem;
max-width: 600px;
margin: 0 auto 1.5rem;
color: var(--dark-color);
font-weight: 300;
}
/* Blog Posts */
.blog-posts {
display: grid;
gap: 2rem;
margin-top: 2rem;
}
.post {
background: white;
border-radius: var(--border-radius);
padding: 2rem;
box-shadow: var(--box-shadow);
transition: var(--transition);
border-left: 4px solid var(--primary-color);
animation: fadeIn 0.6s ease-out forwards;
opacity: 0;
transform: translateY(20px);
animation-fill-mode: forwards;
}
.post:nth-child(1) { animation-delay: 0.1s; }
.post:nth-child(2) { animation-delay: 0.2s; }
.post:nth-child(3) { animation-delay: 0.3s; }
.post:hover {
transform: translateY(-5px);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}
.post-header {
margin-bottom: 1.5rem;
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
gap: 1rem;
}
.post-title {
font-size: 1.8rem;
color: var(--secondary-color);
margin-bottom: 0.5rem;
flex: 1;
}
.post-date {
color: var(--accent-color);
font-weight: 600;
background-color: rgba(247, 37, 133, 0.1);
padding: 0.5rem 1rem;
border-radius: 20px;
font-size: 0.9rem;
white-space: nowrap;
}
.post-content {
font-size: 1.1rem;
line-height: 1.8;
color: #333;
animation: fadeIn 0.6s ease-out 0.2s forwards;
opacity: 0;
}
.post-content p {
margin-bottom: 1.2rem;
}
.post-content a {
color: var(--primary-color);
text-decoration: none;
font-weight: 600;
transition: var(--transition);
}
.post-content a:hover {
text-decoration: underline;
color: var(--secondary-color);
}
.post-content ul {
margin-left: 1.5rem;
margin-bottom: 1.2rem;
}
.post-content li {
margin-bottom: 0.5rem;
}
/* Footer */
footer {
background-color: var(--dark-color);
color: white;
text-align: center;
padding: 2rem;
margin-top: auto;
border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.footer-content {
max-width: 1200px;
margin: 0 auto;
display: flex;
flex-direction: column;
gap: 1rem;
}
.footer-links a {
color: #4cc9f0;
text-decoration: none;
transition: var(--transition);
display: inline-block;
padding: 0.25rem 0.5rem;
border-radius: 4px;
}
.footer-links a:hover {
background-color: rgba(255, 255, 255, 0.1);
text-decoration: underline;
}
/* Responsive Design */
@media (max-width: 768px) {
.nav-container {
flex-direction: column;
gap: 1rem;
}
nav ul {
gap: 0.5rem;
flex-wrap: wrap;
justify-content: center;
}
.hero h1 {
font-size: 2.2rem;
}
.hero p {
font-size: 1.1rem;
}
.post {
padding: 1.5rem;
}
.post-title {
font-size: 1.5rem;
}
.post-header {
flex-direction: column;
align-items: flex-start;
gap: 0.5rem;
}
.post-content {
font-size: 1rem;
}
}
@media (max-width: 480px) {
main {
margin: 1rem auto;
}
.hero {
padding: 2rem 1rem;
}
.hero h1 {
font-size: 1.8rem;
}
.post {
padding: 1rem;
}
.post-title {
font-size: 1.3rem;
}
.post-date {
padding: 0.3rem 0.8rem;
font-size: 0.8rem;
}
}
/* Animations */
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* Button styles */
.btn {
display: inline-block;
padding: 0.75rem 1.5rem;
background-color: var(--primary-color);
color: white;
text-decoration: none;
border-radius: var(--border-radius);
font-weight: 600;
transition: var(--transition);
border: none;
cursor: pointer;
text-align: center;
box-shadow: 0 4px 10px rgba(67, 97, 238, 0.3);
}
.btn:hover {
background-color: var(--secondary-color);
transform: translateY(-2px);
box-shadow: 0 6px 15px rgba(67, 97, 238, 0.4);
}
/* Code blocks styling */
.post-content pre {
background-color: #2d2d2d;
color: #f8f8f2;
padding: 1rem;
border-radius: var(--border-radius);
overflow-x: auto;
margin: 1rem 0;
font-size: 0.9rem;
line-height: 1.5;
}
.post-content code {
background-color: #f0f0f0;
padding: 0.2rem 0.4rem;
border-radius: 4px;
font-family: 'Courier New', monospace;
font-size: 0.9em;
}
/* Card hover effect */
.post {
position: relative;
overflow: hidden;
}
.post::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
transition: left 0.5s;
}
.post:hover::before {
left: 100%;
}
/* Scrollbar styling */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
background: var(--primary-color);
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--secondary-color);
}