@neo4j-ndl/react
Version:
React implementation of Neo4j Design System
45 lines • 3.96 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
import { FilledButton, OutlinedButton, SideNavigation, Spotlight, SpotlightTarget, useNeedleTheme, useSpotlightContext, } from '@neo4j-ndl/react';
import { useEffect, useState } from 'react';
const Component = (props) => {
const { themeClassName } = useNeedleTheme();
const { setActiveSpotlight, setIsOpen } = useSpotlightContext();
const [isSelected, setIsSelected] = useState('aura-db-instances');
const targetId = `test-target-${themeClassName}`;
const handleClick = (item) => {
setIsSelected(item);
};
useEffect(() => {
if (props.isChromatic) {
setActiveSpotlight(targetId);
setIsOpen(true);
}
}, [setActiveSpotlight, setIsOpen, targetId, props.isChromatic]);
return (_jsxs("div", { className: "n-h-[500px] n-flex", children: [_jsxs(SideNavigation, { isExpanded: true, ariaLabel: "Main side navigation", children: [_jsx(SideNavigation.CategoryHeader, { children: "AuraDB" }), _jsx(SideNavigation.ListItem, { children: _jsx(SideNavigation.NavItem, { onClick: () => handleClick('aura-db-instances'), isActive: isSelected === 'aura-db-instances', label: "Instances" }) }), _jsx(SideNavigation.ListItem, { children: _jsx(SideNavigation.NavItem, { onClick: () => handleClick('aura-db-connect'), isActive: isSelected === 'aura-db-connect', label: "Connect" }) }), _jsx(SideNavigation.ListItem, { children: _jsx(SideNavigation.NavItem, { onClick: () => handleClick('aura-db-python'), isActive: isSelected === 'aura-db-python', label: "Python" }) }), _jsx(SideNavigation.ListItem, { children: _jsx(SpotlightTarget, { id: targetId, hasPulse: !props.isChromatic, borderRadius: 4, indicatorVariant: "point", indicatorPlacement: "top-right", asChild: true, children: _jsx(SideNavigation.NavItem, { onClick: () => handleClick('aura-db-javascript'), isActive: isSelected === 'aura-db-javascript', label: "JavaScript" }) }) }), _jsx(SideNavigation.CategoryHeader, { children: "AuraDS" }), _jsx(SideNavigation.ListItem, { children: _jsx(SideNavigation.NavItem, { onClick: () => handleClick('aura-ds-instances'), isActive: isSelected === 'aura-ds-instances', label: "Instances" }) }), _jsx(SideNavigation.ListItem, { children: _jsx(SideNavigation.NavItem, { onClick: () => handleClick('aura-ds-getting-started'), isActive: isSelected === 'aura-ds-getting-started', label: "Getting Started" }) })] }), _jsx("div", { className: "n-w-full n-h-full n-flex n-flex-col n-items-center n-justify-center n-rounded-md n-p-token-16", children: _jsx(FilledButton, { onClick: () => setActiveSpotlight(targetId), children: "Activate Spotlight" }) }), _jsxs(Spotlight, { placement: "top-end-top-start", target: targetId, actions: _jsx(OutlinedButton, { onClick: () => {
setIsOpen(false);
setActiveSpotlight(null);
}, children: "Close" }), children: [_jsx(Spotlight.Header, { children: "This is a header" }), _jsx(Spotlight.Body, { children: "This is content" })] })] }));
};
export default Component;
//# sourceMappingURL=spotlight-in-side-nav.story.js.map