feat: controls styling from gesture info

This commit is contained in:
efim 2023-11-23 15:01:51 +00:00
parent dbae803ead
commit 16ee8a7cd5
6 changed files with 51 additions and 30 deletions

View File

@ -230,7 +230,7 @@ const (
Meta Meta
) )
var GesturesHighToLow = [...]HandGesture{Meta, ClarifyingQ, Expand, ProbingQ, ChangeTopic} var GesturesHighToLow = [...]HandGesture{4, 3, 2, 1, 0}
func GestureFromInt(num int) (HandGesture, bool) { func GestureFromInt(num int) (HandGesture, bool) {
if num >= int(ChangeTopic) && num <= int(Meta) { if num >= int(ChangeTopic) && num <= int(Meta) {
@ -245,9 +245,9 @@ func (g HandGesture) String() string {
} }
type GestureInfo struct { type GestureInfo struct {
Name string Name string
Color, BgColor template.CSS Color, ColorDark template.CSS
IconUrl template.URL IconUrl template.URL
} }
func (g HandGesture) GetGestureInfo() GestureInfo { func (g HandGesture) GetGestureInfo() GestureInfo {
@ -255,28 +255,28 @@ func (g HandGesture) GetGestureInfo() GestureInfo {
switch g { switch g {
case ChangeTopic: case ChangeTopic:
result = GestureInfo{ result = GestureInfo{
Color: "--change-topic-color", Color: "--change-topic-color",
BgColor: "--change-topic-dark", ColorDark: "--change-topic-dark",
} }
case ProbingQ: case ProbingQ:
result = GestureInfo{ result = GestureInfo{
Color: "--probing-q-color", Color: "--probing-q-color",
BgColor: "--probing-q-dark", ColorDark: "--probing-q-dark",
} }
case Expand: case Expand:
result = GestureInfo{ result = GestureInfo{
Color: "--expand-color", Color: "--expand-color",
BgColor: "--expand-dark", ColorDark: "--expand-dark",
} }
case ClarifyingQ: case ClarifyingQ:
result = GestureInfo{ result = GestureInfo{
Color: "--clarifying-q-color", Color: "--clarifying-q-color",
BgColor: "--clarifying-q-dark", ColorDark: "--clarifying-q-dark",
} }
case Meta: case Meta:
result = GestureInfo{ result = GestureInfo{
Color: "--meta-color", Color: "--meta-color",
BgColor: "--meta-dark", ColorDark: "--meta-dark",
} }
} }
result.Name = g.String() result.Name = g.String()

View File

@ -201,14 +201,15 @@ func roomPageRoute(
template.New("").ParseFS(templateFs, tableTemplates, templFile, baseFile)) template.New("").ParseFS(templateFs, tableTemplates, templFile, baseFile))
type GestureData struct { type GestureData struct {
Name string
Url string Url string
Gesture rooms.HandGesture
} }
var gesturesData []GestureData var gesturesData []GestureData
for gesture := rooms.ChangeTopic; gesture <= rooms.Meta; gesture++ { for _, gesture := range rooms.GesturesHighToLow {
gesturesData = append(gesturesData, GestureData{ gesturesData = append(gesturesData, GestureData{
Name: gesture.String(),
Url: fmt.Sprintf("%s%d", raiseHandPath, gesture), Url: fmt.Sprintf("%s%d", raiseHandPath, gesture),
Gesture: gesture,
}) })
} }

View File

@ -250,7 +250,7 @@ func roomTemplatesPreview(
contentData := struct { contentData := struct {
DefaultColor template.CSS DefaultColor template.CSS
Gestures []rooms.HandGesture GesturePreviews []rooms.HandGesture
ABrick brickState ABrick brickState
TestPerson personData TestPerson personData
ARoom *roomTableData ARoom *roomTableData
@ -260,7 +260,7 @@ func roomTemplatesPreview(
TemplateType: "raisedBrick", TemplateType: "raisedBrick",
Gesture: rooms.Expand, Gesture: rooms.Expand,
}, },
Gestures: rooms.GesturesHighToLow[:], GesturePreviews: rooms.GesturesHighToLow[:],
TestPerson: testPersonData, TestPerson: testPersonData,
ARoom: &roomTableData{ ARoom: &roomTableData{
Room: &aRoom, Room: &aRoom,

View File

@ -558,6 +558,10 @@ video {
display: flex; display: flex;
} }
.table {
display: table;
}
.grid { .grid {
display: grid; display: grid;
} }
@ -684,6 +688,10 @@ video {
border-width: 4px; border-width: 4px;
} }
.border-\[hsl\(var\(--border-color\)\)\] {
border-color: hsl(var(--border-color));
}
.border-\[hsl\(var\(--brick-color\)\)\] { .border-\[hsl\(var\(--brick-color\)\)\] {
border-color: hsl(var(--brick-color)); border-color: hsl(var(--brick-color));
} }
@ -697,11 +705,6 @@ video {
border-color: rgb(0 0 0 / var(--tw-border-opacity)); border-color: rgb(0 0 0 / var(--tw-border-opacity));
} }
.border-blue-700 {
--tw-border-opacity: 1;
border-color: rgb(29 78 216 / var(--tw-border-opacity));
}
.border-yellow-700 { .border-yellow-700 {
--tw-border-opacity: 1; --tw-border-opacity: 1;
border-color: rgb(161 98 7 / var(--tw-border-opacity)); border-color: rgb(161 98 7 / var(--tw-border-opacity));
@ -750,6 +753,11 @@ video {
padding: 1rem; padding: 1rem;
} }
.px-10 {
padding-left: 2.5rem;
padding-right: 2.5rem;
}
.px-2 { .px-2 {
padding-left: 0.5rem; padding-left: 0.5rem;
padding-right: 0.5rem; padding-right: 0.5rem;
@ -760,6 +768,11 @@ video {
padding-bottom: 0.25rem; padding-bottom: 0.25rem;
} }
.py-4 {
padding-top: 1rem;
padding-bottom: 1rem;
}
.text-xl { .text-xl {
font-size: 1.25rem; font-size: 1.25rem;
line-height: 1.75rem; line-height: 1.75rem;
@ -773,6 +786,10 @@ video {
color: hsl(var(--brick-color) / 0.5); color: hsl(var(--brick-color) / 0.5);
} }
.text-\[hsl\(var\(--text-color\)\)\] {
color: hsl(var(--text-color));
}
.text-blue-700 { .text-blue-700 {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(29 78 216 / var(--tw-text-opacity)); color: rgb(29 78 216 / var(--tw-text-opacity));

View File

@ -29,6 +29,7 @@
<main class="h-screen"> <main class="h-screen">
<div class="h-full w-full flex flex-row"> <div class="h-full w-full flex flex-row">
<script src="/static/dist/ext/sse.js"></script> <script src="/static/dist/ext/sse.js"></script>
{{/* This is dynamic table, updated from SSE */}}
<div <div
id="roomTextContainer" id="roomTextContainer"
class="grid place-content-center grow" class="grid place-content-center grow"
@ -45,19 +46,21 @@
</div> </div>
{{ end }} {{ end }}
</div> </div>
{{/* This is personal hand controls */}}
<div id="controls" class="bg-green-300 flex flex-col p-10 gap-y-10"> <div id="controls" class="bg-green-300 flex flex-col p-10 gap-y-10">
{{ range .Gestures }} {{ range .Gestures }}
<button <button
hx-get="{{ .Url }}" hx-get="{{ .Url }}"
class="bg-white rounded border-blue-700 border-2" class="bg-white rounded border-[hsl(var(--border-color))] border-2 text-[hsl(var(--text-color))] font-bold px-10 py-4"
> style="--border-color: var({{.Gesture.GetGestureInfo.Color}});
{{ .Name }} --text-color: var({{.Gesture.GetGestureInfo.ColorDark}})
">
{{ .Gesture.String }}
</button> </button>
{{ end }} {{ end }}
<button <button
hx-get="/rooms/releaseHand" hx-get="/rooms/releaseHand"
class="bg-white rounded border-yellow-700 border-4" class="bg-white rounded border-yellow-700 border-4">
>
Release Hand Release Hand
</button> </button>
</div> </div>

View File

@ -9,7 +9,7 @@
<p> speaker </p> <p> speaker </p>
<p> mark </p> <p> mark </p>
<p> mark and active </p> <p> mark and active </p>
{{ range .Gestures }} {{ range .GesturePreviews }}
{{ with .GetGestureInfo }} {{ with .GetGestureInfo }}
<div class="border-2">for {{ .Name }}</div> <div class="border-2">for {{ .Name }}</div>
<div>{{ template "inactiveBrick" . }}</div> <div>{{ template "inactiveBrick" . }}</div>