mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-04 02:01:58 -05:00
AdminX various cleanup (#17522)
refs. https://github.com/TryGhost/Product/issues/3349 - fixed textfield right placeholder bug - fixed menu highlight when settings is searched
This commit is contained in:
parent
0a0fcbc551
commit
db272bf146
3 changed files with 12 additions and 6 deletions
|
@ -33,7 +33,7 @@ function App({ghostVersion, officialThemes}: AppProps) {
|
|||
</div>
|
||||
|
||||
{/* Main container */}
|
||||
<div className="mx-auto flex max-w-[1080px] flex-col px-[5vmin] py-[12vmin] md:flex-row md:items-start md:gap-x-10 md:py-[8vmin]">
|
||||
<div className="mx-auto flex max-w-[1080px] flex-col px-[5vmin] py-[12vmin] md:flex-row md:items-start md:gap-x-10 md:py-[8vmin]" id="admin-x-settings-content">
|
||||
|
||||
{/* Sidebar */}
|
||||
<div className="relative z-20 min-w-[260px] grow-0 md:fixed md:top-[8vmin] md:basis-[260px]">
|
||||
|
|
|
@ -75,12 +75,12 @@ const TextField: React.FC<TextFieldProps> = ({
|
|||
|
||||
if (rightPlaceholder) {
|
||||
const rightPHClasses = !unstyled && clsx(
|
||||
'h-10 border-b py-2 text-right text-grey-500',
|
||||
'order-3 h-10 border-b py-2 text-right text-grey-500',
|
||||
error ? `border-red` : `${disabled ? 'border-grey-300' : 'border-grey-500 peer-hover:border-grey-700 peer-focus:border-black'}`
|
||||
);
|
||||
|
||||
field = (
|
||||
<div className='flex w-full items-center'>
|
||||
<div className='order-2 flex w-full items-center'>
|
||||
{inputField}
|
||||
<span className={rightPHClasses || ''}>{rightPlaceholder}</span>
|
||||
</div>
|
||||
|
|
|
@ -58,7 +58,7 @@ const SettingGroup: React.FC<SettingGroupProps> = ({
|
|||
const {yScroll, updateScrolled, route} = useRouting();
|
||||
const [highlight, setHighlight] = useState(false);
|
||||
const scrollRef = useRef<HTMLDivElement | null>(null);
|
||||
const [currentRect, setCurrentRect] = useState<DOMRect>(DOMRect.fromRect());
|
||||
const [currentRect, setCurrentRect] = useState<{top: number, bottom: number}>({top: 0, bottom: 0});
|
||||
const topOffset = -193.5;
|
||||
const bottomOffset = 36;
|
||||
|
||||
|
@ -134,9 +134,15 @@ const SettingGroup: React.FC<SettingGroupProps> = ({
|
|||
|
||||
useEffect(() => {
|
||||
if (scrollRef.current) {
|
||||
setCurrentRect(scrollRef.current.getBoundingClientRect());
|
||||
const rootElement = document.getElementById('admin-x-settings-content');
|
||||
const rootRect = rootElement?.getBoundingClientRect();
|
||||
const sectionRect = scrollRef.current.getBoundingClientRect();
|
||||
setCurrentRect({
|
||||
top: sectionRect.top - rootRect!.top,
|
||||
bottom: (sectionRect.top - rootRect!.top) + sectionRect.height
|
||||
});
|
||||
}
|
||||
}, [checkVisible]);
|
||||
}, [checkVisible, navid]);
|
||||
|
||||
useEffect(() => {
|
||||
if (currentRect.top && yScroll! >= currentRect.top + topOffset && yScroll! < currentRect.bottom + topOffset + bottomOffset) {
|
||||
|
|
Loading…
Add table
Reference in a new issue