From 7715cdf7aaa941e350e6d9f5808fde9f42ad6ba1 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Mon, 11 May 2026 05:55:01 +0200 Subject: [PATCH] Scrolling --- src/app/(home)/page.tsx | 113 ++++++++++++++++++++++++++++++++++----- src/components/Morph.tsx | 58 ++++++++++++-------- 2 files changed, 136 insertions(+), 35 deletions(-) diff --git a/src/app/(home)/page.tsx b/src/app/(home)/page.tsx index 58fe4f5..2941589 100644 --- a/src/app/(home)/page.tsx +++ b/src/app/(home)/page.tsx @@ -1,24 +1,109 @@ "use client"; import MorphText from "@/components/Morph"; +import { Card } from "fumadocs-ui/components/card"; import { useEffect, useState } from "react"; +export const mistShowcase = [ + { + title: "Hello World", + description: + "Mist starts with familiar syntax, designed to feel immediately readable while compiling into efficient Rust code.", + code: `fn main() { + println("Hello, world!"); +}`, + }, + + { + title: "Rust Compatibility", + description: + "Mist compiles directly into Rust, meaning you can use existing Rust libraries without breaking your workflow.", + code: `use std::fs; + +fn main() { + let data = fs::read_to_string("file.txt"); + println(data); +}`, + }, + + { + title: "Structs", + description: + "Mist keeps Rust’s struct model intact while making declaration more ergonomic.", + code: `struct User { + name: String, + age: int +}`, + }, + + { + title: "Classes (Syntax Sugar)", + description: + "Classes provide a familiar authoring style over Rust structs without introducing a runtime object model.", + code: `class Logger { + String prefix; + + fn info(self, msg: String) { + println(self.prefix + msg); + } +}`, + }, + + { + title: "Inheritance-style Composition", + description: + "Extends provides inheritance-like syntax while compiling down to Rust-style composition.", + code: `struct B extends A { + extra: String +}`, + }, + + { + title: "Zero-cost Abstractions", + description: + "Mist preserves Rust’s performance model — abstractions compile away entirely at runtime.", + code: `fn map(arr: Vec, f: fn(T) -> U) -> Vec { + let mut out = Vec::new(); + for x in arr { + out.push(f(x)); + } + out +}`, + }, + + { + title: "Ecosystem Integration", + description: + "All Rust crates work directly in Mist, keeping the ecosystem fully intact.", + code: `use serde_json::json; + +fn main() { + let data = json!({ "hello": "mist" }); + println(data); +}`, + }, +]; + export default function HomePage() { - const [showNext, setShowNext] = useState(false); - - useEffect(() => { - const timer = setTimeout(() => { - setShowNext(true); - }, 1000); - - return () => clearTimeout(timer); - }, []); - - const text = showNext ? "world hello i32(" : "(hello i32 world"; - return ( -
- +
+
+ {mistShowcase.map((show) => ( +
+

+ {show.title} +

+

{show.description}

+
+ ))} +
+ +
+ +
); } diff --git a/src/components/Morph.tsx b/src/components/Morph.tsx index ef1d83a..c4914bc 100644 --- a/src/components/Morph.tsx +++ b/src/components/Morph.tsx @@ -14,30 +14,46 @@ const tokenize = (str: string) => { }; export default function MorphText({ text }: MorphTextProps) { - const activeTokens = tokenize(text); + const lines = text.split("\n"); // 👈 split by newline return ( -
+
- {activeTokens.map(({ char, id }) => ( - - {char} - - ))} + {lines.map((line, lineIndex) => { + const tokens = tokenize(line); + + // 👇 empty line = real vertical space + if (line === "") { + return ( +
+ ); + } + + return ( +
+ {tokens.map(({ char, id }) => ( + + {char} + + ))} +
+ ); + })}
);