Skip to content

Commit 62b9335

Browse files
committed
fix: CSS styles & add close when clicking outside
1 parent 8905061 commit 62b9335

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

javascript/tokenscript-viewer/src/components/common/tokens-selector/tokens-selector.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
height: 40px;
88
}
99

10+
.tokens-selector span {
11+
color: #fff !important;
12+
}
13+
1014
.tokens-selector .selected {
1115
padding: 6px;
1216
background-color: #292929;
1317
border: 1px solid #858585;
14-
color: #fff;
1518
border-radius: 5px;
1619
display: flex;
1720
align-items: center;
@@ -26,7 +29,6 @@
2629
right: 0;
2730
background-color: #292929;
2831
border: 1px solid #858585;
29-
color: #fff;
3032
border-top: none;
3133
z-index: 100;
3234
max-height: 250px;
@@ -48,6 +50,7 @@
4850
.tokens-selector .icon-label {
4951
display: flex;
5052
align-items: center;
53+
font-size: 14px;
5154
}
5255

5356
.tokens-selector .icon-container {

javascript/tokenscript-viewer/src/components/common/tokens-selector/tokens-selector.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ export class TokensSelector {
3838
await this.updateOptions()
3939
}
4040

41+
async componentDidLoad(){
42+
window.addEventListener("click", (e) => {
43+
if (this.isOpen)
44+
this.isOpen = false;
45+
});
46+
window.addEventListener('blur', (e) => {
47+
if (this.isOpen && document.activeElement === document.querySelector('iframe'))
48+
this.isOpen = false;
49+
});
50+
}
51+
4152
toggleDropdown() {
4253
this.isOpen = !this.isOpen;
4354
}
@@ -81,7 +92,10 @@ export class TokensSelector {
8192

8293
return (
8394
<div class="tokens-selector">
84-
<div class="selected" style={this.isOpen ? {borderBottomColor: "transparent", borderRadius: "5px 5px 0 0"} : {}} onClick={() => this.toggleDropdown()}>
95+
<div class="selected" style={this.isOpen ? {borderBottomColor: "transparent", borderRadius: "5px 5px 0 0"} : {}} onClick={(e) => {
96+
e.stopPropagation();
97+
this.toggleDropdown();
98+
}}>
8599
{selectedOption ? (
86100
[
87101
<span class="icon-container">
@@ -102,7 +116,8 @@ export class TokensSelector {
102116
{this.options.map(option => (
103117
<div
104118
class="option"
105-
onClick={() => {
119+
onClick={(e) => {
120+
e.stopPropagation();
106121
this.currentContext = option.originId + (option.tokenId ? "-" + option.tokenId : "");
107122
this.isOpen = false;
108123
this.switchToken(option);
@@ -111,7 +126,7 @@ export class TokensSelector {
111126
<span class="icon-container">
112127
<token-icon src={option.image} imageTitle={option.name}/>
113128
</span>
114-
<span>{option.name}</span>
129+
<span class="icon-label">{option.name}</span>
115130
</div>
116131
))}
117132
</div>

javascript/tokenscript-viewer/src/components/viewers/mooar/mooar-viewer.css

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ body, action-overflow-modal .popover-container {
2626
}
2727

2828
.mooar-header .text {
29-
font-size: 15px;
29+
font-size: 16px;
3030
font-weight: 500;
3131
color: #fff;
3232
}
3333

3434
.mooar-header .header-icon {
35-
height: 25px !important;
35+
height: 24px !important;
3636
padding-left: 8px;
37-
padding-top: 2px;
3837
}
3938

4039
.mooar-header-right {

0 commit comments

Comments
 (0)