forked from jakekara/margo-editor-a
-
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.
Create dropdown for relationship labels
- Loading branch information
Showing
7 changed files
with
198 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,5 @@ | |
padding-bottom: 3px; | ||
border-bottom: 5px solid #ddd; | ||
margin-bottom: 5px; | ||
font-size: 9px; | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.ControlBar { | ||
font-size: 12; | ||
/* width: 100%; | ||
display: flex; | ||
justify-content: right; */ | ||
|
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,82 @@ | ||
.SelectPlusGroup{ | ||
display: flex; | ||
} | ||
|
||
.SelectPlusGroup .Title{ | ||
font-weight: 900; | ||
padding-right: 2px; | ||
|
||
display: flex; | ||
justify-content: right; | ||
align-items: center; | ||
|
||
color: #555; | ||
} | ||
|
||
.SelectPlusWrapper{ | ||
position: relative; | ||
width: 60px; | ||
height: 14px; | ||
overflow: hidden; | ||
transition: unset; | ||
} | ||
|
||
.SelectPlusWrapper:hover{ | ||
height: unset; | ||
overflow: unset; | ||
} | ||
|
||
.SelectPlus{ | ||
cursor: pointer; | ||
position: absolute; | ||
background-color: white; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
z-index: 200; | ||
transition: all 0.5s ease-out; | ||
} | ||
|
||
.SelectPlus:hover .SelectPlusItem { | ||
border: 1px solid gray; | ||
border-bottom-width: 0px; | ||
border-top-width: 0px; | ||
} | ||
|
||
.SelectPlus:hover .SelectPlusItem:first-child { | ||
border-top-width: 1px; | ||
} | ||
|
||
.SelectPlus:hover .SelectPlusItem:last-child { | ||
border-bottom-width: 1px; | ||
} | ||
|
||
.SelectPlusItem { | ||
padding: 3px; | ||
user-select: none; | ||
border: 1px solid transparent; | ||
|
||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
} | ||
.SelectPlusItem:hover{ | ||
color: hotpink; | ||
border-color: #eee; | ||
|
||
white-space: unset; | ||
|
||
} | ||
|
||
.SelectPlusItem.ButtonContainer:hover{ | ||
background-color: unset; | ||
} | ||
|
||
.CenterButton{ | ||
text-align: center; | ||
margin: 0; | ||
} | ||
|
||
.CenterButton:hover{ | ||
background-color: white; | ||
} |
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,63 @@ | ||
import { | ||
faCircle, | ||
faDotCircle, | ||
faPen, | ||
faPlus, | ||
} from '@fortawesome/free-solid-svg-icons' | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' | ||
import React from 'react' | ||
import styles from './SelectPlus.module.css' | ||
|
||
interface SelectPlusItemProps { | ||
onClick: () => void | ||
} | ||
|
||
const SelectPlusItem: React.FunctionComponent<SelectPlusItemProps> = ( | ||
props | ||
) => { | ||
const { onClick } = props | ||
return ( | ||
<div onClick={onClick} className={styles.SelectPlusItem}> | ||
{props.children} | ||
</div> | ||
) | ||
} | ||
|
||
export interface SelectPlusProps { | ||
title?: string | ||
items: Array<string> | ||
selectedIndex: number | ||
addItem: (newItem: string) => void | ||
} | ||
|
||
export default function SelectPlus(props: SelectPlusProps) { | ||
const { items, addItem, selectedIndex, title } = props | ||
|
||
const promptForNewValue = () => { | ||
const newRel = prompt(title, items[selectedIndex]) | ||
if (newRel === null) { | ||
return | ||
} | ||
|
||
addItem(newRel) | ||
} | ||
return ( | ||
<div className={styles.SelectPlusGroup}> | ||
<div className={styles.Title}>{title ? title + ':' : null}</div> | ||
<div className={styles.SelectPlusWrapper}> | ||
<div className={styles.SelectPlus}> | ||
{items.map((item: string, idx: number) => { | ||
return ( | ||
<SelectPlusItem onClick={() => addItem(item)} key={idx}> | ||
{item} | ||
</SelectPlusItem> | ||
) | ||
})} | ||
<SelectPlusItem onClick={promptForNewValue}> | ||
<FontAwesomeIcon icon={faPen} /> new | ||
</SelectPlusItem> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |