Skip to content

Commit

Permalink
Fix CSS issue for mobile devices in twoslash module (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adammatthiesen authored Nov 20, 2024
1 parent 55c0afa commit 178ae11
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/friendly-brooms-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"expressive-code-twoslash": patch
---

Fix: Small CSS issue for mobile devices
4 changes: 2 additions & 2 deletions packages/twoslash/src/module-code/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function setupTooltip(ToolTip, isMobileScreen) {
FloatingUIDOM.size({
apply({ availableWidth }) {
Object.assign(hoverAnnotation.style, {
maxWidth: `${Math.max(0, isMobileScreen ? 300 : availableWidth)}px`,
maxWidth: `${Math.max(300, availableWidth)}px`,
maxHeight: "100%",
});
},
Expand All @@ -46,7 +46,7 @@ function setupTooltip(ToolTip, isMobileScreen) {
.then(({ x, y }) => {
Object.assign(hoverAnnotation.style, {
display: "block",
left: `${isMobileScreen ? 50 : x}px`,
left: `${isMobileScreen ? 20 : x}px`,
top: `${y}px`,
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/twoslash/src/module-code/popup.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions packages/twoslash/src/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,8 @@ export function getTwoSlashBaseStyles({ cssVar }: ResolverContext): string {
.twoslash-popup-code {
display: block;
width: fit-content;
width: 100%;
max-width: 600px;
min-width: 100%;
padding: 6px 12px;
font-size: ${cssVar("codeFontSize")};
font-weight: 400;
Expand Down Expand Up @@ -332,6 +331,13 @@ export function getTwoSlashBaseStyles({ cssVar }: ResolverContext): string {
background-color: ${cssVar("scrollbarThumbHoverColor")};
}
.twoslash-popup-code::-webkit-scrollbar-corner,
.twoslash-popup-docs::-webkit-scrollbar-corner {
background: transparent;
width: 0;
height: 0;
}
.twoslash-popup-code,
.twoslash-popup-docs {
max-height: ${cssVar("twoSlash.popupDocsMaxHeight")} !important;
Expand Down

0 comments on commit 178ae11

Please sign in to comment.