Skip to content

Commit 1de17d8

Browse files
committed
css and functional tweaks
1 parent c538ca4 commit 1de17d8

5 files changed

Lines changed: 90 additions & 55 deletions

File tree

src/app.postcss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* .decoration-transparent {
44
font-size: 2rem;
55
} */
6-
@tailwind components;
6+
/* @tailwind components; */
77
@tailwind utilities;
88

99
h1 {

src/lib/components/Calendar.svelte

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@
112112
113113
$: times = dates.map(date => { date = new Date(date); date.setHours(0,0); return date.getTime() });
114114
$: dataset = compute(activeDate, dates, currentView, i18n, weekStart);
115-
$: dayLabels = weekStart > -1
116-
? i18n.daysMin.concat(i18n.daysMin).slice(weekStart, 7 + weekStart)
117-
: i18n.daysMin.slice(weekStart, 7 + weekStart)
115+
$: dayLabels = i18n.daysMin.concat(...i18n.daysMin.slice(1)).slice(weekStart, 7 + weekStart);
118116
119117
function isBetween(/** @type {number} */num) {
120118
return dataset.prevTo <= num && num < dataset.nextFrom;
@@ -419,7 +417,7 @@
419417
padding: 0;
420418
font-size: 90%;
421419
text-align: center;
422-
background-color: var(--sdt-bg-main);
420+
background-color: var(--sdt-bg-main);;
423421
}
424422
.sdt-cal-th {
425423
text-align: center;
@@ -439,6 +437,7 @@
439437
.sdt-table {
440438
width: 100%;
441439
border-collapse: collapse;
440+
margin: 0;
442441
}
443442
.sdt-table-height {
444443
height: 222px;

src/lib/components/SveltyPicker.svelte

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<script>
77
/**
88
* TODO: handle displayFormat change dynamically
9+
* TODO: properly handle 'clear' when `autocommit` is `false (make it undoable)
910
*/
1011
import { createEventDispatcher, onMount, tick } from "svelte";
1112
import { fade } from "svelte/transition";
@@ -203,15 +204,15 @@
203204
}
204205
205206
function computeStringValue() {
206-
return valueArray.join('');
207+
return valueArray.join(',');
207208
}
208209
209210
/**
210211
* @param {string[]} values
211212
* @returns {boolean}
212213
*/
213214
function computeDirty(values) {
214-
return values.join('') !== undoHistory.join('');
215+
return values.join(',') !== undoHistory.join(',');
215216
}
216217
217218
function resetView() {
@@ -341,7 +342,7 @@
341342
prevValue = [];
342343
innerDates = [];
343344
currentValue = '';
344-
onValueSet();
345+
autocommit && onValueSet();
345346
}
346347
347348
/**
@@ -426,7 +427,8 @@
426427
* @param {{ target: HTMLInputElement}} event
427428
*/
428429
function onManualInput(event) {
429-
430+
event.preventDefault();
431+
event.stopPropagation();
430432
const parsedInput = parseDate(event.target.value, displayFormat || format, i18n, displayFormatType || formatType);
431433
const formattedInput = formatDate(parsedInput, displayFormat || format, i18n, displayFormatType || formatType);
432434
if (formattedInput === event.target.value) {
@@ -472,7 +474,7 @@
472474
ce_valueElement.dispatchEvent(new Event('input'));
473475
ce_displayElement.dispatchEvent(new Event('input'));
474476
}
475-
dispatchInputEvent && dispatch("input", value);
477+
dispatchInputEvent && dispatch('input', currentValue);
476478
}
477479
478480
/**
@@ -503,33 +505,38 @@
503505
</script>
504506

505507
<span class="std-component-wrap">
506-
{#if !ce_displayElement}
507-
<input type="hidden" {name} {value}>
508-
{#if !pickerOnly}
509-
<input bind:this={ref_input} type={pickerOnly ? "hidden" : "text"}
510-
id={inputId}
511-
tabindex="0"
512-
name={name.endsWith(']') ? name.substring(0, name.length-1) + '_input]' : name + '_input'}
513-
class:value-dirty={!autocommit && isDirty}
514-
value={displayValue}
515-
{placeholder} {disabled} {required}
516-
autocomplete="off"
517-
inputmode="none"
518-
class={inputClasses}
519-
readonly={isFocused && !manualInput && !isRange}
520-
on:input={manualInput ? onManualInput : () => {}}
521-
use:inputAction={inputActionParams}
522-
on:focus={onInputFocus}
523-
on:blur={onInputBlur}
524-
on:click={() => {
525-
!pickerVisible && onInputFocus();
526-
}}
527-
on:input
528-
on:change
529-
on:keydown={onKeyDown}
530-
/>
508+
<slot name="inputs"
509+
value={value} displayValue={displayValue} disabled={disabled} isDirty={isDirty}
510+
onKeyDown={onKeyDown} onInputFocus={onInputFocus} onInputBlur={onInputBlur}
511+
>
512+
{#if !ce_displayElement}
513+
<input type="hidden" {name} {value}>
514+
{#if !pickerOnly}
515+
<input bind:this={ref_input} type="text"
516+
id={inputId}
517+
tabindex="0"
518+
name={name.endsWith(']') ? name.substring(0, name.length-1) + '_input]' : name + '_input'}
519+
class:value-dirty={!autocommit && isDirty}
520+
value={displayValue}
521+
{placeholder} {disabled} {required}
522+
autocomplete="off"
523+
inputmode="none"
524+
class={inputClasses}
525+
readonly={isFocused && !manualInput && !isRange}
526+
on:input={manualInput ? onManualInput : () => {}}
527+
use:inputAction={inputActionParams}
528+
on:focus={onInputFocus}
529+
on:blur={onInputBlur}
530+
on:click={() => {
531+
!pickerVisible && onInputFocus();
532+
}}
533+
on:input
534+
on:change
535+
on:keydown={onKeyDown}
536+
/>
537+
{/if}
531538
{/if}
532-
{/if}
539+
</slot>
533540
{#if pickerVisible && isFocused }
534541
<!-- svelte-ignore a11y-no-static-element-interactions -->
535542
<div
@@ -637,7 +644,6 @@
637644
padding: 0.5em;
638645
color: var(--sdt-color);
639646
}
640-
/* FUTURE: */
641647
.std-calendar-wrap.is-range-wrap {
642648
width: 560px;
643649
}
@@ -652,7 +658,7 @@
652658
min-width: 264px;
653659
}
654660
.value-dirty {
655-
color: color-mix(in srgb, black 50%, currentColor);
661+
color: color-mix(in srgb, black 20%, white);
656662
}
657663
.std-calendar-wrap.is-popup {
658664
position: absolute;

src/lib/components/Time.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,16 +332,16 @@
332332

333333
<div class="sdt-time-head">
334334
{#if hasDateComponent}
335-
<button class="sdt-time-btn sdt-back-btn" title={i18n.backToDate} on:click={onModeSwitch}>
335+
<button type="button" class="sdt-time-btn sdt-back-btn" title={i18n.backToDate} on:click={onModeSwitch}>
336336
<svg class="sdt-svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20"><path fill-rule="evenodd" d="M6.75 0a.75.75 0 01.75.75V3h9V.75a.75.75 0 011.5 0V3h2.75c.966 0 1.75.784 1.75 1.75v16a1.75 1.75 0 01-1.75 1.75H3.25a1.75 1.75 0 01-1.75-1.75v-16C1.5 3.784 2.284 3 3.25 3H6V.75A.75.75 0 016.75 0zm-3.5 4.5a.25.25 0 00-.25.25V8h18V4.75a.25.25 0 00-.25-.25H3.25zM21 9.5H3v11.25c0 .138.112.25.25.25h17.5a.25.25 0 00.25-.25V9.5z"></path></svg>
337337
</button>
338338
{/if}
339-
<button class="sdt-time-btn sdt-time-figure"
339+
<button type="button" class="sdt-time-btn sdt-time-figure"
340340
class:is-active={!isMinuteView}
341341
on:click={() => isMinuteView = false}
342342
>{view(selectedHour, showMeridian)}</button>
343343
<span>:</span>
344-
<button class="sdt-time-btn sdt-time-figure"
344+
<button type="button" class="sdt-time-btn sdt-time-figure"
345345
class:is-active={isMinuteView}
346346
on:click={() => isMinuteView = true}
347347
>{view(selectedMinutes, false)}</button>

src/lib/i18n/index.js

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
* @property {string} backToDate
2222
*/
2323

24-
// Czech translation
24+
/**
25+
* @type {i18nType} Czech translation
26+
*/
2527
export const cz = {
2628
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
2729
daysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
@@ -38,7 +40,9 @@ export const cz = {
3840
backToDate: 'Zpátky na kalendář'
3941
}
4042

41-
// German translation by emroc GmbH
43+
/**
44+
* @type {i18nType} German translation by emroc GmbH
45+
*/
4246
export const de = {
4347
days: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag'],
4448
daysShort: ['Son', 'Mon', 'Die', 'Mie', 'Don', 'Fre', 'Sam', 'Son'],
@@ -55,7 +59,9 @@ export const de = {
5559
backToDate: 'Zurück zur Kalenderansicht'
5660
}
5761

58-
// English translation
62+
/**
63+
* @type {i18nType} English translation
64+
*/
5965
export const en = {
6066
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
6167
daysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
@@ -72,7 +78,11 @@ export const en = {
7278
backToDate: 'Back to calendar view'
7379
}
7480

75-
// Spanish translation by markoan
81+
82+
/**
83+
* @type {i18nType} Spanish translation by markoan
84+
*/
85+
7686
export const es = {
7787
days: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado', 'Domingo'],
7888
daysShort: ['Dom', 'Lun', 'Mar', 'Mié', 'Jue', 'Vie', 'Sáb', 'Dom'],
@@ -89,7 +99,9 @@ export const es = {
8999
backToDate: 'Regresar al calendario'
90100
}
91101

92-
// Persian (Farsi) translation by sadegh19b
102+
/**
103+
* @type {i18nType} Persian (Farsi) translation by sadegh19b
104+
*/
93105
export const fa = {
94106
days: ['یکشنبه', 'دوشنبه', 'سه‌شنبه‌', 'چهارشنبه', 'پنج‌شنبه', 'جمعه', 'شنبه', 'یکشنبه'],
95107
daysShort: ['یکش', 'دوش', 'سه‌ش', 'چهار', 'پنج', 'جمع', 'شنب', 'یکش'],
@@ -106,7 +118,9 @@ export const fa = {
106118
backToDate: 'بازگشت به بخش تقویم'
107119
}
108120

109-
// French translation by Tuditi
121+
/**
122+
* @type {i18nType} French translation by Tuditi
123+
*/
110124
export const fr = {
111125
days: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche'],
112126
daysShort: ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam', 'Dim'],
@@ -123,7 +137,9 @@ export const fr = {
123137
backToDate: 'Retour au calendrier'
124138
}
125139

126-
// Hungarian translation by Tuditi
140+
/**
141+
* @type {i18nType} Hungarian translation by Tuditi
142+
*/
127143
export const hu = {
128144
days: ['Vasárnap', 'Hétfő', 'Kedd', 'Szerda', 'Csütörtök', 'Péntek', 'Szombat', 'Vasárnap'],
129145
daysShort: ['V', 'H', 'K', 'Sze', 'Cs', 'P', 'Szo', 'V'],
@@ -140,7 +156,9 @@ export const hu = {
140156
backToDate: 'Vissza a naptárhoz'
141157
};
142158

143-
// Indonesian translation
159+
/**
160+
* @type {i18nType} Indonesian translation
161+
*/
144162
export const id = {
145163
days: ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu', 'Minggu'],
146164
daysShort: ['Min', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab', 'Min'],
@@ -157,7 +175,9 @@ export const id = {
157175
backToDate: 'Kembali ke tampilan kalender'
158176
}
159177

160-
// Japanese translation by aska
178+
/**
179+
* @type {i18nType} Japanese translation by aska
180+
*/
161181
export const jp = {
162182
days: ['日曜日', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日', '日曜日'],
163183
daysShort: ['日曜', '月曜', '火曜', '水曜', '木曜', '金曜', '土曜', '日曜'],
@@ -174,7 +194,9 @@ export const jp = {
174194
backToDate: 'カレンダーに戻る'
175195
}
176196

177-
// Dutch Translation by Tuditi
197+
/**
198+
* @type {i18nType} Dutch Translation by Tuditi
199+
*/
178200
export const nl = {
179201
days: ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag', 'Zondag'],
180202
daysShort: ['Zon', 'Maa', 'Din', 'Woe', 'Don', 'Vri', 'Zat', 'Zon'],
@@ -191,7 +213,9 @@ export const nl = {
191213
backToDate: 'Terug naar de kalender'
192214
};
193215

194-
// Slovak Translation
216+
/**
217+
* @type {i18nType} Slovak Translation
218+
*/
195219
export const sk = {
196220
days: ['Nedeľa', 'Pondelok', 'Utorok', 'Streda', 'Štvrtok', 'Piatok', 'Sobota', 'Nedeľa'],
197221
daysShort: ['Ned', 'Pon', 'Uto', 'Str', 'Štv', 'Pia', 'Sob', 'Ned'],
@@ -208,7 +232,9 @@ export const sk = {
208232
backToDate: 'Späť na kalendár'
209233
}
210234

211-
// Korean translation
235+
/**
236+
* @type {i18nType} Korean translation
237+
*/
212238
export const ko = {
213239
days: ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일', '일요일'],
214240
daysShort: ['일', '월', '화', '수', '목', '금', '토', '일'],
@@ -225,7 +251,9 @@ export const ko = {
225251
backToDate: '달력보기'
226252
}
227253

228-
// Brazilian portuguese translation by IgorDalepiane
254+
/**
255+
* @type {i18nType} Brazilian portuguese translation by IgorDalepiane
256+
*/
229257
export const pt_BR = {
230258
days: ['Domingo', 'Segunda-feira', 'Terça-feira', 'Quarta-feira', 'Quinta-feira', 'Sexta-feira', 'Sábado', 'Domingo'],
231259
daysShort: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb', 'Dom'],
@@ -242,7 +270,9 @@ export const pt_BR = {
242270
backToDate: 'Voltar para o calendário'
243271
}
244272

245-
// italian translation by MarkNerdi
273+
/**
274+
* @type {i18nType} italian translation by MarkNerdi
275+
*/
246276
export const it = {
247277
days: ['Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato', 'Domenica'],
248278
daysShort: ['Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab', 'Dom'],

0 commit comments

Comments
 (0)