diff --git a/components/ui/button.tsx b/components/ui/button.tsx index 151015de1..f51f0c0ce 100644 --- a/components/ui/button.tsx +++ b/components/ui/button.tsx @@ -37,16 +37,46 @@ const buttonVariants = cva( }, ); +type ButtonProps = Omit, 'size'> & + Omit, 'size'> & + VariantProps & { + asChild?: boolean; + selectButton?: boolean; + }; + function Button({ className, variant, size, asChild = false, + selectButton = false, + children, ...props -}: React.ComponentProps<'button'> & - VariantProps & { - asChild?: boolean; - }) { +}: ButtonProps) { + if (selectButton) { + return ( +
+ + +
+ + + +
+
+ ); + } + const Comp = asChild ? Slot : 'button'; return ( @@ -54,7 +84,9 @@ function Button({ data-slot='button' className={cn(buttonVariants({ variant, size, className }))} {...props} - /> + > + {children} + ); } diff --git a/pages/tools/components/GroupByMenu.tsx b/pages/tools/components/GroupByMenu.tsx index 3af4fe0f0..c6cb99067 100644 --- a/pages/tools/components/GroupByMenu.tsx +++ b/pages/tools/components/GroupByMenu.tsx @@ -5,11 +5,25 @@ import { Transform } from '../hooks/useToolsTransform'; interface GroupByMenuProps { transform: Transform; setTransform: Dispatch>; + activeSections?: string[]; } -const GroupByMenu = ({ transform, setTransform }: GroupByMenuProps) => { +const GroupByMenu = ({ + transform, + setTransform, + activeSections = [], +}: GroupByMenuProps) => { const groupedBy = transform.groupBy; + const scrollToSection = (section: string) => { + const id = `group-${section}`; + const element = document.getElementById(id); + if (element) { + const y = element.getBoundingClientRect().top + window.scrollY - 100; + window.scrollTo({ top: y, behavior: 'smooth' }); + } + }; + const groupBy = [ { label: 'None', @@ -36,21 +50,43 @@ const GroupByMenu = ({ transform, setTransform }: GroupByMenuProps) => { }; return ( -
- GROUP BY: - {groupBy.map((group) => { - return ( - - ); - })} +
+
+ GROUP BY: + {groupBy.map((group) => { + return ( + + ); + })} +
+ {activeSections.length > 0 && groupedBy !== 'none' && ( + + )}
); }; diff --git a/pages/tools/index.page.tsx b/pages/tools/index.page.tsx index 1f49f73a6..f940794a4 100644 --- a/pages/tools/index.page.tsx +++ b/pages/tools/index.page.tsx @@ -217,7 +217,13 @@ export default function ToolingPage({
- + g !== 'none' && toolsByGroup[g].length > 0, + )} + />