about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2025-03-23 23:58:52 +0100
committerAlan Pearce2025-03-23 23:58:52 +0100
commit4fa3ceb5ac040a84f2da405c46e4af1231d22f17 (patch)
tree6a9015a9c062f9d0346569401a78eb323ab026b1
parent1c56ff7fc392f2d7992e53add5bd76bc8855d4a6 (diff)
downloadsearchix-4fa3ceb5ac040a84f2da405c46e4af1231d22f17.tar.lz
searchix-4fa3ceb5ac040a84f2da405c46e4af1231d22f17.tar.zst
searchix-4fa3ceb5ac040a84f2da405c46e4af1231d22f17.zip
feat: improve handling of long option descriptions
-rw-r--r--frontend/static/style.css28
-rw-r--r--internal/components/combined.go4
-rw-r--r--internal/components/markdown.go2
-rw-r--r--internal/components/options.go6
-rw-r--r--internal/components/packages.go6
5 files changed, 36 insertions, 10 deletions
diff --git a/frontend/static/style.css b/frontend/static/style.css
index d3c9e1d..f7d1f75 100644
--- a/frontend/static/style.css
+++ b/frontend/static/style.css
@@ -162,13 +162,39 @@ dialog > h2 {
 }
 
 table {
-  width: 100%;
   margin-top: 0;
+  width: 100%;
+  table-layout: fixed;
+  white-space: nowrap;
+}
+
+th.description {
+  width: 50%;
+}
+
+th.score {
+  width: 8ex;
 }
 
 td,
 th {
   padding: 0.25rem 0.5rem;
+  text-overflow: ellipsis;
+  overflow: clip;
+}
+
+tr {
+  height: 1.5rem;
+}
+
+td.description > * {
+  max-width: 100%;
+  text-overflow: ellipsis;
+  overflow: clip;
+}
+
+td.description > *:not(:first-child) {
+  display: none;
 }
 
 ul:only-child {
diff --git a/internal/components/combined.go b/internal/components/combined.go
index fe97e14..8c2dc34 100644
--- a/internal/components/combined.go
+++ b/internal/components/combined.go
@@ -31,7 +31,7 @@ func Combined(result *index.Result) g.Node {
 				Th(Scope("col"), g.Text("Attribute")),
 				Th(Scope("col"), g.Text("Description")),
 				g.If(config.DevMode,
-					Th(Scope("col"), g.Text("Score")),
+					Th(Scope("col"), Class("score"), g.Text("Score")),
 				),
 			),
 		),
@@ -41,7 +41,7 @@ func Combined(result *index.Result) g.Node {
 					Td(
 						openCombinedDialogLink(nix.GetKey(hit.Data)),
 					),
-					Td(
+					Td(Class("description"),
 						CombinedData(hit.Data),
 					),
 					g.If(config.DevMode,
diff --git a/internal/components/markdown.go b/internal/components/markdown.go
index 405ab52..a26fe3d 100644
--- a/internal/components/markdown.go
+++ b/internal/components/markdown.go
@@ -4,7 +4,7 @@ import (
 	"regexp"
 )
 
-var firstSentenceRegexp = regexp.MustCompile(`^.*?\.[[:space:]]`)
+var firstSentenceRegexp = regexp.MustCompile(`^.+?(\.[[:space:]]|:\n)`)
 
 func firstSentence[T ~string](text T) T {
 	if fs := firstSentenceRegexp.FindString(string(text)); fs != "" {
diff --git a/internal/components/options.go b/internal/components/options.go
index 1d01784..630fecd 100644
--- a/internal/components/options.go
+++ b/internal/components/options.go
@@ -14,9 +14,9 @@ func Options(result *index.Result) g.Node {
 		THead(
 			Tr(
 				Th(Scope("col"), g.Text("Title")),
-				Th(Scope("col"), g.Text("Description")),
+				Th(Scope("col"), Class("description"), g.Text("Description")),
 				g.If(config.DevMode,
-					Th(Scope("col"), g.Text("Score")),
+					Th(Scope("col"), Class("score"), g.Text("Score")),
 				),
 			),
 		),
@@ -37,7 +37,7 @@ func optionRow(hit index.DocumentMatch, o nix.Option) g.Node {
 		Td(
 			openDialogLink(o.Name),
 		),
-		Td(
+		Td(Class("description"),
 			firstSentence(o.Description),
 			Dialog(ID(o.Name)),
 		),
diff --git a/internal/components/packages.go b/internal/components/packages.go
index db45302..90bf92d 100644
--- a/internal/components/packages.go
+++ b/internal/components/packages.go
@@ -15,9 +15,9 @@ func Packages(result *index.Result) g.Node {
 			Tr(
 				Th(Scope("col"), g.Text("Attribute")),
 				Th(Scope("col"), g.Text("Name")),
-				Th(Scope("col"), g.Text("Description")),
+				Th(Scope("col"), Class("description"), g.Text("Description")),
 				g.If(config.DevMode,
-					Th(Scope("col"), g.Text("Score")),
+					Th(Scope("col"), Class("score"), g.Text("Score")),
 				),
 			),
 		),
@@ -41,7 +41,7 @@ func packageRow(hit index.DocumentMatch, p nix.Package) g.Node {
 		Td(
 			g.Text(p.Name),
 		),
-		Td(
+		Td(Class("description"),
 			g.Text(p.Description),
 		),
 		g.If(config.DevMode,