Skip to content

Commit

Permalink
Format ContextMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
lxsmnsyc committed Jan 21, 2024
1 parent 3750890 commit 299c7fb
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 26 deletions.
25 changes: 14 additions & 11 deletions examples/context-menu/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>

<body>
<div id="app"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

</html>
4 changes: 2 additions & 2 deletions examples/context-menu/postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
}
};
},
};
34 changes: 27 additions & 7 deletions examples/context-menu/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export default function App(): JSX.Element {
)}
onContextMenu={(e: MouseEvent): void => {
if (e.currentTarget) {
const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();
const rect = (
e.currentTarget as HTMLElement
).getBoundingClientRect();
setX(e.clientX - rect.left);
setY(e.clientY - rect.top);
}
Expand All @@ -62,24 +64,42 @@ export default function App(): JSX.Element {
}}
>
<Menu class="overflow-hidden w-64 rounded-lg shadow-lg ring-1 ring-black ring-opacity-5 bg-white flex flex-col space-y-1 p-1">
<MenuItem as="button" class="text-sm p-1 text-left rounded hover:bg-violet-600 hover:text-white focus:outline-none focus:bg-violet-600 focus:text-white">
<MenuItem
as="button"
class="text-sm p-1 text-left rounded hover:bg-violet-600 hover:text-white focus:outline-none focus:bg-violet-600 focus:text-white"
>
Open Link in New Tab
</MenuItem>
<MenuItem as="button" class="text-sm p-1 text-left rounded hover:bg-violet-600 hover:text-white focus:outline-none focus:bg-violet-600 focus:text-white">
<MenuItem
as="button"
class="text-sm p-1 text-left rounded hover:bg-violet-600 hover:text-white focus:outline-none focus:bg-violet-600 focus:text-white"
>
Open Link in New Window
</MenuItem>
<MenuItem as="button" class="text-sm p-1 text-left rounded hover:bg-violet-600 hover:text-white focus:outline-none focus:bg-violet-600 focus:text-white">
<MenuItem
as="button"
class="text-sm p-1 text-left rounded hover:bg-violet-600 hover:text-white focus:outline-none focus:bg-violet-600 focus:text-white"
>
Open Link in New Incognito Window
</MenuItem>
<Separator />
<MenuItem as="button" class="text-sm p-1 text-left rounded hover:bg-violet-600 hover:text-white focus:outline-none focus:bg-violet-600 focus:text-white">
<MenuItem
as="button"
class="text-sm p-1 text-left rounded hover:bg-violet-600 hover:text-white focus:outline-none focus:bg-violet-600 focus:text-white"
>
Save Link As...
</MenuItem>
<MenuItem as="button" class="text-sm p-1 text-left rounded hover:bg-violet-600 hover:text-white focus:outline-none focus:bg-violet-600 focus:text-white">
<MenuItem
as="button"
class="text-sm p-1 text-left rounded hover:bg-violet-600 hover:text-white focus:outline-none focus:bg-violet-600 focus:text-white"
>
Copy Link Address
</MenuItem>
<Separator />
<MenuItem as="button" class="text-sm p-1 text-left rounded hover:bg-violet-600 hover:text-white focus:outline-none focus:bg-violet-600 focus:text-white">
<MenuItem
as="button"
class="text-sm p-1 text-left rounded hover:bg-violet-600 hover:text-white focus:outline-none focus:bg-violet-600 focus:text-white"
>
Inspect
</MenuItem>
</Menu>
Expand Down
9 changes: 3 additions & 6 deletions examples/context-menu/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
module.exports = {
mode: 'jit',
content: [
'./src/**/*.tsx',
],
content: ['./src/**/*.tsx'],
darkMode: 'class', // or 'media' or 'class'
variants: {},
plugins: [
],
};
plugins: [],
};

0 comments on commit 299c7fb

Please sign in to comment.