-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(map,ui): add right-click menu to the map canvas
- Loading branch information
Showing
24 changed files
with
897 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version = 3.8.2 | ||
version = 3.8.3 | ||
runner.dialect = scala3 | ||
align.preset = more | ||
maxColumn = 120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
ul.context-menu { | ||
list-style: none; | ||
border-radius: 5px; | ||
padding: 0.2em 0; | ||
margin: 0.2em 0; | ||
|
||
background-color: $gray-lighter; | ||
color: $gray-darkest; | ||
font-size: 0.75em; | ||
font-weight: 600; | ||
|
||
/* material design corners - TODO need to templatise this */ | ||
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23); | ||
|
||
& .ti { | ||
align-content: end; | ||
} | ||
|
||
& li { | ||
padding: 0 0.5em; | ||
position: relative; /* required ofc to make height: 100% work on ::before */ | ||
/* TODO cursor not working */ | ||
cursor: pointer; | ||
|
||
&.disabled { | ||
color: $gray !important; | ||
cursor: revert; | ||
& * { | ||
color: $gray !important; | ||
} | ||
} | ||
|
||
&:hover:not(.disabled):not(.divider) { | ||
background-color: $gray-light; | ||
} | ||
|
||
&:not(.divider)::before { | ||
position: absolute; | ||
opacity: 0; | ||
content: ''; | ||
background-color: $green; | ||
width: 2px; | ||
left: -4px; | ||
height: 100%; | ||
|
||
transition: left 0.15s ease-out,opacity 0.15s ease-out; | ||
} | ||
|
||
&:hover:not(.disabled)::before { | ||
opacity: 1; | ||
} | ||
|
||
&.divider { | ||
height: 1px; | ||
cursor: initial; | ||
background-color: $gray-light; | ||
margin: 0.2em 0; | ||
} | ||
} | ||
|
||
& button { | ||
display: inline-block; | ||
background-color: transparent; | ||
border: none; | ||
text-align: left; | ||
color: inherit; | ||
font-weight: inherit; | ||
width: 100%; | ||
} | ||
|
||
& i { | ||
color: $gray-darkest; | ||
padding-right: 0.2em; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#map-context-menu { | ||
position: absolute; | ||
z-index: 2000; | ||
|
||
& ul { | ||
min-width: 12em; | ||
|
||
& li[data-action="remove-selected"], & li[data-action="disconnect"], & li[data-action="remove-current"] { | ||
color: $red-darkest; | ||
& i { | ||
color: $red-dark; | ||
} | ||
} | ||
|
||
& i.ti-circle-filled[data-mass="fresh"], & i.ti-circle-filled[data-stance="unknown"] { | ||
color: $gray-light; | ||
} | ||
|
||
& i.ti-circle-filled[data-mass="reduced"] { | ||
color: $orange; | ||
} | ||
|
||
& i.ti-circle-filled[data-mass="critical"] { | ||
color: $red; | ||
} | ||
|
||
& i[data-stance="hostile"] { | ||
color: $red; | ||
} | ||
|
||
& i[data-stance="friendly"] { | ||
color: $blue; | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
ui/src/main/scala/controltower/component/ContextMenu.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package controltower.component | ||
|
||
import com.raquo.laminar.api.L.* | ||
|
||
type Action = String | ||
|
||
enum ContextMenuElement derives CanEqual: | ||
case MenuItem( | ||
action: Action, | ||
view: Element, | ||
disabled: Signal[Boolean] = Val(false), | ||
mod: Modifier[Element] = emptyMod | ||
) | ||
case Divider | ||
|
||
final class ContextMenu(id: String, els: ContextMenuElement*): | ||
def view: Element = ul( | ||
idAttr := id, | ||
cls := "context-menu", | ||
role := "menu", | ||
els.map: | ||
case cmi: ContextMenuElement.MenuItem => | ||
li( | ||
cls := "menu-item", | ||
role := "menuitem", | ||
cls("disabled") <-- cmi.disabled, | ||
dataAttr("action") := cmi.action, | ||
cmi.mod, | ||
cmi.view | ||
) | ||
case ContextMenuElement.Divider => | ||
li(cls := "divider") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.