-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(interface): friendly dependencies & legend
- Loading branch information
1 parent
eb7b60a
commit 77a4cb6
Showing
14 changed files
with
241 additions
and
21 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
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,60 @@ | ||
#legend { | ||
position: absolute; | ||
right: 10px; | ||
bottom: 40px; | ||
z-index: 30; | ||
max-width: 692px; | ||
padding: 4px; | ||
border-radius: 0 0 0 1rem; | ||
overflow: hidden; | ||
transition: transform 0.3s; | ||
display: none; | ||
flex-direction: column; | ||
justify-content: right; | ||
flex-wrap: wrap; | ||
font-size: 14px; | ||
color: #030421; | ||
padding: 0 10px 10px 0; | ||
border-radius: 4px; | ||
} | ||
|
||
.legend-box { | ||
box-sizing: border-box; | ||
display: inline-flex; | ||
flex-direction: row-reverse; | ||
align-items: center; | ||
height: 24px; | ||
border-radius: 4px; | ||
} | ||
|
||
.legend-badge { | ||
display: inline-block; | ||
width: 15px; | ||
height: 15px; | ||
margin: 0 5px; | ||
border-radius: 50%; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.34); | ||
} | ||
|
||
.legend { | ||
font-weight: bold; | ||
padding-left: 6px; | ||
display: none; | ||
} | ||
|
||
.legend-box:not(:hover) { | ||
background: transparent !important; | ||
} | ||
|
||
.legend-box:hover { | ||
border: 1px solid rgba(48, 56, 165, 0.6); | ||
} | ||
|
||
.legend-box:hover > .legend { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.legend-box:hover .legend-badge { | ||
box-shadow: none; | ||
} |
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,74 @@ | ||
// Import Internal Dependencies | ||
import { COLORS } from "../../../workspaces/vis-network/src/constants.js"; | ||
import { currentLang } from "../../common/utils.js"; | ||
|
||
export class Legend { | ||
constructor(options = {}) { | ||
const { show = false } = options; | ||
const lang = currentLang(); | ||
const theme = "LIGHT"; | ||
const legend = document.getElementById("legend"); | ||
const colors = COLORS[theme]; | ||
|
||
const defaultBadgeElement = document.createElement("div"); | ||
defaultBadgeElement.classList.add("legend-badge"); | ||
defaultBadgeElement.style.backgroundColor = colors.DEFAULT.color; | ||
defaultBadgeElement.style.color = colors.DEFAULT.font.color; | ||
const defaultElement = document.createElement("div"); | ||
defaultElement.classList.add("legend"); | ||
defaultElement.textContent = window.i18n[lang].legend.default; | ||
|
||
const warnBadgeElement = document.createElement("div"); | ||
warnBadgeElement.classList.add("legend-badge"); | ||
warnBadgeElement.style.backgroundColor = colors.WARN.color; | ||
warnBadgeElement.style.color = colors.WARN.font.color; | ||
const warnElement = document.createElement("div"); | ||
warnElement.classList.add("legend"); | ||
warnElement.textContent = window.i18n[lang].legend.warn; | ||
|
||
const friendlyBadgeElement = document.createElement("div"); | ||
friendlyBadgeElement.classList.add("legend-badge"); | ||
friendlyBadgeElement.style.backgroundColor = colors.FRIENDLY.color; | ||
friendlyBadgeElement.style.color = colors.FRIENDLY.font.color; | ||
const friendlyElement = document.createElement("div"); | ||
friendlyElement.classList.add("legend"); | ||
friendlyElement.textContent = window.i18n[lang].legend.friendly; | ||
|
||
const warnBox = document.createElement("div"); | ||
warnBox.classList.add("legend-box"); | ||
warnBox.appendChild(warnBadgeElement); | ||
warnBox.appendChild(warnElement); | ||
warnBox.style.backgroundColor = colors.WARN.color; | ||
warnBox.style.color = colors.WARN.font.color; | ||
|
||
const friendlyBox = document.createElement("div"); | ||
friendlyBox.classList.add("legend-box"); | ||
friendlyBox.appendChild(friendlyBadgeElement); | ||
friendlyBox.appendChild(friendlyElement); | ||
friendlyBox.style.backgroundColor = colors.FRIENDLY.color; | ||
friendlyBox.style.color = colors.FRIENDLY.font.color; | ||
|
||
const defaultBox = document.createElement("div"); | ||
defaultBox.classList.add("legend-box"); | ||
defaultBox.appendChild(defaultBadgeElement); | ||
defaultBox.appendChild(defaultElement); | ||
defaultBox.style.backgroundColor = colors.DEFAULT.color; | ||
defaultBox.style.color = colors.DEFAULT.font.color; | ||
|
||
legend.appendChild(warnBox); | ||
legend.appendChild(friendlyBox); | ||
legend.appendChild(defaultBox); | ||
|
||
if (show) { | ||
this.show(); | ||
} | ||
} | ||
|
||
show() { | ||
document.getElementById("legend").style.display = "flex"; | ||
} | ||
|
||
hide() { | ||
document.getElementById("legend").style.display = "none"; | ||
} | ||
} |
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
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.