@neo4j-ndl/react
Version:
React implementation of Neo4j Design System
51 lines • 4.04 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 { Button, Spotlight, SpotlightTarget, useNeedleTheme, useSpotlightContext, } from '@neo4j-ndl/react';
import { SideNavigation } from '@neo4j-ndl/react/next';
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: [_jsx(SideNavigation, { isExpanded: true, children: _jsxs(SideNavigation.List, { children: [_jsx(SideNavigation.CategoryHeader, { children: "AuraDB" }), _jsx(SideNavigation.NavItem, { as: "button", onClick: () => handleClick('aura-db-instances'), isSelected: isSelected === 'aura-db-instances', label: "Instances" }), _jsx(SideNavigation.NavItem, { as: "button", onClick: () => handleClick('aura-db-connect'), isSelected: isSelected === 'aura-db-connect', label: "Connect" }), _jsxs(SideNavigation.List, { children: [_jsx(SideNavigation.NavItem, { as: "button", onClick: () => handleClick('aura-db-python'), isSelected: isSelected === 'aura-db-python', label: "Python" }), _jsx(SpotlightTarget, { as: "li", id: targetId, hasPulse: !props.isChromatic, borderRadius: 4, backgroundColor: "rgb(var(--theme-palette-neutral-bg-weak))", indicatorVariant: "point", indicatorPlacement: "top-right", children: _jsx(SideNavigation.NavItem, { as: "button", onClick: () => handleClick('aura-db-javascript'), isSelected: isSelected === 'aura-db-javascript', label: "JavaScript" }) })] }), _jsx(SideNavigation.CategoryHeader, { children: "AuraDS" }), _jsxs(SideNavigation.List, { children: [_jsx(SideNavigation.NavItem, { as: "button", onClick: () => handleClick('aura-ds-instances'), isSelected: isSelected === 'aura-ds-instances', label: "Instances" }), _jsx(SideNavigation.NavItem, { as: "button", onClick: () => handleClick('aura-ds-getting-started'), isSelected: 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-6", children: _jsx(Button, { onClick: () => setActiveSpotlight(targetId), children: "Activate Spotlight" }) }), _jsxs(Spotlight, { placement: "top-end-top-start", target: targetId, actions: [
{
label: 'Close',
onClick: () => {
setIsOpen(false);
setActiveSpotlight(null);
},
},
], 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