@likable-hair/svelte 0.0.3 → 0.0.6
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/README.md +12 -24
- package/buttons/Button.svelte +102 -0
- package/buttons/Button.svelte.d.ts +25 -0
- package/common/Card.svelte +45 -0
- package/common/Card.svelte.d.ts +24 -0
- package/common/IntersectionObserver.svelte +58 -0
- package/common/IntersectionObserver.svelte.d.ts +39 -0
- package/common/materialDesign.css +1 -0
- package/common/tailwind.css +3 -0
- package/dates/Calendar.svelte +4 -0
- package/dates/Calendar.svelte.d.ts +15 -0
- package/dates/utils.d.ts +11 -0
- package/dates/utils.js +59 -0
- package/enums/elevation.enum.d.ts +7 -0
- package/enums/elevation.enum.js +8 -0
- package/enums/index.d.ts +1 -0
- package/enums/index.js +1 -0
- package/forms/Textfield.svelte +178 -0
- package/forms/Textfield.svelte.d.ts +29 -0
- package/index.d.ts +2 -1
- package/index.js +2 -1
- package/loaders/Skeleton.svelte +78 -0
- package/loaders/Skeleton.svelte.d.ts +28 -0
- package/loaders/sectionType.d.ts +4 -0
- package/loaders/sectionType.js +5 -0
- package/media/Carousel.svelte +67 -0
- package/media/Carousel.svelte.d.ts +21 -0
- package/media/Icon.svelte +25 -0
- package/media/Icon.svelte.d.ts +20 -0
- package/media/Image.svelte +161 -0
- package/media/Image.svelte.d.ts +31 -0
- package/media/ImageGrid.svelte +51 -0
- package/media/ImageGrid.svelte.d.ts +29 -0
- package/navigation/HeaderMenu.svelte +57 -0
- package/navigation/HeaderMenu.svelte.d.ts +24 -0
- package/navigation/Navigator.svelte +53 -0
- package/navigation/Navigator.svelte.d.ts +21 -0
- package/navigation/TabSwitcher.svelte +86 -0
- package/navigation/TabSwitcher.svelte.d.ts +24 -0
- package/package.json +33 -5
- package/shop/ProductCard.svelte +58 -0
- package/shop/ProductCard.svelte.d.ts +25 -0
- package/shop/ProductsGrid.svelte +59 -0
- package/shop/ProductsGrid.svelte.d.ts +42 -0
- package/timeline/ScrollTimeLine.svelte +193 -0
- package/timeline/ScrollTimeLine.svelte.d.ts +15 -0
- package/timeline/SimpleTimeLine.svelte +1 -0
- package/timeline/SimpleTimeLine.svelte.d.ts +19 -0
- package/HelloWorld.svelte +0 -1
- package/HelloWorld.svelte.d.ts +0 -19
package/README.md
CHANGED
|
@@ -1,38 +1,26 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Likablehair Svelte component library
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A simple library that contains svelte components, used by likablehair frontend applications
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Developer guide
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Install dependencies and start a local server to develop components:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
#
|
|
11
|
-
npm
|
|
10
|
+
# Install deps
|
|
11
|
+
npm install
|
|
12
12
|
|
|
13
|
-
#
|
|
14
|
-
npm init svelte@next my-app
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
> Note: the `@next` is temporary
|
|
18
|
-
|
|
19
|
-
## Developing
|
|
20
|
-
|
|
21
|
-
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
13
|
+
# Start local server
|
|
24
14
|
npm run dev
|
|
25
15
|
|
|
26
16
|
# or start the server and open the app in a new browser tab
|
|
27
17
|
npm run dev -- --open
|
|
28
18
|
```
|
|
29
19
|
|
|
30
|
-
##
|
|
31
|
-
|
|
32
|
-
Before creating a production version of your app, install an [adapter](https://kit.svelte.dev/docs#adapters) for your target environment. Then:
|
|
20
|
+
## Publisher guide
|
|
33
21
|
|
|
34
|
-
|
|
35
|
-
npm run build
|
|
36
|
-
```
|
|
22
|
+
To publish the package make the following steps:
|
|
37
23
|
|
|
38
|
-
|
|
24
|
+
- edit the package.json version, then commit all the changes
|
|
25
|
+
- run `npm run package`, svelte will generate a package folder with all the necessary stuff inside
|
|
26
|
+
- make sure you're logged in with your npm account, then run `npm publish ./package --access=public`
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<script >export let type = 'default';
|
|
2
|
+
export let icon = undefined;
|
|
3
|
+
export let iconSize = 15;
|
|
4
|
+
let clazz = '';
|
|
5
|
+
export { clazz as class };
|
|
6
|
+
$: position = !!$$slots.append ? 'relative' : undefined;
|
|
7
|
+
$: cssVariables = Object.entries({
|
|
8
|
+
'--icon-button-height': (iconSize + 15) + 'pt',
|
|
9
|
+
'--icon-button-width': (iconSize + 15) + 'pt',
|
|
10
|
+
'--button-position': position
|
|
11
|
+
}).filter(([key]) => key.startsWith('--'))
|
|
12
|
+
.reduce((css, [key, value]) => {
|
|
13
|
+
return `${css}${key}: ${value};`;
|
|
14
|
+
}, '');
|
|
15
|
+
import '$lib/common/tailwind.css';
|
|
16
|
+
import Icon from '../media/Icon.svelte';
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div
|
|
20
|
+
class="button {clazz}"
|
|
21
|
+
class:button-default={type === 'default'}
|
|
22
|
+
class:button-text={type === 'text'}
|
|
23
|
+
class:button-icon={type === 'icon'}
|
|
24
|
+
on:click
|
|
25
|
+
style={cssVariables}
|
|
26
|
+
>
|
|
27
|
+
{#if !!icon}
|
|
28
|
+
<Icon name={icon} size={iconSize}></Icon>
|
|
29
|
+
{:else}
|
|
30
|
+
<slot></slot>
|
|
31
|
+
{/if}
|
|
32
|
+
{#if $$slots.append}
|
|
33
|
+
<span class="append-item">
|
|
34
|
+
<slot name="append">
|
|
35
|
+
|
|
36
|
+
</slot>
|
|
37
|
+
</span>
|
|
38
|
+
{/if}
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<style>
|
|
42
|
+
.append-item {
|
|
43
|
+
position: absolute;
|
|
44
|
+
right: 0px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.button {
|
|
48
|
+
overflow: hidden;
|
|
49
|
+
position: var(--button-position);
|
|
50
|
+
width: var(--width, fit-content);
|
|
51
|
+
height: var(--height, fit-content);
|
|
52
|
+
text-align: var(--text-align, center);
|
|
53
|
+
cursor: var(--cursor, pointer);
|
|
54
|
+
padding: var(--padding, 5px);
|
|
55
|
+
font-size: var(--font-size);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.button-default {
|
|
59
|
+
transition: background-color 200ms;
|
|
60
|
+
color: var(--color);
|
|
61
|
+
background-color: var(--background-color);
|
|
62
|
+
outline: 0;
|
|
63
|
+
border: 0;
|
|
64
|
+
border-radius: var(--border-radius, 0.25rem);
|
|
65
|
+
box-shadow: var(--box-shadow, 0 0 0.5rem rgba(0, 0, 0, 0.3));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.button-default:hover {
|
|
69
|
+
background-color: var(--hover-background-color, var(--background-color));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.button-text {
|
|
73
|
+
color: var(--color);
|
|
74
|
+
transition: background-color 200ms;
|
|
75
|
+
text-transform: uppercase;
|
|
76
|
+
font-weight: 600;
|
|
77
|
+
outline: 0;
|
|
78
|
+
border: 0;
|
|
79
|
+
border-radius: var(--border-radius, 0.25rem);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.button-text:hover {
|
|
83
|
+
background-color: var(--hover-background-color, transparent);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.button-icon {
|
|
87
|
+
color: var(--color);
|
|
88
|
+
transition: background-color 200ms;
|
|
89
|
+
outline: 0;
|
|
90
|
+
border: 0;
|
|
91
|
+
border-radius: var(--border-radius, 50%);
|
|
92
|
+
height: var(--icon-button-height) !important;
|
|
93
|
+
width: var(--icon-button-width) !important;
|
|
94
|
+
display: flex;
|
|
95
|
+
align-items: center;
|
|
96
|
+
justify-content: center;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.button-icon:hover {
|
|
100
|
+
background-color: var(--hover-background-color, transparent);
|
|
101
|
+
}
|
|
102
|
+
</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import '$lib/common/tailwind.css';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
type?: 'default' | 'text' | 'icon';
|
|
6
|
+
icon?: string;
|
|
7
|
+
iconSize?: number;
|
|
8
|
+
class?: string;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
click: MouseEvent;
|
|
12
|
+
} & {
|
|
13
|
+
[evt: string]: CustomEvent<any>;
|
|
14
|
+
};
|
|
15
|
+
slots: {
|
|
16
|
+
default: {};
|
|
17
|
+
append: {};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare type ButtonProps = typeof __propDef.props;
|
|
21
|
+
export declare type ButtonEvents = typeof __propDef.events;
|
|
22
|
+
export declare type ButtonSlots = typeof __propDef.slots;
|
|
23
|
+
export default class Button extends SvelteComponentTyped<ButtonProps, ButtonEvents, ButtonSlots> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script >import { Elevation } from '../enums/elevation.enum';
|
|
2
|
+
export let rounded = true, outlined = false, elevation = Elevation.md;
|
|
3
|
+
$: cssVariables = Object.entries({}).filter(([key]) => key.startsWith('--'))
|
|
4
|
+
.reduce((css, [key, value]) => {
|
|
5
|
+
return `${css}${key}: ${value};`;
|
|
6
|
+
}, '');
|
|
7
|
+
import '$lib/common/tailwind.css';
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<style>
|
|
11
|
+
.card-container {
|
|
12
|
+
height: var(--height, fit-content);
|
|
13
|
+
width: var(--width, fit-content);
|
|
14
|
+
max-height: var(--max-height);
|
|
15
|
+
max-width: var(--max-width);
|
|
16
|
+
min-height: var(--min-height);
|
|
17
|
+
min-width: var(--min-width);
|
|
18
|
+
padding: var(--padding, 5px);
|
|
19
|
+
background-color: var(--background-color, rgb(252, 252, 252));
|
|
20
|
+
color: var(--color);
|
|
21
|
+
border-color: var(--border-color);
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
24
|
+
|
|
25
|
+
<div
|
|
26
|
+
class="card-container flex flex-col rounded-md shadow-lg"
|
|
27
|
+
style={cssVariables}
|
|
28
|
+
class:shadow-sm={!outlined && elevation == Elevation.sm}
|
|
29
|
+
class:shadow-md={!outlined && elevation == Elevation.md}
|
|
30
|
+
class:shadow-lg={!outlined && elevation == Elevation.lg}
|
|
31
|
+
class:shadow-xl={!outlined && elevation == Elevation.xl}
|
|
32
|
+
class:shadow-2xl={!outlined && elevation == Elevation.xxl}
|
|
33
|
+
class:border-solid={outlined}
|
|
34
|
+
class:rounded-md={rounded}
|
|
35
|
+
>
|
|
36
|
+
<div class="header flex-none">
|
|
37
|
+
<slot name="header"></slot>
|
|
38
|
+
</div>
|
|
39
|
+
<div class="body shrink overflow-y-auto">
|
|
40
|
+
<slot></slot>
|
|
41
|
+
</div>
|
|
42
|
+
<div class="footer flex-none">
|
|
43
|
+
<slot name="footer"></slot>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { Elevation } from '../enums/elevation.enum';
|
|
3
|
+
import '$lib/common/tailwind.css';
|
|
4
|
+
declare const __propDef: {
|
|
5
|
+
props: {
|
|
6
|
+
rounded?: boolean;
|
|
7
|
+
outlined?: boolean;
|
|
8
|
+
elevation?: Elevation;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
};
|
|
13
|
+
slots: {
|
|
14
|
+
header: {};
|
|
15
|
+
default: {};
|
|
16
|
+
footer: {};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare type CardProps = typeof __propDef.props;
|
|
20
|
+
export declare type CardEvents = typeof __propDef.events;
|
|
21
|
+
export declare type CardSlots = typeof __propDef.slots;
|
|
22
|
+
export default class Card extends SvelteComponentTyped<CardProps, CardEvents, CardSlots> {
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
|
|
4
|
+
export let once = false;
|
|
5
|
+
export let top = 0;
|
|
6
|
+
export let bottom = 0;
|
|
7
|
+
export let left = 0;
|
|
8
|
+
export let right = 0;
|
|
9
|
+
|
|
10
|
+
let intersecting = false;
|
|
11
|
+
let container;
|
|
12
|
+
|
|
13
|
+
onMount(() => {
|
|
14
|
+
if (typeof IntersectionObserver !== 'undefined') {
|
|
15
|
+
const rootMargin = `${bottom}px ${left}px ${top}px ${right}px`;
|
|
16
|
+
|
|
17
|
+
const observer = new IntersectionObserver(entries => {
|
|
18
|
+
intersecting = entries[0].isIntersecting;
|
|
19
|
+
if (intersecting && once) {
|
|
20
|
+
observer.unobserve(container);
|
|
21
|
+
}
|
|
22
|
+
}, {
|
|
23
|
+
rootMargin
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
observer.observe(container);
|
|
27
|
+
return () => observer.unobserve(container);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function handler() {
|
|
31
|
+
const bcr = container.getBoundingClientRect();
|
|
32
|
+
intersecting = (
|
|
33
|
+
(bcr.bottom + bottom) > 0 &&
|
|
34
|
+
(bcr.right + right) > 0 &&
|
|
35
|
+
(bcr.top - top) < window.innerHeight &&
|
|
36
|
+
(bcr.left - left) < window.innerWidth
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
if (intersecting && once) {
|
|
40
|
+
window.removeEventListener('scroll', handler);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
window.addEventListener('scroll', handler);
|
|
45
|
+
return () => window.removeEventListener('scroll', handler);
|
|
46
|
+
});
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<style>
|
|
50
|
+
div {
|
|
51
|
+
width: 100%;
|
|
52
|
+
height: 100%;
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
55
|
+
|
|
56
|
+
<div bind:this={container}>
|
|
57
|
+
<slot {intersecting}></slot>
|
|
58
|
+
</div>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} IntersectionObserverProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} IntersectionObserverEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} IntersectionObserverSlots */
|
|
4
|
+
export default class IntersectionObserver extends SvelteComponentTyped<{
|
|
5
|
+
once?: boolean;
|
|
6
|
+
top?: number;
|
|
7
|
+
bottom?: number;
|
|
8
|
+
left?: number;
|
|
9
|
+
right?: number;
|
|
10
|
+
}, {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
}, {
|
|
13
|
+
default: {
|
|
14
|
+
intersecting: boolean;
|
|
15
|
+
};
|
|
16
|
+
}> {
|
|
17
|
+
}
|
|
18
|
+
export type IntersectionObserverProps = typeof __propDef.props;
|
|
19
|
+
export type IntersectionObserverEvents = typeof __propDef.events;
|
|
20
|
+
export type IntersectionObserverSlots = typeof __propDef.slots;
|
|
21
|
+
import { SvelteComponentTyped } from "svelte";
|
|
22
|
+
declare const __propDef: {
|
|
23
|
+
props: {
|
|
24
|
+
once?: boolean;
|
|
25
|
+
top?: number;
|
|
26
|
+
bottom?: number;
|
|
27
|
+
left?: number;
|
|
28
|
+
right?: number;
|
|
29
|
+
};
|
|
30
|
+
events: {
|
|
31
|
+
[evt: string]: CustomEvent<any>;
|
|
32
|
+
};
|
|
33
|
+
slots: {
|
|
34
|
+
default: {
|
|
35
|
+
intersecting: boolean;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import url("https://cdn.jsdelivr.net/npm/@mdi/font@6.5.95/css/materialdesignicons.min.css");
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import '$lib/common/tailwind.css';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {};
|
|
5
|
+
events: {
|
|
6
|
+
[evt: string]: CustomEvent<any>;
|
|
7
|
+
};
|
|
8
|
+
slots: {};
|
|
9
|
+
};
|
|
10
|
+
export declare type CalendarProps = typeof __propDef.props;
|
|
11
|
+
export declare type CalendarEvents = typeof __propDef.events;
|
|
12
|
+
export declare type CalendarSlots = typeof __propDef.slots;
|
|
13
|
+
export default class Calendar extends SvelteComponentTyped<CalendarProps, CalendarEvents, CalendarSlots> {
|
|
14
|
+
}
|
|
15
|
+
export {};
|
package/dates/utils.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const monthNames: string[];
|
|
2
|
+
export declare const monthDays: number[];
|
|
3
|
+
export declare const isLeapYear: (year: number) => boolean;
|
|
4
|
+
export declare const getEmptyRows: () => any[];
|
|
5
|
+
export declare const getMonthDays: (index: number, year: number) => number;
|
|
6
|
+
export declare const getMonthName: (index: number) => string;
|
|
7
|
+
export declare type MonthStats = {
|
|
8
|
+
name: string;
|
|
9
|
+
days: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const getDateRows: (monthIndex: number, year: number) => number[];
|
package/dates/utils.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export const monthNames = [
|
|
2
|
+
"January",
|
|
3
|
+
"February",
|
|
4
|
+
"March",
|
|
5
|
+
"April",
|
|
6
|
+
"May",
|
|
7
|
+
"June",
|
|
8
|
+
"July",
|
|
9
|
+
"August",
|
|
10
|
+
"September",
|
|
11
|
+
"October",
|
|
12
|
+
"November",
|
|
13
|
+
"December"
|
|
14
|
+
];
|
|
15
|
+
export const monthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
16
|
+
export const isLeapYear = year => year % 4 === 0;
|
|
17
|
+
export const getEmptyRows = () => {
|
|
18
|
+
return Array.from({ length: 42 }).map(() => []);
|
|
19
|
+
};
|
|
20
|
+
export const getMonthDays = (index, year) => {
|
|
21
|
+
return index !== 1 ? monthDays[index] : isLeapYear(year) ? 29 : 28;
|
|
22
|
+
};
|
|
23
|
+
export const getMonthName = index => monthNames[index];
|
|
24
|
+
const getMonthStats = (monthIndex, year) => {
|
|
25
|
+
const today = new Date(year, monthIndex, 1);
|
|
26
|
+
const index = today.getMonth();
|
|
27
|
+
return {
|
|
28
|
+
name: index[index],
|
|
29
|
+
days: getMonthDays(index, year)
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export const getDateRows = (monthIndex, year) => {
|
|
33
|
+
const { days } = getMonthStats(monthIndex, year);
|
|
34
|
+
const { days: daysOfPreviousMonth } = getMonthStats(monthIndex - 1, year);
|
|
35
|
+
const rows = getEmptyRows();
|
|
36
|
+
let startIndex = new Date(year, monthIndex, 1).getDay();
|
|
37
|
+
if (startIndex === 0)
|
|
38
|
+
startIndex = 6;
|
|
39
|
+
else
|
|
40
|
+
startIndex -= 1;
|
|
41
|
+
let lastIndex = new Date(year, monthIndex + 1, 0).getDay();
|
|
42
|
+
if (lastIndex === 0)
|
|
43
|
+
lastIndex = 6;
|
|
44
|
+
else
|
|
45
|
+
lastIndex -= 1;
|
|
46
|
+
Array.from({ length: days }).forEach((_, i) => {
|
|
47
|
+
const index = startIndex + i;
|
|
48
|
+
rows[index] = i + 1;
|
|
49
|
+
});
|
|
50
|
+
Array.from({ length: startIndex }).forEach((_, i) => {
|
|
51
|
+
rows[i] = (daysOfPreviousMonth - startIndex) + i + 1;
|
|
52
|
+
});
|
|
53
|
+
if (lastIndex !== 6) {
|
|
54
|
+
Array.from({ length: (6 - lastIndex) }).forEach((_, i) => {
|
|
55
|
+
rows[startIndex + days + i] = i + 1;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return rows.filter(el => !Array.isArray(el));
|
|
59
|
+
};
|
package/enums/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Elevation } from './elevation.enum';
|
package/enums/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Elevation } from './elevation.enum';
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
<script >export let label = "", placeholder = "", color = "", value = "", variant = 'outlined';
|
|
2
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
3
|
+
import { onMount } from 'svelte';
|
|
4
|
+
let inputId = uuidv4(), focused = false, legendWidth = 0, labelElement = undefined;
|
|
5
|
+
onMount(() => {
|
|
6
|
+
if (!!labelElement) {
|
|
7
|
+
legendWidth = (labelElement.offsetWidth * 0.8) + 8;
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
function handleFocus() {
|
|
11
|
+
focused = true;
|
|
12
|
+
}
|
|
13
|
+
function handleBlur() {
|
|
14
|
+
focused = false;
|
|
15
|
+
}
|
|
16
|
+
$: if (!!labelElement) {
|
|
17
|
+
legendWidth = !value && !focused ? 0 : (labelElement.offsetWidth * 0.8) + 8;
|
|
18
|
+
}
|
|
19
|
+
$: cssVariables = Object.entries({
|
|
20
|
+
'--theme-color': color,
|
|
21
|
+
'--legend-width': legendWidth + 'px'
|
|
22
|
+
}).filter(([key]) => key.startsWith('--'))
|
|
23
|
+
.reduce((css, [key, value]) => {
|
|
24
|
+
return `${css}${key}: ${value};`;
|
|
25
|
+
}, '');
|
|
26
|
+
import '$lib/common/tailwind.css';
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<style>
|
|
30
|
+
.input-container {
|
|
31
|
+
margin-top: 15px;
|
|
32
|
+
height: 50px;
|
|
33
|
+
position: relative;
|
|
34
|
+
width: var(--width, 100%);
|
|
35
|
+
--final-color: var(--theme-color, --border-color, rgb(88, 88, 88));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* outlined input */
|
|
39
|
+
|
|
40
|
+
.input-outlined {
|
|
41
|
+
border: 0px solid;
|
|
42
|
+
box-sizing: border-box;
|
|
43
|
+
color: var(--color, black);
|
|
44
|
+
font-size: 18px;
|
|
45
|
+
height: 100%;
|
|
46
|
+
outline: 0;
|
|
47
|
+
padding: 4px 0px 0;
|
|
48
|
+
width: 100%;
|
|
49
|
+
transition: all 0.3s;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.fieldset-outlined {
|
|
53
|
+
border-radius: var(--border-radius, 5px);
|
|
54
|
+
border: 1px solid rgb(122, 122, 122);
|
|
55
|
+
padding-left: 4px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.focused .fieldset-outlined {
|
|
59
|
+
border: 1px solid var(--final-color);
|
|
60
|
+
color: var(--final-color);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.legend-outlined {
|
|
64
|
+
width: var(--legend-width);
|
|
65
|
+
padding: 0px;
|
|
66
|
+
transition: width 0.3s, color 0.1s;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.label-outlined {
|
|
70
|
+
position: relative;
|
|
71
|
+
top: 13px;
|
|
72
|
+
left: 4px;
|
|
73
|
+
display: inline-block;
|
|
74
|
+
transition: all 0.3s;
|
|
75
|
+
transform-origin: top left;
|
|
76
|
+
transform: scale(1);
|
|
77
|
+
z-index: 2;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.texted .label-outlined {
|
|
81
|
+
top: -13px;
|
|
82
|
+
left: 4px;
|
|
83
|
+
transform: scale(.8);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* boxed input */
|
|
87
|
+
|
|
88
|
+
.fieldset-boxed {
|
|
89
|
+
border: 2px solid var(--final-color);
|
|
90
|
+
padding: 5px;
|
|
91
|
+
border-radius: var(--border-radius, 0);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.input-boxed {
|
|
95
|
+
border: 0px solid;
|
|
96
|
+
box-sizing: border-box;
|
|
97
|
+
font-size: 18px;
|
|
98
|
+
height: 100%;
|
|
99
|
+
outline: 0;
|
|
100
|
+
padding: 4px 0px 0;
|
|
101
|
+
width: 100%;
|
|
102
|
+
transition: all 0.3s;
|
|
103
|
+
position: relative;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.input-boxed::placeholder {
|
|
107
|
+
color: var(--final-color);
|
|
108
|
+
opacity: 60%;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
</style>
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
<div
|
|
115
|
+
class="input-container"
|
|
116
|
+
style={cssVariables}
|
|
117
|
+
class:focused={focused}
|
|
118
|
+
class:texted={focused || !!value}
|
|
119
|
+
>
|
|
120
|
+
<fieldset
|
|
121
|
+
aria-hidden="true"
|
|
122
|
+
class="fieldset"
|
|
123
|
+
class:fieldset-outlined={variant == 'outlined'}
|
|
124
|
+
class:fieldset-boxed={variant == 'boxed'}
|
|
125
|
+
>
|
|
126
|
+
{#if variant == 'outlined'}
|
|
127
|
+
<legend class="legend-outlined"></legend>
|
|
128
|
+
<label
|
|
129
|
+
for={inputId}
|
|
130
|
+
class="label-outlined"
|
|
131
|
+
bind:this={labelElement}
|
|
132
|
+
>{label}</label>
|
|
133
|
+
<div class="flex content-center relative bottom-3 ml-2 mr-2">
|
|
134
|
+
<div>
|
|
135
|
+
<slot name="prepend-inner"></slot>
|
|
136
|
+
</div>
|
|
137
|
+
<input
|
|
138
|
+
id={inputId}
|
|
139
|
+
class="input-outlined"
|
|
140
|
+
type="text"
|
|
141
|
+
placeholder={placeholder}
|
|
142
|
+
bind:value={value}
|
|
143
|
+
on:change
|
|
144
|
+
on:input
|
|
145
|
+
on:focus={handleFocus}
|
|
146
|
+
on:focus
|
|
147
|
+
on:blur={handleBlur}
|
|
148
|
+
on:blur
|
|
149
|
+
/>
|
|
150
|
+
<div>
|
|
151
|
+
<slot name="append-inner"></slot>
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
{:else if variant == 'boxed'}
|
|
155
|
+
<div class="flex">
|
|
156
|
+
<div>
|
|
157
|
+
<slot name="prepend-inner"></slot>
|
|
158
|
+
</div>
|
|
159
|
+
<input
|
|
160
|
+
id={inputId}
|
|
161
|
+
class="input-boxed"
|
|
162
|
+
type="text"
|
|
163
|
+
placeholder={placeholder || label}
|
|
164
|
+
bind:value={value}
|
|
165
|
+
on:change
|
|
166
|
+
on:input
|
|
167
|
+
on:focus={handleFocus}
|
|
168
|
+
on:focus
|
|
169
|
+
on:blur={handleBlur}
|
|
170
|
+
on:blur
|
|
171
|
+
/>
|
|
172
|
+
<div>
|
|
173
|
+
<slot name="append-inner"></slot>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
{/if}
|
|
177
|
+
</fieldset>
|
|
178
|
+
</div>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import '$lib/common/tailwind.css';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
label?: string;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
color?: string;
|
|
8
|
+
value?: string;
|
|
9
|
+
variant?: "outlined" | "boxed";
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
change: Event;
|
|
13
|
+
input: Event;
|
|
14
|
+
focus: FocusEvent;
|
|
15
|
+
blur: FocusEvent;
|
|
16
|
+
} & {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
};
|
|
19
|
+
slots: {
|
|
20
|
+
'prepend-inner': {};
|
|
21
|
+
'append-inner': {};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare type TextfieldProps = typeof __propDef.props;
|
|
25
|
+
export declare type TextfieldEvents = typeof __propDef.events;
|
|
26
|
+
export declare type TextfieldSlots = typeof __propDef.slots;
|
|
27
|
+
export default class Textfield extends SvelteComponentTyped<TextfieldProps, TextfieldEvents, TextfieldSlots> {
|
|
28
|
+
}
|
|
29
|
+
export {};
|
package/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default as
|
|
1
|
+
export { default as Button } from './buttons/Button.svelte';
|
|
2
|
+
export { default as HeaderMenu } from './navigation/HeaderMenu.svelte';
|