Code Monkey home page Code Monkey logo

css-everything's Introduction


A ui framework where you only write turing complete CSS. No HTML, no JS, no build system.

Disclaimer: Don't use this

Usage

Add script tag to the renderer to your html

<script async defer src="https://unpkg.com/@css-everything/render/dist/renderer/index.js"></script>

Open up a style tag or link a stylesheet

The renderer by default uses the body element. You can use :root to describe the starting point. Here's a simple counter example:

:root {
  --counter: '0';
  --cssx-children: div#count button#decr button#incr;
}

#count::after { content: "Count: " var(--counter); }

#incr {
  --cssx-on-click: update(':root', --counter, calc(get-var(--counter) + 1));
  --cssx-text: "++";
}
#decr {
  --cssx-on-click: update(':root', --counter, calc(get-var(--counter) - 1));
  --cssx-text: "--";
}

More examples

Here are a few live examples for you to try out -

Docs


Frequently Acquisitioned Queries

Why?

Why not?

What?

What?

What time is it?

You can find the answer with this example.

How does it work?

Here's how it works.

Is this turing complete?

Yep. Not that you asked, but here's how to calculate factorial of a number.

:root { --cssx-children: div#container; }

#container {
  --factorial: func(--n: number)
    if(lte(get-var(--n), 1), 1,
      calc(
        get-var(--n)
        * call(--factorial, map(--n: calc(get-var(--n) - 1)))
      ));

  --cssx-text: string("7! = ", call(--factorial, map(--n: 7)));
}

Escape hatches?

  • If you want to directly render some raw html, you can use --cssx-disgustingly-set-innerhtml.
  • If you want to run js expressions, you can use the js-eval function. Eg: js-eval("new Date().getSeconds()")

Does it need a build step?

No. In fact, this'll probably break if you try to use it with a css preprocessor.

css-everything's People

Contributors

phenax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

css-everything's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.