@softwareone/spi-sv5-library 0.1.2 → 1.0.0
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/Avatar/Avatar.svelte +33 -0
- package/dist/Avatar/Avatar.svelte.d.ts +10 -0
- package/dist/Breadcrumbs/Breadcrumbs.svelte +10 -20
- package/dist/Button/Button.svelte +59 -119
- package/dist/Button/Button.svelte.d.ts +8 -6
- package/dist/Card/Card.svelte +18 -44
- package/dist/Card/Card.svelte.d.ts +1 -1
- package/dist/Chips/Chips.svelte +25 -28
- package/dist/Chips/Chips.svelte.d.ts +2 -1
- package/dist/Chips/chipsState.svelte.d.ts +7 -0
- package/dist/Chips/chipsState.svelte.js +8 -0
- package/dist/ErrorPage/ErrorPage.svelte +98 -0
- package/dist/ErrorPage/ErrorPage.svelte.d.ts +8 -0
- package/dist/Footer/Footer.svelte +29 -135
- package/dist/Footer/Footer.svelte.d.ts +1 -1
- package/dist/Form/Input/Input.svelte +398 -0
- package/dist/Form/Input/Input.svelte.d.ts +14 -0
- package/dist/Form/Input/InputIcon.svelte +97 -0
- package/dist/Form/Input/InputIcon.svelte.d.ts +9 -0
- package/dist/Form/TextArea/TextArea.svelte +258 -0
- package/dist/Form/TextArea/TextArea.svelte.d.ts +13 -0
- package/dist/Form/Toggle/Toggle.svelte +120 -0
- package/dist/{Toggle → Form/Toggle}/Toggle.svelte.d.ts +4 -3
- package/dist/Header/Header.svelte +65 -100
- package/dist/Header/Header.svelte.d.ts +7 -2
- package/dist/Header/HeaderAccount.svelte +6 -29
- package/dist/HighlightPanel/HighlightPanel.svelte +125 -0
- package/dist/HighlightPanel/HighlightPanel.svelte.d.ts +10 -0
- package/dist/HighlightPanel/highlightPanelState.svelte.d.ts +35 -0
- package/dist/HighlightPanel/highlightPanelState.svelte.js +13 -0
- package/dist/Menu/Menu.svelte +158 -0
- package/dist/Menu/Menu.svelte.d.ts +8 -0
- package/dist/Menu/MenuItem.svelte +153 -0
- package/dist/Menu/MenuItem.svelte.d.ts +11 -0
- package/dist/Menu/Sidebar.svelte +228 -0
- package/dist/Menu/Sidebar.svelte.d.ts +11 -0
- package/dist/Menu/SidebarState.svelte.d.ts +6 -0
- package/dist/Menu/SidebarState.svelte.js +1 -0
- package/dist/Modal/Modal.svelte +2 -3
- package/dist/Modal/ModalContent.svelte +11 -18
- package/dist/Modal/ModalFooter.svelte +10 -14
- package/dist/Modal/ModalHeader.svelte +7 -9
- package/dist/ProgressWizard/ProgressWizard.svelte +355 -0
- package/dist/ProgressWizard/ProgressWizard.svelte.d.ts +16 -0
- package/dist/Tabs/Tabs.svelte +111 -0
- package/dist/Tabs/Tabs.svelte.d.ts +8 -0
- package/dist/Tabs/tabsState.svelte.d.ts +7 -0
- package/dist/Tabs/tabsState.svelte.js +1 -0
- package/dist/Toast/Toast.svelte +7 -12
- package/dist/Tooltip/Tooltip.svelte +168 -0
- package/dist/Tooltip/Tooltip.svelte.d.ts +13 -0
- package/dist/assets/icons/feedback.svg +5 -0
- package/dist/index.d.ts +25 -8
- package/dist/index.js +23 -9
- package/package.json +4 -2
- package/dist/Toggle/Toggle.svelte +0 -170
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import { type MenuItem } from '../index.js';
|
|
1
2
|
interface HeaderProps {
|
|
2
3
|
title?: string;
|
|
3
4
|
homeUrl?: string;
|
|
4
|
-
|
|
5
|
+
disableMenuButton?: boolean;
|
|
6
|
+
hideAccount?: boolean;
|
|
7
|
+
hideHelp?: boolean;
|
|
8
|
+
hideNotification?: boolean;
|
|
5
9
|
accountName?: string;
|
|
6
10
|
userName?: string;
|
|
7
11
|
profileUrl?: string;
|
|
8
|
-
|
|
12
|
+
hideLoader?: boolean;
|
|
13
|
+
menuItems: MenuItem[];
|
|
9
14
|
}
|
|
10
15
|
declare const Header: import("svelte").Component<HeaderProps, {}, "">;
|
|
11
16
|
type Header = ReturnType<typeof Header>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { Avatar } from '../index.js';
|
|
3
|
+
|
|
2
4
|
interface HeaderAccountProps {
|
|
3
5
|
accountName?: string;
|
|
4
6
|
userName?: string;
|
|
@@ -8,27 +10,11 @@
|
|
|
8
10
|
|
|
9
11
|
accountName = accountName || 'SoftwareOne';
|
|
10
12
|
userName = userName || 'John Doe';
|
|
11
|
-
|
|
12
|
-
let avatarName = $state(
|
|
13
|
-
userName
|
|
14
|
-
.split(' ')
|
|
15
|
-
.map((word) => word[0])
|
|
16
|
-
.join('')
|
|
17
|
-
);
|
|
18
13
|
</script>
|
|
19
14
|
|
|
20
15
|
<div class="account-container">
|
|
21
16
|
<div class="account-avatar">
|
|
22
|
-
<
|
|
23
|
-
><circle cx="20" cy="20" r="20" fill="#25282D"></circle><text
|
|
24
|
-
x="20"
|
|
25
|
-
y="25"
|
|
26
|
-
text-anchor="middle"
|
|
27
|
-
font-size="14"
|
|
28
|
-
font-weight="normal"
|
|
29
|
-
fill="#FFFFFF">{avatarName}</text
|
|
30
|
-
></svg
|
|
31
|
-
>
|
|
17
|
+
<Avatar text={userName} />
|
|
32
18
|
</div>
|
|
33
19
|
<div class="account">
|
|
34
20
|
<div class="account-name">{accountName}</div>
|
|
@@ -42,7 +28,6 @@
|
|
|
42
28
|
.account-container {
|
|
43
29
|
display: flex;
|
|
44
30
|
max-width: 300px;
|
|
45
|
-
/* padding: 8px 24px; */
|
|
46
31
|
align-items: center;
|
|
47
32
|
gap: 16px;
|
|
48
33
|
border-radius: 8px;
|
|
@@ -52,10 +37,8 @@
|
|
|
52
37
|
display: flex;
|
|
53
38
|
width: 48px;
|
|
54
39
|
height: 48px;
|
|
55
|
-
/* padding: 15px 0px 15.194px 0px; */
|
|
56
40
|
justify-content: center;
|
|
57
41
|
align-items: center;
|
|
58
|
-
font-family: 'Haas Grotesk Display Pro', sans-serif;
|
|
59
42
|
}
|
|
60
43
|
.account {
|
|
61
44
|
display: flex;
|
|
@@ -70,15 +53,12 @@
|
|
|
70
53
|
width: auto;
|
|
71
54
|
max-width: auto;
|
|
72
55
|
overflow: hidden;
|
|
73
|
-
color:
|
|
56
|
+
color: #000;
|
|
74
57
|
text-overflow: ellipsis;
|
|
75
|
-
|
|
76
|
-
/* medium/2 */
|
|
77
|
-
font-family: 'Haas Grotesk Display Pro', sans-serif;
|
|
78
58
|
font-size: 14px;
|
|
79
59
|
font-style: normal;
|
|
80
60
|
font-weight: 500;
|
|
81
|
-
line-height: 20px;
|
|
61
|
+
line-height: 20px;
|
|
82
62
|
}
|
|
83
63
|
.account-more {
|
|
84
64
|
display: flex;
|
|
@@ -93,11 +73,8 @@
|
|
|
93
73
|
-webkit-line-clamp: 1;
|
|
94
74
|
line-clamp: 1;
|
|
95
75
|
overflow: hidden;
|
|
96
|
-
color:
|
|
76
|
+
color: #6b7180;
|
|
97
77
|
text-overflow: ellipsis;
|
|
98
|
-
|
|
99
|
-
/* regular/1 */
|
|
100
|
-
font-family: 'Haas Grotesk Display Pro', sans-serif;
|
|
101
78
|
font-size: 12px;
|
|
102
79
|
font-style: normal;
|
|
103
80
|
font-weight: 400;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
import { Avatar, Chips, ColumnType, ImageType, type HighlightPanelColumn } from '../index.js';
|
|
5
|
+
|
|
6
|
+
interface HighlightPanelProps {
|
|
7
|
+
columns: HighlightPanelColumn[];
|
|
8
|
+
buttonSection?: Snippet;
|
|
9
|
+
distributionType?: 'flex' | 'flex-column' | 'grid';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let { columns, distributionType = 'flex', buttonSection }: HighlightPanelProps = $props();
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<div class="highlight-panel">
|
|
16
|
+
<section class="panel-section-{distributionType}">
|
|
17
|
+
{#each columns as column}
|
|
18
|
+
<div class="panel-element">
|
|
19
|
+
{#if column.type === ColumnType.Text}
|
|
20
|
+
<h2>{column.label}</h2>
|
|
21
|
+
<p>{column.value}</p>
|
|
22
|
+
<p class="text-description">{column.description ?? ''}</p>
|
|
23
|
+
{/if}
|
|
24
|
+
|
|
25
|
+
{#if column.type === ColumnType.Status}
|
|
26
|
+
<h2>{column.label}</h2>
|
|
27
|
+
<Chips text={column.value} type={column.chipType} />
|
|
28
|
+
{/if}
|
|
29
|
+
|
|
30
|
+
{#if column.type === ColumnType.Link}
|
|
31
|
+
<h2>{column.label}</h2>
|
|
32
|
+
<a rel="noreferrer" class="link" target="_blank" href={column.url}>
|
|
33
|
+
{column.value}
|
|
34
|
+
</a>
|
|
35
|
+
{/if}
|
|
36
|
+
|
|
37
|
+
{#if column.type === ColumnType.Image}
|
|
38
|
+
{@const { content, iconType } = column}
|
|
39
|
+
<h2>{column.label}</h2>
|
|
40
|
+
{#if iconType === ImageType.Default}
|
|
41
|
+
<img src={content} alt="icon" />
|
|
42
|
+
{:else if iconType === ImageType.Avatar}
|
|
43
|
+
<Avatar text={content} />
|
|
44
|
+
{:else if iconType === ImageType.Material}
|
|
45
|
+
<span class="material-icons">{content}</span>
|
|
46
|
+
{/if}
|
|
47
|
+
<p class="text-description">{column.description ?? ''}</p>
|
|
48
|
+
{/if}
|
|
49
|
+
</div>
|
|
50
|
+
{/each}
|
|
51
|
+
</section>
|
|
52
|
+
|
|
53
|
+
{#if buttonSection}
|
|
54
|
+
<section class="buttons-section">
|
|
55
|
+
{@render buttonSection()}
|
|
56
|
+
</section>
|
|
57
|
+
{/if}
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<style>
|
|
61
|
+
h2,
|
|
62
|
+
p,
|
|
63
|
+
a {
|
|
64
|
+
font-size: 14px;
|
|
65
|
+
line-height: 20px;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.text-description {
|
|
69
|
+
color: #6b7180;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.link {
|
|
73
|
+
color: #472aff;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.link:hover {
|
|
77
|
+
text-decoration-line: underline;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.highlight-panel {
|
|
81
|
+
display: grid;
|
|
82
|
+
grid-template-columns: 1fr auto;
|
|
83
|
+
gap: 48px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.panel-section-flex {
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-wrap: wrap;
|
|
89
|
+
gap: 48px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.panel-section-flex-column {
|
|
93
|
+
display: flex;
|
|
94
|
+
flex-direction: column;
|
|
95
|
+
gap: 48px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.panel-section-grid {
|
|
99
|
+
display: grid;
|
|
100
|
+
grid-template-columns: repeat(auto-fit, minmax(50px, auto));
|
|
101
|
+
grid-gap: 48px;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.buttons-section {
|
|
105
|
+
display: flex;
|
|
106
|
+
gap: 12px;
|
|
107
|
+
align-items: flex-start;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.panel-element h2 {
|
|
111
|
+
margin-bottom: 8px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.panel-element img {
|
|
115
|
+
width: 40px;
|
|
116
|
+
height: 40px;
|
|
117
|
+
border-radius: 9999px;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@media screen and (max-width: 700px) {
|
|
121
|
+
.buttons-section {
|
|
122
|
+
flex-direction: column;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
</style>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type HighlightPanelColumn } from '../index.js';
|
|
3
|
+
interface HighlightPanelProps {
|
|
4
|
+
columns: HighlightPanelColumn[];
|
|
5
|
+
buttonSection?: Snippet;
|
|
6
|
+
distributionType?: 'flex' | 'flex-column' | 'grid';
|
|
7
|
+
}
|
|
8
|
+
declare const HighlightPanel: import("svelte").Component<HighlightPanelProps, {}, "">;
|
|
9
|
+
type HighlightPanel = ReturnType<typeof HighlightPanel>;
|
|
10
|
+
export default HighlightPanel;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ChipType } from '../index.js';
|
|
2
|
+
export declare enum ImageType {
|
|
3
|
+
Default = "image",
|
|
4
|
+
Avatar = "avatar",
|
|
5
|
+
Material = "material"
|
|
6
|
+
}
|
|
7
|
+
export declare enum ColumnType {
|
|
8
|
+
Text = "text",
|
|
9
|
+
Link = "link",
|
|
10
|
+
Image = "image",
|
|
11
|
+
Status = "status"
|
|
12
|
+
}
|
|
13
|
+
type BaseColumn = {
|
|
14
|
+
label: string;
|
|
15
|
+
value: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
};
|
|
18
|
+
type Text = BaseColumn & {
|
|
19
|
+
type: ColumnType.Text;
|
|
20
|
+
};
|
|
21
|
+
type Link = BaseColumn & {
|
|
22
|
+
type: ColumnType.Link;
|
|
23
|
+
url: string;
|
|
24
|
+
};
|
|
25
|
+
type Icon = BaseColumn & {
|
|
26
|
+
type: ColumnType.Image;
|
|
27
|
+
iconType: ImageType;
|
|
28
|
+
content: string;
|
|
29
|
+
};
|
|
30
|
+
type Status = BaseColumn & {
|
|
31
|
+
type: ColumnType.Status;
|
|
32
|
+
chipType: ChipType;
|
|
33
|
+
};
|
|
34
|
+
export type HighlightPanelColumn = Text | Link | Icon | Status;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export var ImageType;
|
|
2
|
+
(function (ImageType) {
|
|
3
|
+
ImageType["Default"] = "image";
|
|
4
|
+
ImageType["Avatar"] = "avatar";
|
|
5
|
+
ImageType["Material"] = "material";
|
|
6
|
+
})(ImageType || (ImageType = {}));
|
|
7
|
+
export var ColumnType;
|
|
8
|
+
(function (ColumnType) {
|
|
9
|
+
ColumnType["Text"] = "text";
|
|
10
|
+
ColumnType["Link"] = "link";
|
|
11
|
+
ColumnType["Image"] = "image";
|
|
12
|
+
ColumnType["Status"] = "status";
|
|
13
|
+
})(ColumnType || (ColumnType = {}));
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { goto } from '$app/navigation';
|
|
3
|
+
import { page } from '$app/state';
|
|
4
|
+
|
|
5
|
+
import type { MenuItem } from './SidebarState.svelte';
|
|
6
|
+
import MainMenuItem from './MenuItem.svelte';
|
|
7
|
+
|
|
8
|
+
interface MenuProps {
|
|
9
|
+
disableMenuButton?: boolean;
|
|
10
|
+
menuItems: MenuItem[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let showMenu: boolean = $state(false);
|
|
14
|
+
let isMainMenu: boolean = $state(true);
|
|
15
|
+
let activeItem: string = $state('');
|
|
16
|
+
|
|
17
|
+
const { disableMenuButton = false, menuItems }: MenuProps = $props();
|
|
18
|
+
|
|
19
|
+
$effect(() => {
|
|
20
|
+
if (showMenu) {
|
|
21
|
+
setActiveMenuItem();
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const setActiveMenuItem = () => {
|
|
26
|
+
activeItem = menuItems.find((menuItem: MenuItem) => isActiveMenuItem(menuItem.url))?.text || '';
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const isActiveMenuItem = (url: string) => {
|
|
30
|
+
const firstSegmentUrl = page.url.pathname.split('/')[1];
|
|
31
|
+
return existRoute(`/${firstSegmentUrl}`, url);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const existRoute = (url: string, pathname: string) => {
|
|
35
|
+
const regex = new RegExp(`${url}(?![\\w-])`);
|
|
36
|
+
return regex.test(pathname);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const onClickMenuItem = (menuItem: MenuItem) => {
|
|
40
|
+
onHandleMenu();
|
|
41
|
+
goto(String(menuItem.url));
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const onHandleMenu = () => {
|
|
45
|
+
showMenu = !showMenu;
|
|
46
|
+
};
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<button
|
|
50
|
+
type="button"
|
|
51
|
+
class="menu-button"
|
|
52
|
+
class:disabled-menu={disableMenuButton}
|
|
53
|
+
onclick={onHandleMenu}
|
|
54
|
+
disabled={disableMenuButton}
|
|
55
|
+
aria-label="menu button"
|
|
56
|
+
>
|
|
57
|
+
<span class="material-icons icon-span">menu</span>
|
|
58
|
+
</button>
|
|
59
|
+
|
|
60
|
+
{#if showMenu}
|
|
61
|
+
<button
|
|
62
|
+
class="menu-principal"
|
|
63
|
+
onclick={onHandleMenu}
|
|
64
|
+
onkeypress={onHandleMenu}
|
|
65
|
+
aria-label="menu principal"
|
|
66
|
+
></button>
|
|
67
|
+
|
|
68
|
+
<nav class="menu-nav">
|
|
69
|
+
<menu class="menu-list">
|
|
70
|
+
{#each menuItems as menuItem}
|
|
71
|
+
<MainMenuItem
|
|
72
|
+
item={menuItem}
|
|
73
|
+
isCollapsed={false}
|
|
74
|
+
activeItem={activeItem === menuItem.text}
|
|
75
|
+
{isMainMenu}
|
|
76
|
+
onClick={onClickMenuItem}
|
|
77
|
+
/>
|
|
78
|
+
{/each}
|
|
79
|
+
</menu>
|
|
80
|
+
</nav>
|
|
81
|
+
{/if}
|
|
82
|
+
|
|
83
|
+
<style>
|
|
84
|
+
.menu-button {
|
|
85
|
+
border-radius: 0.375rem;
|
|
86
|
+
background: white;
|
|
87
|
+
z-index: 40;
|
|
88
|
+
cursor: pointer;
|
|
89
|
+
border: none;
|
|
90
|
+
width: 40px;
|
|
91
|
+
height: 40px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.icon-span {
|
|
95
|
+
color: #25282d;
|
|
96
|
+
font-size: 24px;
|
|
97
|
+
font-weight: 400;
|
|
98
|
+
line-height: 20px;
|
|
99
|
+
word-wrap: break-word;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.menu-button:hover {
|
|
103
|
+
background-color: #f3f4f6;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.menu-principal {
|
|
107
|
+
position: fixed;
|
|
108
|
+
inset: 0;
|
|
109
|
+
background-color: rgba(243, 244, 246, 0.5);
|
|
110
|
+
cursor: pointer;
|
|
111
|
+
z-index: 30;
|
|
112
|
+
border: none;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.menu-nav {
|
|
116
|
+
position: absolute;
|
|
117
|
+
top: 80px;
|
|
118
|
+
left: 24px;
|
|
119
|
+
bottom: 24px;
|
|
120
|
+
display: flex;
|
|
121
|
+
border: 1px solid #f3f4f6;
|
|
122
|
+
border-bottom-left-radius: 10px;
|
|
123
|
+
border-bottom-right-radius: 10px;
|
|
124
|
+
background-color: white;
|
|
125
|
+
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
|
|
126
|
+
min-height: calc(100vh - 80px - 55px);
|
|
127
|
+
z-index: 40;
|
|
128
|
+
width: auto;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.menu-list {
|
|
132
|
+
display: flex;
|
|
133
|
+
flex-direction: column;
|
|
134
|
+
gap: 0.25rem;
|
|
135
|
+
padding: 0.7rem;
|
|
136
|
+
width: 150px;
|
|
137
|
+
overflow-y: auto;
|
|
138
|
+
overflow-x: hidden;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.disabled-menu {
|
|
142
|
+
cursor: not-allowed;
|
|
143
|
+
opacity: 0.5;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@media (min-width: 768px) {
|
|
147
|
+
.menu-list {
|
|
148
|
+
min-width: 220px;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@media (min-width: 100px) and (max-width: 767px) {
|
|
153
|
+
.menu-list {
|
|
154
|
+
width: auto;
|
|
155
|
+
min-width: none;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
</style>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MenuItem } from './SidebarState.svelte';
|
|
2
|
+
interface MenuProps {
|
|
3
|
+
disableMenuButton?: boolean;
|
|
4
|
+
menuItems: MenuItem[];
|
|
5
|
+
}
|
|
6
|
+
declare const Menu: import("svelte").Component<MenuProps, {}, "">;
|
|
7
|
+
type Menu = ReturnType<typeof Menu>;
|
|
8
|
+
export default Menu;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Tooltip } from '../index.js';
|
|
3
|
+
import type { MenuItem } from './SidebarState.svelte';
|
|
4
|
+
|
|
5
|
+
interface MenuItemProps {
|
|
6
|
+
item: MenuItem;
|
|
7
|
+
isCollapsed: boolean;
|
|
8
|
+
onClick?: (item: MenuItem) => void;
|
|
9
|
+
activeItem: boolean;
|
|
10
|
+
isMainMenu?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let { item, isCollapsed = false, onClick, activeItem, isMainMenu }: MenuItemProps = $props();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<li>
|
|
17
|
+
<Tooltip content={isCollapsed ? item.text : ''} position="right">
|
|
18
|
+
<button
|
|
19
|
+
type="button"
|
|
20
|
+
class={[
|
|
21
|
+
'item',
|
|
22
|
+
isCollapsed ? 'collapsed' : 'expanded',
|
|
23
|
+
activeItem && `active-${isCollapsed ? 'collapsed' : 'expanded'}`,
|
|
24
|
+
isMainMenu && 'main-menu'
|
|
25
|
+
]}
|
|
26
|
+
onclick={() => onClick?.(item)}
|
|
27
|
+
>
|
|
28
|
+
<span class="material-icons-outlined icon-span">{item.icon}</span>
|
|
29
|
+
<h2 class="item-name-span" class:hidden={isCollapsed}>{item.text}</h2>
|
|
30
|
+
</button>
|
|
31
|
+
</Tooltip>
|
|
32
|
+
</li>
|
|
33
|
+
|
|
34
|
+
<style>
|
|
35
|
+
.item {
|
|
36
|
+
height: 36px;
|
|
37
|
+
padding: 8px;
|
|
38
|
+
border-radius: 8px;
|
|
39
|
+
justify-content: flex-start;
|
|
40
|
+
align-items: center;
|
|
41
|
+
gap: 8px;
|
|
42
|
+
display: inline-flex;
|
|
43
|
+
background: none;
|
|
44
|
+
border: none;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
transition: background-color 0.2s ease;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.item-name {
|
|
50
|
+
height: 20px;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
display: flex;
|
|
53
|
+
flex-direction: column;
|
|
54
|
+
}
|
|
55
|
+
.item-name-span {
|
|
56
|
+
color: black;
|
|
57
|
+
font-size: 14px;
|
|
58
|
+
font-weight: 400;
|
|
59
|
+
line-height: 20px;
|
|
60
|
+
word-wrap: break-word;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.icon {
|
|
64
|
+
text-align: center;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.icon-span {
|
|
68
|
+
padding: 8px;
|
|
69
|
+
color: black;
|
|
70
|
+
font-size: 20px;
|
|
71
|
+
font-weight: 400;
|
|
72
|
+
line-height: 20px;
|
|
73
|
+
word-wrap: break-word;
|
|
74
|
+
border-radius: 50%;
|
|
75
|
+
transition: background-color 0.2s ease;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.expanded {
|
|
79
|
+
width: 188px;
|
|
80
|
+
}
|
|
81
|
+
.expanded:hover:not(.active-expanded) {
|
|
82
|
+
background-color: #f4f6f8;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.active-expanded {
|
|
86
|
+
background-color: #eaecff;
|
|
87
|
+
color: #472aff;
|
|
88
|
+
cursor: default;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.collapsed {
|
|
92
|
+
width: 68px;
|
|
93
|
+
justify-content: center;
|
|
94
|
+
position: relative;
|
|
95
|
+
width: 100%;
|
|
96
|
+
}
|
|
97
|
+
.collapsed .icon-span:hover {
|
|
98
|
+
background-color: #f4f6f8;
|
|
99
|
+
}
|
|
100
|
+
.active-collapsed .icon-span {
|
|
101
|
+
background-color: #eaecff;
|
|
102
|
+
color: #472aff;
|
|
103
|
+
}
|
|
104
|
+
.active-collapsed .icon-span:hover {
|
|
105
|
+
background-color: #eaecff;
|
|
106
|
+
cursor: default;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.active-expanded .icon-span,
|
|
110
|
+
.active-collapsed .icon-span,
|
|
111
|
+
.active-expanded .item-name-span,
|
|
112
|
+
.active-collapsed .item-name-span {
|
|
113
|
+
color: #472aff;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.main-menu.expanded:hover:not(.active-expanded),
|
|
117
|
+
.main-menu.collapsed:hover:not(.active-collapsed) {
|
|
118
|
+
background-color: #eaecff;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.main-menu:hover .item-name-span,
|
|
122
|
+
.main-menu:hover .icon-span {
|
|
123
|
+
color: #472aff;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.item.collapsed:focus,
|
|
127
|
+
.item.collapsed:focus-visible {
|
|
128
|
+
outline: none;
|
|
129
|
+
box-shadow: none;
|
|
130
|
+
background-color: transparent;
|
|
131
|
+
}
|
|
132
|
+
.item.collapsed:focus-visible .icon-span,
|
|
133
|
+
.item.expanded:focus-visible {
|
|
134
|
+
box-shadow: 0 0 0 2px #472aff;
|
|
135
|
+
background-color: #eaecff;
|
|
136
|
+
outline: none;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.hidden {
|
|
140
|
+
display: none;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@media (max-width: 768px) {
|
|
144
|
+
.item-name,
|
|
145
|
+
.item-name-span {
|
|
146
|
+
display: none;
|
|
147
|
+
}
|
|
148
|
+
.item {
|
|
149
|
+
width: 100%;
|
|
150
|
+
justify-content: center;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MenuItem } from './SidebarState.svelte';
|
|
2
|
+
interface MenuItemProps {
|
|
3
|
+
item: MenuItem;
|
|
4
|
+
isCollapsed: boolean;
|
|
5
|
+
onClick?: (item: MenuItem) => void;
|
|
6
|
+
activeItem: boolean;
|
|
7
|
+
isMainMenu?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const MenuItem: import("svelte").Component<MenuItemProps, {}, "">;
|
|
10
|
+
type MenuItem = ReturnType<typeof MenuItem>;
|
|
11
|
+
export default MenuItem;
|