@kkkarsss/ui 1.3.0 → 1.4.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/providers/index.d.ts +2 -0
- package/dist/providers/index.js +2 -0
- package/dist/providers/layout/layout-context.d.ts +12 -0
- package/dist/providers/layout/layout-context.js +17 -0
- package/dist/providers/layout/use-layout.d.ts +7 -0
- package/dist/providers/layout/use-layout.js +9 -0
- package/dist/ui/layout/main-page-layout/main-page-layout.d.ts +4 -1
- package/dist/ui/layout/main-page-layout/main-page-layout.js +7 -3
- package/dist/ui/layout/main-page-layout/main-page-layout.stories.js +12 -4
- package/package.json +3 -2
|
@@ -7,3 +7,5 @@ export { ThemeProvider } from './theme/theme-provider';
|
|
|
7
7
|
export { AlertContext, type TAlert } from './alert/alert-context';
|
|
8
8
|
export { AlertProvider } from './alert/alert-provider';
|
|
9
9
|
export { useAlerts } from './alert/use-alerts';
|
|
10
|
+
export { LayoutProvider } from './layout/layout-context';
|
|
11
|
+
export { useLayout } from './layout/use-layout';
|
package/dist/providers/index.js
CHANGED
|
@@ -7,3 +7,5 @@ export { ThemeProvider } from './theme/theme-provider';
|
|
|
7
7
|
export { AlertContext } from './alert/alert-context';
|
|
8
8
|
export { AlertProvider } from './alert/alert-provider';
|
|
9
9
|
export { useAlerts } from './alert/use-alerts';
|
|
10
|
+
export { LayoutProvider } from './layout/layout-context';
|
|
11
|
+
export { useLayout } from './layout/use-layout';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type FC, type PropsWithChildren } from 'react';
|
|
2
|
+
export type TExpandedPanel = 'left' | 'right' | null;
|
|
3
|
+
type TLayoutContext = {
|
|
4
|
+
expandedPanel: TExpandedPanel;
|
|
5
|
+
setExpandedPanel: (panel: TExpandedPanel) => void;
|
|
6
|
+
toggleLeftPanel: () => void;
|
|
7
|
+
toggleRightPanel: () => void;
|
|
8
|
+
closePanels: () => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const LayoutContext: import("react").Context<TLayoutContext | undefined>;
|
|
11
|
+
export declare const LayoutProvider: FC<PropsWithChildren>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useState, useMemo } from 'react';
|
|
3
|
+
export const LayoutContext = createContext(undefined);
|
|
4
|
+
export const LayoutProvider = ({ children }) => {
|
|
5
|
+
const [expandedPanel, setExpandedPanel] = useState(null);
|
|
6
|
+
const toggleLeftPanel = () => setExpandedPanel((prev) => (prev === 'left' ? null : 'left'));
|
|
7
|
+
const toggleRightPanel = () => setExpandedPanel((prev) => (prev === 'right' ? null : 'right'));
|
|
8
|
+
const closePanels = () => setExpandedPanel(null);
|
|
9
|
+
const value = useMemo(() => ({
|
|
10
|
+
expandedPanel,
|
|
11
|
+
setExpandedPanel,
|
|
12
|
+
toggleLeftPanel,
|
|
13
|
+
toggleRightPanel,
|
|
14
|
+
closePanels,
|
|
15
|
+
}), [expandedPanel]);
|
|
16
|
+
return _jsx(LayoutContext.Provider, { value: value, children: children });
|
|
17
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const useLayout: () => {
|
|
2
|
+
expandedPanel: import("./layout-context").TExpandedPanel;
|
|
3
|
+
setExpandedPanel: (panel: import("./layout-context").TExpandedPanel) => void;
|
|
4
|
+
toggleLeftPanel: () => void;
|
|
5
|
+
toggleRightPanel: () => void;
|
|
6
|
+
closePanels: () => void;
|
|
7
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { LayoutContext } from './layout-context';
|
|
3
|
+
export const useLayout = () => {
|
|
4
|
+
const context = useContext(LayoutContext);
|
|
5
|
+
if (!context) {
|
|
6
|
+
throw new Error('useLayout must be used within a LayoutProvider');
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LucideProps } from 'lucide-react';
|
|
2
|
+
import { type FC, type PropsWithChildren, type ReactNode, ReactElement } from 'react';
|
|
2
3
|
type TProps = {
|
|
3
4
|
leftPanel?: ReactNode;
|
|
4
5
|
rightPanel?: ReactNode;
|
|
6
|
+
leftIcon?: ReactElement<LucideProps>;
|
|
7
|
+
rightIcon?: ReactElement<LucideProps>;
|
|
5
8
|
};
|
|
6
9
|
export declare const MainPageLayout: FC<PropsWithChildren<TProps>>;
|
|
7
10
|
export {};
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Menu, X } from 'lucide-react';
|
|
2
3
|
import { Fragment } from 'react';
|
|
3
|
-
import { useWidget } from '../../../providers';
|
|
4
|
+
import { useWidget, useLayout } from '../../../providers';
|
|
5
|
+
import { jc } from '../../../utils';
|
|
4
6
|
import { Flex } from '../flex/flex';
|
|
5
|
-
|
|
7
|
+
import { IconAction } from '../icon-action/icon-action';
|
|
8
|
+
export const MainPageLayout = ({ children, leftPanel, rightPanel, leftIcon, rightIcon, }) => {
|
|
6
9
|
const { widget } = useWidget();
|
|
7
|
-
|
|
10
|
+
const { expandedPanel, toggleLeftPanel, toggleRightPanel } = useLayout();
|
|
11
|
+
return (_jsx("div", { className: "@container w-full h-[100dvh]", children: _jsxs("main", { className: "grid h-full w-full grid-cols-1 @m:grid-cols-[300px_1fr_300px] @m:py-xl @m:px-l @m:gap-l py-m px-s gap-s relative overflow-hidden", children: [_jsx("aside", { className: "hidden @m:block h-full w-full", children: leftPanel }), _jsx("div", { className: "@m:hidden absolute left-4 top-4 z-50", children: _jsx(IconAction, { icon: expandedPanel === 'left' ? _jsx(X, { size: 20 }) : leftIcon || _jsx(Menu, { size: 20 }), onClick: toggleLeftPanel }) }), _jsxs(Flex, { justify: 'center', gap: '16px', type: 'fill', className: jc(expandedPanel ? 'hidden @m:flex' : 'flex', 'h-full'), children: [children, widget && _jsx(Fragment, { children: widget.ui }, widget.id)] }), _jsx("aside", { className: "hidden @m:block h-full w-full", children: rightPanel }), _jsx("div", { className: "@m:hidden absolute right-4 top-4 z-50", children: _jsx(IconAction, { icon: expandedPanel === 'right' ? _jsx(X, { size: 20 }) : rightIcon || _jsx(Menu, { size: 20 }), onClick: toggleRightPanel }) }), expandedPanel && (_jsx("div", { className: "@m:hidden absolute inset-0 z-40 bg-background pt-16 px-4 pb-4 overflow-auto", children: expandedPanel === 'left' ? leftPanel : rightPanel }))] }) }));
|
|
8
12
|
};
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Activity, BookmarkCheck, Calendar, Clock3, LandPlot, Newspaper, Settings, User } from 'lucide-react';
|
|
2
3
|
import { MainPageLayout } from './main-page-layout';
|
|
3
|
-
import { Typo } from '../../information';
|
|
4
|
+
import { Block, Cell, CellsBlock, Typo } from '../../information';
|
|
5
|
+
import { Flex } from '../flex/flex';
|
|
6
|
+
import { Offset } from '../offset/offset';
|
|
4
7
|
const meta = {
|
|
5
8
|
title: 'Layout/MainPageLayout',
|
|
6
9
|
component: MainPageLayout,
|
|
7
10
|
tags: ['autodocs'],
|
|
8
11
|
parameters: {
|
|
9
12
|
layout: 'fullscreen',
|
|
13
|
+
chromatic: { delay: 300 },
|
|
10
14
|
},
|
|
11
15
|
};
|
|
12
16
|
export default meta;
|
|
17
|
+
const LeftSidebarMock = () => (_jsx(Flex, { direction: 'column', gap: '16px', type: 'fill', children: _jsxs(CellsBlock, { title: _jsx(Typo, { size: 'm', weight: '500', color: 'secondary', children: "John Doe" }), children: [_jsx(Cell, { title: _jsx(Typo, { children: "Tasks" }), description: _jsx(Typo, { size: 's', color: 'secondary', children: "Manage everything you should do" }), accLeft: [{ icon: BookmarkCheck }], active: true }), _jsx(Cell, { title: _jsx(Typo, { children: "Projects" }), description: _jsx(Typo, { size: 's', color: 'secondary', children: "Unite tasks and data in one screen" }), accLeft: [{ icon: LandPlot }] }), _jsx(Cell, { title: _jsx(Typo, { children: "Tips" }), description: _jsx(Typo, { size: 's', color: 'secondary', children: "Notes to your tasks and projects" }), accLeft: [{ icon: Newspaper }] }), _jsx(Cell, { title: _jsx(Typo, { children: "Calendar" }), description: _jsx(Typo, { size: 's', color: 'secondary', children: "Your routine and added tasks" }), accLeft: [{ icon: Calendar }] })] }) }));
|
|
18
|
+
const RightSidebarMock = () => (_jsxs(Flex, { direction: 'column', type: 'fill', gap: '16px', children: [_jsx(CellsBlock, { title: _jsx(Typo, { size: 'm', color: 'secondary', weight: '500', children: "Variables" }), children: _jsx(Cell, { title: _jsx(Typo, { children: "System settings" }), description: _jsx(Typo, { size: 's', color: 'secondary', children: "Do not affect the calculation" }), accLeft: [{ icon: Settings }] }) }), _jsxs(CellsBlock, { title: _jsx(Typo, { size: 'm', color: 'secondary', weight: '500', children: "Stats" }), children: [_jsx(Cell, { title: _jsx(Typo, { children: "Productivity" }), description: _jsx(Typo, { size: 's', color: 'secondary', children: "Tasks/day" }), accLeft: [{ icon: Activity }] }), _jsx(Cell, { title: _jsx(Typo, { children: "Latest activity" }), description: _jsx(Typo, { size: 's', color: 'secondary', children: "History of your actions across service" }), accLeft: [{ icon: Clock3 }] })] })] }));
|
|
13
19
|
export const Default = {
|
|
14
20
|
args: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
leftIcon: _jsx(Settings, { size: 20 }),
|
|
22
|
+
rightIcon: _jsx(User, { size: 20 }),
|
|
23
|
+
leftPanel: _jsx(LeftSidebarMock, {}),
|
|
24
|
+
rightPanel: _jsx(RightSidebarMock, {}),
|
|
25
|
+
children: (_jsx(Block, { title: _jsx(Typo, { size: "xl", weight: "500", children: "Main Content Area" }), children: _jsxs(Offset, { children: [_jsx(Typo, { children: "\u042D\u0442\u043E \u0434\u0435\u043C\u043E-\u0432\u0435\u0440\u0441\u0438\u044F \u043E\u0441\u043D\u043E\u0432\u043D\u043E\u0433\u043E \u043C\u0430\u043A\u0435\u0442\u0430 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F \u0441 \u0430\u0434\u0430\u043F\u0442\u0438\u0432\u043D\u044B\u043C\u0438 \u0441\u0430\u0439\u0434\u0431\u0430\u0440\u0430\u043C\u0438." }), _jsx(Typo, { color: "secondary", children: "\u041F\u043E\u043F\u0440\u043E\u0431\u0443\u0439\u0442\u0435 \u0438\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u0448\u0438\u0440\u0438\u043D\u0443 \u043E\u043A\u043D\u0430 (\u0438\u043B\u0438 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u0430 \u0432 Storybook), \u0447\u0442\u043E\u0431\u044B \u0443\u0432\u0438\u0434\u0435\u0442\u044C \u0430\u0434\u0430\u043F\u0442\u0438\u0432\u043D\u043E\u0435 \u043F\u043E\u0432\u0435\u0434\u0435\u043D\u0438\u0435:" }), _jsxs("ul", { className: "list-disc ml-6 space-y-2", children: [_jsx("li", { children: _jsx(Typo, { size: "s", children: "\u041F\u0440\u0438 \u0448\u0438\u0440\u0438\u043D\u0435 > 1100px (L): \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u044E\u0442\u0441\u044F \u043E\u0431\u0430 \u0441\u0430\u0439\u0434\u0431\u0430\u0440\u0430." }) }), _jsx("li", { children: _jsx(Typo, { size: "s", children: "\u041F\u0440\u0438 \u0448\u0438\u0440\u0438\u043D\u0435 680px - 1100px (M): \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u044E\u0442\u0441\u044F \u043E\u0431\u0430 \u0441\u0430\u0439\u0434\u0431\u0430\u0440\u0430 (\u043D\u0430 \u0431\u0430\u0437\u0435 @m/layout)." }) }), _jsx("li", { children: _jsx(Typo, { size: "s", children: "\u041F\u0440\u0438 \u0448\u0438\u0440\u0438\u043D\u0435 < 680px (S): \u0441\u0430\u0439\u0434\u0431\u0430\u0440\u044B \u0441\u043A\u0440\u044B\u0432\u0430\u044E\u0442\u0441\u044F, \u043F\u043E\u044F\u0432\u043B\u044F\u044E\u0442\u0441\u044F \u0438\u043A\u043E\u043D\u043A\u0438 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043E\u0432 \u0432 \u0443\u0433\u043B\u0430\u0445." }) }), _jsx("li", { children: _jsx(Typo, { size: "s", children: "\u041D\u0430\u0436\u0430\u0442\u0438\u0435 \u043D\u0430 \u0438\u043A\u043E\u043D\u043A\u0443 \u043E\u0442\u043A\u0440\u044B\u0432\u0430\u0435\u0442 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044E\u0449\u0438\u0439 \u0441\u0430\u0439\u0434\u0431\u0430\u0440 \u0432\u043E \u0432\u0435\u0441\u044C \u044D\u043A\u0440\u0430\u043D." }) })] }), _jsx("div", { className: "h-[1000px] bg-secondary/10 flex items-center justify-center rounded-lg border-2 border-dashed border-secondary/20", children: _jsx(Typo, { color: "secondary", children: "\u0414\u043B\u0438\u043D\u043D\u044B\u0439 \u043A\u043E\u043D\u0442\u0435\u043D\u0442 \u0434\u043B\u044F \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438 \u043F\u0440\u043E\u043A\u0440\u0443\u0442\u043A\u0438" }) })] }) })),
|
|
18
26
|
},
|
|
19
27
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kkkarsss/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "UI Kit for kkkarsss projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
"@storybook/addon-vitest": "^10.2.7",
|
|
33
33
|
"@storybook/react": "^10.2.7",
|
|
34
34
|
"@storybook/react-vite": "^10.2.7",
|
|
35
|
+
"@tailwindcss/container-queries": "^0.1.1",
|
|
36
|
+
"tailwindcss": "^3.4.19",
|
|
35
37
|
"@types/node": "^25.0.10",
|
|
36
38
|
"@types/react": "^19.2.9",
|
|
37
39
|
"@types/react-dom": "^19.2.3",
|
|
@@ -53,7 +55,6 @@
|
|
|
53
55
|
"react": "^19.2.3",
|
|
54
56
|
"react-dom": "^19.2.3",
|
|
55
57
|
"storybook": "^10.2.7",
|
|
56
|
-
"tailwindcss": "^3.4.19",
|
|
57
58
|
"typescript": "5.9.3",
|
|
58
59
|
"typescript-eslint": "^8.53.1",
|
|
59
60
|
"vite": "^7.3.1",
|