deno.land / x / nano_jsx@v0.1.0 / ui / toolbar.ts

نووسراو ببینە
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import { Component } from '../component.ts'import { h } from '../core.ts'
const classes = { bar: 'toolbar_container', left: 'toolbar_left', right: 'toolbar_right', icon: 'toolbar_icon'}interface ToolbarProps { menu?: boolean back?: boolean actionClick?: Function title?: string children?: any}
export class Toolbar extends Component<ToolbarProps> { static setTitle(title: string) { const el = document.querySelector('.toolbar_title') as HTMLElement if (el) el.innerText = title }
render() { const styles = ` .toolbar_container { padding: 16px; }
.toolbar_container .toolbar_text { font-size: 20px; margin-left: 24px; cursor: pointer; }
.toolbar_container .toolbar_icon { width: 22px; height: 22px; margin-left: 24px; cursor: pointer;
display: inline-block; content: '';
/*-webkit-mask: url(YOUR_SVG_URL) no-repeat 50% 50%; mask: url(YOUR_SVG_URL) no-repeat 50% 50%;*/
-webkit-mask-size: cover; mask-size: cover;
background-color: white; }
.toolbar_navigation_box { padding: 4px; width: 20px; height: 16px; margin-right: 32px; cursor: pointer; }
.toolbar_hamburger_button, .toolbar_hamburger_button::before, .toolbar_hamburger_button::after { position: absolute; width: 20px; height: 2px; border-radius: 2px; background: white; content: ''; } .toolbar_hamburger_button::before { top: 6px; } .toolbar_hamburger_button::after { top: 12px; }
.toolbar_button_wrapper { width: 24px; height: 24px; padding: 2px; position: relative; top: -2px; }
.toolbar_back_button, .toolbar_back_button::before, .toolbar_back_button::after { position: relative; top: 7px; width: 20px; height: 2px; border-radius: 2px; background: white; content: ''; }
.toolbar_back_button::before { position: absolute; top: -5px; transform: translate3d(-4px,0,0) rotate(-45deg) scaleX(.7); }
.toolbar_back_button::after { position: absolute; top: 5px; transform: translate3d(-4px,0,0) rotate(45deg) scaleX(.7); } `
document.head.appendChild(h('style', {}, styles))
const { back = false, actionClick = () => {}, menu } = this.props
const navigationAction = menu ? h( 'div', { class: 'toolbar_button_wrapper', onClick: actionClick }, h('div', { class: 'toolbar_hamburger_button' }) ) : back ? h( 'div', { class: 'toolbar_button_wrapper', onClick: actionClick }, h('div', { class: 'toolbar_back_button' }) ) : null
const navigation = navigationAction ? h('div', { class: 'toolbar_navigation_box' }, navigationAction) : null
const title = this.props.title ? h('div', { class: 'toolbar_title' }, this.props.title) : null
const left = h('div', { class: classes.left }, navigation, title) const right = h('div', { class: classes.right }, this.props.children)
const bar = h('div', { class: classes.bar }, left, right)
return bar }}
nano_jsx

Version Info

Tagged at
8 months ago