UNPKG

4.83 kBMarkdownView Raw
1<p align="center">
2 <a href="https://imba.io">
3 <img height=128 src="https://raw.githubusercontent.com/imba/branding-imba/master/yellow-wing-logo/imba.svg">
4 <h1 align="center">Imba</h1>
5 </a>
6</p>
7
8<p align="center">
9 <a target="_blank" href="https://discord.gg/mkcbkRw">
10 <img src="https://img.shields.io/discord/682180555286380545?color=7289DA&label=%23imba&logo=discord&logoColor=white">
11 </a>
12 <a target="_blank" href="https://www.npmjs.com/package/imba">
13 <img src="https://img.shields.io/npm/dm/imba.svg">
14 </a>
15 <a target="_blank" href="http://makeapullrequest.com">
16 <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg">
17 </a>
18 <a target="_blank" href="https://www.npmjs.com/package/imba">
19 <img src="https://img.shields.io/npm/l/imba.svg">
20 </a>
21</p>
22
23Imba is a friendly full-stack programming language for the web that
24compiles to performant JavaScript. It has language-level support for
25defining, extending, subclassing, instantiating and rendering DOM
26nodes.
27
28## Get started
29
30Try Imba instantly in your browser with our
31[playground](https://imba.io/try/examples/apps/playground/app.imba),
32or create a new project with:
33
34```sh
35npx imba create
36```
37
38## Documentation
39
40To get started with Imba, we recommend reading through the [official guide](https://imba.io/).
41
42## Why Imba?
43
44### Minimal syntax
45
46Imba's syntax is minimal, beautiful, and packed with clever features. It combines logic, markup and styling in a powerful way. Fewer keystrokes and less switching files mean you'll be able to build things fast.
47
48```imba
49import './util/reset.css'
50
51global css html,body m:0 p:0 w:100% h:100%
52
53tag login-form < form
54
55 css input rd:md bc:gray3 h:20px fs:md
56 css button rd:md c:white bg:gray4 @hover:blue4
57
58 <self @submit.prevent=api.login(name,secret)>
59 <input.username type='text' bind=name>
60 <input.password type='password' bind=secret>
61 <button> "Login as {name}"
62
63imba.mount <login-form[pos:abs d:grid ja:center]>
64```
65
66### Runs on both server and client
67
68Imba powers both the frontend and the backend of Scrimba.com, our learning platform with 100K+ monthly active users. On the frontend, Imba replaces e.g., Vue or React, and on the backend, it works with the Node ecosystem (e.g., npm).
69
70```imba
71import express from 'express'
72import services from './services.ts'
73import html from './index.html'
74import image from './confused-cat.png'
75
76const app = express!
77
78app.get '/404' do (req,res)
79 res.send String <html> <body>
80 <img src=image>
81 <h1> "We could not find this page!"
82
83app.get '/' do (req,res)
84 res.send html.body
85```
86
87### Integrated styling
88
89Inspired by Tailwind, Imba brings styles directly into your code. Styles can be scoped to files, components, and even parts of your tag trees. Style modifiers like @hover, @lg, @landscape and @dark can be used for extremely concise yet powerful styling.
90
91```imba
92# global styles
93global css button
94 position: relative
95 display: block
96 background: #b2f5ea
97 @hover background: #b2f9ea
98
99# tailwind-inspired shorthands
100global css button
101 pos:relative d:block bg:blue5 bg@hover:blue6
102
103tag App
104 # scoped styles
105 css item bg:blue4 m:2
106
107 <self[d:grid pos:relative]> # inline styles
108 <ul> for {type,title} in items
109 <li.item is-{type}> title
110```
111
112### Blazing fast, Zero config
113
114Imba comes with a built-in bundler based on the blazing fast esbuild. Import stylesheets, images, typescript, html, workers and more without any configuration. Bundling is so fast that there is no difference between production and development mode - it all happens on-demand.
115
116```imba
117# importing a worker
118const worker = import.worker './analyzer'
119const analyzer = new Worker(worker.url)
120# import an image
121const logo = import './images/logo.png'
122console.log "logo size: {logo.width}x{logo.height} - at {logo.url}"
123```
124
125When you run your app with the `imba` command, it automatically bundles and compiles your imba code, along with typescript, css and many other file types. It provides automatic reloading of both the server and client.
126
127### Typing and tooling
128
129The tooling is implemented as a typescript server plugin giving us great intellisense, diagnostics, and even cross-file refactorings that works with js/ts files in the same project. You can import types just like in typescript, and annotate variables, parameters and expressions. Like the language, the tooling is still in alpha, but improving every day.
130
131```imba
132import type { CookieOptions } from 'express-serve-static-core'
133
134def flash res\Response, body\string, settings = {}
135 let options\CookieOptions = {
136 ...settings
137 maxAge: 86400
138 secure: true
139 httpOnly: false
140 }
141
142 res.cookie('flash',body,options)
143```
144
145## Community
146
147For questions and support, please use our community chat on
148[Discord](https://discord.gg/mkcbkRw).
149
150## License
151
152[MIT](./LICENSE)
153
154Copyright (c) 2015-present, Sindre Aarsaether