Create HTML, CSS only with Javascript/Typescript

Overview

SwiftUI inspired JS FrameWork BreazeJS

GOAL: Rapidly build modern websites without ever leaving your Javascript/Typescript.

Output

const ContentView: View =  {
        
    section: {
            style:{"gap": "10px", "border": "1px dashed red", height: "100%", "background-color": "lightgray"},
            HStack: [
                {
                    div: {
                        style:{"gap": "10px", "border": "1px solid blue"},
                        VStack: [
                            CounterButtonView({}),
                            ButtonView({text: "Button1", style: {"background-color": "red", "font-family": "Helvetica"} }),          
                            ButtonView({text: "Button2", style: {"background-color": "green"}}), 
                            TextView({text:"How does the fish breath inside of the packaging?"}),
                            UnorderedListView({array: [1,2,3,4,5,6,7,8].map(x=>`element ${x}`), stack:"V"}),
                        ]
                    },
                    
                },
                {
                    div: {
                        style:{ "border": "1px solid green", width:"100px", height: "100px"},
                        ZStack: [
                            ButtonView({text: "Button3", style: {"background-color": "blue"}}),          
                            ButtonView({text: "Button4", style: {"background-color": "yellow", left: "10px", top: "20px"}}), 
                            ButtonView({text: "Button5", style: {"background-color": "yellow", left: "40px", top: "60px"}}), 
                        ]
                    },
                    
                },
                {
                    div: {
                        style:{ "border": "1px dashed gray", gap:"20px"},
                        HStack: [
                            ButtonView({text: "Button5", style: {"background-color": "lightgray"}}),          
                            ButtonView({text: "Button6", style: {"background-color": "orange"}}), 
                            ButtonView({text: "Button7", style: {"background-color": "purple"}}), 
                            ButtonView({text: "Button8", style: {"background-color": "yellow"}}), 
                            ButtonView({text: "Button9", style: {"background-color": "green"}}), 
                            ButtonView({text: "Button10", style: {"background-color": "red"}}), 
                        ]
                    },
                    
                }

            ]
    },

}
const TextView: ViewConstructor = ({text="Empty", click=()=>{ return console.log("text is clicked"); }, style={}}) => {
    
    const defaultStyle = { padding: "5%", "font-family":"Helvetica" , "font-weight": "bold", display: "flex", "align-items":"center", "justify-content":"center", border: "1px solid black" }
    return {
            div: {
                events: { click },
                textContent: text,
                pseudoStyle:{hover: {outline: "10px solid black"}},
                style: {...defaultStyle, ...style}
            }
    }
} 
const UnorderedListView: ViewConstructor = ({array=["Empty"], stack="V",style={}}) => {

    const list = {
        ul: {
            style: {...{ "font-family":"Helvetica" , "font-weight": "bold", border: "1px solid black" }, ...style}
        }
    }
    list.ul[stack.toUpperCase()+"Stack"] = array.map(s => TextView({text: s.toString(), style:{border:"none"}}))
    return list 
} 
const CounterButtonView: ViewConstructor = ({start=0, style={}}) => {
    
    const defaultStyle = { padding: "5%", "background-color": "blue", display: "flex", border: "2px solid red" }
    const view = {

               div: {
                    style: {border: "1px solid black"},
                    pseudoStyle:{hover: {outline: "10px solid green"}},
                    VStack: [
                        { h1: { textContent: "Counter", style: {"font-weght": "bold"}} },
                        { button: {
                                textContent: start.toString(),
                                style: {...defaultStyle, ...style},
                                events: {
                                            click: (el: HTMLElement, event: EventType)=>{
                                                    let count =  parseInt(el.textContent)
                                                    el.textContent = `${count+1}`;
                                                    console.log(event)
                             },
                            }
                        }}
                    ]
               }
    }

  
const ButtonView: ViewConstructor = ({text="Button", click=()=>{ return console.log("button is pressed"); }, style={}}) => {

    return {
            button: {
                events: { click },
                textContent: text,
                style: {...{ padding: "5%", "background-color": "blue", display: "flex", border: "2px solid red" }, ...style},
                pseudoStyle:{
                    hover:{ outline: "3px solid black"}
                }
            }
    }
} 
You might also like...

This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js

This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js. But in most cases, I would recommend you to use something like Express in a production project for productivity purposes.

Jul 19, 2022

Easily create key board shortcuts for your JS functions. Built using JS only with no other dependency. Inspired from MacOS spotlight

floodlightjs Inspired from macOS spotlight, floodlight is simple JS library that will show a search area. How the search is handled is completely on y

Aug 12, 2022

Quickly create an interactive HTML mock-up by auto sourcing lorem ipsum/images generators, with minimal html markup, and no server side code

RoughDraft.js v0.1.5 Quickly mockup / prototype HTML pages with auto-generated content, without additional JavaScript or server side code. section

Dec 21, 2022

This is my to-do list website built with html, css and JavaScript. In this project I used Webpack to bundle JavaScript and ES6 modules to write modular JavaScript.

This is my to-do list website built with html, css and JavaScript. In this project I used Webpack to bundle JavaScript and ES6 modules to write modular JavaScript.

To-Do-List App This is my to-do list website built with html, css and JavaScript. In this project I used Webpack to bundle JavaScript and ES6 modules

Sep 20, 2022

Tooltip using only CSS and very low build size.

Tooltip using only CSS and very low build size.

css-only-tooltip A very lightweight tooltip utitlity library, made using only CSS with dynamic light and dark themes. Insatallation Using npm $ npm in

Dec 11, 2022

A jQuery plugin that works in harmony with animate.css in order to enable animations only when content comes into view.

jQuery AniView A jQuery plugin that works in harmony with animate.css in order to enable animations only when content comes into view. Now supports v4

Sep 10, 2022

Simple and flexible, css only, content placeholder loading animation.

Simple and flexible, css only, content placeholder loading animation.

Placeholder loading Simple and flexible, css only, content placeholder loading animation. Demo https://zalog.github.io/placeholder-loading/ Take a loo

Dec 30, 2022

CSS only library to apply color filters.

CSS only library to apply color filters.

filters.css CSS only library to apply color filters. See the full documentation Features Only CSS. No JavaScript! ~1KB minified and gzipped! Supports

Dec 17, 2022

🧩 TypeScript utility type in order to ensure to return only properties (not methods) containing values in primitive types such as number or boolean (not Value Objects)

🧩 TypeScript utility type in order to ensure to return only properties (not methods) containing values in primitive types such as number or boolean (not Value Objects)

🧩 TypeScript Primitives type TypeScript utility type in order to ensure to return only properties (not methods) containing values in primitive types

Dec 7, 2022
Owner
羅文生
Projects code relating to A.I and software development
羅文生
🌈 GitHub following, followers, only-following, only-follower tracker 🌈

github-following-tracker GitHub following, followers, only-following, only-follower tracker ?? Just enter your GitHub name and track your followings!

Youngkwon Kim 10 Jun 15, 2022
advanced calculator using only HTML, CSS and JS

Welcome to GitHub Pages You can use the editor on GitHub to maintain and preview the content for your website in Markdown files. Whenever you commit t

null 9 May 14, 2022
TypeScript CLI for creating HTML & CSS & TypeScript project with different bundlers, v2022.10.23 is ready on NPM

TSCI CLI TypeScript CLI for creating HTML & CSS & TypeScript project with different bundlers. Installation npm i -g tsci Usage Want to contribute? You

Samet ÇELİKBIÇAK 7 Dec 14, 2022
Clinton Mbonu 20 Jun 30, 2022
This website utilizes JavaScript, HTML, and CSS to allow the user to create a to-do list that they can add to, remove from, and edit.

todo Description the project. "To-do list" is a tool that helps to organize your day. It simply lists the things that you need to do and allows you to

Emily Robertson 8 Jul 23, 2022
Create HTML from CSS! A modern javascript library you'd expect Facebook to invent.

Create HTML from CSS! A modern javascript library you'd expect Facebook to invent. Slowly build modern websites without ever leaving your CSS, with HeadwindHTML

Gökhan Mete ERTÜRK 282 Dec 30, 2022
It is an app that allows you to create lists of books and authors made in the course of Microverse. This project was develop using JavaScript, HTML and CSS.

AWESOME BOOKS This is an Awesome book store project that add store and diplay books on the UI. Built With HTML,CSS, JavaScript Frameworks Github, Lint

JUSTINE IMASIKU 5 Jul 28, 2022
In this project, I implement a Simple To Do List with the CRUD (create, read, update, delete) methods. I followed the JavaScript, CSS, HTML, DRY, KISS and YAGNI Best practices.

To Do list: add & remove In this project, I implement a Simple To Do List with the CRUD (create, read, update, delete) methods. All the elements of th

Olivier 6 Nov 20, 2022
Tumaini Maganiko 7 May 9, 2023
A (very) minimalist creative coding playground. Make animations using only 64 HTML sliders!

Sliderland A (very) minimalist creative coding playground. Make animations using only 64 HTML sliders! Credits The recording feature uses ffmpeg.wasm

null 181 Dec 30, 2022