diff --git a/resources/scripts/components/NavigationBar.tsx b/resources/scripts/components/NavigationBar.tsx index 9500d215d..16182e36f 100644 --- a/resources/scripts/components/NavigationBar.tsx +++ b/resources/scripts/components/NavigationBar.tsx @@ -1,4 +1,5 @@ import * as React from 'react'; +import { useState } from 'react'; import { Link, NavLink } from 'react-router-dom'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faCogs, faLayerGroup, faSignOutAlt, faUserCircle } from '@fortawesome/free-solid-svg-icons'; @@ -9,36 +10,18 @@ import tw, { theme } from 'twin.macro'; import styled from 'styled-components/macro'; import http from '@/api/http'; import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; -import { useState } from 'react'; - -const Navigation = styled.div` - ${tw`w-full bg-neutral-900 shadow-md overflow-x-auto`}; - - & > div { - ${tw`mx-auto w-full flex items-center`}; - } - - & #logo { - ${tw`flex-1`}; - - & > a { - ${tw`text-2xl font-header px-4 no-underline text-neutral-200 hover:text-neutral-100 transition-colors duration-150`}; - } - } -`; +import Tooltip from '@/components/elements/tooltip/Tooltip'; const RightNavigation = styled.div` - ${tw`flex h-full items-center justify-center`}; - & > a, & > button, & > .navigation-link { ${tw`flex items-center h-full no-underline text-neutral-300 px-6 cursor-pointer transition-all duration-150`}; - + &:active, &:hover { ${tw`text-neutral-100 bg-black`}; } - + &:active, &:hover, &.active { - box-shadow: inset 0 -2px ${theme`colors.cyan.700`.toString()}; + box-shadow: inset 0 -2px ${theme`colors.cyan.600`.toString()}; } } `; @@ -57,32 +40,43 @@ export default () => { }; return ( - - -
-
- +
+ +
+
+ {name}
- + - - - - - - + + + + + + + + + + {rootAdmin && - - - + + + + + } - + + +
- +
); }; diff --git a/resources/scripts/components/dashboard/search/SearchContainer.tsx b/resources/scripts/components/dashboard/search/SearchContainer.tsx index 36c3ae871..0bb9978ab 100644 --- a/resources/scripts/components/dashboard/search/SearchContainer.tsx +++ b/resources/scripts/components/dashboard/search/SearchContainer.tsx @@ -3,6 +3,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faSearch } from '@fortawesome/free-solid-svg-icons'; import useEventListener from '@/plugins/useEventListener'; import SearchModal from '@/components/dashboard/search/SearchModal'; +import Tooltip from '@/components/elements/tooltip/Tooltip'; export default () => { const [ visible, setVisible ] = useState(false); @@ -24,9 +25,11 @@ export default () => { onDismissed={() => setVisible(false)} /> } -
setVisible(true)}> - -
+ +
setVisible(true)}> + +
+
); }; diff --git a/resources/scripts/components/elements/SubNavigation.tsx b/resources/scripts/components/elements/SubNavigation.tsx index ea6754944..66d8f7f20 100644 --- a/resources/scripts/components/elements/SubNavigation.tsx +++ b/resources/scripts/components/elements/SubNavigation.tsx @@ -21,7 +21,7 @@ const SubNavigation = styled.div` &:active, &.active { ${tw`text-neutral-100`}; - box-shadow: inset 0 -2px ${theme`colors.cyan.700`.toString()}; + box-shadow: inset 0 -2px ${theme`colors.cyan.600`.toString()}; } } } diff --git a/resources/scripts/components/elements/tooltip/Tooltip.tsx b/resources/scripts/components/elements/tooltip/Tooltip.tsx index 9e8de35af..57a95cbf3 100644 --- a/resources/scripts/components/elements/tooltip/Tooltip.tsx +++ b/resources/scripts/components/elements/tooltip/Tooltip.tsx @@ -18,6 +18,9 @@ import { import { AnimatePresence, motion } from 'framer-motion'; interface Props { + rest?: number; + delay?: number | Partial<{ open: number; close: number }>; + alwaysOpen?: boolean; content: string | React.ReactChild; disabled?: boolean; arrow?: boolean; @@ -34,22 +37,35 @@ const arrowSides: Record = { right: 'left', }; -export default ({ content, children, disabled = false, ...props }: Props) => { +export default ({ + content, + children, + disabled = false, + alwaysOpen = false, + delay = { open: 500 }, + rest = 30, + ...props +}: Props) => { const arrowEl = useRef(null); - const [ open, setOpen ] = useState(false); + const [ open, setOpen ] = useState(alwaysOpen || false); const { x, y, reference, floating, middlewareData, strategy, context } = useFloating({ open, placement: props.placement || 'top', strategy: props.strategy || 'absolute', - middleware: [ offset(6), flip(), shift({ padding: 6 }), arrow({ element: arrowEl, padding: 6 }) ], - onOpenChange: setOpen, + middleware: [ + offset(props.arrow ? 10 : 6), + flip(), + shift({ padding: 6 }), + arrow({ element: arrowEl, padding: 6 }), + ], + onOpenChange: (o) => setOpen(o || alwaysOpen || false), whileElementsMounted: autoUpdate, }); const { getReferenceProps, getFloatingProps } = useInteractions([ useFocus(context), - useHover(context, { restMs: 30 }), + useHover(context, { restMs: rest, delay }), useRole(context, { role: 'tooltip' }), useDismiss(context), ]); @@ -70,7 +86,7 @@ export default ({ content, children, disabled = false, ...props }: Props) => { initial={{ opacity: 0, scale: 0.85 }} animate={{ opacity: 1, scale: 1 }} exit={{ opacity: 0 }} - transition={{ type: 'easeIn', damping: 20, stiffness: 300, duration: 0.1 }} + transition={{ type: 'spring', damping: 20, stiffness: 300, duration: 0.075 }} {...getFloatingProps({ ref: floating, className: 'absolute top-0 left-0 bg-gray-900 text-sm text-gray-200 px-3 py-2 rounded pointer-events-none max-w-[90vw]', @@ -86,10 +102,10 @@ export default ({ content, children, disabled = false, ...props }: Props) => {
}