Skip to content

Commit

Permalink
Gp: fix tooltips positions on mobile screens (#721)
Browse files Browse the repository at this point in the history
  • Loading branch information
xbpcb authored Jan 9, 2025
1 parent a4b2e85 commit af26ef9
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ jobs:
run: |
npm ci
npm run build --if-present
npm test
npm run lint
env:
CI: true
4 changes: 4 additions & 0 deletions src/assets/less/common-globalping.less
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,10 @@
}
}
}

&_tt-limit {
white-space: normal;
}
}

// hide GoogleMaps InfoWindow close btn
Expand Down
33 changes: 21 additions & 12 deletions src/assets/less/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -419,12 +419,16 @@ body.noscroll {
transform: translate(-50%, 100%);
}

&-right:before {
left: 0;
top: 50%;
border-left: 0;
border-right: 5px solid rgba(17, 26, 44, .9);
transform: translate(-100%, -50%);
&-right {
margin-right: 20px;

&:before {
left: 0;
top: 50%;
border-left: 0;
border-right: 5px solid rgba(17, 26, 44, .9);
transform: translate(-100%, -50%);
}
}

&-bottom:before {
Expand All @@ -435,12 +439,17 @@ body.noscroll {
transform: translate(-50%, -100%);
}

&-left:before {
right: 0;
top: 50%;
border-right: 0;
border-left: 5px solid rgba(17, 26, 44, .9);
transform: translate(100%, -50%);
&-left {
margin-left: 20px;

&:before {
right: 0;
top: 50%;
border-right: 0;
border-left: 5px solid rgba(17, 26, 44, .9);
transform: translate(100%, -50%);
margin-left: 24px;
}
}

pre {
Expand Down
36 changes: 30 additions & 6 deletions src/views/pages/globalping/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@
gpNotAppliedOpts="{{notAppliedOpts}}"
gpUrlHandlerCb="{{@this.applyOptions}}"
showIPSwitch="{{mainOptions.type !== 'DNS'}}"
ipVersion="{{mainOptions.ipVersion}}">
ipVersion="{{mainOptions.ipVersion}}"
ttPos="{{ttPositions.targetTtPos}}">
{{#partial labelIcon}}
<img as-tooltip="'Up to 2 IP addresses or domains'"
<img as-tooltip="'Up to 2 IP addresses or domains', ttPos"
width="14"
height="14"
src="{{@shared.assetsHost}}/img/globalping/help-icon.svg">
Expand All @@ -150,9 +151,10 @@
placeholder="Enter location"
labelText="Location"
classList="gp_map-block_settings-wrapper_settings_location gp_input"
disabled="{{testInProgress}}">
disabled="{{testInProgress}}"
ttPos="{{ttPositions.locationTtPos}}">
{{#partial labelIcon}}
<img as-tooltip="[ 'This magic field supports names of continents, regions, countries, US states, cities, networks, and our custom tags.', '', 'Use + to combine multiple filters.', 'Use , to select multiple locations.' ], undefined, undefined, undefined, 'multiline'"
<img as-tooltip="[ 'This magic field supports names of continents, regions, countries, US states, cities, networks, and our custom tags.', '', 'Use + to combine multiple filters.', 'Use , to select multiple locations.' ], ttPos, undefined, undefined, 'multiline'"
width="14"
height="14"
src="{{@shared.assetsHost}}/img/globalping/help-icon.svg">
Expand All @@ -168,9 +170,10 @@
labelText="Limit"
classList="gp_map-block_settings-wrapper_settings_limit gp_input"
hideLabelIcon="{{infiniteSwitchEnabled === false}}"
disabled="{{testInProgress}}">
disabled="{{testInProgress}}"
ttPos="{{ttPositions.limitTtPos}}">
{{#partial labelIcon}}
<img as-tooltip="'Values up to 5 are supported for infinite measurements'"
<img as-tooltip="'Values up to 5 are supported for infinite measurements', ttPos, undefined, undefined, 'gp_tt-limit'"
width="14"
height="14"
src="{{@shared.assetsHost}}/img/globalping/help-icon.svg">
Expand Down Expand Up @@ -1786,6 +1789,27 @@
}
});

// handle tooltips positions depending on the screen size
this.observe('screenWidth', (screenWidth) => {
let ttPositions = {};

if (screenWidth >= 1272) {
ttPositions.targetTtPos = 'top';
ttPositions.locationTtPos = 'top';
ttPositions.limitTtPos = 'top';
} else if (screenWidth >= 768) {
ttPositions.targetTtPos = 'top';
ttPositions.locationTtPos = 'right';
ttPositions.limitTtPos = 'top';
} else {
ttPositions.targetTtPos = 'right';
ttPositions.locationTtPos = 'right';
ttPositions.limitTtPos = 'right';
}

this.set('ttPositions', ttPositions);
});

// disable Infinite switch if there is more than one target
this.observe('mainOptions.target', (target) => {
if (target.split(',').length > 1) {
Expand Down

0 comments on commit af26ef9

Please sign in to comment.