-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogress.tsx
More file actions
56 lines (46 loc) · 1.51 KB
/
progress.tsx
File metadata and controls
56 lines (46 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { Attrs, RO, o, DisplayIf } from 'elt'
import { Styling } from './styling'
import { cls } from 'osun'
export interface ProgressAttrs extends Attrs {
mode?: RO<'determinate' | 'indeterminate' | 'query' | 'buffer' | 'off'>
progress?: RO<number>
error?: RO<boolean>
}
export function Progress({error, mode, progress}: ProgressAttrs) {
const o_mode = o(mode || 'determinate')
const o_progress = o(progress || 0)
const o_error = o(error)
return <div
class={[Styling.background.primary5, Progress.holder, {[Progress.error]: o_error}]}
style={{opacity: o_progress.tf(v => v > 0 && v < 100 ? '1' : '0')}}
>
{DisplayIf(o_mode.equals('determinate'), () => <div class={[
Styling.background.primary2,
Progress.determinate
]}
style={{width: o_progress.tf(v => `${v}%`)}}
/>
)}
{/* <div class={CSS.primary}/>
<div class={CSS.secondary}/> */}
</div>
}
export namespace Progress {
export const hidden = cls('hidden', {display: 'none'})
export const error = cls('error', {
'--em-color-primary': 'var(--em-color-accent)'
})
export const holder = cls('progress-holder', {
position: 'absolute',
transition: 'background-color linear 300ms, opacity linear 500ms',
pointerEvents: 'none',
height: '8px',
width: '100%',
margin: '0 !important',
padding: '0 !important'
})
export const determinate = cls('progress-determinate', {
height: '8px',
transition: `width linear 100ms, background-color linear 300ms`,
})
}