Skip to content

Commit

Permalink
[enhancement] happyx hello world
Browse files Browse the repository at this point in the history
  • Loading branch information
Keisuke Izumiya committed Dec 11, 2023
1 parent dc94d03 commit 473486e
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 18 deletions.
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Nim
/nimcache/
/testresults/
/outputGotten.txt
Expand All @@ -7,16 +8,25 @@
/tests/*/*
!/tests/*/main.nim

# Documentation
/src/htmldocs/

# Karax
/www/assets/
/www/index.js
/www/index.min.js
/www/worker.js
/www/worker.min.js

# Binary
/pon2
/pon2.exe

# Benchmark
/benchmark/*
!/benchmark/*.nim*
!/benchmark/*.nim*

# HappyX
/src/assets/
/src/pon2.js
/www-happyx/
8 changes: 8 additions & 0 deletions happyx.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Main]
projectName = pon2
projectType = SPA
mainFile = pon2
srcDir = src
buildDir = www-happyx
assetsDir = assets
language = nim
31 changes: 21 additions & 10 deletions pon2.nimble
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# Package

version = "0.7.0"
author = "Keisuke Izumiya"
description = "Puyo Puyo Library"
license = "Apache-2.0 OR MPL-2.0"
version = "0.7.0"
author = "Keisuke Izumiya"
description = "Puyo Puyo Library"
license = "Apache-2.0"

srcDir = "src"
installExt = @["nim"]
bin = @["pon2"]
srcDir = "src"
installExt = @["nim"]
bin = @["pon2"]


# Dependencies

requires "nim ^= 2.0.0"

requires "docopt ^= 0.7.1"
requires "happyx ^= 3.5.2"
requires "karax ^= 1.3.3"
requires "nigui ^= 0.2.7"
requires "nimsimd ^= 1.2.6"
Expand All @@ -40,10 +41,10 @@ task benchmark, "Benchmarking":
exec &"nim c -r -d:avx2={avx2} -d:bmi2={bmi2} benchmark/main.nim"

task documentation, "Make Documentation":
exec &"nim doc --project -d:avx2=true src/pon2.nim"
exec &"nim doc --project -d:avx2=true src/pon2.nim"
mvDir "src/htmldocs", "src/htmldocs2"

exec &"nim doc --project -d:avx2=false src/pon2.nim"
exec &"nim doc --project -d:avx2=false src/pon2.nim"
exec "cp -r src/htmldocs2 src/htmldocs"
rmDir "src/htmldocs2"

Expand All @@ -64,4 +65,14 @@ task web, "Make Web Page":
"cp www/index.js www/index.min.js"
exec cmd

exec "cp -r assets www"
exec "cp -r assets www"

task happyx, "HappyX":
cpDir "assets", "src/assets"
try:
exec "hpx build"
except OSError:
cpFile "src/index.html", "www-happyx/index.html"
cpFile "src/pon2.js", "www-happyx/pon2.js"
cpDir "src/assets", "www-happyx/public"
rmDir "www-happyx/assets"
25 changes: 25 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang='ja'>

<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<title>Pon!通</title>
<style>
html {
touch-action: manipulation;
}
</style>
<link href='./public/fontawesome/css/fontawesome.min.css' rel='stylesheet'>
<link href='./public/fontawesome/css/brands.min.css' rel='stylesheet'>
<link href='./public/fontawesome/css/solid.min.css' rel='stylesheet'>
<link href='https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css' rel='stylesheet'>
</head>

<body>
<div id='pon2'></div>
<script src='./pon2.js'></script>
<script src='https://html2canvas.hertzen.com/dist/html2canvas.min.js'></script>
</body>

</html>
21 changes: 14 additions & 7 deletions src/pon2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@

{.experimental: "strictDefs".}

#[
import happyx
import ./pon2pkg/private/simulator/components/[hello]
appRoutes "pon2":
"/":
component Hello
]#

when defined(js):
import std/[options, sequtils, uri]
import karax/[karax, karaxdsl, vdom]
Expand Down Expand Up @@ -132,7 +141,7 @@ else:
return none GenerateRequirementColor
{.pop.}

if idx.get notin GenerateRequirementColor.low.ord..
if idx.get notin GenerateRequirementColor.low.ord ..
GenerateRequirementColor.high.ord:
raise newException(ValueError, "クリア条件の色を表す整数が不適切な値です.")

Expand Down Expand Up @@ -206,12 +215,10 @@ else:
kind = args["--rk"].parseRequirementKind.get
req = GenerateRequirement(
kind: kind,
color: (
if kind in ColorKinds: args["--rc"].parseGenerateRequirementColor
else: none GenerateRequirementColor),
number: (
if kind in NumberKinds: args["--rn"].parseRequirementNumber
else: none RequirementNumber))
color: (if kind in ColorKinds: args[
"--rc"].parseGenerateRequirementColor else: none GenerateRequirementColor),
number: (if kind in NumberKinds: args[
"--rn"].parseRequirementNumber else: none RequirementNumber))
{.pop.}

# heights
Expand Down
8 changes: 8 additions & 0 deletions src/pon2pkg/private/simulator/components/hello.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import happyx

component Hello:
`template`:
tDiv(class = "someClass"):
"hello"
`script`:
echo "echo script"

0 comments on commit 473486e

Please sign in to comment.