Skip to content

Commit

Permalink
Fix icon tooltip alignment on instructions modal
Browse files Browse the repository at this point in the history
This commit fixes a UI misalignment issue for toolips in the download
instructions modal.

The existing margin on icons caused tooltips to be misaligned upon hover
or touch.

Changes include:

- Introduce wrapper elements to encapsulate the margin, ensuring
  tooltips align with the corresponding icons.
- Extract the information incon into a separate Vue component to adhere
  to the single-responsibility principle and improve maintainability.
- Remove redundant newline at the end of 'Open terminal' tooltip to
  reduce the visual clutter.
  • Loading branch information
undergroundwires committed Nov 13, 2023
1 parent 949fac1 commit bd383ed
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
<span class="code-wrapper">
<span class="dollar">$</span>
<code ref="codeElement"><slot /></code>
<TooltipWrapper>
<AppIcon
class="copy-button"
icon="copy"
@click="copyCode"
/>
<template v-slot:tooltip>
Copy
</template>
</TooltipWrapper>
<div class="copy-action-container">
<TooltipWrapper>
<AppIcon
icon="copy"
class="copy-button"
@click="copyCode"
/>
<template v-slot:tooltip>
Copy
</template>
</TooltipWrapper>
</div>
</span>
</template>

Expand Down Expand Up @@ -68,8 +70,10 @@ export default defineComponent({
font-size: 0.8rem;
user-select: none;
}
.copy-button {
.copy-action-container {
margin-left: 1rem;
}
.copy-button {
@include clickable;
@include hover-or-touch {
color: $color-primary;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export class LinuxInstructionsBuilder extends InstructionsBuilder {
+ '<li><code>Alt-T</code>: Parrot OS…</li>'
+ '<li><code>Ctrl-Alt-Insert</code>: Bodhi Linux…</li>'
+ '</ul>'
+ '<br/>'
,
},
}))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<TooltipWrapper>
<AppIcon icon="circle-info" />
<template v-slot:tooltip>
<slot />
</template>
</TooltipWrapper>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import TooltipWrapper from '@/presentation/components/Shared/TooltipWrapper.vue';
import AppIcon from '@/presentation/components/Shared/Icon/AppIcon.vue';
export default defineComponent({
components: {
TooltipWrapper,
AppIcon,
},
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<hr />
<p>
<strong>2. The hard (manual) alternative</strong>. This requires you to do additional manual
steps. If you are unsure how to follow the instructions, hover on information
(<AppIcon icon="circle-info" />)
steps. If you are unsure how to follow the instructions, tap or hover on information
(<InfoTooltip>Engage with icons like this for extra wisdom!</InfoTooltip>)
icons near the steps, or follow the easy alternative described above.
</p>
<p>
Expand All @@ -26,27 +26,15 @@
>
<div class="step__action">
<span>{{ step.action.instruction }}</span>
<TooltipWrapper v-if="step.action.details">
<AppIcon
class="explanation"
icon="circle-info"
/>
<template v-slot:tooltip>
<div v-html="step.action.details" />
</template>
</TooltipWrapper>
<div class="details-container" v-if="step.action.details">
<InfoTooltip><div v-html="step.action.details" /></InfoTooltip>
</div>
</div>
<div v-if="step.code" class="step__code">
<CodeInstruction>{{ step.code.instruction }}</CodeInstruction>
<TooltipWrapper v-if="step.code.details">
<AppIcon
class="explanation"
icon="circle-info"
/>
<template v-slot:tooltip>
<div v-html="step.code.details" />
</template>
</TooltipWrapper>
<div class="details-container" v-if="step.code.details">
<InfoTooltip><div v-html="step.code.details" /></InfoTooltip>
</div>
</div>
</li>
</ol>
Expand All @@ -60,16 +48,14 @@ import {
} from 'vue';
import { injectKey } from '@/presentation/injectionSymbols';
import { OperatingSystem } from '@/domain/OperatingSystem';
import TooltipWrapper from '@/presentation/components/Shared/TooltipWrapper.vue';
import AppIcon from '@/presentation/components/Shared/Icon/AppIcon.vue';
import CodeInstruction from './CodeInstruction.vue';
import { IInstructionListData } from './InstructionListData';
import InfoTooltip from './InfoTooltip.vue';
export default defineComponent({
components: {
CodeInstruction,
TooltipWrapper,
AppIcon,
InfoTooltip,
},
props: {
data: {
Expand Down Expand Up @@ -125,7 +111,7 @@ function renderOsName(os: OperatingSystem): string {
margin-top: 0.5em;
}
}
.explanation {
margin-left: 0.5em;
.details-container {
margin-left: 0.5em; // Do not style icon itself to ensure correct tooltip alignment
}
</style>

0 comments on commit bd383ed

Please sign in to comment.