Skip to content

Commit

Permalink
use lists for menus
Browse files Browse the repository at this point in the history
  • Loading branch information
souporserious committed Oct 8, 2023
1 parent a4736dc commit 2daf9c1
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions mdxts/components/client/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export function Editor({
return
}

;(async function init() {
async function init() {
const highlighter = await getHighlighter({
theme,
langs: [
Expand All @@ -111,7 +111,8 @@ export function Editor({
})

highlighterRef.current = highlighter
})()
}
init()
}, [])

useLayoutEffect(() => {
Expand All @@ -129,7 +130,7 @@ export function Editor({
}

const nextSourceFile = project.createSourceFile(
'/index.tsx',
'index.tsx',
resolvedValue,
{ overwrite: true }
)
Expand Down Expand Up @@ -415,11 +416,14 @@ export function Editor({
</div>

{isDropdownOpen && (
<div
<ul
style={{
listStyle: 'none',
fontSize: 14,
width: 200,
maxHeight: 340,
padding: 0,
margin: 0,
overflow: 'auto',
position: 'absolute',
top: row * 20 + 20,
Expand All @@ -441,7 +445,7 @@ export function Editor({
/>
)
})}
</div>
</ul>
)}

{hoverInfo && hoverPosition && (
Expand All @@ -465,18 +469,21 @@ export function Editor({
)}

{diagnostics.length > 0 ? (
<p
<ul
style={{
fontSize: '0.6rem',
listStyle: 'none',
fontSize: '0.8rem',
padding: '0.6rem',
margin: 0,
backgroundColor: 'red',
}}
>
{diagnostics.map((diagnostic) =>
getDiagnosticMessageText(diagnostic.getMessageText())
)}
</p>
{diagnostics.map((diagnostic, index) => (
<li key={index}>
{getDiagnosticMessageText(diagnostic.getMessageText())}
</li>
))}
</ul>
) : null}
</div>
)
Expand All @@ -491,7 +498,7 @@ function Suggestion({
isHighlighted: boolean
onClick: () => void
}) {
const ref = useRef<HTMLDivElement>(null)
const ref = useRef<HTMLLIElement>(null)

useLayoutEffect(() => {
if (isHighlighted) {
Expand All @@ -500,7 +507,7 @@ function Suggestion({
}, [isHighlighted])

return (
<div
<li
ref={ref}
onClick={onClick}
style={{
Expand All @@ -509,6 +516,6 @@ function Suggestion({
}}
>
{suggestion.name}
</div>
</li>
)
}

1 comment on commit 2daf9c1

@vercel
Copy link

@vercel vercel bot commented on 2daf9c1 Oct 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.