Skip to content

Commit f0c9bbe

Browse files
Transition improvements
1 parent f19e673 commit f0c9bbe

File tree

6 files changed

+30
-20
lines changed

6 files changed

+30
-20
lines changed

src/lib/DateInput.svelte

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<script lang="ts">
2+
import { slide, fly } from 'svelte/transition'
23
import { toText } from './date-utils'
34
import { parse, createFormat } from './parse'
45
import type { FormatToken } from './parse'
56
import DateTimePicker from './DatePicker.svelte'
7+
import { cubicInOut } from 'svelte/easing'
68
79
/** Date value */
810
export let value = new Date()
@@ -78,17 +80,19 @@
7880
{placeholder}
7981
on:focus={() => (visible = true)}
8082
on:input={input} />
81-
<div class="picker" class:visible>
82-
<DateTimePicker on:focusout={onFocusOut} bind:value bind:min bind:max />
83-
</div>
83+
{#if visible}
84+
<div class="picker" class:visible transition:fly={{ duration: 80, easing: cubicInOut, y: -5 }}>
85+
<DateTimePicker on:focusout={onFocusOut} bind:value bind:min bind:max />
86+
</div>
87+
{/if}
8488
</div>
8589

8690
<style lang="sass">
8791
.date-time-field
8892
position: relative
8993
input
9094
color: var(--date-picker-foreground, #000000)
91-
background-color: var(--date-picker-background, #ffffff)
95+
background: var(--date-picker-background, #ffffff)
9296
min-width: 0px
9397
box-sizing: border-box
9498
padding: 4px 6px
@@ -97,7 +101,7 @@
97101
border-radius: 3px
98102
width: var(----date-input-width, 150px)
99103
outline: none
100-
transition: all 80ms ease-in-out
104+
transition: all 80ms cubic-bezier(0.4, 0.0, 0.2, 1)
101105
&:focus
102106
border-color: var(--date-picker-highlight-border, #0269f7)
103107
box-shadow: 0px 0px 0px 2px var(--date-picker-highlight-shadow, rgba(#0269f7, 0.4))

src/lib/DatePicker.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,15 @@
226226
display: inline-block
227227
outline: none
228228
color: var(--date-picker-foreground, #000000)
229-
background-color: var(--date-picker-background, #ffffff)
229+
background: var(--date-picker-background, #ffffff)
230230
user-select: none
231231
-webkit-user-select: none
232232
padding: 8px
233233
cursor: default
234234
font-size: 12px
235235
border: 1px solid rgba(103, 113, 137, 0.3)
236236
border-radius: 3px
237-
box-shadow: 0px 3px 6px rgba(#000000,0.08), 0px 3px 6px rgba(#000000,0.11)
237+
box-shadow: 0px 2px 6px rgba(#000000,0.08), 0px 2px 6px rgba(#000000,0.11)
238238
.top
239239
display: flex
240240
justify-content: center
@@ -290,7 +290,7 @@
290290
border: 1px solid rgba(108, 120, 147, 0.3)
291291
border-radius: 3px
292292
outline: none
293-
transition: all 80ms ease-in-out
293+
transition: all 80ms cubic-bezier(0.4, 0.0, 0.2, 1)
294294
&:focus
295295
border-color: var(--date-picker-highlight-border, #0269f7)
296296
box-shadow: 0px 0px 0px 2px var(--date-picker-highlight-shadow, rgba(#0269f7, 0.4))
@@ -323,6 +323,6 @@
323323
opacity: 0.4
324324
&.selected
325325
color: var(--date-picker-selected-color, inherit)
326-
background-color: var(--date-picker-selected-background, rgba(2, 105, 247, 0.2))
326+
background: var(--date-picker-selected-background, rgba(2, 105, 247, 0.2))
327327
border: 2px solid var(--date-picker-highlight-border, #0269f7)
328328
</style>

src/routes/_DateInput.svelte

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
let max: Date
1010
let valid: boolean
1111
let visible: boolean
12-
let width: string
1312
let format: string
1413
</script>
1514

@@ -21,7 +20,6 @@
2120
bind:max
2221
bind:placeholder
2322
bind:valid
24-
bind:width
2523
bind:format
2624
bind:visible />
2725

@@ -32,7 +30,6 @@
3230
<Prop label="max" bind:value={max} />
3331
<Prop label="placeholder" bind:value={placeholder} />
3432
<Prop label="valid" bind:value={valid} />
35-
<Prop label="width" bind:value={width} />
3633
<Prop label="format" bind:value={format} />
3734
<Prop label="visible" bind:value={visible} />
3835
</svelte:fragment>

src/routes/__layout.svelte

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,19 @@
6969
--date-input-width: var(--input-width)
7070
color: var(--foreground)
7171
:global([data-theme='dark'])
72-
--background: #0d0e12
7372
--foreground: #f7f7f7
73+
--background: #0d0e12
74+
--card-background: var(--background)
7475
--border: #1C1E24
7576
--input-background: #1b1e27
7677
--date-picker-background: #1b1e27
7778
--date-picker-foreground: var(--foreground)
7879
--date-picker-highlight-border: var(--input-highlight-border)
7980
--date-picker-highlight-shadow: var(--input-highlight-shadow)
8081
:global([data-theme='light'])
81-
--background: #ffffff
8282
--foreground: #0d0e12
83+
--background: #f6f9fe
84+
--card-background: #ffffff
8385
--border: #c6cddd
8486
--input-background: #ffffff
8587
@@ -92,8 +94,8 @@
9294
color: #074ced
9395
text-decoration: none
9496
.layout
95-
background-color: var(--background)
96-
transition: all 80ms ease-in-out
97+
background: var(--background)
98+
transition: all 80ms cubic-bezier(0.4, 0.0, 0.2, 1)
9799
min-height: 100vh
98100
header
99101
display: flex
@@ -111,6 +113,11 @@
111113
h2
112114
color: var(--primary)
113115
margin-right: 20px
116+
:global(h1)
117+
font-size: 3.5em
118+
:global(::selection)
119+
background: var(--primary)
120+
color: #ffffff
114121
a
115122
color: inherit
116123
a, button.theme-toggle
@@ -121,7 +128,7 @@
121128
a.nav-link
122129
padding: 5px 2px
123130
margin: 0px 8px
124-
transition: all 80ms ease-in-out
131+
transition: all 80ms cubic-bezier(0.4, 0.0, 0.2, 1)
125132
.spacer
126133
margin: auto
127134
button.theme-toggle
@@ -134,7 +141,7 @@
134141
svg
135142
fill: var(--foreground)
136143
display: block
137-
transition: all 80ms ease-in-out
144+
transition: all 80ms cubic-bezier(0.4, 0.0, 0.2, 1)
138145
:global(table)
139146
border-collapse: collapse
140147
:global(td), :global(th)

src/routes/_prop.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@
4141
flex-shrink: 0
4242
input[type='text']
4343
color: var(--foreground)
44-
background-color: var(--input-background)
44+
background: var(--input-background)
4545
border: 1px solid rgba(103, 113, 137, 0.3)
4646
border-radius: 3px
4747
box-sizing: border-box
4848
padding: 4px 6px
4949
width: var(--input-width)
5050
outline: none
51-
transition: all 80ms ease-in-out
51+
transition: all 80ms cubic-bezier(0.4, 0.0, 0.2, 1)
5252
&:focus
5353
border-color: var(--input-highlight-border)
5454
box-shadow: 0px 0px 0px 2px var(--input-highlight-shadow)

src/routes/_split.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
.row
1616
display: flex
1717
border: 1px solid hsla(222, 15%, 50%, 0.1)
18+
background: var(--card-background)
19+
transition: background-color 80ms cubic-bezier(0.4, 0.0, 0.2, 1), box-shadow 300ms cubic-bezier(0.4, 0.0, 0.2, 1)
1820
box-shadow: 0px 1px 3px 0px rgba(#000000, 0.05)
1921
border-radius: 5px
2022
padding: 0px 20px

0 commit comments

Comments
 (0)