refactor: start grouping brick attributes info
This commit is contained in:
parent
2e68b8d8e7
commit
82a96ea9d7
|
@ -1,6 +1,7 @@
|
||||||
package rooms
|
package rooms
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"html/template"
|
||||||
"log"
|
"log"
|
||||||
"maps"
|
"maps"
|
||||||
"slices"
|
"slices"
|
||||||
|
@ -242,3 +243,42 @@ func GestureFromInt(num int) (HandGesture, bool) {
|
||||||
func (g HandGesture) String() string {
|
func (g HandGesture) String() string {
|
||||||
return [...]string{"Change Topic", "Probing Quesion", "Expand", "Clarifying Quesion", "Meta"}[g]
|
return [...]string{"Change Topic", "Probing Quesion", "Expand", "Clarifying Quesion", "Meta"}[g]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GestureInfo struct {
|
||||||
|
Name string
|
||||||
|
Color, BgColor template.CSS
|
||||||
|
IconUrl template.URL
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g HandGesture) GetGestureInfo() GestureInfo {
|
||||||
|
result := GestureInfo{}
|
||||||
|
switch g {
|
||||||
|
case ChangeTopic:
|
||||||
|
result = GestureInfo{
|
||||||
|
Color: "--change-topic-color",
|
||||||
|
BgColor: "--change-topic-dark",
|
||||||
|
}
|
||||||
|
case ProbingQ:
|
||||||
|
result = GestureInfo{
|
||||||
|
Color: "--probing-q-color",
|
||||||
|
BgColor: "--probing-q-dark",
|
||||||
|
}
|
||||||
|
case Expand:
|
||||||
|
result = GestureInfo{
|
||||||
|
Color: "--expand-color",
|
||||||
|
BgColor: "--expand-dark",
|
||||||
|
}
|
||||||
|
case ClarifyingQ:
|
||||||
|
result = GestureInfo{
|
||||||
|
Color: "--clarifying-q-color",
|
||||||
|
BgColor: "--clarifying-q-dark",
|
||||||
|
}
|
||||||
|
case Meta:
|
||||||
|
result = GestureInfo{
|
||||||
|
Color: "--meta-color",
|
||||||
|
BgColor: "--meta-dark",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.Name = g.String()
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
|
@ -4,10 +4,15 @@
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--change-topic-color: 0deg 100% 50%;
|
--change-topic-color: 0deg 100% 50%;
|
||||||
|
--change-topic-dark: 0deg 57% 20%;
|
||||||
--probing-q-color: 48deg 100% 50%;
|
--probing-q-color: 48deg 100% 50%;
|
||||||
|
--probing-q-dark: 48deg 100% 17%;
|
||||||
--expand-color: 120deg 57% 50%;
|
--expand-color: 120deg 57% 50%;
|
||||||
|
--expand-dark: 120deg 57% 20%;
|
||||||
--clarifying-q-color: 216deg 99% 55%;
|
--clarifying-q-color: 216deg 99% 55%;
|
||||||
|
--clarifying-q-dark: 216deg 57% 20%;
|
||||||
--meta-color: 312deg 100% 50%;
|
--meta-color: 312deg 100% 50%;
|
||||||
|
--meta-dark: 312deg 57% 20%;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* https://stackoverflow.com/questions/12813573/position-icons-into-circle */
|
/* https://stackoverflow.com/questions/12813573/position-icons-into-circle */
|
||||||
|
|
|
@ -25,13 +25,6 @@ type personData struct {
|
||||||
Index int
|
Index int
|
||||||
}
|
}
|
||||||
|
|
||||||
var brickColors = map[rooms.HandGesture]template.CSS{
|
|
||||||
rooms.Meta: "--meta-color",
|
|
||||||
rooms.ClarifyingQ: "--clarifying-q-color",
|
|
||||||
rooms.Expand: "--expand-color",
|
|
||||||
rooms.ProbingQ: "--probing-q-color",
|
|
||||||
rooms.ChangeTopic: "--change-topic-color",
|
|
||||||
}
|
|
||||||
|
|
||||||
// data to be passed to "roomPeople" template
|
// data to be passed to "roomPeople" template
|
||||||
type roomTableData struct {
|
type roomTableData struct {
|
||||||
|
@ -191,7 +184,7 @@ func (pData personData) BricksForPerson() []brickState {
|
||||||
}
|
}
|
||||||
|
|
||||||
result[gesture] = brickState{
|
result[gesture] = brickState{
|
||||||
ColorClass: brickColors[gesture],
|
ColorClass: gesture.GetGestureInfo().Color,
|
||||||
TemplateType: templateType,
|
TemplateType: templateType,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,6 +201,7 @@ func roomTemplatesPreview(
|
||||||
type SingleBrickData struct {
|
type SingleBrickData struct {
|
||||||
ColorClass template.CSS
|
ColorClass template.CSS
|
||||||
Name string
|
Name string
|
||||||
|
Gesture rooms.HandGesture
|
||||||
}
|
}
|
||||||
|
|
||||||
testPersonData := personData{
|
testPersonData := personData{
|
||||||
|
@ -262,7 +256,7 @@ func roomTemplatesPreview(
|
||||||
|
|
||||||
contentData := struct {
|
contentData := struct {
|
||||||
DefaultColor template.CSS
|
DefaultColor template.CSS
|
||||||
Bricks []SingleBrickData
|
Gestures []rooms.HandGesture
|
||||||
ABrick brickState
|
ABrick brickState
|
||||||
TestPerson personData
|
TestPerson personData
|
||||||
ARoom *roomTableData
|
ARoom *roomTableData
|
||||||
|
@ -272,28 +266,7 @@ func roomTemplatesPreview(
|
||||||
ColorClass: "--expand-color",
|
ColorClass: "--expand-color",
|
||||||
TemplateType: "raisedBrick",
|
TemplateType: "raisedBrick",
|
||||||
},
|
},
|
||||||
Bricks: []SingleBrickData{
|
Gestures: rooms.GesturesHighToLow[:],
|
||||||
{
|
|
||||||
Name: "expand",
|
|
||||||
ColorClass: brickColors[rooms.Expand],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "probing question",
|
|
||||||
ColorClass: brickColors[rooms.ProbingQ],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "change topic",
|
|
||||||
ColorClass: brickColors[rooms.ChangeTopic],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "clarifying question",
|
|
||||||
ColorClass: brickColors[rooms.ClarifyingQ],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "meta",
|
|
||||||
ColorClass: brickColors[rooms.Meta],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
TestPerson: testPersonData,
|
TestPerson: testPersonData,
|
||||||
ARoom: &roomTableData{
|
ARoom: &roomTableData{
|
||||||
Room: &aRoom,
|
Room: &aRoom,
|
||||||
|
|
|
@ -604,6 +604,10 @@ video {
|
||||||
flex: none;
|
flex: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.grow {
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
|
||||||
.-translate-x-1\/2 {
|
.-translate-x-1\/2 {
|
||||||
--tw-translate-x: -50%;
|
--tw-translate-x: -50%;
|
||||||
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
||||||
|
@ -636,6 +640,10 @@ video {
|
||||||
grid-template-rows: auto 1fr;
|
grid-template-rows: auto 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.flex-row {
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
.flex-col {
|
.flex-col {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
@ -656,6 +664,10 @@ video {
|
||||||
gap: 1.5rem;
|
gap: 1.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.gap-y-10 {
|
||||||
|
row-gap: 2.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.rounded {
|
.rounded {
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
}
|
}
|
||||||
|
@ -783,10 +795,15 @@ video {
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--change-topic-color: 0deg 100% 50%;
|
--change-topic-color: 0deg 100% 50%;
|
||||||
|
--change-topic-dark: 0deg 57% 20%;
|
||||||
--probing-q-color: 48deg 100% 50%;
|
--probing-q-color: 48deg 100% 50%;
|
||||||
|
--probing-q-dark: 48deg 100% 17%;
|
||||||
--expand-color: 120deg 57% 50%;
|
--expand-color: 120deg 57% 50%;
|
||||||
|
--expand-dark: 120deg 57% 20%;
|
||||||
--clarifying-q-color: 216deg 99% 55%;
|
--clarifying-q-color: 216deg 99% 55%;
|
||||||
|
--clarifying-q-dark: 216deg 57% 20%;
|
||||||
--meta-color: 312deg 100% 50%;
|
--meta-color: 312deg 100% 50%;
|
||||||
|
--meta-dark: 312deg 57% 20%;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* https://stackoverflow.com/questions/12813573/position-icons-into-circle */
|
/* https://stackoverflow.com/questions/12813573/position-icons-into-circle */
|
||||||
|
|
|
@ -27,11 +27,11 @@
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
{{ define "main-content" }}
|
{{ define "main-content" }}
|
||||||
<main class="h-screen">
|
<main class="h-screen">
|
||||||
<div class="h-full w-full grid">
|
<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>
|
||||||
<div
|
<div
|
||||||
id="roomTextContainer"
|
id="roomTextContainer"
|
||||||
class="grid place-content-center"
|
class="grid place-content-center grow"
|
||||||
hx-ext="sse"
|
hx-ext="sse"
|
||||||
sse-connect="/rooms/subscribe?roomName={{ .Room.Name }}"
|
sse-connect="/rooms/subscribe?roomName={{ .Room.Name }}"
|
||||||
>
|
>
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
<div id="controls" class="bg-green-300">
|
<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 }}"
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<h2>Single templates</h2>
|
<h2>Single templates</h2>
|
||||||
|
|
||||||
|
|
||||||
|
{{/* takes in rooms.GestureInfo as parameter */}}
|
||||||
|
|
||||||
{{ define "inactiveBrick" }}
|
{{ define "inactiveBrick" }}
|
||||||
<div
|
<div
|
||||||
class="h-[var(--brick-height)] w-20 border-[hsl(var(--brick-color))]/25 border bg-[hsl(var(--brick-color))]/5"
|
class="h-[var(--brick-height)] w-20 border-[hsl(var(--brick-color))]/25 border bg-[hsl(var(--brick-color))]/5"
|
||||||
|
@ -28,7 +31,7 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ define "markAndRaisedBrick" }}
|
{{ define "markAndRaisedBrick" }}
|
||||||
<div
|
<div
|
||||||
class="h-[var(--brick-height)] w-20 border-[hsl(var(--brick-color))] border bg-[hsl(var(--brick-color))]/25 grid place-content-center font-bold text-[hsl(var(--brick-color))]/50"
|
class="h-[var(--brick-height)] w-20 border-[hsl(var(--brick-color))] border-2 bg-[hsl(var(--brick-color))]/25 grid place-content-center font-bold text-[hsl(var(--brick-color))]/50"
|
||||||
style="--brick-color: var({{.}}); --brick-height: calc(var(--d)/5)"
|
style="--brick-color: var({{.}}); --brick-height: calc(var(--d)/5)"
|
||||||
>
|
>
|
||||||
X
|
X
|
||||||
|
|
|
@ -9,13 +9,15 @@
|
||||||
<p> speaker </p>
|
<p> speaker </p>
|
||||||
<p> mark </p>
|
<p> mark </p>
|
||||||
<p> mark and active </p>
|
<p> mark and active </p>
|
||||||
{{ range .Bricks }}
|
{{ range .Gestures }}
|
||||||
|
{{ with .GetGestureInfo }}
|
||||||
<div class="border-2">for {{ .Name }}</div>
|
<div class="border-2">for {{ .Name }}</div>
|
||||||
<div>{{ template "inactiveBrick" .ColorClass }}</div>
|
<div>{{ template "inactiveBrick" .Color }}</div>
|
||||||
<div>{{ template "raisedBrick" .ColorClass }}</div>
|
<div>{{ template "raisedBrick" .Color }}</div>
|
||||||
<div>{{ template "speakerBrick" .ColorClass }}</div>
|
<div>{{ template "speakerBrick" .Color }}</div>
|
||||||
<div>{{ template "markBrick" .ColorClass }}</div>
|
<div>{{ template "markBrick" .Color }}</div>
|
||||||
<div>{{ template "markAndRaisedBrick" .ColorClass }}</div>
|
<div>{{ template "markAndRaisedBrick" .Color }}</div>
|
||||||
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue