@likable-hair/svelte 0.0.18 → 0.0.19

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.
@@ -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 = '#008f8f', borderRadius = undefined, boxShadow = undefined;
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;
@@ -24,7 +24,7 @@ import Icon from '../media/Icon.svelte';
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,139 @@
1
+ <script >import Navigator from './Navigator.svelte';
2
+ export let open = false, position = 'left', space = '200px', openingSpeed = '0.3s', overlaySpeed = '0.2s', blockScroll = true, 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
+ class:animate-left={position == 'left'}
73
+ class:animate-right={position == 'right'}
74
+ class:animate-bottom={position == 'bottom'}
75
+ class:animate-top={position == 'top'}
76
+ >
77
+ <slot {open}>
78
+ <div
79
+ style:display="flex"
80
+ style:justify-content="center"
81
+ style:align-items="center"
82
+ style:margin-top={position == 'left' || position == 'right' ? '10px' : '0px'}
83
+ style:height={position == 'top' || position == 'bottom' ? '100%' : 'fit-content'}
84
+ >
85
+ <Navigator
86
+ items={items}
87
+ vertical={position == 'right' || position == 'left'}
88
+ on:item-click
89
+ ></Navigator>
90
+ </div>
91
+ </slot>
92
+ </div>
93
+ {#if overlay}
94
+ <div
95
+ on:click={handleClickOverlay}
96
+ style:z-index={open ? zIndex - 1 : -5}
97
+ style:position="fixed"
98
+ style:top="0px"
99
+ style:left="0px"
100
+ style:width="100vw"
101
+ style:height="100vh"
102
+ style:background-color={overlayColor}
103
+ style:--drawer-overlay-opacity={overlayOpacity}
104
+ style:--drawer-overlay-speed={overlaySpeed}
105
+ class="overlay"
106
+ class:overlay-active={open}
107
+ class:overlay-hidden={!open}
108
+ ></div>
109
+ {/if}
110
+
111
+ <style>
112
+ .animate-left {
113
+ transition: left var(--drawer-opening-speed) cubic-bezier(0.4, 0, 0.2, 1);
114
+ }
115
+
116
+ .animate-right {
117
+ transition: right var(--drawer-opening-speed) cubic-bezier(0.4, 0, 0.2, 1);
118
+ }
119
+
120
+ .animate-bottom {
121
+ transition: bottom var(--drawer-opening-speed) cubic-bezier(0.4, 0, 0.2, 1);
122
+ }
123
+
124
+ .animate-top {
125
+ transition: top var(--drawer-opening-speed) cubic-bezier(0.4, 0, 0.2, 1);
126
+ }
127
+
128
+ .overlay {
129
+ transition: all var(--drawer-overlay-speed) cubic-bezier(0.4, 0, 0.2, 1);
130
+ }
131
+
132
+ .overlay-active {
133
+ opacity: var(--drawer-overlay-opacity);
134
+ }
135
+
136
+ .overlay-hidden {
137
+ opacity: 0%;
138
+ }
139
+ </style>
@@ -0,0 +1,36 @@
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
+ overlay?: boolean;
12
+ backgroundColor?: string;
13
+ overlayColor?: string;
14
+ overlayOpacity?: string;
15
+ zIndex?: number;
16
+ items?: Item[];
17
+ };
18
+ events: {
19
+ 'item-click': CustomEvent<{
20
+ item: Item;
21
+ }>;
22
+ } & {
23
+ [evt: string]: CustomEvent<any>;
24
+ };
25
+ slots: {
26
+ default: {
27
+ open: boolean;
28
+ };
29
+ };
30
+ };
31
+ export declare type DrawerProps = typeof __propDef.props;
32
+ export declare type DrawerEvents = typeof __propDef.events;
33
+ export declare type DrawerSlots = typeof __propDef.slots;
34
+ export default class Drawer extends SvelteComponentTyped<DrawerProps, DrawerEvents, DrawerSlots> {
35
+ }
36
+ 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,14 @@ 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
+ items={items}
38
+ on:item-click
39
+ ></Drawer>
40
+ {/if}
27
41
  <nav
28
42
  style:color={color}
29
43
  style:background-color={localBackgroundColor}
@@ -37,14 +51,33 @@ import Navigator from './Navigator.svelte';
37
51
  class:top-0={visible}
38
52
  class:shadow-md={!initialRemoveShadow || scrollY != 0}
39
53
  >
40
- {#if $$slots.prepend}
41
- <div
42
- style:height="56px"
43
- style:flex="none"
54
+ <div
55
+ style:height="56px"
56
+ style:flex="none"
57
+ style:display="flex"
58
+ style:align-items="center"
59
+ >
60
+ <slot
61
+ name="prepend"
62
+ toggleDrawer={toggleDrawer}
63
+ openDrawer={openDrawer}
44
64
  >
45
- <slot name="prepend"></slot>
46
- </div>
47
- {/if}
65
+ {#if mobileMenu}
66
+ <div
67
+ style:width="fit-content"
68
+ style:margin-left="10px"
69
+ style:margin-right="10px"
70
+ class="hide-on-desktop"
71
+ >
72
+ <Button
73
+ type="icon"
74
+ icon="mdi-menu"
75
+ on:click={toggleDrawer}
76
+ ></Button>
77
+ </div>
78
+ {/if}
79
+ </slot>
80
+ </div>
48
81
  <div
49
82
  style:flex-grow="1"
50
83
  style:margin-left="4px"
@@ -57,10 +90,14 @@ import Navigator from './Navigator.svelte';
57
90
  </slot>
58
91
  </div>
59
92
  <div>
60
- <Navigator
61
- items={items}
62
- on:item-click
63
- ></Navigator>
93
+ <slot name="menu-desktop">
94
+ <div class="hide-on-mobile">
95
+ <Navigator
96
+ items={items}
97
+ on:item-click
98
+ ></Navigator>
99
+ </div>
100
+ </slot>
64
101
  </div>
65
102
  <slot name="append"></slot>
66
103
  </nav>
@@ -96,4 +133,26 @@ import Navigator from './Navigator.svelte';
96
133
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
97
134
  transition-duration: 150ms;
98
135
  }
136
+
137
+ .hide-on-mobile {
138
+ visibility: visible !important;
139
+ }
140
+
141
+ .hide-on-desktop {
142
+ visibility: visible !important;
143
+ }
144
+
145
+ @media (max-width: 767.98px) {
146
+ .hide-on-mobile {
147
+ visibility: hidden !important;
148
+ display: none !important;
149
+ }
150
+ }
151
+
152
+ @media (min-width: 768px){
153
+ .hide-on-desktop {
154
+ visibility: hidden !important;
155
+ display: none !important;
156
+ }
157
+ }
99
158
  </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:margin-right="20px"
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)}
@@ -8,6 +8,8 @@ declare const __propDef: {
8
8
  props: {
9
9
  items?: Item[];
10
10
  color?: string;
11
+ vertical?: boolean;
12
+ space?: string;
11
13
  };
12
14
  events: {
13
15
  "item-click": CustomEvent<{
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.18",
4
+ "version": "0.0.19",
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",