mirror of
https://git.tesses.org/tesses50/crosslangextras.git
synced 2026-06-13 07:15:31 +00:00
Add the templates for npm
This commit is contained in:
33
Templates/npmwebapp/src/pages/about.tcross
Normal file
33
Templates/npmwebapp/src/pages/about.tcross
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
|
||||
func Pages.About(ctx)
|
||||
{
|
||||
var pages = [
|
||||
{
|
||||
active = false,
|
||||
route = "/",
|
||||
text = "Home",
|
||||
icon = "home"
|
||||
},
|
||||
{
|
||||
active = false,
|
||||
route = "/counter",
|
||||
text = "Counter",
|
||||
icon = "exposure_plus_1"
|
||||
},
|
||||
{
|
||||
active = true,
|
||||
route = "/about",
|
||||
text = "About",
|
||||
icon = "info"
|
||||
}
|
||||
];
|
||||
ctx.WithMimeType("text/html").SendText(Components.Shell("About Me",pages,<section>
|
||||
<h1>About Me</h1>
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||
</p>
|
||||
</section>
|
||||
));
|
||||
return true;
|
||||
}
|
||||
30
Templates/npmwebapp/src/pages/counter.tcross
Normal file
30
Templates/npmwebapp/src/pages/counter.tcross
Normal file
@@ -0,0 +1,30 @@
|
||||
var counter = 0;
|
||||
|
||||
func Pages.Counter(ctx)
|
||||
{
|
||||
var pages = [
|
||||
{
|
||||
active = false,
|
||||
route = "/",
|
||||
text = "Home",
|
||||
icon = "home"
|
||||
},
|
||||
{
|
||||
active = true,
|
||||
route = "/counter",
|
||||
text = "Counter",
|
||||
icon = "exposure_plus_1"
|
||||
},
|
||||
{
|
||||
active = false,
|
||||
route = "/about",
|
||||
text = "About",
|
||||
icon = "info"
|
||||
}
|
||||
];
|
||||
ctx.WithMimeType("text/html").SendText(Components.Shell("Counter",pages,<section>
|
||||
<button hx-get="./counter" hx-target="body" hx-push-url="true">Counter is {++counter}</button>
|
||||
</section>
|
||||
));
|
||||
return true;
|
||||
}
|
||||
35
Templates/npmwebapp/src/pages/echo.tcross
Normal file
35
Templates/npmwebapp/src/pages/echo.tcross
Normal file
@@ -0,0 +1,35 @@
|
||||
func Pages.Echo(ctx)
|
||||
{
|
||||
const text = ctx.QueryParams.TryGetFirst("text");
|
||||
var pages = [
|
||||
{
|
||||
active = true,
|
||||
route = "/",
|
||||
text = "Home",
|
||||
icon = "home"
|
||||
},
|
||||
{
|
||||
active = false,
|
||||
route = "/counter",
|
||||
text = "Counter",
|
||||
icon = "exposure_plus_1"
|
||||
},
|
||||
{
|
||||
active = false,
|
||||
route = "/about",
|
||||
text = "About",
|
||||
icon = "info"
|
||||
}
|
||||
];
|
||||
ctx.WithMimeType("text/html").SendText(Components.Shell("Echo",pages,<section>
|
||||
<if(text != null)>
|
||||
<true>
|
||||
<plink(text)>
|
||||
</true>
|
||||
<false>
|
||||
<p>No text available</p>
|
||||
</false>
|
||||
</if>
|
||||
</section>));
|
||||
return true;
|
||||
}
|
||||
42
Templates/npmwebapp/src/pages/index.tcross
Normal file
42
Templates/npmwebapp/src/pages/index.tcross
Normal file
@@ -0,0 +1,42 @@
|
||||
func Pages.Index(ctx)
|
||||
{
|
||||
var pages = [
|
||||
{
|
||||
active = true,
|
||||
route = "/",
|
||||
text = "Home",
|
||||
icon = "home"
|
||||
},
|
||||
{
|
||||
active = false,
|
||||
route = "/counter",
|
||||
text = "Counter",
|
||||
icon = "exposure_plus_1"
|
||||
},
|
||||
{
|
||||
active = false,
|
||||
route = "/about",
|
||||
text = "About",
|
||||
icon = "info"
|
||||
}
|
||||
];
|
||||
ctx.WithMimeType("text/html").SendText(Components.Shell("Main Page",pages,<section>
|
||||
<form hx-get="./echo" hx-target="body" hx-push-url="true" action="./echo" method="GET">
|
||||
<div class="row">
|
||||
<div class="max">
|
||||
<div class="field label border">
|
||||
<input type="text" name="text">
|
||||
<label>Text to echo</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="min">
|
||||
<button type="submit">
|
||||
Echo
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<p>1 John 4:4: You, dear children, are from God and have overcome them, because the one who is in you is greater than the one who is in the world.</p>
|
||||
</section>));
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user