@things-factory/figure-ui 10.1.3
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/client/bootstrap.ts +16 -0
- package/client/graphql/index.ts +209 -0
- package/client/index.ts +2 -0
- package/client/modeller/figure-ask.ts +247 -0
- package/client/modeller/figure-canvas.ts +482 -0
- package/client/modeller/figure-inspector.ts +1054 -0
- package/client/modeller/figure-parts.ts +479 -0
- package/client/modeller/figure-preview.ts +381 -0
- package/client/modeller/figure-report.ts +895 -0
- package/client/modeller/figure-settings.ts +285 -0
- package/client/modeller/figure-side.ts +162 -0
- package/client/modeller/figure-source.test.ts +336 -0
- package/client/modeller/figure-source.ts +338 -0
- package/client/modeller/figure-view.ts +79 -0
- package/client/modeller/maturity.ts +288 -0
- package/client/modeller/part-edits.test.ts +252 -0
- package/client/modeller/part-edits.ts +246 -0
- package/client/modeller/proposal.ts +142 -0
- package/client/modeller/scene-budget.ts +102 -0
- package/client/pages/figure-list-page.ts +274 -0
- package/client/pages/figure-modeller-page.ts +1067 -0
- package/client/route.ts +11 -0
- package/client/themes/brand.css +51 -0
- package/client/themes/dark.css +64 -0
- package/client/themes/light.css +95 -0
- package/client/tsconfig.json +19 -0
- package/client/types.ts +96 -0
- package/client/viewparts/figure-card.ts +226 -0
- package/dist-client/bootstrap.d.ts +14 -0
- package/dist-client/bootstrap.js +17 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/graphql/index.d.ts +41 -0
- package/dist-client/graphql/index.js +173 -0
- package/dist-client/graphql/index.js.map +1 -0
- package/dist-client/index.d.ts +2 -0
- package/dist-client/index.js +3 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/modeller/figure-ask.d.ts +36 -0
- package/dist-client/modeller/figure-ask.js +256 -0
- package/dist-client/modeller/figure-ask.js.map +1 -0
- package/dist-client/modeller/figure-canvas.d.ts +128 -0
- package/dist-client/modeller/figure-canvas.js +431 -0
- package/dist-client/modeller/figure-canvas.js.map +1 -0
- package/dist-client/modeller/figure-inspector.d.ts +149 -0
- package/dist-client/modeller/figure-inspector.js +991 -0
- package/dist-client/modeller/figure-inspector.js.map +1 -0
- package/dist-client/modeller/figure-parts.d.ts +64 -0
- package/dist-client/modeller/figure-parts.js +478 -0
- package/dist-client/modeller/figure-parts.js.map +1 -0
- package/dist-client/modeller/figure-preview.d.ts +62 -0
- package/dist-client/modeller/figure-preview.js +360 -0
- package/dist-client/modeller/figure-preview.js.map +1 -0
- package/dist-client/modeller/figure-report.d.ts +134 -0
- package/dist-client/modeller/figure-report.js +881 -0
- package/dist-client/modeller/figure-report.js.map +1 -0
- package/dist-client/modeller/figure-settings.d.ts +39 -0
- package/dist-client/modeller/figure-settings.js +277 -0
- package/dist-client/modeller/figure-settings.js.map +1 -0
- package/dist-client/modeller/figure-side.d.ts +41 -0
- package/dist-client/modeller/figure-side.js +175 -0
- package/dist-client/modeller/figure-side.js.map +1 -0
- package/dist-client/modeller/figure-source.d.ts +196 -0
- package/dist-client/modeller/figure-source.js +153 -0
- package/dist-client/modeller/figure-source.js.map +1 -0
- package/dist-client/modeller/figure-view.d.ts +57 -0
- package/dist-client/modeller/figure-view.js +36 -0
- package/dist-client/modeller/figure-view.js.map +1 -0
- package/dist-client/modeller/maturity.d.ts +55 -0
- package/dist-client/modeller/maturity.js +212 -0
- package/dist-client/modeller/maturity.js.map +1 -0
- package/dist-client/modeller/part-edits.d.ts +64 -0
- package/dist-client/modeller/part-edits.js +218 -0
- package/dist-client/modeller/part-edits.js.map +1 -0
- package/dist-client/modeller/proposal.d.ts +45 -0
- package/dist-client/modeller/proposal.js +96 -0
- package/dist-client/modeller/proposal.js.map +1 -0
- package/dist-client/modeller/scene-budget.d.ts +78 -0
- package/dist-client/modeller/scene-budget.js +80 -0
- package/dist-client/modeller/scene-budget.js.map +1 -0
- package/dist-client/pages/figure-list-page.d.ts +40 -0
- package/dist-client/pages/figure-list-page.js +280 -0
- package/dist-client/pages/figure-list-page.js.map +1 -0
- package/dist-client/pages/figure-modeller-page.d.ts +219 -0
- package/dist-client/pages/figure-modeller-page.js +1045 -0
- package/dist-client/pages/figure-modeller-page.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +11 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/themes/brand.css +51 -0
- package/dist-client/themes/dark.css +64 -0
- package/dist-client/themes/light.css +95 -0
- package/dist-client/types.d.ts +93 -0
- package/dist-client/types.js +2 -0
- package/dist-client/types.js.map +1 -0
- package/dist-client/viewparts/figure-card.d.ts +24 -0
- package/dist-client/viewparts/figure-card.js +221 -0
- package/dist-client/viewparts/figure-card.js.map +1 -0
- package/dist-server/index.d.ts +7 -0
- package/dist-server/index.js +3 -0
- package/dist-server/index.js.map +1 -0
- package/package.json +41 -0
- package/server/index.ts +7 -0
- package/server/tsconfig.json +18 -0
- package/test/brand-palette.test.ts +188 -0
- package/test/heading-scale-guard.test.ts +144 -0
- package/test/resolve-ts-siblings.mjs +67 -0
- package/things-factory.config.js +11 -0
- package/translations/en.json +247 -0
- package/translations/ja.json +247 -0
- package/translations/ko.json +247 -0
- package/translations/ms.json +247 -0
- package/translations/zh.json +247 -0
|
@@ -0,0 +1,881 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@material/web/icon/icon.js';
|
|
3
|
+
import { css, html, LitElement, nothing, svg } from 'lit';
|
|
4
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
5
|
+
import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
|
|
6
|
+
import { i18next, localize } from '@operato/i18n';
|
|
7
|
+
import { ScrollbarStyles } from '@operato/styles';
|
|
8
|
+
import { compile, costCurveSvg, costOf, scoreOf, validate } from '@hatiolab/figure-model';
|
|
9
|
+
import { capacityOf } from './scene-budget.js';
|
|
10
|
+
import { maturityOf } from './maturity.js';
|
|
11
|
+
/**
|
|
12
|
+
* 판단 패널. 모델러 화면에 **늘 떠 있다.**
|
|
13
|
+
*
|
|
14
|
+
* 저장을 선택해야 아는 것이 아니다. 부품을 하나 놓을 때마다 무게와 점수가 움직이고,
|
|
15
|
+
* 그것이 보여야 저작자가 고칠 수 있다. 「무엇 때문에 점수가 낮은가」를 말해 주지
|
|
16
|
+
* 않으면 점수는 잔소리일 뿐이다.
|
|
17
|
+
*
|
|
18
|
+
* ## 셈을 여기서 하지 않는다
|
|
19
|
+
*
|
|
20
|
+
* 검증·원가·점수는 전부 `@hatiolab/figure-model` 이 한다. 화면은 **부르고 보여 줄
|
|
21
|
+
* 뿐**이다. 한도나 등급 경계를 화면이 다시 정하면 서버가 거절할 것을 화면이
|
|
22
|
+
* 통과시키게 된다.
|
|
23
|
+
*/
|
|
24
|
+
let FigureReport = class FigureReport extends localize(i18next)(LitElement) {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
this.curve = '';
|
|
28
|
+
/** 추이 그림을 제 크기로 펼쳤나. */
|
|
29
|
+
this.expanded = false;
|
|
30
|
+
this.errors = [];
|
|
31
|
+
this.violations = [];
|
|
32
|
+
}
|
|
33
|
+
static { this.styles = [
|
|
34
|
+
ScrollbarStyles,
|
|
35
|
+
css `
|
|
36
|
+
:host {
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
overflow-y: auto;
|
|
40
|
+
background-color: var(--md-sys-color-surface-container-lowest);
|
|
41
|
+
border-left: 1px solid var(--md-sys-color-outline-variant);
|
|
42
|
+
color: var(--md-sys-color-on-surface);
|
|
43
|
+
font: var(--label-font, inherit);
|
|
44
|
+
/*
|
|
45
|
+
이 패널의 본문 크기를 여기서 한 번 정한다.
|
|
46
|
+
|
|
47
|
+
전에는 규칙마다 따로 적었다. 그러면 빠뜨린 규칙이 본문 기본 크기(1rem)를
|
|
48
|
+
물려받아 그 줄만 제목처럼 커진다. 오류가 아니라서 화면을 띄워 봐야 안다.
|
|
49
|
+
이 파일에서만 두 번 났다.
|
|
50
|
+
|
|
51
|
+
form 요소(input · select · button)는 글꼴을 물려받지 않으므로 각자 적어야 한다.
|
|
52
|
+
그것 말고는 여기 값을 따른다.
|
|
53
|
+
*/
|
|
54
|
+
font-size: 0.76rem;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
section {
|
|
58
|
+
padding: var(--spacing-medium, 8px) var(--spacing-large, 12px);
|
|
59
|
+
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
|
60
|
+
}
|
|
61
|
+
section > h3 {
|
|
62
|
+
margin: 0 0 6px 0;
|
|
63
|
+
font-size: var(--ui-t-micro, 11px);
|
|
64
|
+
font-weight: 700;
|
|
65
|
+
letter-spacing: 0.04em;
|
|
66
|
+
text-transform: uppercase;
|
|
67
|
+
color: var(--md-sys-color-on-surface-variant, var(--md-sys-color-on-surface));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* ── 몇 개까지 편한가 ───────────────────────────────────────────
|
|
71
|
+
로우폴리의 값은 「얼마나 많이 편하게 놓을 수 있나」다. 그 답이 머리에 온다.
|
|
72
|
+
등급은 형상 자체가 한도 안인지를 말할 뿐이라 옆의 작은 badge 로 둔다. */
|
|
73
|
+
div[verdict] {
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: baseline;
|
|
76
|
+
gap: 6px;
|
|
77
|
+
}
|
|
78
|
+
span[capacity] {
|
|
79
|
+
font-size: 2.1rem;
|
|
80
|
+
font-weight: 800;
|
|
81
|
+
line-height: 1;
|
|
82
|
+
letter-spacing: -0.01em;
|
|
83
|
+
color: var(--md-sys-color-primary);
|
|
84
|
+
}
|
|
85
|
+
span[unit] {
|
|
86
|
+
font-size: 0.9rem;
|
|
87
|
+
font-weight: 600;
|
|
88
|
+
color: var(--md-sys-color-primary);
|
|
89
|
+
}
|
|
90
|
+
/*
|
|
91
|
+
등급 badge.
|
|
92
|
+
|
|
93
|
+
전에는 "C 0" 만 있었다. 글자 하나와 숫자 하나인데 어디에도 뜻이 없어서, 크게 뜬
|
|
94
|
+
개수 옆에 빨간 badge 가 붙은 것으로만 읽혔다. 0 을 100점 만점의 0 점으로 읽는 것이
|
|
95
|
+
자연스럽다. 실제 뜻은 "선언한 한도에 남은 여유가 0" 이다.
|
|
96
|
+
|
|
97
|
+
그래서 무엇을 측정하는지를 badge 안에 적고, 눈금은 바로 아래 줄에 늘 보이게 둔다.
|
|
98
|
+
*/
|
|
99
|
+
span[grade] {
|
|
100
|
+
display: flex;
|
|
101
|
+
align-items: baseline;
|
|
102
|
+
gap: 5px;
|
|
103
|
+
margin-left: auto;
|
|
104
|
+
padding: 3px 10px;
|
|
105
|
+
font-size: 0.76rem;
|
|
106
|
+
font-weight: 700;
|
|
107
|
+
color: var(--md-sys-color-on-primary-container);
|
|
108
|
+
background-color: var(--md-sys-color-primary-container);
|
|
109
|
+
border-radius: 999em;
|
|
110
|
+
}
|
|
111
|
+
span[grade] small {
|
|
112
|
+
font-size: 0.68rem;
|
|
113
|
+
font-weight: 500;
|
|
114
|
+
}
|
|
115
|
+
/*
|
|
116
|
+
C 는 한도를 지킨 것이다. 빨강은 넘긴 것(D)에만 쓴다. 지킨 것에 빨강을 쓰면
|
|
117
|
+
고칠 것이 없는데도 고쳐야 할 것처럼 보인다.
|
|
118
|
+
*/
|
|
119
|
+
span[grade][tight] {
|
|
120
|
+
color: var(--md-sys-color-on-tertiary-container, #3d2f00);
|
|
121
|
+
background-color: var(--md-sys-color-tertiary-container, #ffdf9a);
|
|
122
|
+
}
|
|
123
|
+
/*
|
|
124
|
+
Pair the container with its on-container.
|
|
125
|
+
|
|
126
|
+
This used to fill with --md-sys-color-error and write with
|
|
127
|
+
--md-sys-color-on-error-container. Once the palette made containers
|
|
128
|
+
neutral and moved the meaning into the text colour, those two became the
|
|
129
|
+
same red and the badge went blank -- a filled pill with no readable text.
|
|
130
|
+
*/
|
|
131
|
+
span[grade][over] {
|
|
132
|
+
color: var(--md-sys-color-on-error-container);
|
|
133
|
+
background-color: var(--md-sys-color-error-container);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* 등급 눈금. 접어 두지 않는다 — 한 번 보고 마는 값이 아니라 볼 때마다 필요하다 */
|
|
137
|
+
p[scale] {
|
|
138
|
+
display: flex;
|
|
139
|
+
flex-wrap: wrap;
|
|
140
|
+
gap: 2px 10px;
|
|
141
|
+
margin: 6px 0 0 0;
|
|
142
|
+
font-size: 0.7rem;
|
|
143
|
+
color: var(--md-sys-color-on-surface-variant, var(--md-sys-color-on-surface));
|
|
144
|
+
}
|
|
145
|
+
p[scale] b {
|
|
146
|
+
font-weight: 700;
|
|
147
|
+
}
|
|
148
|
+
p[scale] span[now] b {
|
|
149
|
+
color: var(--md-sys-color-primary);
|
|
150
|
+
}
|
|
151
|
+
p[scale] span[now] {
|
|
152
|
+
color: var(--md-sys-color-on-surface);
|
|
153
|
+
}
|
|
154
|
+
/* 이 큰 숫자가 어느 축인지 먼저 말한다 — 성숙도의 한 축이지 전부가 아니다 */
|
|
155
|
+
p[lead] {
|
|
156
|
+
margin: 0 0 4px 0;
|
|
157
|
+
font-size: 0.74rem;
|
|
158
|
+
color: var(--md-sys-color-on-surface-variant, var(--md-sys-color-on-surface));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/* 근거를 함께 낸다 — 숫자만 크게 내걸면 재 본 값처럼 읽힌다 */
|
|
162
|
+
p[basis] {
|
|
163
|
+
margin: 6px 0 0 0;
|
|
164
|
+
font-size: 0.72rem;
|
|
165
|
+
line-height: 1.55;
|
|
166
|
+
color: var(--md-sys-color-on-surface-variant, var(--md-sys-color-on-surface));
|
|
167
|
+
}
|
|
168
|
+
p[basis] em {
|
|
169
|
+
font-style: normal;
|
|
170
|
+
color: var(--md-sys-color-tertiary);
|
|
171
|
+
}
|
|
172
|
+
span[score] {
|
|
173
|
+
font-size: 0.8rem;
|
|
174
|
+
color: var(--md-sys-color-on-surface-variant, var(--md-sys-color-on-surface));
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/* 무엇 때문에 이 등급인가 — 한도에 가장 가까운 항목 */
|
|
178
|
+
p[because] {
|
|
179
|
+
margin: 8px 0 0 0;
|
|
180
|
+
/* 본문 크기를 물려받으면 이 줄만 제목처럼 커진다 — 화면을 띄워 보고 알았다 */
|
|
181
|
+
font-size: 0.78rem;
|
|
182
|
+
line-height: 1.6;
|
|
183
|
+
color: var(--md-sys-color-on-surface-variant, var(--md-sys-color-on-surface));
|
|
184
|
+
}
|
|
185
|
+
p[because] strong {
|
|
186
|
+
color: var(--md-sys-color-on-surface);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/* ── 성숙도 radar ────────────────────────────────────────────────
|
|
190
|
+
여섯 축을 한 그림으로. 목록만 두면 「어느 쪽이 모자란가」가 안 보인다.
|
|
191
|
+
못 잰 축은 점을 찍지 않고 살만 흐리게 남긴다 — 0 으로 찍으면 「나쁘다」가 된다. */
|
|
192
|
+
div[radar] {
|
|
193
|
+
display: flex;
|
|
194
|
+
justify-content: center;
|
|
195
|
+
padding: 2px 0 6px 0;
|
|
196
|
+
color: var(--md-sys-color-primary);
|
|
197
|
+
}
|
|
198
|
+
div[radar] svg {
|
|
199
|
+
width: 100%;
|
|
200
|
+
max-width: 240px;
|
|
201
|
+
height: auto;
|
|
202
|
+
}
|
|
203
|
+
div[radar] polygon[web] {
|
|
204
|
+
fill: none;
|
|
205
|
+
stroke: var(--md-sys-color-outline-variant);
|
|
206
|
+
stroke-width: 0.6;
|
|
207
|
+
}
|
|
208
|
+
div[radar] line[spoke] {
|
|
209
|
+
stroke: var(--md-sys-color-outline-variant);
|
|
210
|
+
stroke-width: 0.6;
|
|
211
|
+
}
|
|
212
|
+
div[radar] polygon[shape] {
|
|
213
|
+
fill: color-mix(in srgb, var(--md-sys-color-primary) 22%, transparent);
|
|
214
|
+
stroke: var(--md-sys-color-primary);
|
|
215
|
+
stroke-width: 1.4;
|
|
216
|
+
stroke-linejoin: round;
|
|
217
|
+
}
|
|
218
|
+
div[radar] circle[dot] {
|
|
219
|
+
fill: var(--md-sys-color-primary);
|
|
220
|
+
}
|
|
221
|
+
div[radar] text {
|
|
222
|
+
font-size: 5.2px;
|
|
223
|
+
fill: var(--md-sys-color-on-surface-variant, var(--md-sys-color-on-surface));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/* 그림에 자리를 주지 않은 축을 글로 밝힌다 */
|
|
227
|
+
p[unmeasured] {
|
|
228
|
+
margin: 0 0 8px 0;
|
|
229
|
+
font-size: 0.7rem;
|
|
230
|
+
line-height: 1.5;
|
|
231
|
+
color: var(--md-sys-color-tertiary);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* ── 성숙도 축 ──────────────────────────────────────────────────
|
|
235
|
+
한 숫자로 합치지 않는다. 합치면 「무엇을 고쳐야 하나」가 사라진다. */
|
|
236
|
+
ul[axes] {
|
|
237
|
+
margin: 0;
|
|
238
|
+
padding: 0;
|
|
239
|
+
list-style: none;
|
|
240
|
+
display: flex;
|
|
241
|
+
flex-direction: column;
|
|
242
|
+
gap: 7px;
|
|
243
|
+
}
|
|
244
|
+
ul[axes] li {
|
|
245
|
+
display: grid;
|
|
246
|
+
grid-template-columns: 1fr auto;
|
|
247
|
+
gap: 2px 8px;
|
|
248
|
+
font-size: 0.75rem;
|
|
249
|
+
}
|
|
250
|
+
ul[axes] li[blocked] {
|
|
251
|
+
opacity: 0.7;
|
|
252
|
+
}
|
|
253
|
+
ul[axes] em {
|
|
254
|
+
grid-column: 1 / -1;
|
|
255
|
+
font-style: normal;
|
|
256
|
+
font-size: 0.68rem;
|
|
257
|
+
line-height: 1.5;
|
|
258
|
+
color: var(--md-sys-color-on-surface-variant, var(--md-sys-color-on-surface));
|
|
259
|
+
}
|
|
260
|
+
/* 못 잰 축은 0 으로 두지 않는다 — 0 은 「나쁘다」는 뜻이 되어 버린다 */
|
|
261
|
+
ul[axes] li[blocked] em {
|
|
262
|
+
color: var(--md-sys-color-tertiary);
|
|
263
|
+
}
|
|
264
|
+
span[reading] {
|
|
265
|
+
font-family: var(--mono-font, monospace);
|
|
266
|
+
color: var(--md-sys-color-on-surface-variant, var(--md-sys-color-on-surface));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/* ── 예산 막대 ────────────────────────────────────────────────── */
|
|
270
|
+
ul[budgets] {
|
|
271
|
+
margin: 0;
|
|
272
|
+
padding: 0;
|
|
273
|
+
list-style: none;
|
|
274
|
+
display: flex;
|
|
275
|
+
flex-direction: column;
|
|
276
|
+
gap: 6px;
|
|
277
|
+
}
|
|
278
|
+
ul[budgets] li {
|
|
279
|
+
display: grid;
|
|
280
|
+
grid-template-columns: 1fr auto;
|
|
281
|
+
gap: 2px 8px;
|
|
282
|
+
font-size: 0.75rem;
|
|
283
|
+
}
|
|
284
|
+
div[bar] {
|
|
285
|
+
grid-column: 1 / -1;
|
|
286
|
+
height: 4px;
|
|
287
|
+
background-color: var(--md-sys-color-surface-container-highest);
|
|
288
|
+
border-radius: 2px;
|
|
289
|
+
overflow: hidden;
|
|
290
|
+
}
|
|
291
|
+
div[bar] > i {
|
|
292
|
+
display: block;
|
|
293
|
+
height: 100%;
|
|
294
|
+
background-color: var(--md-sys-color-primary);
|
|
295
|
+
}
|
|
296
|
+
div[bar] > i[tight] {
|
|
297
|
+
background-color: var(--md-sys-color-error);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/* ── 무게 ─────────────────────────────────────────────────────── */
|
|
301
|
+
dl[metrics] {
|
|
302
|
+
margin: 0;
|
|
303
|
+
display: grid;
|
|
304
|
+
grid-template-columns: 1fr auto;
|
|
305
|
+
gap: 4px 8px;
|
|
306
|
+
font-size: 0.78rem;
|
|
307
|
+
}
|
|
308
|
+
dl[metrics] dt {
|
|
309
|
+
color: var(--md-sys-color-on-surface-variant, var(--md-sys-color-on-surface));
|
|
310
|
+
}
|
|
311
|
+
dl[metrics] dd {
|
|
312
|
+
margin: 0;
|
|
313
|
+
text-align: right;
|
|
314
|
+
font-family: var(--mono-font, monospace);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/* ── 추이 ──────────────────────────────────────────────────────────
|
|
318
|
+
그림은 자연 크기가 680px 다. 300px 칸에 넣으면 글자가 4px 이 되어 아무것도
|
|
319
|
+
읽을 수 없다 — 사이드바에는 숫자를 두고, 그림은 선택해서 크게 본다. */
|
|
320
|
+
button[expand] {
|
|
321
|
+
margin-top: 6px;
|
|
322
|
+
padding: 4px 10px;
|
|
323
|
+
font: var(--label-font, inherit);
|
|
324
|
+
font-size: 0.74rem;
|
|
325
|
+
color: var(--md-sys-color-on-surface);
|
|
326
|
+
background: none;
|
|
327
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
328
|
+
border-radius: 6px;
|
|
329
|
+
cursor: pointer;
|
|
330
|
+
}
|
|
331
|
+
button[expand]:hover {
|
|
332
|
+
background-color: var(--md-sys-color-surface-container);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
div[sheet] {
|
|
336
|
+
position: fixed;
|
|
337
|
+
inset: 0;
|
|
338
|
+
z-index: 10;
|
|
339
|
+
display: flex;
|
|
340
|
+
align-items: center;
|
|
341
|
+
justify-content: center;
|
|
342
|
+
padding: var(--spacing-large, 12px);
|
|
343
|
+
background-color: rgba(0, 0, 0, 0.32);
|
|
344
|
+
}
|
|
345
|
+
div[sheet] > figure {
|
|
346
|
+
max-width: 100%;
|
|
347
|
+
max-height: 100%;
|
|
348
|
+
margin: 0;
|
|
349
|
+
padding: var(--spacing-large, 12px);
|
|
350
|
+
overflow: auto;
|
|
351
|
+
color: var(--md-sys-color-primary);
|
|
352
|
+
background-color: var(--md-sys-color-surface-container-lowest);
|
|
353
|
+
/* 담는 면이 팝업이면 안쪽 모서리는 알약이다 — 시트 자체는 페이지 값을 쓴다 */
|
|
354
|
+
border-radius: 6px;
|
|
355
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
|
|
356
|
+
}
|
|
357
|
+
div[sheet] svg {
|
|
358
|
+
display: block;
|
|
359
|
+
/* 자연 크기보다 작게 줄이지 않는다 — 좁으면 넘겨 보게 둔다 */
|
|
360
|
+
min-width: 680px;
|
|
361
|
+
}
|
|
362
|
+
div[sheet] figcaption {
|
|
363
|
+
display: flex;
|
|
364
|
+
align-items: center;
|
|
365
|
+
justify-content: flex-end;
|
|
366
|
+
}
|
|
367
|
+
div[sheet] button[close] {
|
|
368
|
+
padding: 5px 14px;
|
|
369
|
+
font: var(--label-font, inherit);
|
|
370
|
+
color: var(--md-sys-color-on-surface);
|
|
371
|
+
background: none;
|
|
372
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
373
|
+
border-radius: 999em;
|
|
374
|
+
cursor: pointer;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/* ── 알림 ─────────────────────────────────────────────────────── */
|
|
378
|
+
ul[findings] {
|
|
379
|
+
margin: 0;
|
|
380
|
+
padding: 0;
|
|
381
|
+
list-style: none;
|
|
382
|
+
display: flex;
|
|
383
|
+
flex-direction: column;
|
|
384
|
+
gap: 6px;
|
|
385
|
+
}
|
|
386
|
+
ul[findings] li {
|
|
387
|
+
display: flex;
|
|
388
|
+
gap: 6px;
|
|
389
|
+
line-height: 1.5;
|
|
390
|
+
}
|
|
391
|
+
ul[findings] md-icon {
|
|
392
|
+
--md-icon-size: 16px;
|
|
393
|
+
flex: none;
|
|
394
|
+
color: var(--md-sys-color-error);
|
|
395
|
+
}
|
|
396
|
+
ul[findings] li[violation] md-icon {
|
|
397
|
+
color: var(--md-sys-color-tertiary);
|
|
398
|
+
}
|
|
399
|
+
/* 어긴 자리. 문구에 붙어 흐르면 문장의 일부로 읽힌다 — badge 로 보이게 뗀다 */
|
|
400
|
+
code[at] {
|
|
401
|
+
padding: 1px 5px;
|
|
402
|
+
font-family: var(--mono-font, monospace);
|
|
403
|
+
font-size: 0.68rem;
|
|
404
|
+
color: var(--md-sys-color-on-surface-variant, var(--md-sys-color-on-surface));
|
|
405
|
+
background-color: var(--md-sys-color-surface-container);
|
|
406
|
+
border-radius: 4px;
|
|
407
|
+
white-space: nowrap;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/*
|
|
411
|
+
발견이 없을 때의 문구.
|
|
412
|
+
|
|
413
|
+
크기를 안 적어 두었더니 본문 기본 크기를 물려받아 이 줄만 제목처럼 커졌다. 이
|
|
414
|
+
패널의 글자는 전부 0.7rem 대인데 여기만 1rem 이라 아래쪽이 무너져 보였다.
|
|
415
|
+
|
|
416
|
+
찾은 것이 있을 때의 목록(ul[findings] li)과 같은 크기로 맞춘다. 있을 때와 없을 때
|
|
417
|
+
절의 생김새가 달라질 이유가 없다.
|
|
418
|
+
|
|
419
|
+
이 파일에서 같은 실수를 두 번째로 한다. p[because] 에도 같은 주석이 있다.
|
|
420
|
+
*/
|
|
421
|
+
p[quiet] {
|
|
422
|
+
margin: 0;
|
|
423
|
+
font-size: 0.76rem;
|
|
424
|
+
line-height: 1.6;
|
|
425
|
+
color: var(--md-sys-color-on-surface-variant, var(--md-sys-color-on-surface));
|
|
426
|
+
}
|
|
427
|
+
`
|
|
428
|
+
]; }
|
|
429
|
+
willUpdate(changed) {
|
|
430
|
+
if (changed.has('source')) {
|
|
431
|
+
this.measure();
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
render() {
|
|
435
|
+
if (!this.source) {
|
|
436
|
+
return html `
|
|
437
|
+
<section>
|
|
438
|
+
<p quiet>${i18next.t('text.report-appears-when-you-add-a-part')}</p>
|
|
439
|
+
</section>
|
|
440
|
+
`;
|
|
441
|
+
}
|
|
442
|
+
// 형식을 어긴 상태에서는 셈이 뜻을 갖지 못한다 — 무엇이 잘못됐는지만 보여 준다.
|
|
443
|
+
if (this.errors.length > 0) {
|
|
444
|
+
return html `${this.renderFindings()}`;
|
|
445
|
+
}
|
|
446
|
+
return html `
|
|
447
|
+
${this.renderVerdict()} ${this.renderAxes()} ${this.renderBudgets()} ${this.renderMetrics()} ${this.renderCurve()}
|
|
448
|
+
${this.renderFindings()} ${this.renderSheet()}
|
|
449
|
+
`;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* 머리 — 몇 개까지 편한가.
|
|
453
|
+
*
|
|
454
|
+
* 로우폴리의 값은 「얼마나 많이 편하게 놓을 수 있나」에 있다. 등급 B 는 그 물음에
|
|
455
|
+
* 직접 답하지 않는다 — 형상이 선언된 한도 안인지를 말할 뿐이다. 그래서 개수를
|
|
456
|
+
* 머리에 올리고 등급은 옆의 badge 로 내린다.
|
|
457
|
+
*
|
|
458
|
+
* 근거를 함께 낸다. 이 개수의 분모는 실측이 아니라 설계 문서의 목표치이고(미결
|
|
459
|
+
* D-20), 그 사실이 화면에 없으면 재 본 값처럼 읽힌다.
|
|
460
|
+
*/
|
|
461
|
+
renderVerdict() {
|
|
462
|
+
const score = this.score;
|
|
463
|
+
const capacity = this.capacity;
|
|
464
|
+
if (!score || !capacity)
|
|
465
|
+
return nothing;
|
|
466
|
+
return html `
|
|
467
|
+
<section>
|
|
468
|
+
<h3>${i18next.t('label.maturity')}</h3>
|
|
469
|
+
<p lead>${i18next.t('label.axis-scale')} — ${i18next.t('text.how-many-fit')}</p>
|
|
470
|
+
<div verdict>
|
|
471
|
+
<span capacity>${capacity.instances.toLocaleString()}</span>
|
|
472
|
+
<span unit>${i18next.t('text.instances-unit')}</span>
|
|
473
|
+
<span
|
|
474
|
+
grade
|
|
475
|
+
?tight=${score.grade === 'C'}
|
|
476
|
+
?over=${score.grade === 'D'}
|
|
477
|
+
title=${i18next.t('text.grade-explained')}
|
|
478
|
+
>
|
|
479
|
+
${score.grade}
|
|
480
|
+
<small>${i18next.t('text.headroom-percent', { percent: Math.round(score.score) })}</small>
|
|
481
|
+
</span>
|
|
482
|
+
</div>
|
|
483
|
+
<p because>
|
|
484
|
+
${i18next.t('text.grade-decided-by')}
|
|
485
|
+
<strong>${i18next.t('label.budget-' + score.tightest.key)}</strong>
|
|
486
|
+
— ${score.tightest.used} / ${score.tightest.limit}
|
|
487
|
+
(${Math.round((score.tightest.used / score.tightest.limit) * 100)}%)
|
|
488
|
+
</p>
|
|
489
|
+
${this.renderGradeScale(score.grade)}
|
|
490
|
+
<p basis>
|
|
491
|
+
${i18next.t('text.bound-by-' + capacity.bound, {
|
|
492
|
+
per: capacity.per.toLocaleString(),
|
|
493
|
+
budget: capacity.budget.toLocaleString()
|
|
494
|
+
})}
|
|
495
|
+
<em>${i18next.t('text.budget-not-measured-yet')}</em>
|
|
496
|
+
</p>
|
|
497
|
+
</section>
|
|
498
|
+
`;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* 등급 눈금.
|
|
502
|
+
*
|
|
503
|
+
* A·B·C·D 가 무엇을 뜻하는지 화면 어디에도 없었다. badge 만 보고는 좋은지 나쁜지도,
|
|
504
|
+
* 무엇을 고쳐야 오르는지도 알 수 없다. 눈금을 늘 곁에 두고 지금 어디에 있는지를
|
|
505
|
+
* 표시한다.
|
|
506
|
+
*
|
|
507
|
+
* 접어 두지 않는다. 한 번 배우고 마는 값이 아니라 볼 때마다 대조하는 값이다.
|
|
508
|
+
*/
|
|
509
|
+
renderGradeScale(now) {
|
|
510
|
+
const bounds = [
|
|
511
|
+
['A', '≤ 50%'],
|
|
512
|
+
['B', '≤ 75%'],
|
|
513
|
+
['C', '≤ 100%'],
|
|
514
|
+
['D', '> 100%']
|
|
515
|
+
];
|
|
516
|
+
return html `
|
|
517
|
+
<p scale>
|
|
518
|
+
<span>${i18next.t('text.grade-scale-lead')}</span>
|
|
519
|
+
${bounds.map(([grade, bound]) => html `<span ?now=${grade === now}><b>${grade}</b> ${bound}</span>`)}
|
|
520
|
+
</p>
|
|
521
|
+
`;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* 성숙도 — 여러 축으로 본다.
|
|
525
|
+
*
|
|
526
|
+
* 「몇 개까지 편한가」 하나로는 좋은 형상과 나쁜 형상이 구분되지 않는다. 부품 하나짜리
|
|
527
|
+
* 상자도 그 축에서는 만점이다.
|
|
528
|
+
*
|
|
529
|
+
* **못 재는 축을 0 으로 두지 않는다.** 0 은 「나쁘다」는 뜻이 되는데, 사실은 아직
|
|
530
|
+
* 측정할 방법이 없는 것이다. 측정하지 못한다고 알리고 이유를 붙인다. 지어낸 점수보다 그것이
|
|
531
|
+
* 이 리포트를 믿을 만하게 만든다.
|
|
532
|
+
*/
|
|
533
|
+
renderAxes() {
|
|
534
|
+
if (!this.cost || !this.score || !this.source)
|
|
535
|
+
return nothing;
|
|
536
|
+
/*
|
|
537
|
+
규모는 목록에서 뺀다 — 머리로 올라갔다. 같은 숫자를 두 번 내면 읽는 사람이
|
|
538
|
+
둘이 다른 것인 줄 안다.
|
|
539
|
+
*/
|
|
540
|
+
const axes = maturityOf(this.source, this.cost, this.score).filter(axis => axis.key !== 'scale');
|
|
541
|
+
// radar 에는 여섯을 다 그린다. 규모가 어디쯤인지 함께 보여야 뜻이 있다
|
|
542
|
+
const all = maturityOf(this.source, this.cost, this.score);
|
|
543
|
+
return html `
|
|
544
|
+
<section>
|
|
545
|
+
<h3>${i18next.t('label.by-axis')}</h3>
|
|
546
|
+
<div radar>${this.renderRadar(all.filter(axis => axis.ratio !== undefined))}</div>
|
|
547
|
+
${this.renderUnmeasured(all.filter(axis => axis.ratio === undefined))}
|
|
548
|
+
<ul axes>
|
|
549
|
+
${axes.map(axis => this.renderAxis(axis))}
|
|
550
|
+
</ul>
|
|
551
|
+
</section>
|
|
552
|
+
`;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* 성숙도 radar. **측정한 축만 그린다.**
|
|
556
|
+
*
|
|
557
|
+
* 측정하지 못하는 축도 spoke 를 그려 두고 도형만 건너뛰던 때가 있었다. 그러면 그 방향을 가로지르는
|
|
558
|
+
* 직선이 생겨서 도형이 그쪽으로 움푹 들어간 것처럼 보인다. 0 으로 찍지 않으려고 한
|
|
559
|
+
* 일인데 결과는 0 으로 찍은 것과 똑같이 읽혔다. 점선 살과 물음표로는 그 인상이
|
|
560
|
+
* 지워지지 않았다.
|
|
561
|
+
*
|
|
562
|
+
* 그래서 아예 빼고, 못 재는 축은 그림 아래에 글로 적는다. 잴 수 없는 것은 그림에
|
|
563
|
+
* 자리를 주지 않는 편이 정직하다.
|
|
564
|
+
*/
|
|
565
|
+
renderRadar(axes) {
|
|
566
|
+
// 그림 안에서는 **짧은 이름**을 쓴다. 긴 이름을 그대로 쓰면 왼쪽이 잘린다 —
|
|
567
|
+
// 화면을 띄워 보고 알았다.
|
|
568
|
+
const cx = 60;
|
|
569
|
+
const cy = 46;
|
|
570
|
+
const r = 28;
|
|
571
|
+
const at = (index, ratio) => {
|
|
572
|
+
const angle = -Math.PI / 2 + (index * 2 * Math.PI) / axes.length;
|
|
573
|
+
return [cx + r * ratio * Math.cos(angle), cy + r * ratio * Math.sin(angle)];
|
|
574
|
+
};
|
|
575
|
+
const points = axes
|
|
576
|
+
.map((axis, index) => at(index, Math.max(0.04, Math.min(1, axis.ratio ?? 0))).map(n => n.toFixed(1)).join(','))
|
|
577
|
+
.join(' ');
|
|
578
|
+
return svg `
|
|
579
|
+
<svg viewBox="0 0 120 96" aria-hidden="true">
|
|
580
|
+
${[0.33, 0.66, 1].map(ring => svg `<polygon web points=${axes.map((_, i) => at(i, ring).map(n => n.toFixed(1)).join(',')).join(' ')}></polygon>`)}
|
|
581
|
+
${axes.map((_, index) => {
|
|
582
|
+
const [x, y] = at(index, 1);
|
|
583
|
+
return svg `<line spoke x1=${cx} y1=${cy} x2=${x.toFixed(1)} y2=${y.toFixed(1)}></line>`;
|
|
584
|
+
})}
|
|
585
|
+
<polygon shape points=${points}></polygon>
|
|
586
|
+
${axes.map((axis, index) => {
|
|
587
|
+
const [x, y] = at(index, Math.max(0.04, Math.min(1, axis.ratio ?? 0)));
|
|
588
|
+
return svg `<circle dot cx=${x.toFixed(1)} cy=${y.toFixed(1)} r="1.4"></circle>`;
|
|
589
|
+
})}
|
|
590
|
+
${axes.map((axis, index) => {
|
|
591
|
+
const [x, y] = at(index, 1.28);
|
|
592
|
+
const anchor = x < cx - 3 ? 'end' : x > cx + 3 ? 'start' : 'middle';
|
|
593
|
+
return svg `
|
|
594
|
+
<text x=${x.toFixed(1)} y=${(y + 1.8).toFixed(1)} text-anchor=${anchor}>
|
|
595
|
+
${i18next.t('label.axis-' + axis.key + '-short')}
|
|
596
|
+
</text>
|
|
597
|
+
`;
|
|
598
|
+
})}
|
|
599
|
+
</svg>
|
|
600
|
+
`;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* 그림에 없는 축을 글로 밝힌다.
|
|
604
|
+
*
|
|
605
|
+
* 빼기만 하면 축이 여섯인지 다섯인지 알 수 없고, 없는 것을 없다고 말하지 않은 셈이
|
|
606
|
+
* 된다. 무엇을 아직 못 재는지 한 줄로 적는다. 왜 못 재는지는 아래 목록의 그 항목에
|
|
607
|
+
* 그대로 있다.
|
|
608
|
+
*/
|
|
609
|
+
renderUnmeasured(axes) {
|
|
610
|
+
if (axes.length === 0)
|
|
611
|
+
return nothing;
|
|
612
|
+
return html `
|
|
613
|
+
<p unmeasured>
|
|
614
|
+
${i18next.t('text.axes-not-measurable-yet', {
|
|
615
|
+
axes: axes.map(axis => i18next.t('label.axis-' + axis.key)).join(' · ')
|
|
616
|
+
})}
|
|
617
|
+
</p>
|
|
618
|
+
`;
|
|
619
|
+
}
|
|
620
|
+
renderAxis(axis) {
|
|
621
|
+
const name = i18next.t('label.axis-' + axis.key);
|
|
622
|
+
if (axis.blocked) {
|
|
623
|
+
return html `
|
|
624
|
+
<li blocked>
|
|
625
|
+
<span>${name}</span>
|
|
626
|
+
<span reading>${i18next.t('text.not-measurable-yet')}</span>
|
|
627
|
+
<em>${i18next.t(axis.blocked)}</em>
|
|
628
|
+
</li>
|
|
629
|
+
`;
|
|
630
|
+
}
|
|
631
|
+
const ratio = Math.max(0, Math.min(1, axis.ratio ?? 0));
|
|
632
|
+
return html `
|
|
633
|
+
<li>
|
|
634
|
+
<span>${name}</span>
|
|
635
|
+
<span reading>${axis.readingKey ? i18next.t(axis.readingKey) : (axis.reading ?? '')}</span>
|
|
636
|
+
<div bar><i style="width:${Math.round(ratio * 100)}%"></i></div>
|
|
637
|
+
${axis.because ? html `<em>${i18next.t(axis.because)}</em>` : ''}
|
|
638
|
+
</li>
|
|
639
|
+
`;
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* 예산 막대.
|
|
643
|
+
*
|
|
644
|
+
* 숫자만 늘어놓으면 어느 것이 꽉 찼는지 눈에 안 들어온다. 한도에 가장 가까운 하나를 색으로
|
|
645
|
+
* 구분한다. 그것이 점수를 정한 항목이다.
|
|
646
|
+
*
|
|
647
|
+
* ## `use.label` 을 쓰지 않는 이유
|
|
648
|
+
*
|
|
649
|
+
* `FigureBudgetUse` 에 `label` 과 `why` 가 있고 「저작자에게 그대로 보여 준다」고
|
|
650
|
+
* 적혀 있다. 그런데 그 문구가 **한국어로 구워져** 있다. 이 제품은 5언어를 쓰므로
|
|
651
|
+
* 그것을 그대로 실으면 다른 언어 사용자에게 한국어가 나온다.
|
|
652
|
+
*
|
|
653
|
+
* `budgets` 는 **배열**이다. `Object.entries` 로 돌면 키가 인덱스(0·1·2…)가 되어
|
|
654
|
+
* `label.budget-0` 같은 없는 키를 찾는다 — 화면을 띄워 보고서야 드러났다.
|
|
655
|
+
* 배열을 그대로 돌고 `use.key` 를 쓴다.
|
|
656
|
+
*
|
|
657
|
+
* 그래서 **안정된 `key`** 로 이 화면의 i18n 을 찾는다. `key` 는 열거형이라 형식의
|
|
658
|
+
* 일부이고, 문구는 화면의 몫이다. figure-model 이 문구를 언어 중립으로 바꾸면
|
|
659
|
+
* 그때 `label` 을 쓸 수 있다.
|
|
660
|
+
*/
|
|
661
|
+
renderBudgets() {
|
|
662
|
+
const score = this.score;
|
|
663
|
+
if (!score)
|
|
664
|
+
return nothing;
|
|
665
|
+
return html `
|
|
666
|
+
<section>
|
|
667
|
+
<h3>${i18next.t('label.budgets')}</h3>
|
|
668
|
+
<ul budgets>
|
|
669
|
+
${score.budgets.map(use => {
|
|
670
|
+
const ratio = Math.min(1, use.ratio);
|
|
671
|
+
const tight = use.key === score.tightest.key;
|
|
672
|
+
return html `
|
|
673
|
+
<li>
|
|
674
|
+
<span>${i18next.t('label.budget-' + use.key)}</span>
|
|
675
|
+
<span>${use.used} / ${use.limit}</span>
|
|
676
|
+
<div bar><i ?tight=${tight} style="width:${Math.round(ratio * 100)}%"></i></div>
|
|
677
|
+
</li>
|
|
678
|
+
`;
|
|
679
|
+
})}
|
|
680
|
+
</ul>
|
|
681
|
+
</section>
|
|
682
|
+
`;
|
|
683
|
+
}
|
|
684
|
+
renderMetrics() {
|
|
685
|
+
const cost = this.cost;
|
|
686
|
+
if (!cost)
|
|
687
|
+
return nothing;
|
|
688
|
+
return html `
|
|
689
|
+
<section>
|
|
690
|
+
<h3>${i18next.t('label.weight')}</h3>
|
|
691
|
+
<dl metrics>
|
|
692
|
+
<dt>${i18next.t('label.triangles')}</dt>
|
|
693
|
+
<dd>${cost.triangles.toLocaleString()}</dd>
|
|
694
|
+
|
|
695
|
+
<dt>${i18next.t('label.triangles-at-100')}</dt>
|
|
696
|
+
<dd>${cost.at.triangles.toLocaleString()}</dd>
|
|
697
|
+
|
|
698
|
+
<dt>${i18next.t('label.draw-calls-at-100')}</dt>
|
|
699
|
+
<dd>${cost.at.drawCalls.toLocaleString()}</dd>
|
|
700
|
+
|
|
701
|
+
<dt>${i18next.t('label.distinct-shapes')}</dt>
|
|
702
|
+
<dd>${cost.distinctShapes}</dd>
|
|
703
|
+
|
|
704
|
+
<dt>${i18next.t('label.distinct-materials')}</dt>
|
|
705
|
+
<dd>${cost.distinctMaterials}</dd>
|
|
706
|
+
</dl>
|
|
707
|
+
</section>
|
|
708
|
+
`;
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* 재활용 추이 — 「많이 놓으면 어떻게 되나」에 답한다.
|
|
712
|
+
*
|
|
713
|
+
* ## 그림을 사이드바에 밀어 넣지 않는다
|
|
714
|
+
*
|
|
715
|
+
* `costCurveSvg` 의 자연 크기는 680x380 이고 글자가 11px 다. 300px 칸에서
|
|
716
|
+
* width:100% 로 줄이면 글자가 4px 이 되어 **아무것도 읽을 수 없다** — 화면을 띄워
|
|
717
|
+
* 보고서야 드러났다. 읽을 수 없는 그림은 없는 것과 같으므로, 사이드바에는 저작자가
|
|
718
|
+
* 실제로 궁금한 숫자(1만 개일 때)를 두고 그림은 선택해서 제 크기로 본다.
|
|
719
|
+
*/
|
|
720
|
+
renderCurve() {
|
|
721
|
+
const many = this.many;
|
|
722
|
+
if (!many && !this.curve)
|
|
723
|
+
return nothing;
|
|
724
|
+
return html `
|
|
725
|
+
<section>
|
|
726
|
+
<h3>${i18next.t('label.reuse-trend')}</h3>
|
|
727
|
+
${many
|
|
728
|
+
? html `
|
|
729
|
+
<dl metrics>
|
|
730
|
+
<dt>${i18next.t('label.triangles-at-10k')}</dt>
|
|
731
|
+
<dd>${many.at.triangles.toLocaleString()}</dd>
|
|
732
|
+
|
|
733
|
+
<dt>${i18next.t('label.draw-calls-at-10k')}</dt>
|
|
734
|
+
<dd>${many.at.drawCalls.toLocaleString()}</dd>
|
|
735
|
+
</dl>
|
|
736
|
+
`
|
|
737
|
+
: nothing}
|
|
738
|
+
${this.curve
|
|
739
|
+
? html `
|
|
740
|
+
<button expand @click=${() => (this.expanded = true)}>
|
|
741
|
+
${i18next.t('button.see-the-trend-chart')}
|
|
742
|
+
</button>
|
|
743
|
+
`
|
|
744
|
+
: nothing}
|
|
745
|
+
</section>
|
|
746
|
+
`;
|
|
747
|
+
}
|
|
748
|
+
/** 그림을 제 크기로 보여 준다. 좁으면 줄이지 않고 넘겨 보게 둔다. */
|
|
749
|
+
renderSheet() {
|
|
750
|
+
if (!this.expanded || !this.curve)
|
|
751
|
+
return nothing;
|
|
752
|
+
return html `
|
|
753
|
+
<div sheet @click=${() => (this.expanded = false)}>
|
|
754
|
+
<figure @click=${(e) => e.stopPropagation()}>
|
|
755
|
+
${unsafeSVG(this.curve)}
|
|
756
|
+
<figcaption>
|
|
757
|
+
<button close @click=${() => (this.expanded = false)}>${i18next.t('button.close')}</button>
|
|
758
|
+
</figcaption>
|
|
759
|
+
</figure>
|
|
760
|
+
</div>
|
|
761
|
+
`;
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* 발견.
|
|
765
|
+
*
|
|
766
|
+
* 오류(막는 것)와 위반(알리는 것)을 **가려서** 보여 준다. 섞으면 저작자가 무엇을
|
|
767
|
+
* 반드시 고쳐야 하는지 모른다. 아무것도 없으면 「없다」고 말한다 — 빈 자리로 두면
|
|
768
|
+
* 검사가 돌았는지 알 수 없다.
|
|
769
|
+
*/
|
|
770
|
+
renderFindings() {
|
|
771
|
+
if (this.errors.length === 0 && this.violations.length === 0) {
|
|
772
|
+
return html `
|
|
773
|
+
<section>
|
|
774
|
+
<h3>${i18next.t('label.findings')}</h3>
|
|
775
|
+
<p quiet>${i18next.t('text.no-findings')}</p>
|
|
776
|
+
</section>
|
|
777
|
+
`;
|
|
778
|
+
}
|
|
779
|
+
return html `
|
|
780
|
+
<section>
|
|
781
|
+
<h3>${i18next.t('label.findings')}</h3>
|
|
782
|
+
<ul findings>
|
|
783
|
+
${this.errors.map(e => html `
|
|
784
|
+
<li>
|
|
785
|
+
<md-icon>error</md-icon>
|
|
786
|
+
<span>${e.message} ${e.at ? html `<code at>${e.at}</code>` : ''}</span>
|
|
787
|
+
</li>
|
|
788
|
+
`)}
|
|
789
|
+
${this.violations.map(v => html `
|
|
790
|
+
<li violation>
|
|
791
|
+
<md-icon>info</md-icon>
|
|
792
|
+
<span>${v.message}</span>
|
|
793
|
+
</li>
|
|
794
|
+
`)}
|
|
795
|
+
</ul>
|
|
796
|
+
</section>
|
|
797
|
+
`;
|
|
798
|
+
}
|
|
799
|
+
/** 원본 데이터를 측정해 결과를 상태에 담는다. 셈은 전부 figure-model 이 한다. */
|
|
800
|
+
measure() {
|
|
801
|
+
const source = this.source;
|
|
802
|
+
if (!source) {
|
|
803
|
+
this.cost = undefined;
|
|
804
|
+
this.score = undefined;
|
|
805
|
+
this.many = undefined;
|
|
806
|
+
this.capacity = undefined;
|
|
807
|
+
this.curve = '';
|
|
808
|
+
this.errors = [];
|
|
809
|
+
this.violations = [];
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
const result = validate(source);
|
|
813
|
+
this.errors = result.errors.map(e => ({ code: e.code, message: e.message, at: e.path }));
|
|
814
|
+
this.violations = result.violations.map(v => ({ code: v.code, message: v.message }));
|
|
815
|
+
if (this.errors.length > 0) {
|
|
816
|
+
// 형식을 어겼으면 컴파일이 던진다. 셈을 비우고 오류만 보여 준다.
|
|
817
|
+
this.cost = undefined;
|
|
818
|
+
this.score = undefined;
|
|
819
|
+
this.many = undefined;
|
|
820
|
+
this.capacity = undefined;
|
|
821
|
+
this.curve = '';
|
|
822
|
+
this.dispatchEvent(new CustomEvent('verdict-changed', { detail: {}, bubbles: true, composed: true }));
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
const blueprint = compile(source);
|
|
826
|
+
this.cost = costOf(blueprint, 100);
|
|
827
|
+
// 1만 개는 figure-model 에 다시 묻는다 — 화면이 곱셈으로 짐작하지 않는다.
|
|
828
|
+
this.many = costOf(blueprint, 10000);
|
|
829
|
+
this.score = scoreOf(blueprint);
|
|
830
|
+
this.capacity = capacityOf(this.cost);
|
|
831
|
+
// 개수를 밖으로 알린다. 탭 이름표가 이 값을 보여 주는데, 거기서 다시 셈하면
|
|
832
|
+
// 같은 형상이 두 자리에서 다르게 나올 수 있다.
|
|
833
|
+
this.dispatchEvent(new CustomEvent('verdict-changed', {
|
|
834
|
+
detail: { instances: this.capacity?.instances, grade: this.score?.grade },
|
|
835
|
+
bubbles: true,
|
|
836
|
+
composed: true
|
|
837
|
+
}));
|
|
838
|
+
this.curve = costCurveSvg(blueprint);
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
__decorate([
|
|
842
|
+
property({ type: Object }),
|
|
843
|
+
__metadata("design:type", Object)
|
|
844
|
+
], FigureReport.prototype, "source", void 0);
|
|
845
|
+
__decorate([
|
|
846
|
+
state(),
|
|
847
|
+
__metadata("design:type", Object)
|
|
848
|
+
], FigureReport.prototype, "cost", void 0);
|
|
849
|
+
__decorate([
|
|
850
|
+
state(),
|
|
851
|
+
__metadata("design:type", Object)
|
|
852
|
+
], FigureReport.prototype, "score", void 0);
|
|
853
|
+
__decorate([
|
|
854
|
+
state(),
|
|
855
|
+
__metadata("design:type", Object)
|
|
856
|
+
], FigureReport.prototype, "curve", void 0);
|
|
857
|
+
__decorate([
|
|
858
|
+
state(),
|
|
859
|
+
__metadata("design:type", Object)
|
|
860
|
+
], FigureReport.prototype, "many", void 0);
|
|
861
|
+
__decorate([
|
|
862
|
+
state(),
|
|
863
|
+
__metadata("design:type", Object)
|
|
864
|
+
], FigureReport.prototype, "capacity", void 0);
|
|
865
|
+
__decorate([
|
|
866
|
+
state(),
|
|
867
|
+
__metadata("design:type", Object)
|
|
868
|
+
], FigureReport.prototype, "expanded", void 0);
|
|
869
|
+
__decorate([
|
|
870
|
+
state(),
|
|
871
|
+
__metadata("design:type", Array)
|
|
872
|
+
], FigureReport.prototype, "errors", void 0);
|
|
873
|
+
__decorate([
|
|
874
|
+
state(),
|
|
875
|
+
__metadata("design:type", Array)
|
|
876
|
+
], FigureReport.prototype, "violations", void 0);
|
|
877
|
+
FigureReport = __decorate([
|
|
878
|
+
customElement('figure-report')
|
|
879
|
+
], FigureReport);
|
|
880
|
+
export { FigureReport };
|
|
881
|
+
//# sourceMappingURL=figure-report.js.map
|