Skip to content

Commit 28b53c9

Browse files
committed
add tabs to modal
1 parent 13d5975 commit 28b53c9

File tree

3 files changed

+134
-57
lines changed

3 files changed

+134
-57
lines changed

css/style-files/modal.css

Lines changed: 62 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,81 +7,112 @@ div.modal {
77
display: none; /* hidden by default */
88
height: 100%; /* full height */
99
left: 0;
10-
overflow: hidden; /* enable scroll if needed */
10+
overflow: auto; /* enable scroll if needed */
1111
position: fixed; /* stay in place */
1212
top: 0;
1313
width: 100%; /* full width */
1414
z-index: var(--z-index-modal); /* sit on top */
1515
}
1616

17-
/* modal content box */
18-
div.modal div.modal-content {
17+
/* modal container box */
18+
div.modal div.modal-container {
1919
background-color: var(--elevation-color-l2);
2020
border-radius: 20px;
2121
margin: 10% auto; /* 15% from the top and centered */
2222
overflow: scroll; /* hide text overflowing but allow scroll */
2323
width: 60%; /* Could be more or less, depending on screen size */
2424
}
2525

26-
/* MODAL CONTENT HEADER */
26+
/* MODAL TAB PICKER */
2727

28-
/* modal content header */
29-
div.modal div.modal-content div.modal-content-header {
28+
/* modal tab picker */
29+
div.modal div.modal-container div.modal-tab-picker {
3030
color: var(--text-color-he);
3131
font-size: 30px;
32-
padding: 5px 0px;
3332
text-align: center;
3433
}
3534

36-
/* close button */
37-
div.modal div.modal-content div.modal-content-header button {
35+
/* modal tab picker buttons */
36+
div.modal div.modal-container div.modal-tab-picker button {
3837
background-color: var(--elevation-color-l2);
3938
border: 0px;
4039
color: var(--text-color-me);
4140
cursor: pointer; /* change pointer */
42-
float: right;
41+
float: left;
42+
line-height: 30px;
43+
margin: 0px;
44+
padding: 5px;
45+
width: 47%;
4346
}
4447

45-
/* close button icon */
46-
div.modal div.modal-content div.modal-content-header button span {
47-
font-size: 30px;
48+
/* modal tab picker tab buttons */
49+
div.modal div.modal-container div.modal-tab-picker button:not(:last-of-type) {
50+
font-size: 22px;
51+
width: 47%;
4852
}
4953

50-
/* google material icon definitions */
51-
div.modal div.modal-content div.modal-content-header .material-symbols-outlined {
52-
font-variation-settings: 'FILL' 1, 'wght' 200, 'GRAD' 200, 'opsz' 24;
54+
/* modal tab picker close button */
55+
div.modal div.modal-container div.modal-tab-picker button:last-of-type {
56+
width: 6%;
5357
}
5458

55-
/* close button on hover */
56-
div.modal div.modal-content div.modal-content-header button:hover {
59+
/* modal tab picker buttons on hover */
60+
div.modal div.modal-container div.modal-tab-picker button:hover {
5761
color: var(--text-color-he);
5862
}
5963

60-
/* END MODAL CONTENT HEADER */
64+
/* modal tab picker tab buttons on hover */
65+
div.modal div.modal-container div.modal-tab-picker button:not(:last-of-type):hover {
66+
background-color: var(--elevation-color-l3);
67+
}
68+
69+
/* modal tab picker tab buttons on hover */
70+
div.modal div.modal-container div.modal-tab-picker button:not(:last-of-type).active {
71+
background-color: var(--elevation-color-l3);
72+
}
73+
74+
/* modal tab picker close button icon */
75+
div.modal div.modal-container div.modal-tab-picker button:last-of-type span {
76+
font-size: 26px;
77+
vertical-align: middle;
78+
}
79+
80+
/* google material icon definitions */
81+
div.modal div.modal-container div.modal-tab-picker .material-symbols-outlined {
82+
font-variation-settings: 'FILL' 1, 'wght' 200, 'GRAD' 200, 'opsz' 24;
83+
}
6184

62-
/* MODAL CONTENT BODY */
85+
/* END MODAL TAB PICKER */
86+
87+
/* MODAL TAB CONTENT */
88+
89+
div.modal div.modal-container div.modal-tab-content {
90+
display: none;
91+
}
92+
93+
/* MODAL TAB CONTENT BODY */
6394

6495
/* modal content body */
65-
div.modal div.modal-content div.modal-content-body {
96+
div.modal div.modal-container div.modal-tab-content-body {
6697
background-color: var(--elevation-color-l3);
6798
height: 250px;
6899
overflow: scroll;
69100
padding: 0px 15px;
70101
white-space: pre-wrap; /* wrap text to fit box, preserve whitespace */
71102
}
72103

73-
/* END MODAL CONTENT BODY */
104+
/* END MODAL TAB CONTENT BODY */
74105

75-
/* MODAL CONTENT FOOTER */
106+
/* MODAL TAB CONTENT FOOTER */
76107

77108
/* modal content footer */
78-
div.modal div.modal-content div.modal-content-footer {
109+
div.modal div.modal-container div.modal-tab-content-footer {
79110
text-align: right;
80111
/* padding: 5px 0px; */
81112
}
82113

83114
/* modal content footer iteration buttons */
84-
div.modal div.modal-content div.modal-content-footer button {
115+
div.modal div.modal-container div.modal-tab-content-footer button {
85116
display: inline-block;
86117
background-color: var(--elevation-color-l2);
87118
border: 0px; /* remove standard button border */
@@ -95,21 +126,23 @@ div.modal div.modal-content div.modal-content-footer button {
95126
}
96127

97128
/* modal content footer iteration button icon */
98-
div.modal div.modal-content div.modal-content-footer button span {
129+
div.modal div.modal-container div.modal-tab-content-footer button span {
99130
float: left;
100131
font-size: 20px;
101132
margin: 0px 8px 0px 0px;
102133
}
103134

104135
/* google material icon definitions */
105-
div.modal div.modal-content div.modal-content-footer .material-symbols-outlined {
136+
div.modal div.modal-container div.modal-tab-content-footer .material-symbols-outlined {
106137
font-variation-settings: 'FILL' 1, 'wght' 200, 'GRAD' 200, 'opsz' 24;
107138
}
108139

109140
/* modal content footer iteration button on hover */
110-
div.modal div.modal-content div.modal-content-footer button:hover {
141+
div.modal div.modal-container div.modal-tab-content-footer button:hover {
111142
/* background-color: var(--elevation-color-l4); */
112143
color: var(--text-color-he);
113144
}
114145

115-
/* END MODAL CONTENT FOOTER */
146+
/* END MODAL TAB CONTENT FOOTER */
147+
148+
/* END MODAL TAB CONTENT */

javascript/modal.js

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function getModalFromChild(object) {
2424
return getModal(paperReference);
2525
}
2626

27-
// SHOW AND HIDE FUNCTIONS
27+
// MODAL SHOW AND HIDE FUNCTIONS
2828

2929
// show selected modal
3030
function showModal(reference) {
@@ -60,16 +60,39 @@ function hideAllModal() {
6060
}
6161
}
6262

63-
// BUTTON ACTION FUNCTIONS
63+
// TAB SHOW AND HIDE FUNCTIONS
6464

65-
// copy .bib file contents
66-
function copyBib(object) {
67-
// get .bib file contents from .modal-content p element
68-
let modalContent = object.closest('.modal-content').querySelector('div.modal-content-body');
65+
function toggleTabFromChild(object, tab) {
66+
// DEACTIVATE ACTIVE
67+
68+
// get modal
69+
let modal = getModalFromChild(object);
70+
// get modal-container
71+
let modalContainer = modal.querySelector(".modal-container");
72+
// get active buttons from .modal-tab-picker
73+
let activeButtons = modalContainer.querySelectorAll(".modal-tab-picker button.active");
74+
// remove active from all buttons in .modal-tab-picker
75+
for (let i = 0; i < activeButtons.length; i++) {
76+
activeButtons[i].classList.remove = "active";
77+
}
78+
// get active buttons from .modal-tab-picker
79+
let tabContents = modalContainer.querySelectorAll(".modal-tab-content");
80+
// hide all .modal-tab-content
81+
for (let i = 0; i < tabContents.length; i++) {
82+
tabContents[i].style.display = "none";
83+
}
84+
}
85+
86+
// TAB BUTTON ACTION FUNCTIONS
87+
88+
// copy tab-content body contents
89+
function copyContents(object) {
90+
// get tab contents
91+
let modalTabContent = object.closest('.modal-tab-content').querySelector('.modal-tab-content-body');
6992
// obtain inner html from element
70-
let bibText = modalContent.innerHTML;
93+
let content = modalTabContent.innerHTML;
7194
// copy to clipboard
72-
navigator.clipboard.writeText(bibText);
95+
navigator.clipboard.writeText(content);
7396
}
7497

7598
// download .bib file
@@ -82,18 +105,6 @@ function downloadBib(object) {
82105

83106
// INITIALIZATION FUNCTONS
84107

85-
// fill modal with information
86-
function populateModal(paperReference) {
87-
// get selected modal
88-
let modal = getModal(paperReference);
89-
// get modal text element
90-
let modalText = modal.querySelector("div.modal-content div.modal-content-body");
91-
// get bib file contents
92-
let content = paperReference;
93-
// write contents
94-
modalText.innerHTML = content;
95-
}
96-
97108
// initialize modals
98109
function initializeModals() {
99110
// get paper references
@@ -106,3 +117,17 @@ function initializeModals() {
106117
window.addEventListener('click', function(event) { if (event.target == getModal(paperReferences[i])) { hideModal(paperReferences[i]); }});
107118
}
108119
}
120+
121+
// NOT USED
122+
123+
// fill modal with information
124+
function populateModal(paperReference) {
125+
// get selected modal
126+
let modal = getModal(paperReference);
127+
// get modal text element
128+
let modalText = modal.querySelector("div.modal-content div.modal-content-body");
129+
// get bib file contents
130+
let content = paperReference;
131+
// write contents
132+
modalText.innerHTML = content;
133+
}

pages/research/index.html

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,24 @@ <h3>Conference papers</h3>
126126
</div>
127127

128128
<div class="modal">
129-
<div class="modal-content">
129+
<div class="modal-container">
130130

131-
<div class="modal-content-header">
131+
<div class="modal-tab-picker">
132+
<button onclick="toggleTabFromChild(this,'cite')">
132133
Cite
134+
</button>
135+
136+
<button onclick="toggleTabFromChild(this,'abstract')">
137+
Abstract
138+
</button>
139+
133140
<button onclick="hideModalFromChild(this)">
134141
<span class="material-symbols-outlined">close</span>
135142
</button>
136143
</div>
137144

138-
<div class="modal-content-body">
145+
<div class="modal-tab-content cite">
146+
<div class="modal-tab-content-body">
139147
@InProceedings{angelo2022type,
140148
author="{\^A}ngelo, Pedro and Florido, M{\'a}rio",
141149
editor="Seidl, Helmut and Liu, Zhiming and Pasareanu, Corina S.",
@@ -152,8 +160,8 @@ <h3>Conference papers</h3>
152160
}
153161
</div>
154162

155-
<div class="modal-content-footer">
156-
<button onclick="copyBib(this)">
163+
<div class="modal-tab-content-footer">
164+
<button onclick="copyContents(this)">
157165
<span class="material-symbols-outlined">content_copy</span>
158166
copy
159167
</button>
@@ -162,10 +170,21 @@ <h3>Conference papers</h3>
162170
<span class="material-symbols-outlined">download</span>
163171
download
164172
</button>
173+
</div>
174+
</div>
165175

166-
<button onclick="hideModalFromChild(this)">
167-
<span class="material-symbols-outlined">close</span>
168-
close</button>
176+
<div class="modal-tab-content abstract">
177+
<div class="modal-tab-content-body">
178+
Several type inference approaches for rank-2 idempotent and commutative intersection types have been presented in the literature. Type inference relies on two stages: type constraint generation and solving. Defining constraint generation rules is rather straightforward, with one exception. To infer the type of an application, several derivations of the argument are required, one for each instance of the domain type of the function. The types of these derivations are then constrained against the instances. Noting that these derivations are isomorphic, by renaming of type variables, they can be obtained via a duplication operation on a single derivation of the argument. The application rule then constrains the intersection type resulting from duplication against the domain type of the function, resulting in an equality constraint between intersections. By treating intersections as sets, these constraints can be solved by solving a set unification problem, thus ensuring the types of the argument unify with the domain type of the function. Here we present a new type inference algorithm for rank-2 intersection types, which relies on set unification to solve equality constraints between intersections, and show it is both sound and complete.
179+
</div>
180+
181+
<div class="modal-tab-content-footer">
182+
<button onclick="copyContents(this)">
183+
<span class="material-symbols-outlined">content_copy</span>
184+
copy
185+
</button>
186+
187+
</div>
169188
</div>
170189

171190
</div>

0 commit comments

Comments
 (0)