@kkkarsss/ui 1.4.12 → 1.4.14
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.
|
@@ -8,5 +8,5 @@ import { IconAction } from '../icon-action/icon-action';
|
|
|
8
8
|
export const MainPageLayout = ({ children, leftPanel, rightPanel, leftIcon, rightIcon, }) => {
|
|
9
9
|
const { widget } = useWidget();
|
|
10
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 @s:grid-cols-[300px_1fr_300px] @s:py-xl @s:px-l @s:gap-l py-m px-s gap-s relative overflow-hidden", children: [_jsx("aside", { className: "hidden @s:block h-full w-full", children: leftPanel }), _jsx("div", { className: "@s: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 @s:flex' : 'flex', 'h-full mt-[50px] @s:m-0'), children: [_jsx("div", { className: 'hidden @
|
|
11
|
+
return (_jsx("div", { className: "@container w-full h-[100dvh]", children: _jsxs("main", { className: "grid h-full w-full grid-cols-1 @s:grid-cols-[300px_1fr_300px] @s:py-xl @s:px-l @s:gap-l py-m px-s gap-s relative overflow-hidden", children: [_jsx("aside", { className: "hidden @s:block h-full w-full", children: leftPanel }), _jsx("div", { className: "@s: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, { direction: 'column', justify: 'center', gap: '16px', type: 'fill', className: jc(expandedPanel ? 'hidden @s:flex' : 'flex', 'h-full mt-[50px] @s:m-0'), children: [_jsx("div", { className: jc('h-full overflow-auto @s:block', widget ? 'hidden @s:block' : 'block'), children: children }), widget && (_jsx("div", { className: "flex-1 min-h-0 @s:flex-initial h-full", children: _jsx(Fragment, { children: widget.ui }, widget.id) }))] }), _jsx("aside", { className: "hidden @s:block h-full w-full", children: rightPanel }), _jsx("div", { className: "@s: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: "@s:hidden absolute inset-0 z-40 bg-background pt-16 px-4 pb-4 overflow-auto", children: expandedPanel === 'left' ? leftPanel : rightPanel }))] }) }));
|
|
12
12
|
};
|
|
@@ -3,4 +3,5 @@ import { MainPageLayout } from './main-page-layout';
|
|
|
3
3
|
declare const meta: Meta<typeof MainPageLayout>;
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof meta>;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const WithWidgets: Story;
|
|
7
|
+
export declare const ResponsiveWidget: Story;
|
|
@@ -1,9 +1,12 @@
|
|
|
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
|
+
import { Activity, BookmarkCheck, Calendar, Clock3, LandPlot, Newspaper, Settings, User, X } from 'lucide-react';
|
|
3
|
+
import { useEffect } from 'react';
|
|
3
4
|
import { MainPageLayout } from './main-page-layout';
|
|
4
|
-
import { useLayout } from '../../../providers';
|
|
5
|
+
import { useLayout, WidgetProvider, LayoutProvider, useWidget } from '../../../providers';
|
|
6
|
+
import { Button } from '../../controls';
|
|
5
7
|
import { Block, Cell, CellsBlock, Typo } from '../../information';
|
|
6
8
|
import { Flex } from '../flex/flex';
|
|
9
|
+
import { IconAction } from '../icon-action/icon-action';
|
|
7
10
|
import { Offset } from '../offset/offset';
|
|
8
11
|
const meta = {
|
|
9
12
|
title: 'Layout/MainPageLayout',
|
|
@@ -13,6 +16,9 @@ const meta = {
|
|
|
13
16
|
layout: 'fullscreen',
|
|
14
17
|
chromatic: { delay: 300 },
|
|
15
18
|
},
|
|
19
|
+
decorators: [
|
|
20
|
+
(Story) => (_jsx(LayoutProvider, { children: _jsx(WidgetProvider, { children: _jsx(Story, {}) }) })),
|
|
21
|
+
],
|
|
16
22
|
};
|
|
17
23
|
export default meta;
|
|
18
24
|
const LeftSidebarMock = () => {
|
|
@@ -23,12 +29,43 @@ const RightSidebarMock = () => {
|
|
|
23
29
|
const { closePanels } = useLayout();
|
|
24
30
|
return (_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 }], onClick: closePanels }) }), _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 }], onClick: closePanels }), _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 }], onClick: closePanels })] })] }));
|
|
25
31
|
};
|
|
26
|
-
export const
|
|
32
|
+
export const WithWidgets = {
|
|
33
|
+
render: (args) => {
|
|
34
|
+
const { setWidget } = useWidget();
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
setWidget({
|
|
37
|
+
id: 'demo-widget',
|
|
38
|
+
ui: (_jsx(Block, { title: _jsx(Typo, { size: "xl", weight: "500", children: "Demo Widget" }), onBack: () => setWidget(null), children: _jsxs(Offset, { children: [_jsx(Typo, { children: "\u042D\u0442\u043E \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u043C\u043E\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u0430, \u043A\u043E\u0442\u043E\u0440\u043E\u0435 \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044F \u0441\u043F\u0440\u0430\u0432\u0430 \u043E\u0442 \u043E\u0441\u043D\u043E\u0432\u043D\u043E\u0433\u043E \u043A\u043E\u043D\u0442\u0435\u043D\u0442\u0430." }), _jsx(Typo, { color: "secondary", size: "s", children: "\u0412\u0438\u0434\u0436\u0435\u0442\u044B \u043E\u0431\u044B\u0447\u043D\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u044E\u0442\u0441\u044F \u0434\u043B\u044F \u0441\u043E\u0437\u0434\u0430\u043D\u0438\u044F \u043D\u043E\u0432\u044B\u0445 \u0441\u0443\u0449\u043D\u043E\u0441\u0442\u0435\u0439 \u0438\u043B\u0438 \u0440\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044E\u0449\u0438\u0445 \u0431\u0435\u0437 \u0443\u0445\u043E\u0434\u0430 \u0441 \u043E\u0441\u043D\u043E\u0432\u043D\u043E\u0439 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B." })] }) })),
|
|
39
|
+
});
|
|
40
|
+
return () => setWidget(null);
|
|
41
|
+
}, []);
|
|
42
|
+
return _jsx(MainPageLayout, { ...args });
|
|
43
|
+
},
|
|
27
44
|
args: {
|
|
28
45
|
leftIcon: _jsx(Settings, { size: 20 }),
|
|
29
46
|
rightIcon: _jsx(User, { size: 20 }),
|
|
30
47
|
leftPanel: _jsx(LeftSidebarMock, {}),
|
|
31
48
|
rightPanel: _jsx(RightSidebarMock, {}),
|
|
32
|
-
children: (_jsx(Block, { title: _jsx(Typo, { size: "xl", weight: "500", children: "Main Content
|
|
49
|
+
children: (_jsx(Block, { title: _jsx(Typo, { size: "xl", weight: "500", children: "Main Content" }), children: _jsx(Offset, { children: _jsxs(Flex, { direction: "column", gap: "16px", children: [_jsx(Typo, { children: "\u041D\u0430 \u044D\u0442\u043E\u0439 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0435 \u0434\u0435\u043C\u043E\u043D\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044F \u0440\u0430\u0431\u043E\u0442\u0430 \u0441 \u0432\u0438\u0434\u0436\u0435\u0442\u0430\u043C\u0438." }), _jsx(Button, { onClick: () => {
|
|
50
|
+
alert('Виджет уже открыт или переоткрывается через useEffect в этой истории');
|
|
51
|
+
}, children: "\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0432\u0438\u0434\u0436\u0435\u0442 (\u0434\u0435\u043C\u043E)" })] }) }) })),
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
export const ResponsiveWidget = {
|
|
55
|
+
args: {
|
|
56
|
+
leftIcon: _jsx(Settings, { size: 20 }),
|
|
57
|
+
rightIcon: _jsx(User, { size: 20 }),
|
|
58
|
+
leftPanel: _jsx(LeftSidebarMock, {}),
|
|
59
|
+
rightPanel: _jsx(RightSidebarMock, {}),
|
|
60
|
+
},
|
|
61
|
+
render: (args) => {
|
|
62
|
+
const { setWidget, widget } = useWidget();
|
|
63
|
+
const openWidget = () => {
|
|
64
|
+
setWidget({
|
|
65
|
+
id: 'responsive-demo',
|
|
66
|
+
ui: (_jsx(Block, { title: _jsx(Typo, { size: "xl", weight: "500", children: "Responsive Widget" }), onBack: () => setWidget(null), topAcc: _jsx(IconAction, { icon: _jsx(X, { size: 16, color: 'var(--accent)' }), onClick: () => setWidget(null) }), children: _jsx(Offset, { children: _jsxs(Flex, { direction: "column", gap: "16px", children: [_jsx(Typo, { children: "\u041D\u0430 \u043C\u043E\u0431\u0438\u043B\u043A\u0430\u0445 \u044D\u0442\u043E\u0442 \u0432\u0438\u0434\u0436\u0435\u0442 \u043F\u0435\u0440\u0435\u043A\u0440\u044B\u0432\u0430\u0435\u0442 \u043E\u0441\u043D\u043E\u0432\u043D\u043E\u0439 \u043A\u043E\u043D\u0442\u0435\u043D\u0442 \u043F\u043E\u043B\u043D\u043E\u0441\u0442\u044C\u044E." }), _jsx(Typo, { color: "secondary", children: "\u041D\u0430 \u0434\u0435\u0441\u043A\u0442\u043E\u043F\u0435 \u043E\u043D \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044F \u0441\u043F\u0440\u0430\u0432\u0430 \u043E\u0442 \u043E\u0441\u043D\u043E\u0432\u043D\u043E\u0433\u043E \u043A\u043E\u043D\u0442\u0435\u043D\u0442\u0430." }), _jsx(Button, { onClick: () => setWidget(null), variant: "active", children: "Close" })] }) }) })),
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
return (_jsx(MainPageLayout, { ...args, children: _jsx(Block, { title: _jsx(Typo, { size: "xl", weight: "500", children: "Main Page Content" }), children: _jsx(Offset, { children: _jsxs(Flex, { direction: "column", gap: "16px", children: [_jsx(Typo, { children: "\u041F\u043E\u043F\u0440\u043E\u0431\u0443\u0439\u0442\u0435 \u0443\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u044C \u0448\u0438\u0440\u0438\u043D\u0443 \u043E\u043A\u043D\u0430 \u0434\u043E \u043C\u043E\u0431\u0438\u043B\u044C\u043D\u043E\u0433\u043E \u0440\u0430\u0437\u043C\u0435\u0440\u0430, \u0447\u0442\u043E\u0431\u044B \u0443\u0432\u0438\u0434\u0435\u0442\u044C \u043A\u0430\u043A \u0432\u0438\u0434\u0436\u0435\u0442 \u043F\u043E\u043B\u043D\u043E\u0441\u0442\u044C\u044E \u043F\u0435\u0440\u0435\u043A\u0440\u044B\u0432\u0430\u0435\u0442 \u043A\u043E\u043D\u0442\u0435\u043D\u0442." }), !widget && _jsx(Button, { onClick: openWidget, children: "Open Responsive Widget" }), widget && _jsx(Typo, { color: "secondary", children: "\u0412\u0438\u0434\u0436\u0435\u0442 \u043E\u0442\u043A\u0440\u044B\u0442!" }), _jsx("div", { className: "h-[400px] bg-secondary/10 flex items-center justify-center rounded-lg border-2 border-dashed border-secondary/20", children: _jsx(Typo, { color: "secondary", children: "\u041E\u0441\u043D\u043E\u0432\u043D\u043E\u0439 \u043A\u043E\u043D\u0442\u0435\u043D\u0442 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B" }) })] }) }) }) }));
|
|
33
70
|
},
|
|
34
71
|
};
|