Skip to content

Commit

Permalink
make good example on context-menu
Browse files Browse the repository at this point in the history
  • Loading branch information
irsyadadl committed Nov 19, 2024
1 parent e5bd939 commit 608c184
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { ContextMenu } from "ui"
export default function ContextMenuDangerDemo() {
return (
<ContextMenu>
<ContextMenu.Trigger>Right click me</ContextMenu.Trigger>
<ContextMenu.Trigger className="h-28 w-56 border-2 border-dashed rounded-lg grid place-content-center">
Right click me
</ContextMenu.Trigger>
<ContextMenu.Content>
<ContextMenu.Item>Open</ContextMenu.Item>
<ContextMenu.Item>Rename</ContextMenu.Item>
Expand Down
4 changes: 3 additions & 1 deletion components/docs/controls/context-menu/context-menu-demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { ContextMenu } from "ui"
export default function ContextMenuDemo() {
return (
<ContextMenu>
<ContextMenu.Trigger>Right click me</ContextMenu.Trigger>
<ContextMenu.Trigger className="h-28 w-56 border-2 border-dashed rounded-lg grid place-content-center">
Right click me
</ContextMenu.Trigger>
<ContextMenu.Content className="sm:min-w-56">
<ContextMenu.Item>Back</ContextMenu.Item>
<ContextMenu.Item isDisabled>Forward</ContextMenu.Item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { ContextMenu } from "ui"
export default function ContextMenuDisabledDemo() {
return (
<ContextMenu>
<ContextMenu.Trigger>Right click me</ContextMenu.Trigger>
<ContextMenu.Trigger className="h-28 w-56 border-2 border-dashed rounded-lg grid place-content-center">
Right click me
</ContextMenu.Trigger>
<ContextMenu.Content>
<ContextMenu.Item id="view">View</ContextMenu.Item>
<ContextMenu.Item id="edit">Edit</ContextMenu.Item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { ContextMenu } from "ui"
export default function ContextMenuItemDetailsDemo() {
return (
<ContextMenu>
<ContextMenu.Trigger>Right click me</ContextMenu.Trigger>
<ContextMenu.Trigger className="h-28 w-56 border-2 border-dashed rounded-lg grid place-content-center">
Right click me
</ContextMenu.Trigger>
<ContextMenu.Content items={roles}>
{(item) => (
<ContextMenu.Item id={item.id} textValue={item.name}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { ContextMenu } from "ui"
export default function ContextMenuSeparatorDemo() {
return (
<ContextMenu>
<ContextMenu.Trigger>Right click me</ContextMenu.Trigger>
<ContextMenu.Trigger className="h-28 w-56 border-2 border-dashed rounded-lg grid place-content-center">
Right click me
</ContextMenu.Trigger>
<ContextMenu.Content>
<ContextMenu.Item id="view">View</ContextMenu.Item>
<ContextMenu.Item id="edit">Edit</ContextMenu.Item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { ContextMenu } from "ui"
export default function ContextMenuWithIconDemo() {
return (
<ContextMenu>
<ContextMenu.Trigger>Right click me</ContextMenu.Trigger>
<ContextMenu.Trigger className="h-28 w-56 border-2 border-dashed rounded-lg grid place-content-center">
Right click me
</ContextMenu.Trigger>
<ContextMenu.Content>
<ContextMenu.Item>
<IconFolder />
Expand Down
2 changes: 1 addition & 1 deletion components/docs/generated/previews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file is autogenerated by scripts/create-pr-content.ts.
// Do not edit this file directly.

import React from 'react';
import React from "react"

export const previews: Record<string, any> = {
"date-and-time/date-field/date-field-demo": {
Expand Down
6 changes: 3 additions & 3 deletions components/ui/context-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client"

import React, { useRef, useState } from "react"
import React from "react"

import { tv } from "tailwind-variants"

Expand Down Expand Up @@ -33,11 +33,11 @@ interface ContextMenuRootComponent {
}

const ContextMenu = ({ children }: ContextMenuRootComponent) => {
const [contextMenuOffset, setContextMenuOffset] = useState<{
const [contextMenuOffset, setContextMenuOffset] = React.useState<{
offset: number
crossOffset: number
} | null>(null)
const buttonRef = useRef<HTMLButtonElement>(null)
const buttonRef = React.useRef<HTMLButtonElement>(null)

return (
<ContextMenuTriggerContext.Provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Context Menu"
description: Pops a menu right where you click or hold down long, perfect for a right-click or a solid long press. It's all about quick access and easy picks!
order: 6
published: true
status: alpha
status: beta
---

## Basic
Expand Down

0 comments on commit 608c184

Please sign in to comment.