This repository was archived by the owner on Mar 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathna-note.html
More file actions
162 lines (143 loc) · 3.82 KB
/
na-note.html
File metadata and controls
162 lines (143 loc) · 3.82 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
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
151
152
153
154
155
156
157
158
159
160
161
162
<!--
@license
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-styles/shadow.html">
<link rel="import" href="../paper-styles/typography.html">
<link rel="import" href="../iron-input/iron-input.html">
<link rel="import" href="../iron-autogrow-textarea/iron-autogrow-textarea.html">
<dom-module id="na-note">
<template>
<style>
:host {
display: block;
box-sizing: border-box;
background-color: #fafafa;
color: #212121;
padding: 1em;
@apply --paper-font-common-base;
@apply --shadow-elevation-2dp;
border-radius: 2px;
--iron-autogrow-textarea: {
margin: 0;
padding: 0;
font-family: 'Roboto Slab', Times New Roman, serif;
white-space: pre-wrap;
}
}
iron-autogrow-textarea {
display: block;
box-sizing: border-box;
width: 100%;
border: 0;
margin: 1em 0 0;
padding: 0;
font-size: 0.9em;
font-family: 'Roboto Slab', Times New Roman, serif;
}
.hidden {
display: none;
}
h1 {
font-size: 1.15em;
margin: 0;
white-space: pre-wrap;
}
h1:not(.hidden)+p {
margin-top: 1em;
}
p {
margin: 0;
font-family: 'Roboto Slab', Times New Roman, serif;
font-size: 0.9em;
white-space: pre-wrap;
}
.placeholder:after {
content: 'Tap to edit';
opacity: 0.5;
}
.hidden {
display: none;
}
.empty {
font-style: italic;
color: #737373;
line-height: 0;
pointer-events: none;
}
input {
display: block;
box-sizing: border-box;
width: 100%;
margin: 0;
outline: none;
border: 0;
background: transparent;
white-space: pre-wrap;
font-family: 'Roboto', 'Noto', sans-serif;
font-size: 1.15em;
font-weight: bold;
color: #212121;
}
</style>
<template is="dom-if" if="[[editable]]">
<iron-input bind-value="{{title}}">
<input is="iron-input"
placeholder="Title"
bind-value="{{title}}">
</input>
</iron-input>
<iron-autogrow-textarea
placeholder="Note"
bind-value="{{body}}">
</iron-autogrow-textarea>
</template>
<template is="dom-if" if="[[!editable]]">
<h1 class$="[[emptyClass(title)]]">[[title]]</h1>
<p class$="[[emptyClass(body)]]">[[body]]</p>
</template>
</template>
<script>
Polymer({
is: 'na-note',
properties: {
editable: {
type: Boolean,
reflectToAttribute: true,
value: false
},
title: {
type: String,
notify: true,
value: ''
},
body: {
type: String,
notify: true,
value: ''
},
lastUpdated: {
type: Number,
value: 0
}
},
emptyClass: function(content) {
return !content ? 'hidden' : '';
},
propertiesAreEmpty: function() {
for (var i = 0; i < arguments.length; ++i) {
if (arguments[i]) {
return false;
}
}
return true;
}
})
</script>
</dom-module>