Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethosa committed May 11, 2024
0 parents commit a5d3579
Show file tree
Hide file tree
Showing 14 changed files with 265 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.nim]
indent_style = space
indent_size = 2
77 changes: 77 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Testing 👨‍🔬

on:
push:
branches:
- 'master'
- 'dev'
paths-ignore:
- 'docs/**'
- '.github/ISSUE_TEMPLATE/*'
- '*.md'
- '*.nimble'
- '.gitignore'
- 'LICENSE'
pull_request:
paths-ignore:
- 'docs/**'
- '.github/ISSUE_TEMPLATE/*'
- '*.md'
- '*.nimble'
- '.gitignore'
- 'LICENSE'

jobs:
dependencies:
name: Install dependencies 🧩
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
nim_version:
- '2.0.0'
- '2.0.4'
env:
TIMEOUT_EXIT_STATUS: 124
steps:
- uses: actions/checkout@v4
- uses: jiro4989/setup-nim-action@v1
with:
nim-version: ${{ matrix.nim_version }}
- uses: actions/cache@v4
with:
path: |
~/.nimble
~/.choosenim
key: ${{ runner.os }}-nimble-${{ hashFiles('*.nimble') }}
- name: Install Dependencies 🔃
run: |
nimble refresh
nimble install -y -d
js:
name: Test with JavaScript 🧪
needs: dependencies
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
env:
TIMEOUT_EXIT_STATUS: 124
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.nimble
~/.choosenim
key: ${{ runner.os }}-nimble-${{ hashFiles('*.nimble') }}
- name: Build JS tests 🍍
run: |
cd tests
for file in $(ls -v testjs*.nim); do
echo "###===--- JS Test for " $file " ---===###"
/home/runner/.nimble/bin/nim js -d:debug --hints:off --warnings:off $file
done
shell: bash
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# IDE
.idea/
.vs-code/
.vscode/
.vs/

# Cache
nimcache/
nimble/
htmldocs/

# builded
**/build/
happyx_ui_linkerArgs.txt

# Logs
*.log

# Compiled
*.js
*.exe
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 HapticX

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div align="center">

# HappyX-UI
### HappyX UI library

</div>



12 changes: 12 additions & 0 deletions happyx_ui.nimble
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Package

description = "UI library for HappyX web framework"
author = "HapticX"
version = "1.0.0"
license = "MIT"
srcDir = "src"

# Deps

requires "nim >= 1.6.14"
requires "happyx >= 3.10.2"
10 changes: 10 additions & 0 deletions src/happyx_ui.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import
happyx_ui/[
core, column, button
]


export
core,
column,
button
41 changes: 41 additions & 0 deletions src/happyx_ui/button.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import
happyx,
./colors


type
ButtonAction* = proc(): void
const defaultButtonAction = proc() = discard


component Button:
action: ButtonAction = defaultButtonAction

html:
tButton:
slot
@click:
self.action()

`style`: """
button {
border-radius: .4rem;
border: 0 solid transparent;
cursor: pointer;
background-color: <PRIMARY_COLOR>;
padding: .5rem 1rem;
outline: none;
transition: all;
transition-duration: .3s;
color: <BACKGROUND_COLOR>;
font-weight: 700;
}
button:hover {
background-color: <PRIMARY_HOVER_COLOR>;
}
button:active {
background-color: <PRIMARY_ACTIVE_COLOR>;
}
"""
10 changes: 10 additions & 0 deletions src/happyx_ui/colors.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var
PRIMARY_COLOR* = "#d56c6c"
PRIMARY_HOVER_COLOR* = "#e26969"
PRIMARY_ACTIVE_COLOR* = "#ec6f6f"
FOREGROUND_COLOR* = "#f1dcc1"
FOREGROUND_HOVER_COLOR* = "#dfccb4"
FOREGROUND_ACTIVE_COLOR* = "#d4c1ab"
BACKGROUND_COLOR* = "#141d1f"
BACKGROUND_HOVER_COLOR* = "#182225"
BACKGROUND_ACTIVE_COLOR* = "#1c282b"
17 changes: 17 additions & 0 deletions src/happyx_ui/column.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import happyx


component Column:
spacing: string = "0"

html:
tDiv(class = "column"):
slot

`style`: """
div.column {
display: flex;
flex-direction: column;
gap: <self.spacing>;
}
"""
5 changes: 5 additions & 0 deletions src/happyx_ui/core.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
proc px*(val: SomeNumber): string = $val.float & "px"
proc em*(val: SomeNumber): string = $val.float & "em"
proc rem*(val: SomeNumber): string = $val.float & "rem"
proc vw*(val: int): string = $val & "vw"
proc vh*(val: int): string = $val & "vh"
18 changes: 18 additions & 0 deletions tests/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<title>HappyX UI library</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Comfortaa:[email protected]&display=swap');
* {
font-family: "Comfortaa", sans-serif;
font-optical-sizing: auto;
font-style: normal;
}
</style>
</head>
<body>
<div id="app"></div>
<script src="test.js"></script>
</body>
</html>
14 changes: 14 additions & 0 deletions tests/test.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import
happyx,
happyx_ui


appRoutes "app":
"/":
tDiv:
Column(1.em):
Button(
proc() =
echo "Hello, world!"
):
"Hello, world!"
1 change: 1 addition & 0 deletions tests/test.nim.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--path:"../src"

0 comments on commit a5d3579

Please sign in to comment.