Skip to content

Commit 05564c4

Browse files
committed
Fixed positioning and modified UI.
1 parent d93d57b commit 05564c4

File tree

3 files changed

+49
-14
lines changed

3 files changed

+49
-14
lines changed

src/CodeSnippetDisplay.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ export class CodeSnippetDisplay extends React.Component<
434434
target.addEventListener('mousemove', this.handleDragMove, true);
435435

436436
// since a browser has its own drag'n'drop support for images and some other elements.
437-
target.ondragstart = () => false;
437+
target.ondragstart = (): boolean => false;
438438

439439
event.preventDefault();
440440
}
@@ -566,7 +566,7 @@ export class CodeSnippetDisplay extends React.Component<
566566
}
567567

568568
//Set the position of the option to be under to the three dots on snippet.
569-
private _setOptionsPosition(
569+
public static _setOptionsPosition(
570570
event: React.MouseEvent<HTMLButtonElement, MouseEvent>
571571
): void {
572572
const target = event.target as HTMLElement;
@@ -1083,7 +1083,7 @@ export class CodeSnippetDisplay extends React.Component<
10831083
event: React.MouseEvent<HTMLButtonElement, MouseEvent>
10841084
): void => {
10851085
showMoreOptions({ body: new OptionsHandler(this, codeSnippet) });
1086-
this._setOptionsPosition(event);
1086+
CodeSnippetDisplay._setOptionsPosition(event);
10871087
}
10881088
}
10891089
];

src/SortTools.tsx

+30-11
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ const SORT_ICON_INACTIVE = 'jp-codeSnippet-sort-icon-inactive';
1010
const SORT_ICON_ACTIVE = 'jp-codeSnippet-sort-icon-active';
1111
const CODE_SNIPPET_SORT_CONTENT = 'jp-codeSnippet-sort-content';
1212
const CODE_SNIPPET_SORT_SORTBY = 'jp-codeSnippet-sort-sortby';
13-
const CODE_SNIPPET_SORT_LAST_MOD = 'jp-codeSnippet-sort-last-mod';
14-
const CODE_SNIPPET_SORT_DATE_NEW = 'jp-codeSnippet-sort-date-new';
15-
const CODE_SNIPPET_SORT_DATE_OLD = 'jp-codeSnippet-sort-date-old';
13+
const CODE_SNIPPET_SORT_OPTION = 'jp-codeSnippet-sort-option';
1614

1715
/* Add on click to span and then create function to actually do the sorting*/
1816
/* Right now the coloring of the arrows is off, make sure when dialog disappears arrow turns back to gray*/
@@ -28,26 +26,46 @@ export class SortTools extends React.Component {
2826
this.handleClick = this.handleClick.bind(this);
2927
}
3028

29+
private _setSortToolPosition(
30+
event: React.MouseEvent<HTMLButtonElement, MouseEvent>
31+
): void {
32+
const target = event.target as HTMLElement;
33+
const top: number;
34+
top = target.getBoundingClientRect().top + 30;
35+
const leftAsString =
36+
(target.getBoundingClientRect().left - 164).toString(10) + 'px';
37+
const topAsString = top.toString(10) + 'px';
38+
document.documentElement.style.setProperty(
39+
'--more-options-top',
40+
topAsString
41+
);
42+
document.documentElement.style.setProperty(
43+
'--more-options-left',
44+
leftAsString
45+
);
46+
}
47+
3148
public createOptionsNode(): HTMLElement {
3249
const body = document.createElement('div');
33-
50+
body.className = 'jp-codeSnippet-sort-test-container';
3451
const optionsContainer = document.createElement('div');
3552
optionsContainer.className = CODE_SNIPPET_SORT_CONTENT;
3653
const insertSnip = document.createElement('div');
3754
insertSnip.className = CODE_SNIPPET_SORT_SORTBY;
38-
insertSnip.textContent = 'Sort by:';
55+
// 4 space start to sortby
56+
insertSnip.textContent = ' Sort by:';
3957
/*insertSnip.onclick = (): void => {};*/
4058
const copySnip = document.createElement('div');
41-
copySnip.className = CODE_SNIPPET_SORT_LAST_MOD;
42-
copySnip.textContent = 'Last Modified';
59+
copySnip.className = CODE_SNIPPET_SORT_OPTION;
60+
copySnip.textContent = ' Last Modified';
4361
/*copySnip.onclick = (): void => {};*/
4462
const editSnip = document.createElement('div');
45-
editSnip.className = CODE_SNIPPET_SORT_DATE_NEW;
46-
editSnip.textContent = 'Date Created: Newest';
63+
editSnip.className = CODE_SNIPPET_SORT_OPTION;
64+
editSnip.textContent = ' Date Created: Newest';
4765
/*editSnip.onclick = (): void => {};*/
4866
const deleteSnip = document.createElement('div');
49-
deleteSnip.className = CODE_SNIPPET_SORT_DATE_OLD;
50-
deleteSnip.textContent = 'Date Created: Oldest';
67+
deleteSnip.className = CODE_SNIPPET_SORT_OPTION;
68+
deleteSnip.textContent = ' Date Created: Oldest';
5169
/*deleteSnip.onclick = (): void => {};*/
5270
optionsContainer.appendChild(insertSnip);
5371
optionsContainer.appendChild(copySnip);
@@ -63,6 +81,7 @@ export class SortTools extends React.Component {
6381
// const parent = target.parentElement;
6482
this.handleClickHelper(target);
6583
showMoreOptions({ body: new OptionsHandler(this) });
84+
this._setSortToolPosition(event);
6685
}
6786

6887
handleClickHelper(parent: HTMLElement): void {

style/index.css

+16
Original file line numberDiff line numberDiff line change
@@ -681,3 +681,19 @@ mark.jp-codeSnippet-search-bolding {
681681
float: right;
682682
cursor: pointer;
683683
}
684+
685+
.jp-codeSnippet-sort-content {
686+
width: 158px;
687+
}
688+
689+
.jp-codeSnippet-sort-sortby {
690+
white-space: pre;
691+
border-bottom: 1px var(--jp-layout-color3) solid;
692+
padding-bottom: 2px;
693+
}
694+
695+
.jp-codeSnippet-sort-option {
696+
padding-top: 2px;
697+
white-space: pre;
698+
cursor: pointer;
699+
}

0 commit comments

Comments
 (0)