@formicoidea/labre-framework-cynefin 0.23.1 → 0.23.2
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/package.json +6 -15
- package/src/cynefin/consts.ts +188 -0
- package/src/cynefin/element-renderer.ts +156 -0
- package/src/cynefin/element-view.ts +32 -0
- package/src/cynefin/toolbar/config.ts +60 -0
- package/{dist/descriptor.js → src/descriptor.ts} +1 -1
- package/src/effects.ts +20 -0
- package/src/estuarine/consts.ts +69 -0
- package/src/estuarine/element-renderer.ts +122 -0
- package/src/estuarine/element-view.ts +32 -0
- package/src/estuarine/toolbar/config.ts +65 -0
- package/src/index.ts +1 -0
- package/src/templates/index.ts +130 -0
- package/{dist/toolbar/icons.js → src/toolbar/icons.ts} +17 -14
- package/{dist/toolbar/menu.js → src/toolbar/menu.ts} +156 -133
- package/{dist/toolbar/senior-button.js → src/toolbar/senior-button.ts} +95 -90
- package/{dist/toolbar/senior-tool.js → src/toolbar/senior-tool.ts} +15 -12
- package/{dist/utils.js → src/utils.ts} +11 -11
- package/src/view.ts +44 -0
- package/dist/cynefin/consts.d.ts +0 -80
- package/dist/cynefin/consts.js +0 -142
- package/dist/cynefin/element-renderer.d.ts +0 -15
- package/dist/cynefin/element-renderer.js +0 -115
- package/dist/cynefin/element-view.d.ts +0 -15
- package/dist/cynefin/element-view.js +0 -24
- package/dist/cynefin/toolbar/config.d.ts +0 -32
- package/dist/cynefin/toolbar/config.js +0 -44
- package/dist/descriptor.d.ts +0 -7
- package/dist/effects.d.ts +0 -10
- package/dist/effects.js +0 -7
- package/dist/estuarine/consts.d.ts +0 -85
- package/dist/estuarine/consts.js +0 -55
- package/dist/estuarine/element-renderer.d.ts +0 -14
- package/dist/estuarine/element-renderer.js +0 -84
- package/dist/estuarine/element-view.d.ts +0 -15
- package/dist/estuarine/element-view.js +0 -24
- package/dist/estuarine/toolbar/config.d.ts +0 -38
- package/dist/estuarine/toolbar/config.js +0 -48
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/templates/index.d.ts +0 -4
- package/dist/templates/index.js +0 -95
- package/dist/toolbar/cynefin-menu.d.ts +0 -12
- package/dist/toolbar/cynefin-menu.js +0 -66
- package/dist/toolbar/cynefin-senior-button.d.ts +0 -13
- package/dist/toolbar/cynefin-senior-button.js +0 -90
- package/dist/toolbar/estuarine-menu.d.ts +0 -14
- package/dist/toolbar/estuarine-menu.js +0 -113
- package/dist/toolbar/estuarine-senior-button.d.ts +0 -13
- package/dist/toolbar/estuarine-senior-button.js +0 -90
- package/dist/toolbar/icons.d.ts +0 -9
- package/dist/toolbar/menu.d.ts +0 -18
- package/dist/toolbar/senior-button.d.ts +0 -13
- package/dist/toolbar/senior-tool.d.ts +0 -3
- package/dist/utils.d.ts +0 -12
- package/dist/view.d.ts +0 -7
- package/dist/view.js +0 -38
|
@@ -1,133 +1,156 @@
|
|
|
1
|
-
import { DefaultTool } from '@formicoidea/labre-core/blocks/surface';
|
|
2
|
-
import { EmptyTool } from '@formicoidea/labre-core/gfx/pointer';
|
|
3
|
-
import { ShapeStyle } from '@formicoidea/labre-core/model';
|
|
4
|
-
import { EdgelessToolbarToolMixin } from '@formicoidea/labre-core/widgets/edgeless-toolbar';
|
|
5
|
-
import { Bound } from '@formicoidea/labre-core/global/gfx';
|
|
6
|
-
import { css, html, LitElement } from 'lit';
|
|
7
|
-
|
|
8
|
-
import { REF_H as
|
|
9
|
-
import {
|
|
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
|
-
display: flex;
|
|
46
|
-
align-items: center;
|
|
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
|
-
|
|
1
|
+
import { DefaultTool } from '@formicoidea/labre-core/blocks/surface';
|
|
2
|
+
import { EmptyTool } from '@formicoidea/labre-core/gfx/pointer';
|
|
3
|
+
import { ShapeStyle } from '@formicoidea/labre-core/model';
|
|
4
|
+
import { EdgelessToolbarToolMixin } from '@formicoidea/labre-core/widgets/edgeless-toolbar';
|
|
5
|
+
import { Bound } from '@formicoidea/labre-core/global/gfx';
|
|
6
|
+
import { css, html, LitElement } from 'lit';
|
|
7
|
+
|
|
8
|
+
import { REF_H as CYN_H, REF_W as CYN_W } from '../cynefin/consts';
|
|
9
|
+
import { REF_H as EST_H, REF_W as EST_W } from '../estuarine/consts';
|
|
10
|
+
import {
|
|
11
|
+
cynefinMenuIcon,
|
|
12
|
+
estuarineMenuIcon,
|
|
13
|
+
hexagonMenuIcon,
|
|
14
|
+
} from './icons';
|
|
15
|
+
|
|
16
|
+
/** Estuarine map default size (REF aspect, scaled up so it reads on canvas). */
|
|
17
|
+
const MAP_SCALE = 1.2;
|
|
18
|
+
const HEX_SIZE = 60;
|
|
19
|
+
const HEX_FILL = '#34c724';
|
|
20
|
+
const HEX_STROKE = '#1f1f1f';
|
|
21
|
+
/** Flat-top regular hexagon, normalized vertices. */
|
|
22
|
+
const HEX_VERTICES: number[][] = [
|
|
23
|
+
[1, 0.5],
|
|
24
|
+
[0.75, 0.933],
|
|
25
|
+
[0.25, 0.933],
|
|
26
|
+
[0, 0.5],
|
|
27
|
+
[0.25, 0.067],
|
|
28
|
+
[0.75, 0.067],
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The popover above the toolbar hosting both frameworks: create the Cynefin
|
|
33
|
+
* diagram, the Estuarine map, or a hexagon constraint node.
|
|
34
|
+
*/
|
|
35
|
+
export class EdgelessCynefinEstuarineMenu extends EdgelessToolbarToolMixin(
|
|
36
|
+
LitElement
|
|
37
|
+
) {
|
|
38
|
+
static override styles = css`
|
|
39
|
+
:host {
|
|
40
|
+
position: absolute;
|
|
41
|
+
display: flex;
|
|
42
|
+
z-index: -1;
|
|
43
|
+
}
|
|
44
|
+
.menu-content {
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
}
|
|
49
|
+
.button-group-container {
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
gap: 14px;
|
|
53
|
+
fill: var(--affine-icon-color);
|
|
54
|
+
}
|
|
55
|
+
.button-group-container svg {
|
|
56
|
+
width: 24px;
|
|
57
|
+
height: 24px;
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
override type = EmptyTool;
|
|
62
|
+
|
|
63
|
+
private _finish(id: string) {
|
|
64
|
+
const { gfx } = this;
|
|
65
|
+
gfx.doc.captureSync();
|
|
66
|
+
gfx.tool.setTool(DefaultTool);
|
|
67
|
+
gfx.selection.set({ elements: [id], editing: false });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private _createCynefin() {
|
|
71
|
+
const { gfx } = this;
|
|
72
|
+
if (!gfx.surface) return;
|
|
73
|
+
const { centerX, centerY } = gfx.viewport;
|
|
74
|
+
const id = gfx.surface.addElement({
|
|
75
|
+
type: 'cynefin',
|
|
76
|
+
xywh: new Bound(
|
|
77
|
+
centerX - CYN_W / 2,
|
|
78
|
+
centerY - CYN_H / 2,
|
|
79
|
+
CYN_W,
|
|
80
|
+
CYN_H
|
|
81
|
+
).serialize(),
|
|
82
|
+
});
|
|
83
|
+
this._finish(id);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private _createMap() {
|
|
87
|
+
const { gfx } = this;
|
|
88
|
+
if (!gfx.surface) return;
|
|
89
|
+
const width = EST_W * MAP_SCALE;
|
|
90
|
+
const height = EST_H * MAP_SCALE;
|
|
91
|
+
const { centerX, centerY } = gfx.viewport;
|
|
92
|
+
const id = gfx.surface.addElement({
|
|
93
|
+
type: 'estuarine',
|
|
94
|
+
xywh: new Bound(
|
|
95
|
+
centerX - width / 2,
|
|
96
|
+
centerY - height / 2,
|
|
97
|
+
width,
|
|
98
|
+
height
|
|
99
|
+
).serialize(),
|
|
100
|
+
});
|
|
101
|
+
this._finish(id);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private _createHexagon() {
|
|
105
|
+
const { gfx } = this;
|
|
106
|
+
if (!gfx.surface) return;
|
|
107
|
+
const { centerX: cx, centerY: cy } = gfx.viewport;
|
|
108
|
+
const id = gfx.surface.addElement({
|
|
109
|
+
type: 'shape',
|
|
110
|
+
shapeType: 'polygon',
|
|
111
|
+
vertices: HEX_VERTICES,
|
|
112
|
+
filled: true,
|
|
113
|
+
fillColor: HEX_FILL,
|
|
114
|
+
strokeColor: HEX_STROKE,
|
|
115
|
+
strokeWidth: 2,
|
|
116
|
+
shapeStyle: ShapeStyle.General,
|
|
117
|
+
roughness: 0,
|
|
118
|
+
xywh: new Bound(
|
|
119
|
+
cx - HEX_SIZE / 2,
|
|
120
|
+
cy - HEX_SIZE / 2,
|
|
121
|
+
HEX_SIZE,
|
|
122
|
+
HEX_SIZE
|
|
123
|
+
).serialize(),
|
|
124
|
+
});
|
|
125
|
+
this._finish(id);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
override render() {
|
|
129
|
+
return html`
|
|
130
|
+
<edgeless-slide-menu>
|
|
131
|
+
<div class="menu-content">
|
|
132
|
+
<div class="button-group-container">
|
|
133
|
+
<edgeless-tool-icon-button
|
|
134
|
+
.tooltip=${'Cynefin framework'}
|
|
135
|
+
@click=${this._createCynefin}
|
|
136
|
+
>
|
|
137
|
+
${cynefinMenuIcon}
|
|
138
|
+
</edgeless-tool-icon-button>
|
|
139
|
+
<edgeless-tool-icon-button
|
|
140
|
+
.tooltip=${'Estuarine map'}
|
|
141
|
+
@click=${this._createMap}
|
|
142
|
+
>
|
|
143
|
+
${estuarineMenuIcon}
|
|
144
|
+
</edgeless-tool-icon-button>
|
|
145
|
+
<edgeless-tool-icon-button
|
|
146
|
+
.tooltip=${'Hexagon node'}
|
|
147
|
+
@click=${this._createHexagon}
|
|
148
|
+
>
|
|
149
|
+
${hexagonMenuIcon}
|
|
150
|
+
</edgeless-tool-icon-button>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
</edgeless-slide-menu>
|
|
154
|
+
`;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -1,90 +1,95 @@
|
|
|
1
|
-
import { DefaultTool } from '@formicoidea/labre-core/blocks/surface';
|
|
2
|
-
import { EmptyTool } from '@formicoidea/labre-core/gfx/pointer';
|
|
3
|
-
import { EdgelessToolbarToolMixin } from '@formicoidea/labre-core/widgets/edgeless-toolbar';
|
|
4
|
-
import { SignalWatcher } from '@formicoidea/labre-core/global/lit';
|
|
5
|
-
import { css, html, LitElement } from 'lit';
|
|
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
|
-
|
|
1
|
+
import { DefaultTool } from '@formicoidea/labre-core/blocks/surface';
|
|
2
|
+
import { EmptyTool } from '@formicoidea/labre-core/gfx/pointer';
|
|
3
|
+
import { EdgelessToolbarToolMixin } from '@formicoidea/labre-core/widgets/edgeless-toolbar';
|
|
4
|
+
import { SignalWatcher } from '@formicoidea/labre-core/global/lit';
|
|
5
|
+
import { css, html, LitElement } from 'lit';
|
|
6
|
+
|
|
7
|
+
import { cynefinToolbarIcon } from './icons';
|
|
8
|
+
|
|
9
|
+
/** Main toolbar button that opens the combined Cynefin / Estuarine sub-menu. */
|
|
10
|
+
export class EdgelessCynefinEstuarineSeniorButton extends EdgelessToolbarToolMixin(
|
|
11
|
+
SignalWatcher(LitElement)
|
|
12
|
+
) {
|
|
13
|
+
static override styles = css`
|
|
14
|
+
:host,
|
|
15
|
+
.ce-button {
|
|
16
|
+
display: block;
|
|
17
|
+
width: 100%;
|
|
18
|
+
height: 100%;
|
|
19
|
+
}
|
|
20
|
+
:host {
|
|
21
|
+
position: relative;
|
|
22
|
+
}
|
|
23
|
+
.ce-root {
|
|
24
|
+
width: 100%;
|
|
25
|
+
height: 64px;
|
|
26
|
+
position: relative;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: flex-end;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
}
|
|
33
|
+
.ce-card {
|
|
34
|
+
--y: -4px;
|
|
35
|
+
--s: 1;
|
|
36
|
+
position: absolute;
|
|
37
|
+
bottom: 0;
|
|
38
|
+
width: 54px;
|
|
39
|
+
height: 54px;
|
|
40
|
+
transform: translateY(var(--y)) scale(var(--s));
|
|
41
|
+
transition: transform 0.3s ease;
|
|
42
|
+
}
|
|
43
|
+
.ce-card svg {
|
|
44
|
+
display: block;
|
|
45
|
+
width: 100%;
|
|
46
|
+
height: 100%;
|
|
47
|
+
}
|
|
48
|
+
.ce-root:hover .ce-card {
|
|
49
|
+
--y: -10px;
|
|
50
|
+
--s: 1.07;
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
override enableActiveBackground = true;
|
|
55
|
+
|
|
56
|
+
override type = EmptyTool;
|
|
57
|
+
|
|
58
|
+
private _toggleMenu() {
|
|
59
|
+
if (this.popper) {
|
|
60
|
+
this.popper.dispose();
|
|
61
|
+
this.popper = null;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this.setEdgelessTool(DefaultTool);
|
|
65
|
+
const menu = this.createPopper('edgeless-cynefin-estuarine-menu', this);
|
|
66
|
+
menu.element.edgeless = this.edgeless;
|
|
67
|
+
|
|
68
|
+
const el = menu.element as HTMLElement;
|
|
69
|
+
const wrap = el.parentElement;
|
|
70
|
+
if (wrap) {
|
|
71
|
+
wrap.style.overflow = 'visible';
|
|
72
|
+
wrap.style.justifyContent = 'flex-end';
|
|
73
|
+
}
|
|
74
|
+
Object.assign(el.style, {
|
|
75
|
+
position: 'static',
|
|
76
|
+
width: 'max-content',
|
|
77
|
+
maxWidth: 'calc(100vw - 16px)',
|
|
78
|
+
marginLeft: '0',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
override render() {
|
|
83
|
+
return html`<edgeless-toolbar-button
|
|
84
|
+
class="ce-button"
|
|
85
|
+
.tooltip=${this.popper ? '' : 'Cynefin / Estuarine'}
|
|
86
|
+
.tooltipOffset=${4}
|
|
87
|
+
.active=${!!this.popper}
|
|
88
|
+
@click=${this._toggleMenu}
|
|
89
|
+
>
|
|
90
|
+
<div class="ce-root">
|
|
91
|
+
<div class="ce-card">${cynefinToolbarIcon}</div>
|
|
92
|
+
</div>
|
|
93
|
+
</edgeless-toolbar-button>`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { SeniorToolExtension } from '@formicoidea/labre-core/widgets/edgeless-toolbar';
|
|
2
|
-
import { html } from 'lit';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
1
|
+
import { SeniorToolExtension } from '@formicoidea/labre-core/widgets/edgeless-toolbar';
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
|
|
4
|
+
/** A single senior tool hosting both the Cynefin and Estuarine frameworks. */
|
|
5
|
+
export const cynefinEstuarineSeniorTool = SeniorToolExtension(
|
|
6
|
+
'cynefin-estuarine',
|
|
7
|
+
({ block }) => {
|
|
8
|
+
return {
|
|
9
|
+
name: 'Cynefin / Estuarine',
|
|
10
|
+
content: html`<edgeless-cynefin-estuarine-senior-button
|
|
11
|
+
.edgeless=${block}
|
|
12
|
+
></edgeless-cynefin-estuarine-senior-button>`,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Uniform fit of a fixed reference design (`refW × refH`) into an element of
|
|
3
|
-
* size `w × h`: the scale factor plus the centering offsets (letterboxed).
|
|
4
|
-
* Keeps the artwork undistorted at any element size.
|
|
5
|
-
*/
|
|
6
|
-
export function refScale(w, h, refW, refH) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Uniform fit of a fixed reference design (`refW × refH`) into an element of
|
|
3
|
+
* size `w × h`: the scale factor plus the centering offsets (letterboxed).
|
|
4
|
+
* Keeps the artwork undistorted at any element size.
|
|
5
|
+
*/
|
|
6
|
+
export function refScale(w: number, h: number, refW: number, refH: number) {
|
|
7
|
+
const s = Math.min(w / refW, h / refH);
|
|
8
|
+
return { s, ox: (w - refW * s) / 2, oy: (h - refH * s) / 2 };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const FONT_FAMILY = 'Inter, sans-serif';
|
package/src/view.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ViewExtensionContext,
|
|
3
|
+
ViewExtensionProvider,
|
|
4
|
+
} from '@formicoidea/labre-core/ext-loader';
|
|
5
|
+
import { extendTemplateCategory } from '@formicoidea/labre-core/gfx/template';
|
|
6
|
+
|
|
7
|
+
import { CynefinRendererExtension } from './cynefin/element-renderer';
|
|
8
|
+
import { CynefinInteraction, CynefinView } from './cynefin/element-view';
|
|
9
|
+
import { cynefinToolbarExtension } from './cynefin/toolbar/config';
|
|
10
|
+
import { effects } from './effects';
|
|
11
|
+
import { EstuarineRendererExtension } from './estuarine/element-renderer';
|
|
12
|
+
import { EstuarineInteraction, EstuarineView } from './estuarine/element-view';
|
|
13
|
+
import { estuarineToolbarExtension } from './estuarine/toolbar/config';
|
|
14
|
+
import {
|
|
15
|
+
cynefinTemplateCategory,
|
|
16
|
+
estuarineTemplateCategory,
|
|
17
|
+
} from './templates';
|
|
18
|
+
import { cynefinEstuarineSeniorTool } from './toolbar/senior-tool';
|
|
19
|
+
|
|
20
|
+
export class CynefinEstuarineViewExtension extends ViewExtensionProvider {
|
|
21
|
+
override name = 'affine-cynefin-estuarine-gfx';
|
|
22
|
+
|
|
23
|
+
override effect(): void {
|
|
24
|
+
super.effect();
|
|
25
|
+
effects();
|
|
26
|
+
extendTemplateCategory(cynefinTemplateCategory);
|
|
27
|
+
extendTemplateCategory(estuarineTemplateCategory);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override setup(context: ViewExtensionContext) {
|
|
31
|
+
super.setup(context);
|
|
32
|
+
context.register(CynefinView);
|
|
33
|
+
context.register(CynefinRendererExtension);
|
|
34
|
+
context.register(EstuarineView);
|
|
35
|
+
context.register(EstuarineRendererExtension);
|
|
36
|
+
if (this.isEdgeless(context.scope)) {
|
|
37
|
+
context.register(CynefinInteraction);
|
|
38
|
+
context.register(EstuarineInteraction);
|
|
39
|
+
context.register(cynefinEstuarineSeniorTool);
|
|
40
|
+
context.register(cynefinToolbarExtension);
|
|
41
|
+
context.register(estuarineToolbarExtension);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
package/dist/cynefin/consts.d.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Visual constants for the Liminal Cynefin diagram, reproduced from the official
|
|
3
|
-
* SVG (viewBox 0 0 1080 777). All geometry is authored in that fixed reference
|
|
4
|
-
* space and scaled uniformly to the element bounds by the renderer.
|
|
5
|
-
*/
|
|
6
|
-
export declare const REF_W = 1080;
|
|
7
|
-
export declare const REF_H = 777;
|
|
8
|
-
export declare const COLORS: {
|
|
9
|
-
readonly boundary: "#333333";
|
|
10
|
-
readonly teal: "#2a9d99";
|
|
11
|
-
/** Domain headings + subheadings (h1 / h2). */
|
|
12
|
-
readonly heading: "#6d6e71";
|
|
13
|
-
/** Body, small annotations and the big A / C glyphs. */
|
|
14
|
-
readonly body: "#231f20";
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Dark boundary strokes drawn *behind* the teal "iterate" curve:
|
|
18
|
-
* [svg path, lineWidth, miterJoin].
|
|
19
|
-
*/
|
|
20
|
-
export declare const DARK_BACK_PATHS: ReadonlyArray<readonly [string, number, boolean]>;
|
|
21
|
-
/** Teal "iterate" curve, drawn *over* the back arcs and the dashed paving. */
|
|
22
|
-
export declare const TEAL_PATH = "M 475.1 9.1 C 477.5 13.3, 484.4 26.1, 489.3 34.6 C 494.2 43.1, 499.7 51.7, 504.4 60.2 C 509.1 68.7, 513.4 77.2, 517.6 85.7 C 521.8 94.2, 525.7 102.7, 529.7 111.2 C 533.7 119.7, 538.1 128.3, 541.8 136.8 C 545.5 145.3, 549.0 153.8, 551.9 162.3 C 554.8 170.8, 557.1 179.3, 559.0 187.8 C 560.9 196.3, 562.0 204.8, 563.0 213.3 C 564.0 221.8, 564.8 230.4, 565.0 238.9 C 565.2 247.4, 565.0 255.9, 564.0 264.4 C 563.0 272.9, 561.2 281.4, 559.0 289.9 C 556.8 298.4, 554.6 307.0, 550.9 315.5 C 547.2 324.0, 542.3 332.5, 536.8 341.0 C 531.2 349.5, 524.9 358.3, 517.6 366.5 C 510.4 374.7, 501.6 383.0, 493.3 390.0 C 485.0 397.0, 476.4 403.1, 468.0 408.4 C 459.6 413.7, 451.2 418.0, 442.8 421.7 C 434.4 425.4, 425.9 427.4, 417.5 430.8 C 409.1 434.2, 400.3 437.5, 392.2 442.1 C 384.1 446.7, 377.1 455.5, 369.0 458.4 C 360.9 461.3, 352.1 459.4, 343.7 459.4 C 335.3 459.4, 326.9 459.1, 318.5 458.4 C 310.1 457.7, 301.6 456.8, 293.2 455.4 C 284.8 454.0, 276.4 452.2, 268.0 450.3 C 259.6 448.4, 251.1 446.2, 242.7 444.1 C 234.3 442.1, 225.8 440.0, 217.4 438.0 C 209.0 436.0, 200.6 434.4, 192.2 431.9 C 183.8 429.3, 175.3 426.1, 166.9 422.7 C 158.5 419.3, 150.0 415.5, 141.6 411.4 C 133.2 407.3, 124.8 403.3, 116.4 398.2 C 108.0 393.1, 99.5 386.9, 91.1 380.8 C 82.7 374.7, 74.3 368.7, 65.9 361.4 C 57.5 354.1, 45.7 342.8, 40.6 336.9 C 35.5 330.9, 36.4 327.6, 35.5 325.7";
|
|
23
|
-
export declare const TEAL_WIDTH = 10.5;
|
|
24
|
-
/**
|
|
25
|
-
* Dark boundary strokes drawn *over* the teal curve:
|
|
26
|
-
* [svg path, lineWidth, miterJoin].
|
|
27
|
-
*/
|
|
28
|
-
export declare const DARK_FRONT_PATHS: ReadonlyArray<readonly [string, number, boolean]>;
|
|
29
|
-
/** Cliff hatching: [x1,y1,x2,y2], lineWidth 3. */
|
|
30
|
-
export declare const HATCHES: ReadonlyArray<readonly [number, number, number, number]>;
|
|
31
|
-
/** Dashed Complicated↔Clear boundary, as oriented square pavings: [x,y,size,rotateDeg]. */
|
|
32
|
-
export declare const DASH_RECTS: ReadonlyArray<readonly [number, number, number, number]>;
|
|
33
|
-
/**
|
|
34
|
-
* The four domain blocks. Each has a heading (h1) and, when descriptions are
|
|
35
|
-
* shown, a subheading (h2) and three decision lines whose lead word is bold.
|
|
36
|
-
* All three text levels share the block's left `x`.
|
|
37
|
-
*/
|
|
38
|
-
export interface DomainBlock {
|
|
39
|
-
heading: string;
|
|
40
|
-
/** Left edge shared by heading, subheading and body lines. */
|
|
41
|
-
x: number;
|
|
42
|
-
/** Heading (h1) baseline. */
|
|
43
|
-
hy: number;
|
|
44
|
-
subheading: string;
|
|
45
|
-
/** Subheading (h2) baseline. */
|
|
46
|
-
sy: number;
|
|
47
|
-
/** Decision lines: bold lead word + remainder, with their baseline. */
|
|
48
|
-
lines: ReadonlyArray<{
|
|
49
|
-
lead: string;
|
|
50
|
-
rest: string;
|
|
51
|
-
y: number;
|
|
52
|
-
}>;
|
|
53
|
-
}
|
|
54
|
-
export declare const DOMAINS: ReadonlyArray<DomainBlock>;
|
|
55
|
-
/** Teal annotation labels (centered): [text, x, y]. */
|
|
56
|
-
export declare const TEAL_LABELS: ReadonlyArray<readonly [string, number, number]>;
|
|
57
|
-
/** Small exaptation sub-labels (centered): [text, x, y]. */
|
|
58
|
-
export declare const SMALL_LABELS: ReadonlyArray<readonly [string, number, number]>;
|
|
59
|
-
/**
|
|
60
|
-
* The two central markers — Aporia (A) and Confusion (C) — each a big glyph and
|
|
61
|
-
* a name, with an optional teal note ("prepare to exit"). All centered.
|
|
62
|
-
*/
|
|
63
|
-
export interface Marker {
|
|
64
|
-
letter: string;
|
|
65
|
-
/** Big glyph position. */
|
|
66
|
-
lx: number;
|
|
67
|
-
ly: number;
|
|
68
|
-
name: string;
|
|
69
|
-
/** Name (body) position. */
|
|
70
|
-
nx: number;
|
|
71
|
-
ny: number;
|
|
72
|
-
/** Optional teal note position + text. */
|
|
73
|
-
note?: {
|
|
74
|
-
text: string;
|
|
75
|
-
x: number;
|
|
76
|
-
y: number;
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
export declare const MARKERS: ReadonlyArray<Marker>;
|
|
80
|
-
//# sourceMappingURL=consts.d.ts.map
|