5 releases

0.2.22 Oct 18, 2024
0.2.21 Oct 18, 2024
0.1.1 Oct 17, 2024

#1766 in Web programming

ISC license

73KB

BasiCss

A CSS framework insipred by Tailwind CSS.

Attention

This project is still in development, use it with another CSS file to complement it for now, i will try to do frequent updates! But, for now, Enjoy! Feel free to tell me if you find any problem with the README, i will try to update it for other http frameworks as well.

Usage

With tiny_http

main.rs

use tiny_http::{Server, Request, Response};
// import the module
use basi_css::serve_css;

fn main() {
    // We create the server
    let server = Server::http("127.0.0.1:8080").unwrap();
    println!("Server started at http://127.0.0.1:8080");

    for request in server.incoming_requests() {
        // If the request is for the css file, we serve it
        if request.url() == "/css/basicss.css" {
            let response = serve_css(request);
            server.respond(response).unwrap();
        } else {
            // Otherwise, we respond with a 404 error.
            server.respond(Response::from_string("404 Not Found".to_string())).unwrap();
        }
    }
}

index.html

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="/css/basicss.css">
</head>
<body>
    <nav class="navbar navbar-dark"></nav>
    <main class="width-100-percents height-100-percents flex justify-center width-100-percents flex-column" >
        <h1>Hello, World!</h1>
    </main>
    <footer class="footer footer-dark"></footer>
</body>
</html>

Result

example.png

Dependencies

~380KB