• Stars
    star
    757
  • Rank 58,112 (Top 2 %)
  • Language
    Nim
  • License
    MIT License
  • Created over 5 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Figma based UI library for nim, with HTML and OpenGL backends.

πŸ‘ πŸ‘ πŸ‘ Check out video about the library: Fidget: Let's rethink UI development with Nim (NimConf 2020) πŸ‘ πŸ‘ πŸ‘

⚠️ WARNING: This library is still in heavy development. ⚠️

Fidget - A cross platform UI library for nim

nimble install fidget

Github Actions

API reference

About

Fidget aims to provide performant natively compiled cross platform UIs for any platform - Web with HTML5, Windows, macOS, Linux, iOS and Android with OpenGL.

Fidget leverages Figma - an app that is taking the design world by storm. It does this by providing a Figma Plugin to export directly to fidget code! No more counting stupid pixels, no more CSS puzzles. Want to change some spaces? Change it in Figma and export.

Fidget uses plain nim-procs, nim-templates, if-statements and for-loops. As well as providing only minimal primitives found in Figma.

Example:


Design done by Kate von Houck. Available for hire.

See code here: examples/demo/demo.nim

Minimal Sample:

import fidget, vmath

proc drawMain() =
  frame "main":
    box 0, 0, 620, 140
    for i in 0 .. 4:
      group "block":
        box 20+i*120, 20, 100, 100
        fill "#2B9FEA"

windowFrame = vec2(620, 140)
startFidget(drawMain)


See code here: examples/minimal/minimal.nim

Backends

Fidget has several backends that are planned:

  • HTML (best supported)
  • Windows (next best support)
  • Mac (less support)
  • Linux (less support)
  • iOS (proof of concept only)
  • Android (proof of concept only)

Philosophy - Minimalism

  • Mimic how Figma (Amazing UI/UX app) does it.
  • Everything is a Node.
  • There are Group, Rectangle, Image and Text Nodes.
  • Nodes are positions relative to the parent
  • Nodes have minimal set of properties that match Figma.
  • Resizing is done same way as Fimga's Constraints.
  • Layout is done same way as Figma's Auto Layout.

The main idea of fidget is to use standard imperative nim paradigms like nim-procs, nim-for-loops, nim-ifs, nim-templates instead of say providing a custom language, XML templates, HTML, Jinja templates, CSS ...

Instead of creating CSS classes you just create a nim proc or a nim template with the things you want and reuse that. Instead of having some sort of list controller you just use a for loop to position your list elements.

There are very little UI layout primitives just align left, center, right, both, or scale for the X axis and top, center, bottom, both, or scale for the Y axis. There is none of margin, padding, float, absolute, relative, border box, flex, recycle view controllers, stack layout, constraints ...

If you want to do something fancy just do a little math. Many times a simple math formula is smaller, simpler, and easier to figure out then layout puzzles.

Why Nim?

Nim is a great languages because it’s easy on the eyes like Python, but typed and is performant as C. It can also compile to JavaScript, C, C++, ObjC. Nim is a great language for UI design because it has advanced templates and macros can make a really good DSL (domain specific language) - that makes writing UIs straightforward, intuitive and crossplatform.

Imperative UI Style

I like imperative style of programming. This is a style you probably learned to program at the start, but was forced to abandon with more complex and ill fitting object oriented style. Imperative style to me means when you are only using functions, if-statements and for-loops. Imperative style to me means simple data structures of structs, lists and tables. Simple functions that read from top to bottom with as few branches as possible.

Each UI frame is drawn completely from start to finish all in the code you control. Use of callbacks is discouraged. Think liner, think simple. After any event by the user, data or timer, the UI is redrawn. The UI is redrawn in an efficient way as to allow this. With HTML a modification cache is used to ensure only a minimal amount of DOM changes are needed. With OpenGL you redraw the whole screen using as few state transitions and batching everything into a texture atlas and single global vertex buffer.

How to run the examples:

git clone https://github.com/treeform/fidget
cd fidget
nimble install
cd examples/minimal
nim c -r minimal

Native examples for Windows, macOS, and Linux:

First cd to each folder then compile and run.

nim c -r bars.nim
nim c -r hovers.nim
nim c -r inputs.nim
nim c -r padoftext.nim
nim c -r padofcode.nim
nim c -r basic.nim

Runs the same examples as HTML:

First cd to each folder then run js compile command then open the .html file in a browser.

nim js bars.nim
nim js hovers.nim
nim js inputs.nim
nim js padoftext.nim
nim js padofcode.nim
nim js basic.nim

Run all tests and save a screenshot

nim c -r tests/run --compile --native --testOneFrame

Figma Plug

To compile the figma plug run TypeScript in the figma_plugin folder.

tsc

Then go to figma and add a development plugin from this folder.

More Repositories

1

pixie

Full-featured 2d graphics library for Nim.
Nim
726
star
2

ws

Simple WebSocket library for Nim.
Nim
254
star
3

jsony

A loose, direct to object json parser with hooks.
Nim
254
star
4

genny

Generate a shared library and bindings for many languages.
Nim
219
star
5

puppy

Puppy fetches via HTTP and HTTPS
Nim
181
star
6

typography

Fonts, Typesetting and Rasterization.
Nim
152
star
7

shady

Nim to GPU shader language compiler and supporting utilities.
Nim
141
star
8

netty

Netty - reliable UDP connection library for games in Nim.
Nim
120
star
9

windy

Windowing library for Nim using OS native APIs.
Nim
110
star
10

nimtemplate

You can use this Nim template to jump start your Nim library or project.
Nim
107
star
11

print

Print is a set of pretty print macros, useful for print-debugging.
Nim
104
star
12

chroma

Everything you want to do with colors, in Nim.
Nim
103
star
13

boxy

2D GPU rendering with a tiling atlas.
Nim
101
star
14

vmath

Math vector library for graphical things.
Nim
91
star
15

pixie-python

Full-featured 2D graphics library for Python.
Python
90
star
16

flatty

Flatty - tools and serializer for plain flat binary files.
Nim
86
star
17

chrono

Chrono a Timestamps, Calendars, and Timezones library for nim.
Nim
79
star
18

nim_emscripten_tutorial

Nim emscripten tutorial.
JavaScript
78
star
19

spacy

Spatial data structures for Nim.
Nim
68
star
20

flippy

Flippy is a simple 2d image and drawing library.
Nim
60
star
21

debby

Database ORM layer for Nim
Nim
55
star
22

benchy

Benchmarking.
Nim
52
star
23

orbits

Orbits - orbital mechanics library for nim.
Nim
49
star
24

urlly

URL and URI parsing for Nim for C/JS backends. Similar api to browsers's window.location.
Nim
47
star
25

steganography

Steganography - hide data inside an image.
Nim
45
star
26

hottie

Sampling profiler that finds hot paths in your code.
Nim
43
star
27

thready

Alternative Interface for threads in Nim.
Nim
42
star
28

pretty

Pretty printer for Nim used for debugging.
Nim
42
star
29

webby

Web utilities - HTTP headers, query parsing etc
Nim
41
star
30

bumpy

2d collision library for Nim.
Nim
39
star
31

slappy

3d sound api for nim.
C
38
star
32

glfm

Wrapper of GLFM (OpenGL ES and input for iOS and Android) library for Nim.
Nim
37
star
33

pg

Very simple PostgreSQL async api for nim.
Nim
37
star
34

greenlet

Greenlet - Coroutines library for nim similar to python's greenlet.
C
34
star
35

pixiebook

Nim
33
star
36

googleapi

GoogleAPI access from nim.
Nim
33
star
37

word2vec

Word2vec implemented in nim.
Nim
30
star
38

dumpincludes

See where your exe size comes from.
Nim
30
star
39

guardmons

Collection of nim shell utilities and libraries.
Nim
30
star
40

llama2.nim

Inference Llama 2 in pure Nim
Nim
29
star
41

asyncssh

SSH and run commands on other servers asynchronously for Nim.
Nim
25
star
42

steamworks

Nim bindings to steamworks, valve's steam sdk.
Nim
25
star
43

sysinfo

Cross-platform way to find common system resources like, os, os version, machine name, cpu stats...
Nim
24
star
44

taggy

Everything to do with HTML and XML.
Nim
23
star
45

nimdocs

Automatic Nim document generator.
Nim
23
star
46

morepretty

Morepretty - like nimpretty but with more stuff.
Nim
22
star
47

icons2font

This utility takes vector icons in svg format and convert them to icon fonts (svg,ttf,waff,eot) to be display in all browsers.
Python
21
star
48

forematics

Formatics - Metamath verifier written in Nim.
Nim
19
star
49

globby

Glob pattern matching for Nim.
Nim
18
star
50

tabby

Direct to object CSV/TSV/tabulated data parser with hooks.
Nim
18
star
51

simple-fps

simple fps demo for panda3d
16
star
52

obj2egg

converts obj to egg format for panda3d
16
star
53

openal

An OpenAL wrapper for nim.
Nim
15
star
54

hobby

Treeform's hobby is to create Nim libraries that end with y.
14
star
55

nimby

Nimby is a very simple and unofficial package manager for nim language.
Nim
14
star
56

encode

Encode/decode utf8 utf16 and utf32.
Nim
13
star
57

miniz

Miniz wrapper for nim.
C
13
star
58

ptest

Print-testing for nim.
Nim
12
star
59

bitty

Tightly packed 1d and 2d bit arrays.
Nim
12
star
60

mddoc

Generated Nim's API docs in markdown for github's README.md files. Great for small libraries with simple APIs.
Nim
12
star
61

quickcairo

Nim Cairo bindings
Nim
11
star
62

digitalocean

Wrapper for DigitalOcean HTTP API.
Nim
10
star
63

useragents

User Agent parser for nim.
Nim
9
star
64

webkit2.net

My take on embedded webkit for .net (based on open-webkit-sharp, which is based on webkit.net)
JavaScript
8
star
65

statistics

Common and uncommon statistical functions for Nim.
Nim
8
star
66

jsutils

A library for nim that makes working with JS easier.
Nim
7
star
67

vt100terminal

Terminal VT100 emulation in pure Nim.
Nim
7
star
68

ssh

Connect to machines over SSH and run commands there from nim.
Nim
7
star
69

proffy

Profiler for nim.
Nim
6
star
70

mpeg

Nim wrapper for pl_mpeg single header mpeg library.
C
6
star
71

onecup

Plain coffee script HTML templeting library.
CoffeeScript
6
star
72

supreme-tictactoe

Multi player tick tack toe web game using tornado, JQuery, and Jinja.
Python
5
star
73

panda3d-CSM

panda3d's cascading shadowmaps sample thing
Python
5
star
74

meshDrawer

explains mesh Drawer element to panda3d folks
Python
5
star
75

istrolid-bugs

Official Istrolid Bug Tracking
4
star
76

freefrontfinder

A file that maps font names to where you can download them.
Nim
4
star
77

fidgetfonts

Collection of fonts that might be useful with fidget.
4
star
78

pystorm

pystrom is a python to javascript compiler based on Niall McCarroll's py2js released under MIT licence.
Python
4
star
79

asterisk

Web based code editor.
CoffeeScript
3
star
80

re.edit

Simple web editor based on Code Mirror
CoffeeScript
3
star
81

consfyre

HTML5 2d spaceship building and flying game.
JavaScript
3
star
82

treescript

LISP like language that compiles to javascript.
JavaScript
3
star
83

panda3d-sample-models

I hope to come up with some nice models to use for panda3d
3
star
84

mysqler

a better command line client for mysql to replace the "the MySQL command-line tool"
Python
2
star
85

ddbase

Very dumb disk key-value store.
Python
2
star
86

Atomic4

May 10, 2004 - My first cool project.
Assembly
2
star
87

Re-edit

Client-server, in browser, code editor based on concept of shifting "boards"
Python
2
star
88

Java-Doc-Test

Simple implementation of Doc Tests for Java using Bean Shell
2
star
89

zlibstatic

Zlib Static - statically link zlib for nim.
C
2
star
90

randcss

Generates a random CSS/HTML layout and style
2
star
91

basic-coffee-2d-html5-game-starter

for what you want to start a project with coffee quickly
2
star
92

eggOctree

eggOctree script for panda3d
2
star
93

treeterm

clone of ajaxterm and some changes
1
star
94

libuv

nimuv is libuv dynamic bind for nim.
C
1
star
95

nimbench

Set of nim benchmarks.
JavaScript
1
star
96

new-ajaxterm

My fork of ajaxterm.
Python
1
star
97

orekit

Fork of a free low-level space dynamics library: https://www.orekit.org/
Java
1
star
98

strapless

easy coffeescript dynamic HTML MVC
JavaScript
1
star
99

Java-Forms

Django-like "forms" implementation for java
1
star
100

panda3dmanual

converting panda3d manual from wiki-html mess into nice RST format
1
star