style
This commit is contained in:
parent
528e434c16
commit
224dc563e9
9 changed files with 200 additions and 46 deletions
31
examples/StyleExample/main.cpp
Normal file
31
examples/StyleExample/main.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import Crafter.CppDOM;
|
||||
using namespace Crafter;
|
||||
|
||||
int main(){
|
||||
HtmlElement body("body","<div id=\"myDiv\"></div>");
|
||||
// Create a div element
|
||||
HtmlElement div("myDiv");
|
||||
|
||||
// Set some initial content
|
||||
div.SetInnerHTML("<p>This is a styled paragraph</p>");
|
||||
|
||||
// Apply styles using different methods
|
||||
div.SetStyle("color: blue; font-size: 20px; background-color: lightgray;");
|
||||
|
||||
// Or apply individual properties
|
||||
div.SetProperty("border", "2px solid red");
|
||||
div.SetProperty("padding", "10px");
|
||||
|
||||
// Add CSS classes
|
||||
div.AddClass("highlight");
|
||||
div.AddClass("container");
|
||||
|
||||
// Demonstrate class toggling
|
||||
div.ToggleClass("active");
|
||||
|
||||
// Check if class exists
|
||||
bool hasActiveClass = div.HasClass("active");
|
||||
|
||||
// Remove a class
|
||||
div.RemoveClass("highlight");
|
||||
}
|
||||
17
examples/StyleExample/project.json
Normal file
17
examples/StyleExample/project.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "main",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "executable",
|
||||
"implementations": ["main"],
|
||||
"target": "wasm32-wasi",
|
||||
"debug" : true,
|
||||
"dependencies": [
|
||||
{
|
||||
"path":"../../project.json",
|
||||
"configuration":"lib-debug"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
1
examples/StyleExample/run.sh
Executable file
1
examples/StyleExample/run.sh
Executable file
|
|
@ -0,0 +1 @@
|
|||
caddy file-server --listen :8080 --root bin/executable
|
||||
Loading…
Add table
Add a link
Reference in a new issue