@operato/font 1.0.0-beta.17 → 1.0.0-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/custom-elements.json +841 -0
- package/dist/src/font-creation-card.d.ts +18 -0
- package/dist/src/font-creation-card.js +258 -0
- package/dist/src/font-creation-card.js.map +1 -0
- package/dist/src/font-selector.d.ts +36 -0
- package/dist/src/font-selector.js +285 -0
- package/dist/src/font-selector.js.map +1 -0
- package/dist/src/graphql-client.d.ts +20 -0
- package/dist/src/graphql-client.js +109 -0
- package/dist/src/graphql-client.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/ox-file-selector.d.ts +12 -0
- package/dist/src/ox-file-selector.js +129 -0
- package/dist/src/ox-file-selector.js.map +1 -0
- package/dist/src/ox-font-selector.d.ts +15 -0
- package/dist/src/ox-font-selector.js +88 -0
- package/dist/src/ox-font-selector.js.map +1 -0
- package/dist/src/ox-property-editor-font-selector.d.ts +8 -0
- package/dist/src/ox-property-editor-font-selector.js +13 -0
- package/dist/src/ox-property-editor-font-selector.js.map +1 -0
- package/dist/src/redux-font-actions.d.ts +7 -0
- package/dist/src/redux-font-actions.js +19 -0
- package/dist/src/redux-font-actions.js.map +1 -0
- package/dist/src/redux-font-reducers.d.ts +12 -0
- package/dist/src/redux-font-reducers.js +70 -0
- package/dist/src/redux-font-reducers.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +30 -18
- package/src/font-creation-card.ts +260 -0
- package/src/font-selector.ts +284 -0
- package/src/{graphql-client.js → graphql-client.ts} +5 -6
- package/src/index.ts +6 -0
- package/src/ox-file-selector.ts +114 -0
- package/src/{ox-font-selector.js → ox-font-selector.ts} +32 -36
- package/src/{ox-property-editor-font-selector.js → ox-property-editor-font-selector.ts} +1 -2
- package/src/redux-font-actions.ts +21 -0
- package/src/{redux-font-reducers.js → redux-font-reducers.ts} +17 -9
- package/src/font-creation-card.js +0 -270
- package/src/font-selector.js +0 -287
- package/src/index.js +0 -6
- package/src/ox-file-selector.js +0 -138
- package/src/redux-font-actions.js +0 -20
- package/things-factory.config.js +0 -5
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
import './ox-file-selector'
|
|
2
|
-
|
|
3
|
-
import { css, html, LitElement } from 'lit'
|
|
4
|
-
|
|
5
|
-
import { i18next, localize } from '@operato/i18n'
|
|
6
|
-
|
|
7
|
-
export class FontCreationCard extends localize(i18next)(LitElement) {
|
|
8
|
-
static get properties() {
|
|
9
|
-
return {
|
|
10
|
-
provider: {
|
|
11
|
-
type: String
|
|
12
|
-
},
|
|
13
|
-
googleFonts: {
|
|
14
|
-
type: Array
|
|
15
|
-
},
|
|
16
|
-
files: {
|
|
17
|
-
type: Array
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
constructor() {
|
|
23
|
-
super()
|
|
24
|
-
this.provider = 'google'
|
|
25
|
-
this.providers = [
|
|
26
|
-
{ value: 'google', display: 'Google' },
|
|
27
|
-
// TODO 구글 외 폰트 서비스 구현
|
|
28
|
-
// { value: 'typekit', display: 'Typekit' },
|
|
29
|
-
{ value: 'custom', display: 'Custom' }
|
|
30
|
-
]
|
|
31
|
-
this.googleFonts = []
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static get styles() {
|
|
35
|
-
return [
|
|
36
|
-
css`
|
|
37
|
-
:host {
|
|
38
|
-
position: relative;
|
|
39
|
-
|
|
40
|
-
padding: 0;
|
|
41
|
-
margin: 0;
|
|
42
|
-
height: 100%;
|
|
43
|
-
|
|
44
|
-
-webkit-transform-style: preserve-3d;
|
|
45
|
-
transform-style: preserve-3d;
|
|
46
|
-
-webkit-transition: all 0.5s ease-in-out;
|
|
47
|
-
transition: all 0.5s ease-in-out;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
:host(.flipped) {
|
|
51
|
-
-webkit-transform: var(--card-list-flip-transform);
|
|
52
|
-
transform: var(--card-list-flip-transform);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
[front],
|
|
56
|
-
[back] {
|
|
57
|
-
position: absolute;
|
|
58
|
-
|
|
59
|
-
width: 100%;
|
|
60
|
-
height: 100%;
|
|
61
|
-
margin: 0;
|
|
62
|
-
padding: 0;
|
|
63
|
-
|
|
64
|
-
border: var(--card-list-create-border);
|
|
65
|
-
border-radius: var(--card-list-create-border-radius);
|
|
66
|
-
|
|
67
|
-
background-color: #fff;
|
|
68
|
-
|
|
69
|
-
-webkit-backface-visibility: hidden;
|
|
70
|
-
backface-visibility: hidden;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
[front] {
|
|
74
|
-
display: flex;
|
|
75
|
-
flex-direction: column;
|
|
76
|
-
align-items: center;
|
|
77
|
-
justify-content: center;
|
|
78
|
-
|
|
79
|
-
text-align: center;
|
|
80
|
-
font-size: 0.8em;
|
|
81
|
-
color: var(--card-list-create-color);
|
|
82
|
-
text-transform: capitalize;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
[front] mwc-icon {
|
|
86
|
-
font-size: 3.5em;
|
|
87
|
-
color: var(--card-list-create-icon-color);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
[back] {
|
|
91
|
-
-webkit-transform: var(--card-list-flip-transform);
|
|
92
|
-
transform: var(--card-list-flip-transform);
|
|
93
|
-
box-sizing: border-box;
|
|
94
|
-
display: grid;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
[back] form {
|
|
98
|
-
padding: var(--card-list-create-form-padding);
|
|
99
|
-
width: 100%;
|
|
100
|
-
height: 100%;
|
|
101
|
-
box-sizing: border-box;
|
|
102
|
-
display: grid;
|
|
103
|
-
grid-template-columns: 1fr;
|
|
104
|
-
grid-template-rows: auto 1fr auto;
|
|
105
|
-
justify-content: center;
|
|
106
|
-
align-items: center;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
[back] form .props {
|
|
110
|
-
width: 100%;
|
|
111
|
-
height: 100%;
|
|
112
|
-
box-sizing: border-box;
|
|
113
|
-
display: grid;
|
|
114
|
-
grid-template-columns: repeat(10, 1fr);
|
|
115
|
-
grid-row-gap: 7px;
|
|
116
|
-
justify-content: center;
|
|
117
|
-
align-items: center;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
[back] form .props label {
|
|
121
|
-
grid-column: span 4;
|
|
122
|
-
font: var(--card-list-create-label-font);
|
|
123
|
-
color: var(--card-list-create-label-color);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
[back] form .props input,
|
|
127
|
-
[back] form .props select {
|
|
128
|
-
grid-column: span 6;
|
|
129
|
-
background-color: #fff;
|
|
130
|
-
border: var(--card-list-create-input-border);
|
|
131
|
-
border-radius: var(--card-list-create-input-border-radius);
|
|
132
|
-
font: var(--card-list-create-input-font);
|
|
133
|
-
color: var(--card-list-create-input-color);
|
|
134
|
-
width: -moz-available;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
ox-file-selector {
|
|
138
|
-
grid-column: span 6;
|
|
139
|
-
font: var(--card-list-create-input-font);
|
|
140
|
-
border: none;
|
|
141
|
-
box-sizing: border-box;
|
|
142
|
-
padding: 0;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
[back] input[type='submit'] {
|
|
146
|
-
background-color: var(--button-background-color) !important;
|
|
147
|
-
font: var(--button-font);
|
|
148
|
-
color: var(--button-color) !important;
|
|
149
|
-
border-radius: var(--button-radius);
|
|
150
|
-
border: var(--button-border);
|
|
151
|
-
grid-column: span 10;
|
|
152
|
-
grid-row: auto / -1;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.hidden {
|
|
156
|
-
display: none !important;
|
|
157
|
-
}
|
|
158
|
-
`
|
|
159
|
-
]
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
render() {
|
|
163
|
-
let isProviderGoogle = this.provider == 'google' && this.googleFonts.length > 0
|
|
164
|
-
let isFileAttached = this.files.length > 0 ? true : false
|
|
165
|
-
return html`
|
|
166
|
-
<div @click=${e => this.onClickFlip(e)} front><mwc-icon>add_circle_outline</mwc-icon>create font</div>
|
|
167
|
-
|
|
168
|
-
<div @click=${e => this.onClickFlip(e)} back>
|
|
169
|
-
<form @submit=${e => this.onClickSubmit(e)}>
|
|
170
|
-
<div class="props">
|
|
171
|
-
<label>${i18next.t('label.provider')}</label>
|
|
172
|
-
<select
|
|
173
|
-
name="provider"
|
|
174
|
-
@change=${e => {
|
|
175
|
-
this.provider = e.target.value
|
|
176
|
-
if (e.target.value === 'google') {
|
|
177
|
-
fetch(`/all-google-fonts`).then(async response => {
|
|
178
|
-
if (response.ok) this.googleFonts = await response.json()
|
|
179
|
-
else {
|
|
180
|
-
console.warn(
|
|
181
|
-
`(${response.url}) ${response.status} ${response.statusText}. Could not load Google fonts.`
|
|
182
|
-
)
|
|
183
|
-
}
|
|
184
|
-
})
|
|
185
|
-
}
|
|
186
|
-
}}
|
|
187
|
-
>
|
|
188
|
-
${this.providers.map(
|
|
189
|
-
p => html` <option value=${p.value} ?selected=${this.provider == p.value}>${p.display}</option> `
|
|
190
|
-
)}
|
|
191
|
-
</select>
|
|
192
|
-
|
|
193
|
-
<label>${i18next.t('label.name')}</label>
|
|
194
|
-
<input type="text" name="${isProviderGoogle ? '' : 'name'}" ?hidden=${isProviderGoogle} />
|
|
195
|
-
<select name="${isProviderGoogle ? 'name' : ''}" ?hidden=${!isProviderGoogle}>
|
|
196
|
-
<option value=""> </option>
|
|
197
|
-
${isProviderGoogle && this.googleFonts.map(f => html` <option value=${f}>${f}</option> `)}
|
|
198
|
-
</select>
|
|
199
|
-
|
|
200
|
-
<label ?hidden=${this.provider != 'custom'}>${i18next.t('label.uri')}</label>
|
|
201
|
-
<input
|
|
202
|
-
?hidden=${this.provider != 'custom'}
|
|
203
|
-
?disabled=${isFileAttached}
|
|
204
|
-
.value=${isFileAttached ? this.files[0].name : ''}
|
|
205
|
-
type="text"
|
|
206
|
-
name="uri"
|
|
207
|
-
/>
|
|
208
|
-
<!-- display when attachment module is imported -->
|
|
209
|
-
<label ?hidden=${this.provider != 'custom'}>${i18next.t('label.file')}</label>
|
|
210
|
-
<ox-file-selector
|
|
211
|
-
class="${this.provider != 'custom' ? 'hidden' : ''}"
|
|
212
|
-
name="file"
|
|
213
|
-
label="${i18next.t('label.select file')}"
|
|
214
|
-
accept=".ttf,.otf,.woff,.woff2,.eot,.svg,.svgz"
|
|
215
|
-
multiple
|
|
216
|
-
@file-change=${e => {
|
|
217
|
-
this.files = Array.from(e.detail.files)
|
|
218
|
-
}}
|
|
219
|
-
></ox-file-selector>
|
|
220
|
-
<!------------------------------------------------>
|
|
221
|
-
|
|
222
|
-
<label for="checkbox-active" @click=${e => e.stopPropagation()}> ${i18next.t('label.active')} </label>
|
|
223
|
-
<input id="checkbox-active" type="checkbox" name="active" checked />
|
|
224
|
-
</div>
|
|
225
|
-
<div></div>
|
|
226
|
-
<input type="submit" value=${i18next.t('button.create')} />
|
|
227
|
-
</form>
|
|
228
|
-
</div>
|
|
229
|
-
`
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
onClickFlip(e) {
|
|
233
|
-
if (!['INPUT', 'SELECT', 'OPTION'].find(tagName => tagName === e.target.tagName)) {
|
|
234
|
-
if (e.currentTarget.hasAttribute('front')) this.reset() // 입력 폼으로 뒤집기 전에 한 번 리셋
|
|
235
|
-
this.classList.toggle('flipped')
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
async onClickSubmit(e) {
|
|
240
|
-
e.preventDefault()
|
|
241
|
-
e.stopPropagation()
|
|
242
|
-
|
|
243
|
-
var form = e.target
|
|
244
|
-
|
|
245
|
-
var detail = {}
|
|
246
|
-
detail.name = form.elements['name'].value
|
|
247
|
-
detail.provider = form.elements['provider'].value
|
|
248
|
-
detail.active = form.elements['active'].checked
|
|
249
|
-
if (this.provider === 'custom') {
|
|
250
|
-
detail.uri = form.elements['uri'].value
|
|
251
|
-
if (this.files?.length > 0) {
|
|
252
|
-
detail.files = this.files
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
this.dispatchEvent(new CustomEvent('create-font', { detail }))
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
reset() {
|
|
260
|
-
var form = this.shadowRoot.querySelector('form')
|
|
261
|
-
if (form) {
|
|
262
|
-
form.reset()
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
this.files = []
|
|
266
|
-
this.classList.remove('flipped')
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
customElements.define('font-creation-card', FontCreationCard)
|
package/src/font-selector.js
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
import './font-creation-card'
|
|
2
|
-
|
|
3
|
-
import { css, html, LitElement } from 'lit'
|
|
4
|
-
import { connect } from 'pwa-helpers/connect-mixin.js'
|
|
5
|
-
|
|
6
|
-
import Headroom from '@operato/headroom'
|
|
7
|
-
import { i18next, localize } from '@operato/i18n'
|
|
8
|
-
import { pulltorefresh } from '@operato/pull-to-refresh'
|
|
9
|
-
import { store } from '@operato/shell'
|
|
10
|
-
import { HeadroomStyles, ScrollbarStyles } from '@operato/styles'
|
|
11
|
-
|
|
12
|
-
import { createFont, deleteFont, updateFont } from './graphql-client'
|
|
13
|
-
import { actionUpdateFontList } from './redux-font-actions'
|
|
14
|
-
|
|
15
|
-
export class FontSelector extends localize(i18next)(connect(store)(LitElement)) {
|
|
16
|
-
static get styles() {
|
|
17
|
-
return [
|
|
18
|
-
ScrollbarStyles,
|
|
19
|
-
HeadroomStyles,
|
|
20
|
-
css`
|
|
21
|
-
:host {
|
|
22
|
-
display: flex;
|
|
23
|
-
flex-direction: column;
|
|
24
|
-
overflow: hidden;
|
|
25
|
-
background-color: var(--popup-content-background-color);
|
|
26
|
-
|
|
27
|
-
position: relative;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
#main {
|
|
31
|
-
overflow: auto;
|
|
32
|
-
padding: var(--popup-content-padding);
|
|
33
|
-
display: grid;
|
|
34
|
-
grid-template-columns: var(--card-list-template);
|
|
35
|
-
grid-auto-rows: var(--card-list-rows-height);
|
|
36
|
-
grid-gap: 20px;
|
|
37
|
-
box-sizing: border-box;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
#main .card {
|
|
41
|
-
display: flex;
|
|
42
|
-
flex-direction: column;
|
|
43
|
-
align-items: center;
|
|
44
|
-
overflow: hidden;
|
|
45
|
-
border-radius: var(--card-list-border-radius);
|
|
46
|
-
border: var(--font-selector-border);
|
|
47
|
-
background-color: var(--card-list-background-color);
|
|
48
|
-
|
|
49
|
-
position: relative;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.card .button-container {
|
|
53
|
-
position: absolute;
|
|
54
|
-
right: 0;
|
|
55
|
-
height: 100%;
|
|
56
|
-
display: flex;
|
|
57
|
-
direction: rtl;
|
|
58
|
-
flex-direction: column;
|
|
59
|
-
flex-wrap: wrap;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.card .button-container > mwc-icon {
|
|
63
|
-
background-color: var(--font-selector-icon-background-color);
|
|
64
|
-
text-align: center;
|
|
65
|
-
width: var(--font-selector-icon-size);
|
|
66
|
-
height: var(--font-selector-icon-size);
|
|
67
|
-
font: var(--font-selector-icon-font);
|
|
68
|
-
color: var(--font-selector-icon-color);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.card .button-container > mwc-icon:last-child {
|
|
72
|
-
border-bottom-left-radius: 12px;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.card .button-container > mwc-icon:hover,
|
|
76
|
-
.card .button-container > mwc-icon:active {
|
|
77
|
-
background-color: var(--primary-color);
|
|
78
|
-
color: #fff;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
#main .card.create {
|
|
82
|
-
overflow: visible;
|
|
83
|
-
background-color: initial;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
#main .card:hover {
|
|
87
|
-
cursor: pointer;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
[face] {
|
|
91
|
-
flex: 1;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
[name] {
|
|
95
|
-
background-color: var(--board-renderer-name-background-color);
|
|
96
|
-
opacity: 0.8;
|
|
97
|
-
margin-top: -35px;
|
|
98
|
-
width: 100%;
|
|
99
|
-
color: #fff;
|
|
100
|
-
font-weight: bolder;
|
|
101
|
-
font-size: 13px;
|
|
102
|
-
text-indent: 7px;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
[provider] {
|
|
106
|
-
background-color: rgba(0, 0, 0, 0.7);
|
|
107
|
-
width: 100%;
|
|
108
|
-
min-height: 15px;
|
|
109
|
-
font-size: 0.6rem;
|
|
110
|
-
color: #fff;
|
|
111
|
-
text-indent: 7px;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
#filter {
|
|
115
|
-
padding: var(--popup-content-padding);
|
|
116
|
-
background-color: var(--font-tools-background-color);
|
|
117
|
-
box-shadow: var(--box-shadow);
|
|
118
|
-
|
|
119
|
-
position: absolute;
|
|
120
|
-
width: 100%;
|
|
121
|
-
box-sizing: border-box;
|
|
122
|
-
z-index: 1;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
#filter * {
|
|
126
|
-
font-size: 15px;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
select {
|
|
130
|
-
text-transform: capitalize;
|
|
131
|
-
float: right;
|
|
132
|
-
}
|
|
133
|
-
`
|
|
134
|
-
]
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
static get properties() {
|
|
138
|
-
return {
|
|
139
|
-
fonts: Array,
|
|
140
|
-
_page: Number,
|
|
141
|
-
_total: Number,
|
|
142
|
-
creatable: Boolean
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
render() {
|
|
147
|
-
var fonts = this.fonts || []
|
|
148
|
-
|
|
149
|
-
return html`
|
|
150
|
-
<div id="filter">
|
|
151
|
-
<select
|
|
152
|
-
@change=${e => {
|
|
153
|
-
this.provider = e.currentTarget.value
|
|
154
|
-
this.requestUpdate()
|
|
155
|
-
}}
|
|
156
|
-
>
|
|
157
|
-
<option value="">--${i18next.t('text.please choose a provider')}--</option>
|
|
158
|
-
${['google', 'custom'].map(provider => html` <option value=${provider}>${provider}</option> `)}
|
|
159
|
-
</select>
|
|
160
|
-
</div>
|
|
161
|
-
|
|
162
|
-
<div id="main">
|
|
163
|
-
${this.creatable
|
|
164
|
-
? html`
|
|
165
|
-
<font-creation-card class="card create" @create-font=${e => this.onCreateFont(e)}></font-creation-card>
|
|
166
|
-
`
|
|
167
|
-
: html``}
|
|
168
|
-
${fonts.map(
|
|
169
|
-
font => html`
|
|
170
|
-
<div class="card" @click=${e => this.onClickSelect(font)}>
|
|
171
|
-
<div face>
|
|
172
|
-
<font .face=${font.name}>ABCDEFGHIJKLMN</font>
|
|
173
|
-
<font .face=${font.name}>abcdefghijklmn</font>
|
|
174
|
-
</div>
|
|
175
|
-
<div name>${font.name}</div>
|
|
176
|
-
<div provider>${font.provider}</div>
|
|
177
|
-
<div class="button-container">
|
|
178
|
-
<mwc-icon
|
|
179
|
-
@click=${e => {
|
|
180
|
-
e.stopPropagation()
|
|
181
|
-
this.toggleActive(font)
|
|
182
|
-
}}
|
|
183
|
-
>${font.active ? 'check_box' : 'check_box_outline_blank'}</mwc-icon
|
|
184
|
-
>
|
|
185
|
-
<mwc-icon
|
|
186
|
-
@click=${e => {
|
|
187
|
-
e.stopPropagation()
|
|
188
|
-
this.deleteFont(font)
|
|
189
|
-
}}
|
|
190
|
-
>delete</mwc-icon
|
|
191
|
-
>
|
|
192
|
-
</div>
|
|
193
|
-
</div>
|
|
194
|
-
`
|
|
195
|
-
)}
|
|
196
|
-
</div>
|
|
197
|
-
`
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
async firstUpdated() {
|
|
201
|
-
var list = this.shadowRoot.querySelector('#main')
|
|
202
|
-
|
|
203
|
-
pulltorefresh({
|
|
204
|
-
container: this.shadowRoot,
|
|
205
|
-
scrollable: list,
|
|
206
|
-
refresh: () => {
|
|
207
|
-
return this.refresh()
|
|
208
|
-
}
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
/* for headroom */
|
|
212
|
-
var main = this.renderRoot.querySelector('#main')
|
|
213
|
-
main.addEventListener('scroll', e => {
|
|
214
|
-
this.showGotoTop = e.target.scrollTop !== 0
|
|
215
|
-
})
|
|
216
|
-
|
|
217
|
-
var filter = this.renderRoot.querySelector('#filter')
|
|
218
|
-
|
|
219
|
-
await this.requestUpdate()
|
|
220
|
-
|
|
221
|
-
var originPaddingTop = parseFloat(getComputedStyle(main, null).getPropertyValue('padding-top'))
|
|
222
|
-
main.style.paddingTop = filter.clientHeight + originPaddingTop + 'px'
|
|
223
|
-
var headroom = new Headroom(filter, {
|
|
224
|
-
scroller: main
|
|
225
|
-
})
|
|
226
|
-
headroom.init()
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
get creationCard() {
|
|
230
|
-
return this.shadowRoot.querySelector('font-creation-card')
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
updated(changes) {
|
|
234
|
-
if (changes.has('fonts')) {
|
|
235
|
-
this.creationCard?.reset()
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
stateChanged(state) {
|
|
240
|
-
this.fonts = state.font
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
refresh() {
|
|
244
|
-
return store.dispatch(actionUpdateFontList())
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
async toggleActive(font) {
|
|
248
|
-
try {
|
|
249
|
-
await updateFont({ id: font.id, active: !font.active })
|
|
250
|
-
this.refresh()
|
|
251
|
-
} catch (e) {
|
|
252
|
-
console.error(e)
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
async onCreateFont(e) {
|
|
257
|
-
try {
|
|
258
|
-
await createFont(e.detail)
|
|
259
|
-
this.refresh()
|
|
260
|
-
} catch (e) {
|
|
261
|
-
console.error(e)
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
async deleteFont(font) {
|
|
266
|
-
try {
|
|
267
|
-
await deleteFont(font.id)
|
|
268
|
-
this.refresh()
|
|
269
|
-
} catch (e) {
|
|
270
|
-
console.error(e)
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
onClickSelect(font) {
|
|
275
|
-
this.dispatchEvent(
|
|
276
|
-
new CustomEvent('font-selected', {
|
|
277
|
-
composed: true,
|
|
278
|
-
bubbles: true,
|
|
279
|
-
detail: {
|
|
280
|
-
font
|
|
281
|
-
}
|
|
282
|
-
})
|
|
283
|
-
)
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
customElements.define('font-selector', FontSelector)
|
package/src/index.js
DELETED
package/src/ox-file-selector.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import '@material/mwc-icon'
|
|
2
|
-
import '@material/mwc-icon-button'
|
|
3
|
-
|
|
4
|
-
import { css, html, LitElement } from 'lit'
|
|
5
|
-
|
|
6
|
-
export class OxFileSelector extends LitElement {
|
|
7
|
-
static get styles() {
|
|
8
|
-
return [
|
|
9
|
-
css`
|
|
10
|
-
:host {
|
|
11
|
-
flex: 1;
|
|
12
|
-
display: flex;
|
|
13
|
-
flex-direction: column;
|
|
14
|
-
position: relative;
|
|
15
|
-
overflow: hidden;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
#input-box {
|
|
19
|
-
display: flex;
|
|
20
|
-
width: 100%;
|
|
21
|
-
height: 100%;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
input[type='file'] {
|
|
25
|
-
position: absolute;
|
|
26
|
-
width: 0px;
|
|
27
|
-
height: 0px;
|
|
28
|
-
padding: 0;
|
|
29
|
-
margin: -1px;
|
|
30
|
-
overflow: hidden;
|
|
31
|
-
clip: rect(0, 0, 0, 0);
|
|
32
|
-
border: 0;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
label {
|
|
36
|
-
padding: unset;
|
|
37
|
-
width: 100%;
|
|
38
|
-
height: 100%;
|
|
39
|
-
box-sizing: border-box;
|
|
40
|
-
display: flex;
|
|
41
|
-
align-items: center;
|
|
42
|
-
justify-content: center;
|
|
43
|
-
|
|
44
|
-
color: var(--file-selector-color, #999);
|
|
45
|
-
font-size: inherit;
|
|
46
|
-
line-height: normal;
|
|
47
|
-
vertical-align: middle;
|
|
48
|
-
background-color: var(--file-selector-bg-color, #fdfdfd);
|
|
49
|
-
cursor: pointer;
|
|
50
|
-
border: var(--file-selector-border, 1px solid #ebebeb);
|
|
51
|
-
border-radius: var(--file-selector-border-radius, 0.25em);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/* named upload */
|
|
55
|
-
.upload-name {
|
|
56
|
-
flex: 1;
|
|
57
|
-
padding: 0.5em 0.75em; /* label의 패딩값과 일치 */
|
|
58
|
-
font-size: inherit;
|
|
59
|
-
font-family: inherit;
|
|
60
|
-
line-height: normal;
|
|
61
|
-
vertical-align: middle;
|
|
62
|
-
background-color: #f5f5f5;
|
|
63
|
-
border: 1px solid #ebebeb;
|
|
64
|
-
border-bottom-color: #e2e2e2;
|
|
65
|
-
border-radius: 0.25em;
|
|
66
|
-
-webkit-appearance: none; /* 네이티브 외형 감추기 */
|
|
67
|
-
-moz-appearance: none;
|
|
68
|
-
appearance: none;
|
|
69
|
-
}
|
|
70
|
-
`
|
|
71
|
-
]
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
static get properties() {
|
|
75
|
-
return {
|
|
76
|
-
label: String,
|
|
77
|
-
accept: String,
|
|
78
|
-
showFilename: {
|
|
79
|
-
type: Boolean,
|
|
80
|
-
attribute: 'show-filename'
|
|
81
|
-
},
|
|
82
|
-
multiple: {
|
|
83
|
-
type: Boolean,
|
|
84
|
-
attribute: 'multiple'
|
|
85
|
-
},
|
|
86
|
-
_files: Array
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
constructor() {
|
|
91
|
-
super()
|
|
92
|
-
|
|
93
|
-
this._files = []
|
|
94
|
-
this.label = 'select file'
|
|
95
|
-
this.multiple = false
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
render() {
|
|
99
|
-
return html`
|
|
100
|
-
<div id="input-box">
|
|
101
|
-
${this.showFilename
|
|
102
|
-
? html`
|
|
103
|
-
<input class="upload-name" value=${this._files.map(f => f.name).join(', ') || this.label} disabled />
|
|
104
|
-
`
|
|
105
|
-
: html``}
|
|
106
|
-
<label for="input-file">${this.label}</label>
|
|
107
|
-
<input
|
|
108
|
-
id="input-file"
|
|
109
|
-
type="file"
|
|
110
|
-
accept="${this.accept}"
|
|
111
|
-
class="upload-hidden"
|
|
112
|
-
?multiple=${this.multiple}
|
|
113
|
-
hidden
|
|
114
|
-
@change=${e => {
|
|
115
|
-
const el = e.currentTarget
|
|
116
|
-
this.dispatchEvent(
|
|
117
|
-
new CustomEvent('file-change', {
|
|
118
|
-
bubbles: true,
|
|
119
|
-
composed: true,
|
|
120
|
-
detail: {
|
|
121
|
-
files: el.files
|
|
122
|
-
}
|
|
123
|
-
})
|
|
124
|
-
)
|
|
125
|
-
|
|
126
|
-
el.value = null
|
|
127
|
-
}}
|
|
128
|
-
/>
|
|
129
|
-
</div>
|
|
130
|
-
`
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
get fileInput() {
|
|
134
|
-
return this.renderRoot.querySelector('#input-file')
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
window.customElements.define('ox-file-selector', OxFileSelector)
|