diff --git a/package.json b/package.json index 56e1527..dbeebe7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@internxt/ui", - "version": "0.0.8", + "version": "0.0.9", "description": "Library of Internxt components", "repository": { "type": "git", diff --git a/src/components/breadcrumbs/__test__/__snapshots__/Breadcrumbs.test.tsx.snap b/src/components/breadcrumbs/__test__/__snapshots__/Breadcrumbs.test.tsx.snap index 70a05c7..230e08d 100644 --- a/src/components/breadcrumbs/__test__/__snapshots__/Breadcrumbs.test.tsx.snap +++ b/src/components/breadcrumbs/__test__/__snapshots__/Breadcrumbs.test.tsx.snap @@ -81,10 +81,10 @@ exports[`Breadcrumbs Component > should match snapshot 1`] = ` >
should match snapshot 1`] = `
- @@ -248,10 +245,10 @@ exports[`Breadcrumbs Component > should match snapshot 1`] = ` >
should match snapshot 1`] = `
- diff --git a/src/components/contextMenu/__test__/__snapshots__/ContextMenu.test.tsx.snap b/src/components/contextMenu/__test__/__snapshots__/ContextMenu.test.tsx.snap index d081fe8..400affe 100644 --- a/src/components/contextMenu/__test__/__snapshots__/ContextMenu.test.tsx.snap +++ b/src/components/contextMenu/__test__/__snapshots__/ContextMenu.test.tsx.snap @@ -18,9 +18,9 @@ exports[`ContextMenu Component > should match snapshot 1`] = ` >
@@ -31,9 +31,6 @@ exports[`ContextMenu Component > should match snapshot 1`] = ` Option 1
- @@ -43,9 +40,9 @@ exports[`ContextMenu Component > should match snapshot 1`] = ` >
@@ -56,9 +53,6 @@ exports[`ContextMenu Component > should match snapshot 1`] = ` Option 2
- @@ -77,9 +71,9 @@ exports[`ContextMenu Component > should match snapshot 1`] = ` >
@@ -90,9 +84,6 @@ exports[`ContextMenu Component > should match snapshot 1`] = ` Option 3
- @@ -114,9 +105,9 @@ exports[`ContextMenu Component > should match snapshot 1`] = ` >
@@ -127,9 +118,6 @@ exports[`ContextMenu Component > should match snapshot 1`] = ` Option 1
- @@ -139,9 +127,9 @@ exports[`ContextMenu Component > should match snapshot 1`] = ` >
@@ -152,9 +140,6 @@ exports[`ContextMenu Component > should match snapshot 1`] = ` Option 2
- @@ -173,9 +158,9 @@ exports[`ContextMenu Component > should match snapshot 1`] = ` >
@@ -186,9 +171,6 @@ exports[`ContextMenu Component > should match snapshot 1`] = ` Option 3
- diff --git a/src/components/dropdown/Dropdown.tsx b/src/components/dropdown/Dropdown.tsx index 1d4be7b..cc81c65 100644 --- a/src/components/dropdown/Dropdown.tsx +++ b/src/components/dropdown/Dropdown.tsx @@ -44,6 +44,16 @@ export type DropdownProps = { * allowing customization of the dropdown's logic. */ +const extractPaddingValues = (className: string) => { + const pxMatch = className.match(/px-(\d+(\.\d+)?)/); + const pyMatch = className.match(/py-(\d+(\.\d+)?)/); + + const px = pxMatch ? pxMatch[1] : undefined; + const py = pyMatch ? pyMatch[1] : undefined; + + return { px, py }; +}; + const Dropdown = ({ children, options, @@ -94,6 +104,8 @@ const Dropdown = ({ const toggleMenu = () => setIsOpen((prev) => !prev); const closeMenu = () => setIsOpen(false); + const { px, py } = extractPaddingValues(classMenuItems); + return (
diff --git a/src/components/dropdown/__test__/__snapshots__/Dropdown.test.tsx.snap b/src/components/dropdown/__test__/__snapshots__/Dropdown.test.tsx.snap index f2eb38e..bbfe1b6 100644 --- a/src/components/dropdown/__test__/__snapshots__/Dropdown.test.tsx.snap +++ b/src/components/dropdown/__test__/__snapshots__/Dropdown.test.tsx.snap @@ -29,9 +29,9 @@ exports[`Dropdown component > should match snapshot 1`] = ` >
@@ -42,9 +42,6 @@ exports[`Dropdown component > should match snapshot 1`] = ` Option 1
- @@ -54,9 +51,9 @@ exports[`Dropdown component > should match snapshot 1`] = ` >
@@ -67,9 +64,6 @@ exports[`Dropdown component > should match snapshot 1`] = ` Option 2
- @@ -79,9 +73,9 @@ exports[`Dropdown component > should match snapshot 1`] = ` >
@@ -92,9 +86,6 @@ exports[`Dropdown component > should match snapshot 1`] = ` Action 1
- diff --git a/src/components/menu/Menu.tsx b/src/components/menu/Menu.tsx index 81f693d..b886b7d 100644 --- a/src/components/menu/Menu.tsx +++ b/src/components/menu/Menu.tsx @@ -27,6 +27,8 @@ export interface MenuProps { menu?: MenuItemsType; handleMenuClose: () => void; genericEnterKey?: () => void; + paddingX?: string; + paddingY?: string; } /** @@ -50,6 +52,12 @@ export interface MenuProps { * @property {() => void} [genericEnterKey] * - Optional callback for when the Enter key is pressed without selecting a menu item. * + * @property {string} [paddingX='px-4'] + * - Optional padding for the X axis (horizontal) of each menu item. Defaults to `px-4`. + * + * @property {string} [paddingY='py-1.5'] + * - Optional padding for the Y axis (vertical) of each menu item. Defaults to `py-1.5`. + * * @returns {JSX.Element} * - The rendered Menu component. * @@ -62,7 +70,15 @@ export interface MenuProps { * It features a dynamic index for item selection, with keyboard and mouse-based navigation. */ -const Menu = ({ item, menu, isOpen, genericEnterKey, handleMenuClose }: MenuProps): JSX.Element => { +const Menu = ({ + item, + menu, + isOpen, + genericEnterKey, + handleMenuClose, + paddingX = 'px-4', + paddingY = 'py-1.5', +}: MenuProps): JSX.Element => { const [selectedIndex, setSelectedIndex] = useState(null); const [enterPressed, setEnterPressed] = useState(false); const handleMouseEnter = (index: number) => { @@ -150,7 +166,9 @@ const Menu = ({ item, menu, isOpen, genericEnterKey, handleMenuClose }: Menu ); return ( -
+
{menu?.map((option, i) => (
{option && option.separator ? ( @@ -172,11 +190,11 @@ const Menu = ({ item, menu, isOpen, genericEnterKey, handleMenuClose }: Menu onMouseEnter={() => handleMouseEnter(i)} >
{option.node ? ( @@ -187,12 +205,14 @@ const Menu = ({ item, menu, isOpen, genericEnterKey, handleMenuClose }: Menu {option.name}
)} - - {option.keyboardShortcutOptions?.keyboardShortcutIcon && ( - - )} - {option.keyboardShortcutOptions?.keyboardShortcutText ?? ''} - + {option.keyboardShortcutOptions && ( + + {option.keyboardShortcutOptions?.keyboardShortcutIcon && ( + + )} + {option.keyboardShortcutOptions?.keyboardShortcutText ?? ''} + + )}
) diff --git a/src/components/menu/__test__/__snapshots__/Menu.test.tsx.snap b/src/components/menu/__test__/__snapshots__/Menu.test.tsx.snap index 3a60ec0..0d5990e 100644 --- a/src/components/menu/__test__/__snapshots__/Menu.test.tsx.snap +++ b/src/components/menu/__test__/__snapshots__/Menu.test.tsx.snap @@ -11,9 +11,9 @@ exports[`Menu Component > should match snapshot 1`] = ` >
@@ -24,9 +24,6 @@ exports[`Menu Component > should match snapshot 1`] = ` Option 1
-
@@ -46,9 +43,9 @@ exports[`Menu Component > should match snapshot 1`] = `
should match snapshot 1`] = ` Option 2
-
@@ -70,10 +64,10 @@ exports[`Menu Component > should match snapshot 1`] = ` >
should match snapshot 1`] = ` Option 3
-
@@ -95,9 +86,9 @@ exports[`Menu Component > should match snapshot 1`] = ` >