@gadagi/ui-navigation 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -0
- package/dist/index.js.LICENSE.txt +9 -0
- package/package.json +8 -7
- package/src/NavItem.tsx +0 -41
- package/src/Navigation.tsx +0 -55
- package/src/index.ts +0 -2
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("@gadagi/design-system"),require("react-router-dom")):"function"==typeof define&&define.amd?define(["React",,],t):"object"==typeof exports?exports.gadagiUiNavigation=t(require("react"),require("@gadagi/design-system"),require("react-router-dom")):e.gadagiUiNavigation=t(e.React,e[void 0],e[void 0])}(this,(e,t,r)=>(()=>{"use strict";var o={698(e,t){var r=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function i(e,t,o){var i=null;if(void 0!==o&&(i=""+o),void 0!==t.key&&(i=""+t.key),"key"in t)for(var n in o={},t)"key"!==n&&(o[n]=t[n]);else o=t;return t=o.ref,{$$typeof:r,type:e,key:i,ref:void 0!==t?t:null,props:o}}t.Fragment=o,t.jsx=i,t.jsxs=i},848(e,t,r){e.exports=r(698)},158(e){e.exports=t},156(t){t.exports=e},362(e){e.exports=r}},i={};function n(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return o[e](r,r.exports,n),r.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};n.r(a),n.d(a,{NavItem:()=>c,Navigation:()=>f});var s=n(848),l=n(156),d=n(158),p=n(362);const c=({item:e,collapsed:t})=>(0,s.jsxs)(p.NavLink,{to:e.path,style:({isActive:e})=>({display:"flex",alignItems:"center",gap:"10px",padding:t?"10px 12px":"10px 16px",borderRadius:"6px",textDecoration:"none",fontSize:d.typography.fontSize.sm,fontWeight:d.typography.fontWeight.medium,color:e?d.colors.primary[600]:d.colors.neutral[600],background:e?d.colors.primary[50]:"transparent",transition:"background 0.15s, color 0.15s",justifyContent:t?"center":void 0}),children:[e.icon&&(0,s.jsx)("span",{style:{fontSize:"16px",flexShrink:0},children:e.icon}),!t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{style:{flex:1},children:e.label}),void 0!==e.badge&&e.badge>0&&(0,s.jsx)(d.Badge,{variant:"info",children:e.badge})]})]}),f=({config:e,defaultCollapsed:t=!1})=>{const[r,o]=(0,l.useState)(t);return(0,s.jsxs)("nav",{style:{width:r?"56px":"240px",minHeight:"100vh",background:"#fff",borderRight:`1px solid ${d.colors.neutral[200]}`,padding:"12px 8px",display:"flex",flexDirection:"column",gap:"2px",transition:"width 0.2s ease",overflowX:"hidden"},children:[(0,s.jsx)("button",{onClick:()=>o(e=>!e),style:{alignSelf:r?"center":"flex-end",background:"transparent",border:"none",cursor:"pointer",padding:"6px",color:d.colors.neutral[400],fontSize:"18px",lineHeight:1,marginBottom:"8px"},title:r?"Expand":"Collapse",children:r?"->":"<-"}),e.items.map(e=>(0,s.jsx)(c,{item:e,collapsed:r},e.id))]})};return a})());
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gadagi/ui-navigation",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Sidebar navigation for gadagi micro-frontends",
|
|
5
|
-
"main": "
|
|
6
|
-
"module": "
|
|
7
|
-
"types": "
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"types": "./
|
|
11
|
-
"
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.esm.js",
|
|
12
|
+
"require": "./dist/index.js"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
|
-
"files": ["
|
|
15
|
+
"files": ["dist"],
|
|
15
16
|
"scripts": {
|
|
16
17
|
"build": "webpack --mode production && tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
17
18
|
"dev": "webpack --mode development --watch"
|
package/src/NavItem.tsx
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { NavLink } from 'react-router-dom';
|
|
3
|
-
import { NavItem as NavItemType } from '@gadagi/types';
|
|
4
|
-
import { colors, typography, Badge } from '@gadagi/design-system';
|
|
5
|
-
|
|
6
|
-
interface NavItemProps {
|
|
7
|
-
item: NavItemType;
|
|
8
|
-
collapsed?: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const NavItem: React.FC<NavItemProps> = ({ item, collapsed }) => {
|
|
12
|
-
return (
|
|
13
|
-
<NavLink
|
|
14
|
-
to={item.path}
|
|
15
|
-
style={({ isActive }) => ({
|
|
16
|
-
display: 'flex',
|
|
17
|
-
alignItems: 'center',
|
|
18
|
-
gap: '10px',
|
|
19
|
-
padding: collapsed ? '10px 12px' : '10px 16px',
|
|
20
|
-
borderRadius: '6px',
|
|
21
|
-
textDecoration: 'none',
|
|
22
|
-
fontSize: typography.fontSize.sm,
|
|
23
|
-
fontWeight: typography.fontWeight.medium,
|
|
24
|
-
color: isActive ? colors.primary[600] : colors.neutral[600],
|
|
25
|
-
background: isActive ? colors.primary[50] : 'transparent',
|
|
26
|
-
transition: 'background 0.15s, color 0.15s',
|
|
27
|
-
justifyContent: collapsed ? 'center' : undefined,
|
|
28
|
-
})}
|
|
29
|
-
>
|
|
30
|
-
{item.icon && <span style={{ fontSize: '16px', flexShrink: 0 }}>{item.icon}</span>}
|
|
31
|
-
{!collapsed && (
|
|
32
|
-
<>
|
|
33
|
-
<span style={{ flex: 1 }}>{item.label}</span>
|
|
34
|
-
{item.badge !== undefined && item.badge > 0 && (
|
|
35
|
-
<Badge variant="info">{item.badge}</Badge>
|
|
36
|
-
)}
|
|
37
|
-
</>
|
|
38
|
-
)}
|
|
39
|
-
</NavLink>
|
|
40
|
-
);
|
|
41
|
-
};
|
package/src/Navigation.tsx
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { NavigationConfig } from '@gadagi/types';
|
|
3
|
-
import { colors, typography } from '@gadagi/design-system';
|
|
4
|
-
import { NavItem } from './NavItem';
|
|
5
|
-
|
|
6
|
-
interface NavigationProps {
|
|
7
|
-
config: NavigationConfig;
|
|
8
|
-
defaultCollapsed?: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const Navigation: React.FC<NavigationProps> = ({
|
|
12
|
-
config,
|
|
13
|
-
defaultCollapsed = false,
|
|
14
|
-
}) => {
|
|
15
|
-
const [collapsed, setCollapsed] = useState(defaultCollapsed);
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<nav
|
|
19
|
-
style={{
|
|
20
|
-
width: collapsed ? '56px' : '240px',
|
|
21
|
-
minHeight: '100vh',
|
|
22
|
-
background: '#fff',
|
|
23
|
-
borderRight: `1px solid ${colors.neutral[200]}`,
|
|
24
|
-
padding: '12px 8px',
|
|
25
|
-
display: 'flex',
|
|
26
|
-
flexDirection: 'column',
|
|
27
|
-
gap: '2px',
|
|
28
|
-
transition: 'width 0.2s ease',
|
|
29
|
-
overflowX: 'hidden',
|
|
30
|
-
}}
|
|
31
|
-
>
|
|
32
|
-
<button
|
|
33
|
-
onClick={() => setCollapsed(c => !c)}
|
|
34
|
-
style={{
|
|
35
|
-
alignSelf: collapsed ? 'center' : 'flex-end',
|
|
36
|
-
background: 'transparent',
|
|
37
|
-
border: 'none',
|
|
38
|
-
cursor: 'pointer',
|
|
39
|
-
padding: '6px',
|
|
40
|
-
color: colors.neutral[400],
|
|
41
|
-
fontSize: '18px',
|
|
42
|
-
lineHeight: 1,
|
|
43
|
-
marginBottom: '8px',
|
|
44
|
-
}}
|
|
45
|
-
title={collapsed ? 'Expand' : 'Collapse'}
|
|
46
|
-
>
|
|
47
|
-
{collapsed ? '->' : '<-'}
|
|
48
|
-
</button>
|
|
49
|
-
|
|
50
|
-
{config.items.map(item => (
|
|
51
|
-
<NavItem key={item.id} item={item} collapsed={collapsed} />
|
|
52
|
-
))}
|
|
53
|
-
</nav>
|
|
54
|
-
);
|
|
55
|
-
};
|
package/src/index.ts
DELETED