Skip to content

Commit

Permalink
add diff to none empty nodes (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skarlso authored Dec 26, 2023
1 parent 32f570b commit 762448b
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 32 deletions.
6 changes: 3 additions & 3 deletions wasm/app-worker.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const cacheName = "app-" + "4b705cbe38f400c5db0320ed10fc29357d6d1889";
const cacheName = "app-" + "e31aa1c4d4bf560a2b0d649865fab57a2bf48d9c";
const resourcesToCache = ["/","/app.css","/app.js","/manifest.webmanifest","/wasm_exec.js","/web/app.wasm","/web/css/alert.css","/web/img/logo.png","https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js","https://cdn.jsdelivr.net/npm/[email protected]/css/halfmoon.min.css","https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css","https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js","https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/yaml.min.js","https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css"];

self.addEventListener("install", (event) => {
console.log("installing app worker 4b705cbe38f400c5db0320ed10fc29357d6d1889");
console.log("installing app worker e31aa1c4d4bf560a2b0d649865fab57a2bf48d9c");

event.waitUntil(
caches
Expand All @@ -28,7 +28,7 @@ self.addEventListener("activate", (event) => {
);
})
);
console.log("app worker 4b705cbe38f400c5db0320ed10fc29357d6d1889 is activated");
console.log("app worker e31aa1c4d4bf560a2b0d649865fab57a2bf48d9c is activated");
});

self.addEventListener("fetch", (event) => {
Expand Down
51 changes: 32 additions & 19 deletions wasm/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,30 +161,43 @@ func render(d app.UI, p []*Property, accordionID string, depth int) app.UI {
headerElements = append(headerElements, app.Div().Class("col").Class("fst-italic").Text(prop.Patterns))
}

header := app.H2().Class("accordion-header").Class(borderOpacity).Body(
app.Button().ID("accordion-button-id-"+prop.Name+accordionID).Class("accordion-button").Type("button").DataSets(
map[string]any{
"bs-toggle": "collapse",
"bs-target": "#accordion-collapse-for-" + prop.Name + accordionID}).
Aria("expanded", "false").
Aria("controls", "accordion-collapse-for-"+prop.Name+accordionID).
Body(
app.Div().Class("container").Body(
// Both row's are important here to produce the desired outcome.
app.Div().Class("row").Body(
app.P().Class("fw-bold").Class("row").Body(
headerElements...,
),
app.Div().Class("row").Class("text-break").Body(app.Text(prop.Description)),
),
),
))
headerContainer := app.Div().Class("container").Body(
// Both rows are important here to produce the desired outcome.
app.Div().Class("row").Body(
app.P().Class("fw-bold").Class("row").Body(
headerElements...,
),
app.Div().Class("row").Class("text-break").Body(app.Text(prop.Description)),
),
)

button := app.Button().ID("accordion-button-id-"+prop.Name+accordionID).Class("accordion-button").Type("button").DataSets(
map[string]any{
"bs-toggle": "collapse",
"bs-target": "#accordion-collapse-for-" + prop.Name + accordionID}).
Aria("expanded", "false").
Aria("controls", "accordion-collapse-for-"+prop.Name+accordionID).
Body(
headerContainer,
)

if len(prop.Properties) != 0 {
button.Class("bg-success-subtle")
}

header := app.H2().Class("accordion-header").Class(borderOpacity).Body(button)

elements = append(elements, header)

// The next section can be skipped if there are no child properties.
if len(prop.Properties) == 0 {
continue
}

accordionDiv := app.Div().Class("accordion-collapse collapse").ID("accordion-collapse-for-"+prop.Name+accordionID).DataSet("bs-parent", "#"+accordionID)
accordionBody := app.Div().Class("accordion-body")

bodyElements := []app.UI{}
var bodyElements []app.UI

// add any children that the parent has
if len(prop.Properties) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion wasm/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var goappNav = function () {};
var goappOnUpdate = function () {};
var goappOnAppInstallChange = function () {};

const goappEnv = {"GOAPP_INTERNAL_URLS":"null","GOAPP_ROOT_PREFIX":"","GOAPP_STATIC_RESOURCES_URL":"","GOAPP_VERSION":"4b705cbe38f400c5db0320ed10fc29357d6d1889"};
const goappEnv = {"GOAPP_INTERNAL_URLS":"null","GOAPP_ROOT_PREFIX":"","GOAPP_STATIC_RESOURCES_URL":"","GOAPP_VERSION":"e31aa1c4d4bf560a2b0d649865fab57a2bf48d9c"};
const goappLoadingLabel = "{progress}%";
const goappWasmContentLengthHeader = "";

Expand Down
16 changes: 8 additions & 8 deletions wasm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
<head>
<meta charset="UTF-8">
<meta name="author" content="Gergely Brautigam">
<meta name="description" content>
<meta content name="description">
<meta name="keywords" content>
<meta name="theme-color" content="#2d2c2c">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0, viewport-fit=cover">
<meta property="og:url" content="http://127.0.0.1:64621/">
<meta property="og:url" content="http://127.0.0.1:49600/">
<meta property="og:title" content="Preview CRDs">
<meta property="og:description" content>
<meta property="og:type" content="website">
<meta property="og:image" content>
<title>Preview CRDs</title>
<link rel="preload" href="/app.css" as="style" type="text/css">
<link href="/app.css" as="style" type="text/css" rel="preload">
<link type="text/css" rel="preload" href="/web/css/alert.css" as="style">
<link rel="preload" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css" as="style" type="text/css">
<link type="text/css" rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/css/halfmoon.min.css" as="style">
<link type="text/css" rel="preload" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css" as="style">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/css/halfmoon.min.css" as="style" type="text/css">
<link type="text/css" rel="preload" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" as="style">
<link rel="icon" href="https://raw.githubusercontent.com/maxence-charriere/go-app/master/docs/web/icon.svg">
<link href="https://raw.githubusercontent.com/maxence-charriere/go-app/master/docs/web/icon.svg" rel="icon">
<link rel="apple-touch-icon" href="/web/img/logo.png">
<link rel="manifest" href="/manifest.webmanifest">
<link rel="stylesheet" type="text/css" href="/app.css">
Expand All @@ -27,7 +27,7 @@
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/css/halfmoon.min.css">
<link type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<script defer src="/wasm_exec.js"></script>
<script src="/app.js" defer></script>
<script defer src="/app.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/yaml.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
Expand Down Expand Up @@ -64,7 +64,7 @@
<body>
<main></main>
<aside id="app-wasm-loader" class="goapp-app-info">
<img src="/web/img/logo.png" id="app-wasm-loader-icon" class="goapp-logo goapp-spin">
<img class="goapp-logo goapp-spin" src="/web/img/logo.png" id="app-wasm-loader-icon">
<p id="app-wasm-loader-label" class="goapp-label">0%</p>
</aside>
</body>
Expand Down
1 change: 0 additions & 1 deletion wasm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func main() {
Title: "Preview CRDs",
Author: "Gergely Brautigam",
HTML: func() app.HTMLHtml { return app.Html().DataSet("bs-core", "modern").DataSet("bs-theme", "dark") },
// Body: func() app.HTMLBody { return app.Body().Class("dark-mode") },
Styles: []string{
"web/css/alert.css",
"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css",
Expand Down
Binary file modified wasm/web/app.wasm
Binary file not shown.

0 comments on commit 762448b

Please sign in to comment.