@likable-hair/svelte 0.0.18 → 0.0.21
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/buttons/Button.svelte +13 -3
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/navigation/Drawer.svelte +140 -0
- package/navigation/Drawer.svelte.d.ts +37 -0
- package/navigation/HeaderMenu.svelte +72 -12
- package/navigation/HeaderMenu.svelte.d.ts +7 -1
- package/navigation/Navigator.svelte +5 -2
- package/navigation/Navigator.svelte.d.ts +2 -0
- package/package.json +2 -1
package/buttons/Button.svelte
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script >export let type = 'default', icon = undefined, iconSize = 15, clazz = '', maxWidth = undefined, maxHeight = undefined, minWidth = undefined, minHeight = undefined, width = undefined, height = undefined, textAlign = "center", cursor = "pointer", padding = "5px", fontSize = undefined, color = undefined, backgroundColor = undefined, hoverBackgroundColor = '#
|
|
1
|
+
<script >export let type = 'default', icon = undefined, iconSize = 15, clazz = '', maxWidth = undefined, maxHeight = undefined, minWidth = undefined, minHeight = undefined, width = undefined, height = undefined, textAlign = "center", cursor = "pointer", padding = "5px", fontSize = undefined, color = undefined, backgroundColor = undefined, hoverBackgroundColor = '#88888847', borderRadius = undefined, boxShadow = undefined;
|
|
2
2
|
export { clazz as class };
|
|
3
3
|
$: defaultBorderRadius = type == 'icon' ? '50%' : '5px';
|
|
4
4
|
$: position = !!$$slots.append ? 'relative' : undefined;
|
|
@@ -18,13 +18,13 @@ import Icon from '../media/Icon.svelte';
|
|
|
18
18
|
style:padding={padding}
|
|
19
19
|
style:font-size={fontSize}
|
|
20
20
|
style:color={color}
|
|
21
|
-
style
|
|
21
|
+
style:--button-border-radius={!!borderRadius ? borderRadius : defaultBorderRadius}
|
|
22
22
|
style:--button-background-color={backgroundColor}
|
|
23
23
|
style:--button-hover-background-color={hoverBackgroundColor}
|
|
24
24
|
style:--button-box-shadow={boxShadow}
|
|
25
25
|
style:--button-icon-height={(iconSize + 5) + 'pt'}
|
|
26
26
|
style:--button-icon-width={(iconSize + 5) + 'pt'}
|
|
27
|
-
class="button {clazz}"
|
|
27
|
+
class="button no-select {clazz}"
|
|
28
28
|
class:button-default={type === 'default'}
|
|
29
29
|
class:button-text={type === 'text'}
|
|
30
30
|
class:button-icon={type === 'icon'}
|
|
@@ -94,4 +94,14 @@ import Icon from '../media/Icon.svelte';
|
|
|
94
94
|
.button-icon:hover {
|
|
95
95
|
background-color: var(--button-hover-background-color, transparent);
|
|
96
96
|
}
|
|
97
|
+
|
|
98
|
+
.no-select {
|
|
99
|
+
-webkit-touch-callout: none; /* iOS Safari */
|
|
100
|
+
-webkit-user-select: none; /* Safari */
|
|
101
|
+
-khtml-user-select: none; /* Konqueror HTML */
|
|
102
|
+
-moz-user-select: none; /* Old versions of Firefox */
|
|
103
|
+
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
104
|
+
user-select: none; /* Non-prefixed version, currently
|
|
105
|
+
supported by Chrome, Edge, Opera and Firefox */
|
|
106
|
+
}
|
|
97
107
|
</style>
|
package/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export { default as BreadCrumb } from './navigation/BreadCrumb.svelte';
|
|
|
15
15
|
export { default as HeaderMenu } from './navigation/HeaderMenu.svelte';
|
|
16
16
|
export { default as Navigator } from './navigation/Navigator.svelte';
|
|
17
17
|
export { default as TabSwitcher } from './navigation/TabSwitcher.svelte';
|
|
18
|
+
export { default as Drawer } from './navigation/Drawer.svelte';
|
|
18
19
|
export { default as ProgressBar } from './progress/ProgressBar.svelte';
|
|
19
20
|
export { default as ProductCard } from './shop/ProductCard.svelte';
|
|
20
21
|
export { default as ProductGrid } from './shop/ProductCard.svelte';
|
package/index.js
CHANGED
|
@@ -21,6 +21,7 @@ export { default as BreadCrumb } from './navigation/BreadCrumb.svelte';
|
|
|
21
21
|
export { default as HeaderMenu } from './navigation/HeaderMenu.svelte';
|
|
22
22
|
export { default as Navigator } from './navigation/Navigator.svelte';
|
|
23
23
|
export { default as TabSwitcher } from './navigation/TabSwitcher.svelte';
|
|
24
|
+
export { default as Drawer } from './navigation/Drawer.svelte';
|
|
24
25
|
// progress
|
|
25
26
|
export { default as ProgressBar } from './progress/ProgressBar.svelte';
|
|
26
27
|
// shop
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
<script >import Navigator from './Navigator.svelte';
|
|
2
|
+
export let open = false, position = 'left', space = '200px', openingSpeed = '0.3s', overlaySpeed = '0.2s', blockScroll = true, color = undefined, overlay = true, backgroundColor = undefined, overlayColor = '#282828', overlayOpacity = '30%', zIndex = 30, items = [];
|
|
3
|
+
let height = undefined, width = undefined, top = undefined, bottom = undefined, left = undefined, right = undefined;
|
|
4
|
+
function handleClickOverlay() {
|
|
5
|
+
open = false;
|
|
6
|
+
}
|
|
7
|
+
$: if (position == 'left') {
|
|
8
|
+
height = '100vh';
|
|
9
|
+
width = space;
|
|
10
|
+
top = '0px';
|
|
11
|
+
bottom = undefined;
|
|
12
|
+
right = undefined;
|
|
13
|
+
if (open) {
|
|
14
|
+
left = `0px`;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
left = `-${space}`;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else if (position == 'right') {
|
|
21
|
+
height = '100vh';
|
|
22
|
+
width = space;
|
|
23
|
+
top = '0px';
|
|
24
|
+
bottom = undefined;
|
|
25
|
+
left = 'auto';
|
|
26
|
+
if (open) {
|
|
27
|
+
right = `0px`;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
right = `calc(0vw - ${space})`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else if (position == 'top') {
|
|
34
|
+
height = space;
|
|
35
|
+
width = '100vw';
|
|
36
|
+
bottom = undefined;
|
|
37
|
+
left = '0px';
|
|
38
|
+
right = undefined;
|
|
39
|
+
if (open) {
|
|
40
|
+
top = `0px`;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
top = `-${space}`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else if (position == 'bottom') {
|
|
47
|
+
height = space;
|
|
48
|
+
width = '100vw';
|
|
49
|
+
top = 'auto';
|
|
50
|
+
left = '0px';
|
|
51
|
+
right = undefined;
|
|
52
|
+
if (open) {
|
|
53
|
+
bottom = `0px`;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
bottom = `calc(0vh - ${space})`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<div
|
|
62
|
+
style:--drawer-opening-speed={openingSpeed}
|
|
63
|
+
style:position="fixed"
|
|
64
|
+
style:height={height}
|
|
65
|
+
style:width={width}
|
|
66
|
+
style:top={top}
|
|
67
|
+
style:bottom={bottom}
|
|
68
|
+
style:left={left}
|
|
69
|
+
style:right={right}
|
|
70
|
+
style:background-color={backgroundColor}
|
|
71
|
+
style:z-index={zIndex}
|
|
72
|
+
style:color={color}
|
|
73
|
+
class:animate-left={position == 'left'}
|
|
74
|
+
class:animate-right={position == 'right'}
|
|
75
|
+
class:animate-bottom={position == 'bottom'}
|
|
76
|
+
class:animate-top={position == 'top'}
|
|
77
|
+
>
|
|
78
|
+
<slot {open}>
|
|
79
|
+
<div
|
|
80
|
+
style:display="flex"
|
|
81
|
+
style:justify-content="center"
|
|
82
|
+
style:align-items="center"
|
|
83
|
+
style:margin-top={position == 'left' || position == 'right' ? '10px' : '0px'}
|
|
84
|
+
style:height={position == 'top' || position == 'bottom' ? '100%' : 'fit-content'}
|
|
85
|
+
>
|
|
86
|
+
<Navigator
|
|
87
|
+
items={items}
|
|
88
|
+
vertical={position == 'right' || position == 'left'}
|
|
89
|
+
on:item-click
|
|
90
|
+
></Navigator>
|
|
91
|
+
</div>
|
|
92
|
+
</slot>
|
|
93
|
+
</div>
|
|
94
|
+
{#if overlay}
|
|
95
|
+
<div
|
|
96
|
+
on:click={handleClickOverlay}
|
|
97
|
+
style:z-index={open ? zIndex - 1 : -5}
|
|
98
|
+
style:position="fixed"
|
|
99
|
+
style:top="0px"
|
|
100
|
+
style:left="0px"
|
|
101
|
+
style:width="100vw"
|
|
102
|
+
style:height="100vh"
|
|
103
|
+
style:background-color={overlayColor}
|
|
104
|
+
style:--drawer-overlay-opacity={overlayOpacity}
|
|
105
|
+
style:--drawer-overlay-speed={overlaySpeed}
|
|
106
|
+
class="overlay"
|
|
107
|
+
class:overlay-active={open}
|
|
108
|
+
class:overlay-hidden={!open}
|
|
109
|
+
></div>
|
|
110
|
+
{/if}
|
|
111
|
+
|
|
112
|
+
<style>
|
|
113
|
+
.animate-left {
|
|
114
|
+
transition: left var(--drawer-opening-speed) cubic-bezier(0.4, 0, 0.2, 1);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.animate-right {
|
|
118
|
+
transition: right var(--drawer-opening-speed) cubic-bezier(0.4, 0, 0.2, 1);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.animate-bottom {
|
|
122
|
+
transition: bottom var(--drawer-opening-speed) cubic-bezier(0.4, 0, 0.2, 1);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.animate-top {
|
|
126
|
+
transition: top var(--drawer-opening-speed) cubic-bezier(0.4, 0, 0.2, 1);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.overlay {
|
|
130
|
+
transition: all var(--drawer-overlay-speed) cubic-bezier(0.4, 0, 0.2, 1);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.overlay-active {
|
|
134
|
+
opacity: var(--drawer-overlay-opacity);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.overlay-hidden {
|
|
138
|
+
opacity: 0%;
|
|
139
|
+
}
|
|
140
|
+
</style>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Item } from './Navigator.svelte';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
position?: 'left' | 'top' | 'right' | 'bottom';
|
|
7
|
+
space?: string;
|
|
8
|
+
openingSpeed?: string;
|
|
9
|
+
overlaySpeed?: string;
|
|
10
|
+
blockScroll?: boolean;
|
|
11
|
+
color?: string;
|
|
12
|
+
overlay?: boolean;
|
|
13
|
+
backgroundColor?: string;
|
|
14
|
+
overlayColor?: string;
|
|
15
|
+
overlayOpacity?: string;
|
|
16
|
+
zIndex?: number;
|
|
17
|
+
items?: Item[];
|
|
18
|
+
};
|
|
19
|
+
events: {
|
|
20
|
+
'item-click': CustomEvent<{
|
|
21
|
+
item: Item;
|
|
22
|
+
}>;
|
|
23
|
+
} & {
|
|
24
|
+
[evt: string]: CustomEvent<any>;
|
|
25
|
+
};
|
|
26
|
+
slots: {
|
|
27
|
+
default: {
|
|
28
|
+
open: boolean;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare type DrawerProps = typeof __propDef.props;
|
|
33
|
+
export declare type DrawerEvents = typeof __propDef.events;
|
|
34
|
+
export declare type DrawerSlots = typeof __propDef.slots;
|
|
35
|
+
export default class Drawer extends SvelteComponentTyped<DrawerProps, DrawerEvents, DrawerSlots> {
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script >export let title = "", items = [], hideOnScroll = true, initialRemoveShadow = false, initialBackgroundColor = undefined, backgroundColor = 'white', color = undefined;
|
|
1
|
+
<script >export let title = "", items = [], hideOnScroll = true, initialRemoveShadow = false, initialBackgroundColor = undefined, backgroundColor = 'white', color = undefined, mobileMenu = true;
|
|
2
2
|
let scrollY, lastScrollY, visible = true;
|
|
3
3
|
function handleScroll() {
|
|
4
4
|
if (hideOnScroll) {
|
|
@@ -11,12 +11,18 @@ function handleScroll() {
|
|
|
11
11
|
}
|
|
12
12
|
lastScrollY = scrollY;
|
|
13
13
|
}
|
|
14
|
+
export let openDrawer = false;
|
|
15
|
+
function toggleDrawer() {
|
|
16
|
+
openDrawer = !openDrawer;
|
|
17
|
+
}
|
|
14
18
|
let localBackgroundColor = undefined;
|
|
15
19
|
$: if (scrollY == 0 && !!initialBackgroundColor)
|
|
16
20
|
localBackgroundColor = initialBackgroundColor;
|
|
17
21
|
else
|
|
18
22
|
localBackgroundColor = backgroundColor;
|
|
19
23
|
import Navigator from './Navigator.svelte';
|
|
24
|
+
import Button from '../buttons/Button.svelte';
|
|
25
|
+
import Drawer from './Drawer.svelte';
|
|
20
26
|
</script>
|
|
21
27
|
|
|
22
28
|
<svelte:window
|
|
@@ -24,6 +30,15 @@ import Navigator from './Navigator.svelte';
|
|
|
24
30
|
on:scroll={handleScroll}
|
|
25
31
|
></svelte:window>
|
|
26
32
|
|
|
33
|
+
{#if mobileMenu }
|
|
34
|
+
<Drawer
|
|
35
|
+
bind:open={openDrawer}
|
|
36
|
+
backgroundColor={backgroundColor}
|
|
37
|
+
color={color}
|
|
38
|
+
items={items}
|
|
39
|
+
on:item-click
|
|
40
|
+
></Drawer>
|
|
41
|
+
{/if}
|
|
27
42
|
<nav
|
|
28
43
|
style:color={color}
|
|
29
44
|
style:background-color={localBackgroundColor}
|
|
@@ -37,14 +52,33 @@ import Navigator from './Navigator.svelte';
|
|
|
37
52
|
class:top-0={visible}
|
|
38
53
|
class:shadow-md={!initialRemoveShadow || scrollY != 0}
|
|
39
54
|
>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
55
|
+
<div
|
|
56
|
+
style:height="56px"
|
|
57
|
+
style:flex="none"
|
|
58
|
+
style:display="flex"
|
|
59
|
+
style:align-items="center"
|
|
60
|
+
>
|
|
61
|
+
<slot
|
|
62
|
+
name="prepend"
|
|
63
|
+
toggleDrawer={toggleDrawer}
|
|
64
|
+
openDrawer={openDrawer}
|
|
44
65
|
>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
66
|
+
{#if mobileMenu}
|
|
67
|
+
<div
|
|
68
|
+
style:width="fit-content"
|
|
69
|
+
style:margin-left="10px"
|
|
70
|
+
style:margin-right="10px"
|
|
71
|
+
class="hide-on-desktop"
|
|
72
|
+
>
|
|
73
|
+
<Button
|
|
74
|
+
type="icon"
|
|
75
|
+
icon="mdi-menu"
|
|
76
|
+
on:click={toggleDrawer}
|
|
77
|
+
></Button>
|
|
78
|
+
</div>
|
|
79
|
+
{/if}
|
|
80
|
+
</slot>
|
|
81
|
+
</div>
|
|
48
82
|
<div
|
|
49
83
|
style:flex-grow="1"
|
|
50
84
|
style:margin-left="4px"
|
|
@@ -57,10 +91,14 @@ import Navigator from './Navigator.svelte';
|
|
|
57
91
|
</slot>
|
|
58
92
|
</div>
|
|
59
93
|
<div>
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
94
|
+
<slot name="menu-desktop">
|
|
95
|
+
<div class="hide-on-mobile">
|
|
96
|
+
<Navigator
|
|
97
|
+
items={items}
|
|
98
|
+
on:item-click
|
|
99
|
+
></Navigator>
|
|
100
|
+
</div>
|
|
101
|
+
</slot>
|
|
64
102
|
</div>
|
|
65
103
|
<slot name="append"></slot>
|
|
66
104
|
</nav>
|
|
@@ -96,4 +134,26 @@ import Navigator from './Navigator.svelte';
|
|
|
96
134
|
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
97
135
|
transition-duration: 150ms;
|
|
98
136
|
}
|
|
137
|
+
|
|
138
|
+
.hide-on-mobile {
|
|
139
|
+
visibility: visible !important;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.hide-on-desktop {
|
|
143
|
+
visibility: visible !important;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@media (max-width: 767.98px) {
|
|
147
|
+
.hide-on-mobile {
|
|
148
|
+
visibility: hidden !important;
|
|
149
|
+
display: none !important;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@media (min-width: 768px){
|
|
154
|
+
.hide-on-desktop {
|
|
155
|
+
visibility: hidden !important;
|
|
156
|
+
display: none !important;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
99
159
|
</style>
|
|
@@ -9,6 +9,8 @@ declare const __propDef: {
|
|
|
9
9
|
initialBackgroundColor?: string;
|
|
10
10
|
backgroundColor?: string;
|
|
11
11
|
color?: string;
|
|
12
|
+
mobileMenu?: boolean;
|
|
13
|
+
openDrawer?: boolean;
|
|
12
14
|
};
|
|
13
15
|
events: {
|
|
14
16
|
'item-click': CustomEvent<{
|
|
@@ -18,8 +20,12 @@ declare const __propDef: {
|
|
|
18
20
|
[evt: string]: CustomEvent<any>;
|
|
19
21
|
};
|
|
20
22
|
slots: {
|
|
21
|
-
prepend: {
|
|
23
|
+
prepend: {
|
|
24
|
+
toggleDrawer: () => void;
|
|
25
|
+
openDrawer: boolean;
|
|
26
|
+
};
|
|
22
27
|
title: {};
|
|
28
|
+
'menu-desktop': {};
|
|
23
29
|
append: {};
|
|
24
30
|
};
|
|
25
31
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script context="module" >export {};
|
|
2
2
|
</script>
|
|
3
3
|
|
|
4
|
-
<script >export let items = [], color = undefined;
|
|
4
|
+
<script >export let items = [], color = undefined, vertical = false, space = '20px';
|
|
5
5
|
import { createEventDispatcher } from 'svelte';
|
|
6
6
|
const dispatch = createEventDispatcher();
|
|
7
7
|
function handleItemClick(item) {
|
|
@@ -11,10 +11,13 @@ function handleItemClick(item) {
|
|
|
11
11
|
|
|
12
12
|
<div
|
|
13
13
|
style:display="flex"
|
|
14
|
+
style:flex-direction={vertical ? 'column' : 'row'}
|
|
14
15
|
>
|
|
15
16
|
{#each items as item}
|
|
16
17
|
<div
|
|
17
|
-
style:
|
|
18
|
+
style:width="fit-content"
|
|
19
|
+
style:margin-right={!vertical ? space : undefined}
|
|
20
|
+
style:margin-bottom={vertical ? space : undefined}
|
|
18
21
|
style:color={color}
|
|
19
22
|
class="link bar-link"
|
|
20
23
|
on:click={() => handleItemClick(item)}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likable-hair/svelte",
|
|
3
3
|
"description": "A Svelte component for likablehair",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.21",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@sveltejs/adapter-auto": "next",
|
|
7
7
|
"@sveltejs/kit": "next",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"./media/Image.svelte": "./media/Image.svelte",
|
|
44
44
|
"./media/ImageGrid.svelte": "./media/ImageGrid.svelte",
|
|
45
45
|
"./navigation/Breadcrumb.svelte": "./navigation/Breadcrumb.svelte",
|
|
46
|
+
"./navigation/Drawer.svelte": "./navigation/Drawer.svelte",
|
|
46
47
|
"./navigation/HeaderMenu.svelte": "./navigation/HeaderMenu.svelte",
|
|
47
48
|
"./navigation/Navigator.svelte": "./navigation/Navigator.svelte",
|
|
48
49
|
"./navigation/TabSwitcher.svelte": "./navigation/TabSwitcher.svelte",
|