@operato/font 7.1.31 → 7.1.32
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 +10 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/custom-elements.json +0 -860
- package/src/font-creation-card.ts +0 -263
- package/src/font-graphql-client.ts +0 -117
- package/src/font-selector.ts +0 -261
- package/src/index.ts +0 -6
- package/src/ox-file-selector.ts +0 -113
- package/src/ox-font-selector.ts +0 -94
- package/src/ox-property-editor-font-selector.ts +0 -17
- package/src/redux-font-actions.ts +0 -21
- package/src/redux-font-reducers.ts +0 -88
- package/src/themes/font-theme.css +0 -14
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import './ox-file-selector'
|
|
2
|
-
|
|
3
|
-
import { LitElement, css, html } from 'lit'
|
|
4
|
-
import { customElement, property } from 'lit/decorators.js'
|
|
5
|
-
import { i18next, localize } from '@operato/i18n'
|
|
6
|
-
|
|
7
|
-
@customElement('font-creation-card')
|
|
8
|
-
export class FontCreationCard extends localize(i18next)(LitElement) {
|
|
9
|
-
static styles = [
|
|
10
|
-
css`
|
|
11
|
-
:host {
|
|
12
|
-
position: relative;
|
|
13
|
-
|
|
14
|
-
padding: 0;
|
|
15
|
-
margin: 0;
|
|
16
|
-
height: 100%;
|
|
17
|
-
|
|
18
|
-
-webkit-transform-style: preserve-3d;
|
|
19
|
-
transform-style: preserve-3d;
|
|
20
|
-
-webkit-transition: all 0.5s ease-in-out;
|
|
21
|
-
transition: all 0.5s ease-in-out;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
:host(.flipped) {
|
|
25
|
-
-webkit-transform: var(--card-list-flip-transform);
|
|
26
|
-
transform: var(--card-list-flip-transform);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
[front],
|
|
30
|
-
[back] {
|
|
31
|
-
position: absolute;
|
|
32
|
-
|
|
33
|
-
width: 100%;
|
|
34
|
-
height: 100%;
|
|
35
|
-
margin: 0;
|
|
36
|
-
padding: 0;
|
|
37
|
-
|
|
38
|
-
border: var(--card-list-create-border);
|
|
39
|
-
|
|
40
|
-
color: var(--md-sys-color-on-surface);
|
|
41
|
-
background-color: var(--md-sys-color-surface);
|
|
42
|
-
|
|
43
|
-
-webkit-backface-visibility: hidden;
|
|
44
|
-
backface-visibility: hidden;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
[front] {
|
|
48
|
-
display: flex;
|
|
49
|
-
flex-direction: column;
|
|
50
|
-
align-items: center;
|
|
51
|
-
justify-content: center;
|
|
52
|
-
|
|
53
|
-
text-align: center;
|
|
54
|
-
font-size: 0.8em;
|
|
55
|
-
text-transform: capitalize;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
[front] md-icon {
|
|
59
|
-
--md-icon-size: 42px;
|
|
60
|
-
font-size: 3.5em;
|
|
61
|
-
color: var(--md-sys-color-primary);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
[back] {
|
|
65
|
-
-webkit-transform: var(--card-list-flip-transform);
|
|
66
|
-
transform: var(--card-list-flip-transform);
|
|
67
|
-
box-sizing: border-box;
|
|
68
|
-
display: grid;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
[back] form {
|
|
72
|
-
padding: var(--card-list-create-form-padding);
|
|
73
|
-
width: 100%;
|
|
74
|
-
height: 100%;
|
|
75
|
-
box-sizing: border-box;
|
|
76
|
-
display: grid;
|
|
77
|
-
grid-template-columns: 1fr;
|
|
78
|
-
grid-template-rows: auto 1fr auto;
|
|
79
|
-
justify-content: center;
|
|
80
|
-
align-items: center;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
[back] form .props {
|
|
84
|
-
width: 100%;
|
|
85
|
-
height: 100%;
|
|
86
|
-
box-sizing: border-box;
|
|
87
|
-
display: grid;
|
|
88
|
-
grid-template-columns: repeat(10, 1fr);
|
|
89
|
-
grid-row-gap: 7px;
|
|
90
|
-
justify-content: center;
|
|
91
|
-
align-items: center;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
[back] form .props label {
|
|
95
|
-
grid-column: span 4;
|
|
96
|
-
font: var(--card-list-create-label-font);
|
|
97
|
-
color: var(--card-list-create-label-color, var(--md-sys-color-secondary));
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
input,
|
|
101
|
-
select,
|
|
102
|
-
ox-file-selector {
|
|
103
|
-
background-color: var(--card-list-create-input-background-color, var(--md-sys-color-surface-variant));
|
|
104
|
-
color: var(--card-list-create-input-color, var(--md-sys-color-on-surface));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
[back] form .props input,
|
|
108
|
-
[back] form .props select {
|
|
109
|
-
grid-column: span 6;
|
|
110
|
-
border: var(--card-list-create-input-border);
|
|
111
|
-
border-radius: var(--card-list-create-input-border-radius);
|
|
112
|
-
font: var(--card-list-create-input-font);
|
|
113
|
-
width: -moz-available;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
ox-file-selector {
|
|
117
|
-
grid-column: span 6;
|
|
118
|
-
font: var(--card-list-create-input-font);
|
|
119
|
-
border: none;
|
|
120
|
-
box-sizing: border-box;
|
|
121
|
-
padding: 0;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
[back] input[type='submit'] {
|
|
125
|
-
font: var(--button-font);
|
|
126
|
-
border-radius: var(--button-radius);
|
|
127
|
-
border: var(--button-border);
|
|
128
|
-
grid-column: span 10;
|
|
129
|
-
grid-row: auto / -1;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.hidden {
|
|
133
|
-
display: none !important;
|
|
134
|
-
}
|
|
135
|
-
`
|
|
136
|
-
]
|
|
137
|
-
|
|
138
|
-
@property({ type: String }) provider: string = 'google'
|
|
139
|
-
@property({ type: Array }) googleFonts: Array<string> = []
|
|
140
|
-
@property({ type: Array }) files?: Array<any>
|
|
141
|
-
|
|
142
|
-
providers: Array<{ value: string; display: string }> = [
|
|
143
|
-
{ value: 'google', display: 'Google' },
|
|
144
|
-
// TODO 구글 외 폰트 서비스 구현
|
|
145
|
-
// { value: 'typekit', display: 'Typekit' },
|
|
146
|
-
{ value: 'custom', display: 'Custom' }
|
|
147
|
-
]
|
|
148
|
-
|
|
149
|
-
render() {
|
|
150
|
-
let isProviderGoogle = this.provider == 'google' && this.googleFonts.length > 0
|
|
151
|
-
let isFileAttached = this.files && this.files.length > 0 ? true : false
|
|
152
|
-
|
|
153
|
-
return html`
|
|
154
|
-
<div @click=${(e: Event) => this.onClickFlip(e)} front><md-icon>add_circle_outline</md-icon>create font</div>
|
|
155
|
-
|
|
156
|
-
<div @click=${(e: Event) => this.onClickFlip(e)} back>
|
|
157
|
-
<form @submit=${(e: Event) => this.onClickSubmit(e)}>
|
|
158
|
-
<div class="props">
|
|
159
|
-
<label>${i18next.t('label.provider')}</label>
|
|
160
|
-
<select
|
|
161
|
-
name="provider"
|
|
162
|
-
@change=${(e: Event) => {
|
|
163
|
-
this.provider = (e.target as HTMLInputElement).value
|
|
164
|
-
if (this.provider === 'google') {
|
|
165
|
-
fetch(`/all-google-fonts`).then(async response => {
|
|
166
|
-
if (response.ok) this.googleFonts = await response.json()
|
|
167
|
-
else {
|
|
168
|
-
console.warn(
|
|
169
|
-
`(${response.url}) ${response.status} ${response.statusText}. Could not load Google fonts.`
|
|
170
|
-
)
|
|
171
|
-
}
|
|
172
|
-
})
|
|
173
|
-
}
|
|
174
|
-
}}
|
|
175
|
-
>
|
|
176
|
-
${this.providers.map(
|
|
177
|
-
p => html` <option value=${p.value} ?selected=${this.provider == p.value}>${p.display}</option> `
|
|
178
|
-
)}
|
|
179
|
-
</select>
|
|
180
|
-
|
|
181
|
-
<label>${i18next.t('label.name')}</label>
|
|
182
|
-
<input type="text" name="${isProviderGoogle ? '' : 'name'}" ?hidden=${isProviderGoogle} />
|
|
183
|
-
<select name="${isProviderGoogle ? 'name' : ''}" ?hidden=${!isProviderGoogle}>
|
|
184
|
-
<option value=""> </option>
|
|
185
|
-
${isProviderGoogle && this.googleFonts.map(f => html` <option value=${f}>${f}</option> `)}
|
|
186
|
-
</select>
|
|
187
|
-
|
|
188
|
-
<label ?hidden=${this.provider != 'custom'}>${i18next.t('label.uri')}</label>
|
|
189
|
-
<input
|
|
190
|
-
?hidden=${this.provider != 'custom'}
|
|
191
|
-
?disabled=${isFileAttached}
|
|
192
|
-
.value=${isFileAttached ? this.files![0].name : ''}
|
|
193
|
-
type="text"
|
|
194
|
-
name="uri"
|
|
195
|
-
/>
|
|
196
|
-
<!-- display when attachment module is imported -->
|
|
197
|
-
<label ?hidden=${this.provider != 'custom'}>${i18next.t('label.file')}</label>
|
|
198
|
-
<ox-file-selector
|
|
199
|
-
class="${this.provider != 'custom' ? 'hidden' : ''}"
|
|
200
|
-
name="file"
|
|
201
|
-
label="${i18next.t('label.select file')}"
|
|
202
|
-
accept=".ttf,.otf,.woff,.woff2,.eot,.svg,.svgz"
|
|
203
|
-
multiple
|
|
204
|
-
@file-change=${(e: CustomEvent) => {
|
|
205
|
-
this.files = Array.from(e.detail.files)
|
|
206
|
-
}}
|
|
207
|
-
></ox-file-selector>
|
|
208
|
-
<!------------------------------------------------>
|
|
209
|
-
|
|
210
|
-
<label for="checkbox-active" @click=${(e: Event) => e.stopPropagation()}>
|
|
211
|
-
${i18next.t('label.active')}
|
|
212
|
-
</label>
|
|
213
|
-
<input id="checkbox-active" type="checkbox" name="active" checked />
|
|
214
|
-
</div>
|
|
215
|
-
<div></div>
|
|
216
|
-
<input type="submit" value=${i18next.t('button.create')} />
|
|
217
|
-
</form>
|
|
218
|
-
</div>
|
|
219
|
-
`
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
onClickFlip(e: Event) {
|
|
223
|
-
const target = e.target as HTMLElement
|
|
224
|
-
const currentTarget = e.currentTarget as HTMLElement
|
|
225
|
-
|
|
226
|
-
if (!['INPUT', 'SELECT', 'OPTION'].find(tagName => tagName === target.tagName)) {
|
|
227
|
-
if (currentTarget.hasAttribute('front')) this.reset() // 입력 폼으로 뒤집기 전에 한 번 리셋
|
|
228
|
-
this.classList.toggle('flipped')
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
async onClickSubmit(e: Event) {
|
|
233
|
-
e.preventDefault()
|
|
234
|
-
e.stopPropagation()
|
|
235
|
-
|
|
236
|
-
var form = e.target as HTMLFormElement
|
|
237
|
-
|
|
238
|
-
var detail = {} as any
|
|
239
|
-
|
|
240
|
-
detail.name = (form.elements.namedItem('name') as HTMLInputElement).value
|
|
241
|
-
detail.provider = (form.elements.namedItem('provider') as HTMLInputElement).value
|
|
242
|
-
detail.active = (form.elements.namedItem('active') as HTMLInputElement).checked
|
|
243
|
-
|
|
244
|
-
if (this.provider === 'custom') {
|
|
245
|
-
detail.uri = (form.elements.namedItem('uri') as HTMLInputElement).value
|
|
246
|
-
if (this.files && this.files.length > 0) {
|
|
247
|
-
detail.files = this.files
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
this.dispatchEvent(new CustomEvent('create-font', { detail }))
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
reset() {
|
|
255
|
-
var form = this.renderRoot.querySelector('form')
|
|
256
|
-
if (form) {
|
|
257
|
-
form.reset()
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
this.files = []
|
|
261
|
-
this.classList.remove('flipped')
|
|
262
|
-
}
|
|
263
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { client } from '@operato/graphql'
|
|
2
|
-
import gql from 'graphql-tag'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @param {Object} listParam {filters, pagination, sortings}
|
|
6
|
-
*/
|
|
7
|
-
export async function fetchFontList(listParam?: { sortings?: any; filters?: any; pagination?: any }) {
|
|
8
|
-
const response = await client.query({
|
|
9
|
-
query: gql`
|
|
10
|
-
query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
|
|
11
|
-
fonts(filters: $filters, pagination: $pagination, sortings: $sortings) {
|
|
12
|
-
items {
|
|
13
|
-
id
|
|
14
|
-
name
|
|
15
|
-
provider
|
|
16
|
-
uri
|
|
17
|
-
path
|
|
18
|
-
active
|
|
19
|
-
files {
|
|
20
|
-
name
|
|
21
|
-
fullpath
|
|
22
|
-
}
|
|
23
|
-
createdAt
|
|
24
|
-
updatedAt
|
|
25
|
-
}
|
|
26
|
-
total
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
`,
|
|
30
|
-
variables: listParam
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
return response.data && response.data.fonts
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @param {Object} font Font patch
|
|
38
|
-
*/
|
|
39
|
-
export async function createFont(font: any) {
|
|
40
|
-
const response = await client.mutate({
|
|
41
|
-
mutation: gql`
|
|
42
|
-
mutation CreateFont($font: NewFont!) {
|
|
43
|
-
createFont(font: $font) {
|
|
44
|
-
name
|
|
45
|
-
provider
|
|
46
|
-
uri
|
|
47
|
-
path
|
|
48
|
-
active
|
|
49
|
-
createdAt
|
|
50
|
-
updatedAt
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
`,
|
|
54
|
-
variables: {
|
|
55
|
-
font: { active: false, ...font }
|
|
56
|
-
},
|
|
57
|
-
context: {
|
|
58
|
-
hasUpload: true
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
return response.data
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @param {Object} font Font patch
|
|
67
|
-
*/
|
|
68
|
-
export async function updateFont(font: any) {
|
|
69
|
-
var { id, ...patch } = font
|
|
70
|
-
|
|
71
|
-
const response = await client.mutate({
|
|
72
|
-
mutation: gql`
|
|
73
|
-
mutation UpdateFont($id: String!, $patch: FontPatch!) {
|
|
74
|
-
updateFont(id: $id, patch: $patch) {
|
|
75
|
-
id
|
|
76
|
-
name
|
|
77
|
-
provider
|
|
78
|
-
files {
|
|
79
|
-
name
|
|
80
|
-
fullpath
|
|
81
|
-
}
|
|
82
|
-
path
|
|
83
|
-
active
|
|
84
|
-
createdAt
|
|
85
|
-
updatedAt
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
`,
|
|
89
|
-
variables: {
|
|
90
|
-
id,
|
|
91
|
-
patch
|
|
92
|
-
},
|
|
93
|
-
context: {
|
|
94
|
-
hasUpload: true
|
|
95
|
-
}
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
return response.data
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* @param {String} id Font id
|
|
103
|
-
*/
|
|
104
|
-
export async function deleteFont(id: string) {
|
|
105
|
-
const response = await client.mutate({
|
|
106
|
-
mutation: gql`
|
|
107
|
-
mutation ($id: String!) {
|
|
108
|
-
deleteFont(id: $id)
|
|
109
|
-
}
|
|
110
|
-
`,
|
|
111
|
-
variables: {
|
|
112
|
-
id
|
|
113
|
-
}
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
return response.data
|
|
117
|
-
}
|
package/src/font-selector.ts
DELETED
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import '@material/web/icon/icon.js'
|
|
2
|
-
import '@operato/input/ox-select.js'
|
|
3
|
-
import '@operato/popup/ox-popup-list.js'
|
|
4
|
-
import './font-creation-card'
|
|
5
|
-
|
|
6
|
-
import { css, html, LitElement, PropertyValues } from 'lit'
|
|
7
|
-
import { customElement, property, query } from 'lit/decorators.js'
|
|
8
|
-
import { connect } from 'pwa-helpers/connect-mixin.js'
|
|
9
|
-
|
|
10
|
-
import { i18next, localize } from '@operato/i18n'
|
|
11
|
-
import { pulltorefresh } from '@operato/pull-to-refresh'
|
|
12
|
-
import { store } from '@operato/shell'
|
|
13
|
-
import { ScrollbarStyles, CommonHeaderStyles } from '@operato/styles'
|
|
14
|
-
|
|
15
|
-
import { createFont, deleteFont, updateFont } from './font-graphql-client'
|
|
16
|
-
import { actionUpdateFontList } from './redux-font-actions'
|
|
17
|
-
|
|
18
|
-
@customElement('font-selector')
|
|
19
|
-
export class FontSelector extends localize(i18next)(connect(store)(LitElement)) {
|
|
20
|
-
static styles = [
|
|
21
|
-
ScrollbarStyles,
|
|
22
|
-
CommonHeaderStyles,
|
|
23
|
-
css`
|
|
24
|
-
:host {
|
|
25
|
-
display: flex;
|
|
26
|
-
flex-direction: column;
|
|
27
|
-
overflow: hidden;
|
|
28
|
-
color: var(--md-sys-color-on-background);
|
|
29
|
-
background-color: var(--md-sys-color-background);
|
|
30
|
-
|
|
31
|
-
position: relative;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
#main {
|
|
35
|
-
overflow: auto;
|
|
36
|
-
display: grid;
|
|
37
|
-
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
|
38
|
-
grid-auto-rows: var(--card-list-rows-height);
|
|
39
|
-
grid-gap: 20px;
|
|
40
|
-
box-sizing: border-box;
|
|
41
|
-
padding: var(--spacing-medium);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
#main .card {
|
|
45
|
-
display: flex;
|
|
46
|
-
flex-direction: column;
|
|
47
|
-
align-items: center;
|
|
48
|
-
overflow: hidden;
|
|
49
|
-
border: 1px solid rgba(0, 0, 0, 0.2);
|
|
50
|
-
border-radius: var(--md-sys-shape-corner-small);
|
|
51
|
-
color: var(--md-sys-color-on-surface);
|
|
52
|
-
background-color: var(--md-sys-color-surface);
|
|
53
|
-
|
|
54
|
-
position: relative;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
#main .card.create {
|
|
58
|
-
overflow: visible;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.card .button-container {
|
|
62
|
-
position: absolute;
|
|
63
|
-
right: 0;
|
|
64
|
-
height: 100%;
|
|
65
|
-
display: flex;
|
|
66
|
-
direction: rtl;
|
|
67
|
-
flex-direction: column;
|
|
68
|
-
flex-wrap: wrap;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.card .button-container > md-icon {
|
|
72
|
-
text-align: center;
|
|
73
|
-
width: var(--font-selector-icon-size, 35px);
|
|
74
|
-
height: var(--font-selector-icon-size, 35px);
|
|
75
|
-
color: var(--md-sys-color-on-primary-container);
|
|
76
|
-
background-color: var(--md-sys-color-primary-container);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.card .button-container > md-icon:last-child {
|
|
80
|
-
border-bottom-left-radius: var(--md-sys-shape-corner-medium);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.card .button-container > md-icon:hover,
|
|
84
|
-
.card .button-container > md-icon:active {
|
|
85
|
-
color: var(--md-sys-color-on-secondary);
|
|
86
|
-
background-color: var(--md-sys-color-secondary);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
#main .card:hover {
|
|
90
|
-
cursor: pointer;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
[face] {
|
|
94
|
-
flex: 1;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
[name] {
|
|
98
|
-
color: var(--md-sys-color-on-tertiary);
|
|
99
|
-
background-color: var(--md-sys-color-tertiary);
|
|
100
|
-
opacity: 0.8;
|
|
101
|
-
margin-top: -35px;
|
|
102
|
-
width: 100%;
|
|
103
|
-
color: #fff;
|
|
104
|
-
font-weight: bolder;
|
|
105
|
-
font-size: 13px;
|
|
106
|
-
text-indent: 7px;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
[provider] {
|
|
110
|
-
color: var(--md-sys-color-on-secondary);
|
|
111
|
-
background-color: var(--md-sys-color-secondary);
|
|
112
|
-
width: 100%;
|
|
113
|
-
min-height: 15px;
|
|
114
|
-
font-size: 0.6rem;
|
|
115
|
-
color: #fff;
|
|
116
|
-
text-indent: 7px;
|
|
117
|
-
}
|
|
118
|
-
`
|
|
119
|
-
]
|
|
120
|
-
|
|
121
|
-
@property({ type: Array }) fonts: Array<any> = []
|
|
122
|
-
@property({ type: Boolean }) creatable: boolean = false
|
|
123
|
-
@property({ type: String }) provider: string = ''
|
|
124
|
-
|
|
125
|
-
@query('#main') main!: HTMLElement
|
|
126
|
-
@query('.header') header!: HTMLElement
|
|
127
|
-
@query('font-creation-card') creationCard!: { reset: () => {} }
|
|
128
|
-
|
|
129
|
-
showGotoTop: boolean = false
|
|
130
|
-
|
|
131
|
-
render() {
|
|
132
|
-
var fonts = this.fonts || []
|
|
133
|
-
|
|
134
|
-
return html`
|
|
135
|
-
<div class="header">
|
|
136
|
-
<div class="filters">
|
|
137
|
-
<ox-select
|
|
138
|
-
.placeholder=${i18next.t('text.please choose a provider')}
|
|
139
|
-
.value=${this.provider}
|
|
140
|
-
@change=${(e: Event) => {
|
|
141
|
-
this.provider = (e.currentTarget as HTMLInputElement).value
|
|
142
|
-
}}
|
|
143
|
-
>
|
|
144
|
-
<ox-popup-list>
|
|
145
|
-
${['', 'google', 'custom'].map(provider => html` <div option value=${provider}>${provider} </div> `)}
|
|
146
|
-
</ox-popup-list>
|
|
147
|
-
</ox-select>
|
|
148
|
-
</div>
|
|
149
|
-
</div>
|
|
150
|
-
|
|
151
|
-
<div id="main">
|
|
152
|
-
${this.creatable
|
|
153
|
-
? html`
|
|
154
|
-
<font-creation-card
|
|
155
|
-
class="card create"
|
|
156
|
-
@create-font=${(e: CustomEvent) => this.onCreateFont(e)}
|
|
157
|
-
></font-creation-card>
|
|
158
|
-
`
|
|
159
|
-
: html``}
|
|
160
|
-
${fonts
|
|
161
|
-
.filter(font => (this.provider ? font.provider === this.provider : true))
|
|
162
|
-
.map(
|
|
163
|
-
font => html`
|
|
164
|
-
<div class="card" @click=${(e: Event) => this.onClickSelect(font)}>
|
|
165
|
-
<div face>
|
|
166
|
-
<font .face=${font.name}>ABCDEFGHIJKLMNOPQRSTUVWXYZ</font>
|
|
167
|
-
<br />
|
|
168
|
-
<font .face=${font.name}>abcdefghijklmnopqrstuvwxyz</font>
|
|
169
|
-
<br />
|
|
170
|
-
<font .face=${font.name}>1234567890~!@#$%^&*</font>
|
|
171
|
-
</div>
|
|
172
|
-
<div name>${font.name}</div>
|
|
173
|
-
<div provider>${font.provider}</div>
|
|
174
|
-
<div class="button-container">
|
|
175
|
-
<md-icon
|
|
176
|
-
@click=${(e: Event) => {
|
|
177
|
-
e.stopPropagation()
|
|
178
|
-
this.toggleActive(font)
|
|
179
|
-
}}
|
|
180
|
-
>${font.active ? 'check_box' : 'check_box_outline_blank'}</md-icon
|
|
181
|
-
>
|
|
182
|
-
<md-icon
|
|
183
|
-
@click=${(e: Event) => {
|
|
184
|
-
e.stopPropagation()
|
|
185
|
-
this.deleteFont(font)
|
|
186
|
-
}}
|
|
187
|
-
>delete</md-icon
|
|
188
|
-
>
|
|
189
|
-
</div>
|
|
190
|
-
</div>
|
|
191
|
-
`
|
|
192
|
-
)}
|
|
193
|
-
</div>
|
|
194
|
-
`
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
async firstUpdated() {
|
|
198
|
-
var list = this.renderRoot.querySelector('#main')
|
|
199
|
-
|
|
200
|
-
pulltorefresh({
|
|
201
|
-
container: this.renderRoot,
|
|
202
|
-
scrollable: list,
|
|
203
|
-
refresh: () => {
|
|
204
|
-
return this.refresh()
|
|
205
|
-
}
|
|
206
|
-
})
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
stateChanged(state: any) {
|
|
210
|
-
this.fonts = state.font
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
updated(changes: PropertyValues<this>) {
|
|
214
|
-
if (changes.has('fonts')) {
|
|
215
|
-
this.creationCard.reset()
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
async refresh() {
|
|
220
|
-
return store.dispatch(actionUpdateFontList() as any)
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
async toggleActive(font: { id: string; active: boolean }) {
|
|
224
|
-
try {
|
|
225
|
-
await updateFont({ id: font.id, active: !font.active })
|
|
226
|
-
this.refresh()
|
|
227
|
-
} catch (e) {
|
|
228
|
-
console.error(e)
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
async onCreateFont(e: CustomEvent) {
|
|
233
|
-
try {
|
|
234
|
-
await createFont(e.detail)
|
|
235
|
-
this.refresh()
|
|
236
|
-
} catch (e) {
|
|
237
|
-
console.error(e)
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
async deleteFont(font: { id: string }) {
|
|
242
|
-
try {
|
|
243
|
-
await deleteFont(font.id)
|
|
244
|
-
this.refresh()
|
|
245
|
-
} catch (e) {
|
|
246
|
-
console.error(e)
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
onClickSelect(font: any) {
|
|
251
|
-
this.dispatchEvent(
|
|
252
|
-
new CustomEvent('font-selected', {
|
|
253
|
-
composed: true,
|
|
254
|
-
bubbles: true,
|
|
255
|
-
detail: {
|
|
256
|
-
font
|
|
257
|
-
}
|
|
258
|
-
})
|
|
259
|
-
)
|
|
260
|
-
}
|
|
261
|
-
}
|
package/src/index.ts
DELETED