1
0
mirror of https://github.com/actix/actix-website synced 2025-02-17 10:13:31 +01:00

Improve home page (#305)

* improve landing page

* revert navbar
This commit is contained in:
Ibraheem Ahmed 2023-01-09 04:52:42 -05:00 committed by GitHub
parent 77ef3b62d1
commit 034a6f1890
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 97 additions and 100 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ build/
.docusaurus .docusaurus
.cache-loader .cache-loader
Cargo.lock Cargo.lock
yarn.lock

View File

@ -1,8 +1,8 @@
use actix_web::{web, App, HttpResponse, HttpServer, Responder}; use actix_web::{web, App, HttpResponse, HttpServer, Responder};
use serde::Deserialize; use serde::Deserialize;
// <easy-form-handling>
use actix_web::web::{Either, Json, Form}; use actix_web::web::{Either, Json, Form};
// <easy-form-handling>
#[derive(Deserialize)] #[derive(Deserialize)]
struct Register { struct Register {
username: String, username: String,

View File

@ -1,22 +1,19 @@
// <request-routing> // <request-routing>
use actix_web::{get, web, App, HttpRequest, HttpServer, Responder}; use actix_web::{get, web, App, HttpServer, Responder};
#[get("/")] #[get("/")]
async fn index(_req: HttpRequest) -> impl Responder { async fn index() -> impl Responder {
"Hello from the index page." "Hello, World!"
} }
async fn hello(path: web::Path<String>) -> impl Responder { #[get("/{name}")]
format!("Hello {}!", &path) async fn hello(name: web::Path<String>) -> impl Responder {
format!("Hello {}!", &name)
} }
#[actix_web::main] #[actix_web::main]
async fn main() -> std::io::Result<()> { async fn main() -> std::io::Result<()> {
HttpServer::new(|| { HttpServer::new(|| App::new().service(index).service(hello))
App::new()
.service(index)
.route("/{name}", web::get().to(hello))
})
.bind(("127.0.0.1", 8080))? .bind(("127.0.0.1", 8080))?
.run() .run()
.await .await

View File

@ -22,7 +22,6 @@ const Home = () => {
<Layout description={siteConfig.tagline}> <Layout description={siteConfig.tagline}>
<Hero /> <Hero />
<main className={styles.main}> <main className={styles.main}>
<MainExample />
<Highlights /> <Highlights />
<Examples /> <Examples />
</main> </main>
@ -97,21 +96,13 @@ const Hero = () => {
); );
}; };
const MainExample = () => (
<div className={styles.main_example}>
<div className={styles.main_example__code}>
<CodeBlock example="main-example" section="main-example" />
</div>
</div>
);
const Highlights = () => { const Highlights = () => {
return ( return (
<> <>
<section id="highlights" className={styles.highlights}> <section id="highlights" className={styles.highlights}>
<div className="container"> <div className="container">
<div className="row"> <div className="row">
<div className="col col--11 col--offset-1"> <div className="col">
<div className="row"> <div className="row">
{highlights.map((highlight, idx) => ( {highlights.map((highlight, idx) => (
<div <div
@ -140,8 +131,23 @@ const Highlights = () => {
const Examples = () => { const Examples = () => {
return ( return (
<div> <div className={styles.examples}>
<div className={styles.example}> <div className={styles.example}>
<div className={styles.exampleContent}>
<div className={styles.featureText}>
<h3 className={styles.featureTitle}>Hello World!</h3>
<p>
Getting started with actix is easy. An actix app comes with a URL routing system that lets you match on
URLs and invoke individual handlers.
</p>
</div>
<div className={styles.example__code}>
<CodeBlock example="request-routing" section="request-routing" />
</div>
</div>
</div>
<div className={styles.example}>
<div className={styles.exampleContent}>
<div className={styles.featureText}> <div className={styles.featureText}>
<h3 className={styles.featureTitle}>Flexible Responders</h3> <h3 className={styles.featureTitle}>Flexible Responders</h3>
<p> <p>
@ -157,7 +163,9 @@ const Examples = () => {
/> />
</div> </div>
</div> </div>
</div>
<div className={styles.example}> <div className={styles.example}>
<div className={styles.exampleContent}>
<div className={styles.featureText}> <div className={styles.featureText}>
<h3 className={styles.featureTitle}>Powerful Extractors</h3> <h3 className={styles.featureTitle}>Powerful Extractors</h3>
<p> <p>
@ -175,7 +183,9 @@ const Examples = () => {
/> />
</div> </div>
</div> </div>
</div>
<div className={styles.example}> <div className={styles.example}>
<div className={styles.exampleContent}>
<div className={styles.featureText}> <div className={styles.featureText}>
<h3 className={styles.featureTitle}>Easy Form Handling</h3> <h3 className={styles.featureTitle}>Easy Form Handling</h3>
<p> <p>
@ -190,18 +200,6 @@ const Examples = () => {
/> />
</div> </div>
</div> </div>
<div className={styles.example}>
<div className={styles.featureText}>
<h3 className={styles.featureTitle}>Request Routing</h3>
<p>
An actix app comes with a URL routing system that lets you match on
URLs and invoke individual handlers. For extra flexibility, scopes
can be used.
</p>
</div>
<div className={styles.example__code}>
<CodeBlock example="request-routing" section="request-routing" />
</div>
</div> </div>
</div> </div>
); );

View File

@ -110,28 +110,8 @@
color: var(--ifm-color-emphasis-600); color: var(--ifm-color-emphasis-600);
} }
.main_example {
display: flex;
justify-content: center;
padding-left: 1rem;
padding-right: 1rem;
flex-wrap: wrap;
padding-top: 2rem;
padding-bottom: 2rem;
}
.main_example__code {
width: 100%;
}
@media (min-width: 1024px) {
.main_example__code {
width: unset;
}
}
// features // features
.example { .exampleContent {
display: flex; display: flex;
width: 100%; width: 100%;
flex-direction: column; flex-direction: column;
@ -145,30 +125,51 @@
} }
.example__code { .example__code {
flex: 1;
width: 100%; width: 100%;
} }
.featureText { .featureText {
flex: 1;
justify-self: center; justify-self: center;
padding-bottom: 1rem; padding-bottom: 1rem;
} }
@media (min-width: 1024px) { @media (min-width: 1024px) {
.example { .exampleContent {
flex-direction: row; flex-direction: row;
padding-top: 7rem; padding-top: 7rem;
padding-bottom: 7rem; padding-bottom: 7rem;
max-width: 1280px;
margin: auto;
} }
.example:nth-child(odd) { .example:nth-child(odd) {
flex-direction: row-reverse;
background-color: var(--examples-odd-background-color); background-color: var(--examples-odd-background-color);
.exampleContent {
flex-direction: row-reverse;
.featureText {
padding-right: 0px;
padding-left: 30px;
} }
.example__code {
padding-left: 0px;
padding-right: 30px;
}
}
}
.featureText { .featureText {
width: 33%; width: 33%;
padding-right: 30px;
} }
.example__code { .example__code {
width: unset; width: unset;
padding-left: 30px;
} }
} }