@@ -10,9 +10,7 @@ const SORT_ICON_INACTIVE = 'jp-codeSnippet-sort-icon-inactive';
10
10
const SORT_ICON_ACTIVE = 'jp-codeSnippet-sort-icon-active' ;
11
11
const CODE_SNIPPET_SORT_CONTENT = 'jp-codeSnippet-sort-content' ;
12
12
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' ;
16
14
17
15
/* Add on click to span and then create function to actually do the sorting*/
18
16
/* 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 {
28
26
this . handleClick = this . handleClick . bind ( this ) ;
29
27
}
30
28
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
+
31
48
public createOptionsNode ( ) : HTMLElement {
32
49
const body = document . createElement ( 'div' ) ;
33
-
50
+ body . className = 'jp-codeSnippet-sort-test-container' ;
34
51
const optionsContainer = document . createElement ( 'div' ) ;
35
52
optionsContainer . className = CODE_SNIPPET_SORT_CONTENT ;
36
53
const insertSnip = document . createElement ( 'div' ) ;
37
54
insertSnip . className = CODE_SNIPPET_SORT_SORTBY ;
38
- insertSnip . textContent = 'Sort by:' ;
55
+ // 4 space start to sortby
56
+ insertSnip . textContent = ' Sort by:' ;
39
57
/*insertSnip.onclick = (): void => {};*/
40
58
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' ;
43
61
/*copySnip.onclick = (): void => {};*/
44
62
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' ;
47
65
/*editSnip.onclick = (): void => {};*/
48
66
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' ;
51
69
/*deleteSnip.onclick = (): void => {};*/
52
70
optionsContainer . appendChild ( insertSnip ) ;
53
71
optionsContainer . appendChild ( copySnip ) ;
@@ -63,6 +81,7 @@ export class SortTools extends React.Component {
63
81
// const parent = target.parentElement;
64
82
this . handleClickHelper ( target ) ;
65
83
showMoreOptions ( { body : new OptionsHandler ( this ) } ) ;
84
+ this . _setSortToolPosition ( event ) ;
66
85
}
67
86
68
87
handleClickHelper ( parent : HTMLElement ) : void {
0 commit comments