@likable-hair/svelte 0.0.58 → 0.0.59

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.
@@ -3,20 +3,20 @@ import YearSelector from "./YearSelector.svelte";
3
3
  import MonthSelector from "./MonthSelector.svelte";
4
4
  import Calendar from "./Calendar.svelte";
5
5
  import Button from "../buttons/Button.svelte";
6
- export let selectedYear = new Date().getFullYear(), selectedMonth = new Date().getMonth(), selectedDate = new Date(), view = 'day', locale = 'it', primaryColor = "#008080", headerBackgroundColor = primaryColor, arrowColor = primaryColor, hoverColor = "#00808012", selectedDayColor = "black", headerColor = "white", cardColor = "black", cardBackGroundColor = "rgba(255,255,255,0)", height = "100%", width = "100%";
6
+ export let selectedYear = new Date().getFullYear(), selectedMonth = new Date().getMonth(), selectedDate = new Date(), view = "day", locale = "it", primaryColor = "#008080", headerBackgroundColor = primaryColor, arrowColor = primaryColor, hoverColor = "#00808012", selectedDayColor = "black", headerColor = "white", cardColor = "black", cardBackGroundColor = "rgba(255,255,255,0)", height = "100%", width = "100%";
7
7
  let selectorText = undefined;
8
8
  let selectableYears = [...Array(150).keys()].map((i) => i + (new Date().getFullYear() - 75));
9
- let elementDisabled = 'date';
10
- $: visibleSelector = view == 'day' || view == 'month';
9
+ let elementDisabled = "date";
10
+ $: visibleSelector = view == "day" || view == "month";
11
11
  $: {
12
12
  selectorText =
13
- view == 'day'
13
+ view == "day"
14
14
  ? getMonthName(selectedMonth, locale) + " " + selectedYear
15
15
  : selectedYear.toString();
16
16
  }
17
- $: elementDisabled = view == 'year' ? 'year' : 'date';
17
+ $: elementDisabled = view == "year" ? "year" : "date";
18
18
  function next() {
19
- if (view == 'day') {
19
+ if (view == "day") {
20
20
  if (selectedMonth == 11) {
21
21
  selectedMonth = 0;
22
22
  selectedYear += 1;
@@ -31,7 +31,7 @@ function next() {
31
31
  }
32
32
  }
33
33
  function previous() {
34
- if (view == 'day') {
34
+ if (view == "day") {
35
35
  if (selectedMonth == 0) {
36
36
  selectedMonth = 11;
37
37
  selectedYear -= 1;
@@ -46,10 +46,10 @@ function previous() {
46
46
  }
47
47
  }
48
48
  function SelectorHandler() {
49
- if (view == 'month')
50
- view = 'year';
49
+ if (view == "month")
50
+ view = "year";
51
51
  else
52
- view = 'month';
52
+ view = "month";
53
53
  }
54
54
  function handleYearChange() {
55
55
  view = "month";
@@ -60,151 +60,152 @@ function handleMonthChange() {
60
60
  </script>
61
61
 
62
62
  <div
63
- class="container"
64
- style:background={cardBackGroundColor}
65
- style:color={cardColor}
66
- style:height
67
- style:width
63
+ class="container"
64
+ style:background={cardBackGroundColor}
65
+ style:color={cardColor}
66
+ style:height
67
+ style:width
68
68
  >
69
- <div
70
- class="header"
71
- style:height="25%"
72
- style:background={headerBackgroundColor}
73
- style:color={headerColor}
69
+ <div
70
+ class="header"
71
+ style:height="25%"
72
+ style:background={headerBackgroundColor}
73
+ style:color={headerColor}
74
+ >
75
+ <span
76
+ class:disabled={elementDisabled == "year"}
77
+ on:click={() => {
78
+ view = "year";
79
+ }}>{selectedYear}</span
74
80
  >
75
- <span
76
- class:disabled="{elementDisabled == 'year'}"
77
- on:click={() => {
78
- view = 'year';
79
- }}>{selectedYear}</span
80
- >
81
- <h2
82
- class:disabled="{elementDisabled == 'date'}"
83
- on:click={() => {
84
- view = 'day';
85
- }}
86
- >
87
- {dateToString(selectedDate, 'dayAndMonth', locale)}
88
- </h2>
89
- </div>
90
- <div class="body" style:height="75%">
91
- {#if visibleSelector}
92
- <div class="selector-row" style:height="25%">
93
- <div class="row-elem">
94
- <Button
95
- color={arrowColor}
96
- hoverBackgroundColor={hoverColor}
97
- type="icon"
98
- iconSize={25}
99
- icon="mdi-chevron-left"
100
- on:click={previous}
101
- />
102
- </div>
103
- <div class="row-elem selector">
104
- {#key selectorText}
105
- <div
106
- on:click={SelectorHandler}
107
- style:--primary-color={primaryColor}
108
- >
109
- {selectorText}
110
- </div>
111
- {/key}
112
- </div>
113
- <div class="row-elem">
114
- <Button
115
- color={arrowColor}
116
- hoverBackgroundColor={hoverColor}
117
- type="icon"
118
- iconSize={25}
119
- icon="mdi-chevron-right"
120
- on:click={next}
121
- />
122
- </div>
81
+ <h2
82
+ class:disabled={elementDisabled == "date"}
83
+ on:click={() => {
84
+ view = "day";
85
+ }}
86
+ >
87
+ {dateToString(selectedDate, "dayAndMonth", locale)}
88
+ </h2>
89
+ </div>
90
+ <div class="body" style:height="75%">
91
+ {#if visibleSelector}
92
+ <div class="selector-row" style:height="25%">
93
+ <div class="row-elem">
94
+ <Button
95
+ color={arrowColor}
96
+ hoverBackgroundColor={hoverColor}
97
+ type="icon"
98
+ iconSize={25}
99
+ icon="mdi-chevron-left"
100
+ on:click={previous}
101
+ />
102
+ </div>
103
+ <div class="row-elem selector">
104
+ {#key selectorText}
105
+ <div
106
+ on:click={SelectorHandler}
107
+ style:--primary-color={primaryColor}
108
+ >
109
+ {selectorText}
123
110
  </div>
124
- {/if}
125
- {#if view == 'month'}
126
- <MonthSelector
127
- height="75%"
128
- {width}
129
- bind:selectedMonth
130
- on:click={handleMonthChange}
131
- locale={locale}
132
- monthSelectedColor={primaryColor}
133
- monthSelectedTextColor={selectedDayColor}
134
- />
135
- {:else if view == 'year'}
136
- <YearSelector
137
- height="100%"
138
- {width}
139
- bind:selectedYear
140
- {selectableYears}
141
- on:click={handleYearChange}
142
- />
143
- {:else}
144
- <Calendar
145
- height="75%"
146
- {width}
147
- bind:visibleMonth={selectedMonth}
148
- bind:visibleYear={selectedYear}
149
- bind:selectedDate={selectedDate}
150
- dayHoverColor={hoverColor}
151
- daySelectedColor={primaryColor}
152
- selectedTextColor={selectedDayColor}
153
- locale={locale}
154
- />
155
- {/if}
156
- </div>
111
+ {/key}
112
+ </div>
113
+ <div class="row-elem">
114
+ <Button
115
+ color={arrowColor}
116
+ hoverBackgroundColor={hoverColor}
117
+ type="icon"
118
+ iconSize={25}
119
+ icon="mdi-chevron-right"
120
+ on:click={next}
121
+ />
122
+ </div>
123
+ </div>
124
+ {/if}
125
+ {#if view == "month"}
126
+ <MonthSelector
127
+ height="75%"
128
+ {width}
129
+ bind:selectedMonth
130
+ on:click={handleMonthChange}
131
+ {locale}
132
+ monthSelectedColor={primaryColor}
133
+ monthSelectedTextColor={selectedDayColor}
134
+ />
135
+ {:else if view == "year"}
136
+ <YearSelector
137
+ height="100%"
138
+ {width}
139
+ bind:selectedYear
140
+ {selectableYears}
141
+ on:click={handleYearChange}
142
+ />
143
+ {:else}
144
+ <Calendar
145
+ height="75%"
146
+ {width}
147
+ bind:visibleMonth={selectedMonth}
148
+ bind:visibleYear={selectedYear}
149
+ bind:selectedDate
150
+ dayHoverColor={hoverColor}
151
+ daySelectedColor={primaryColor}
152
+ selectedTextColor={selectedDayColor}
153
+ {locale}
154
+ on:day-click
155
+ />
156
+ {/if}
157
+ </div>
157
158
  </div>
158
159
 
159
160
  <style>
160
- .container {
161
- border-radius: 5px;
162
- }
163
- .header {
164
- border-radius: 5px 5px 0 0;
165
- }
166
- .header > h2 {
167
- margin-left: 30px;
168
- transition: 0.1s;
169
- opacity: 0.8;
170
- }
171
- .header > h2:hover {
172
- opacity: 1;
173
- cursor: pointer;
174
- }
175
- .header > span {
176
- display: inline-block;
177
- line-height: 100%;
178
- margin-left: 15px;
179
- margin-top: 10px;
180
- opacity: 0.8;
181
- transition: 0.1s;
182
- }
183
- .header > span:hover {
184
- opacity: 1;
185
- cursor: pointer;
186
- }
187
- .selector-row {
188
- display: flex;
189
- justify-content: space-between;
190
- line-height: 100%;
191
- }
192
- .row-elem {
193
- margin: auto;
194
- }
195
- .selector {
196
- width: 50%;
197
- text-align: center;
198
- }
199
- .selector > div {
200
- transition: 0.1s;
201
- }
202
- .selector > div:hover {
203
- cursor: pointer;
204
- color: var(--primary-color);
205
- }
206
- .disabled {
207
- pointer-events: none;
208
- opacity: 1 !important;
209
- }
161
+ .container {
162
+ border-radius: 5px;
163
+ }
164
+ .header {
165
+ border-radius: 5px 5px 0 0;
166
+ }
167
+ .header > h2 {
168
+ margin-left: 30px;
169
+ transition: 0.1s;
170
+ opacity: 0.8;
171
+ }
172
+ .header > h2:hover {
173
+ opacity: 1;
174
+ cursor: pointer;
175
+ }
176
+ .header > span {
177
+ display: inline-block;
178
+ line-height: 100%;
179
+ margin-left: 15px;
180
+ margin-top: 10px;
181
+ opacity: 0.8;
182
+ transition: 0.1s;
183
+ }
184
+ .header > span:hover {
185
+ opacity: 1;
186
+ cursor: pointer;
187
+ }
188
+ .selector-row {
189
+ display: flex;
190
+ justify-content: space-between;
191
+ line-height: 100%;
192
+ }
193
+ .row-elem {
194
+ margin: auto;
195
+ }
196
+ .selector {
197
+ width: 50%;
198
+ text-align: center;
199
+ }
200
+ .selector > div {
201
+ transition: 0.1s;
202
+ }
203
+ .selector > div:hover {
204
+ cursor: pointer;
205
+ color: var(--primary-color);
206
+ }
207
+ .disabled {
208
+ pointer-events: none;
209
+ opacity: 1 !important;
210
+ }
210
211
  </style>
@@ -5,7 +5,7 @@ declare const __propDef: {
5
5
  selectedYear?: number;
6
6
  selectedMonth?: number;
7
7
  selectedDate?: Date;
8
- view?: 'year' | 'month' | 'day';
8
+ view?: "year" | "month" | "day";
9
9
  locale?: Locale;
10
10
  primaryColor?: string;
11
11
  headerBackgroundColor?: string;
@@ -19,6 +19,12 @@ declare const __propDef: {
19
19
  width?: string;
20
20
  };
21
21
  events: {
22
+ 'day-click': CustomEvent<{
23
+ dateStat: import("./utils").DateStat;
24
+ selected: boolean;
25
+ extraMonth: boolean;
26
+ }>;
27
+ } & {
22
28
  [evt: string]: CustomEvent<any>;
23
29
  };
24
30
  slots: {};
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.58",
4
+ "version": "0.0.59",
5
5
  "devDependencies": {
6
6
  "@sveltejs/adapter-auto": "next",
7
7
  "@sveltejs/kit": "next",