@mlightcad/ribbon 0.0.1

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.
Files changed (46) hide show
  1. package/.github/workflows/ci.yml +110 -0
  2. package/.vscode/extensions.json +3 -0
  3. package/AGENTS.md +42 -0
  4. package/README.md +168 -0
  5. package/docs/requirements.md +96 -0
  6. package/eslint.config.js +41 -0
  7. package/images/ribbon.jpg +0 -0
  8. package/index.html +13 -0
  9. package/package.json +43 -0
  10. package/playwright/ribbon.spec.ts +6 -0
  11. package/playwright.config.ts +10 -0
  12. package/public/favicon.svg +1 -0
  13. package/public/icons.svg +24 -0
  14. package/src/App.vue +418 -0
  15. package/src/assets/hero.png +0 -0
  16. package/src/assets/vite.svg +1 -0
  17. package/src/assets/vue.svg +1 -0
  18. package/src/components/HelloWorld.vue +106 -0
  19. package/src/main.ts +9 -0
  20. package/src/ribbon/components/Ribbon.vue +844 -0
  21. package/src/ribbon/components/RibbonCollection.vue +51 -0
  22. package/src/ribbon/components/RibbonGroup.vue +327 -0
  23. package/src/ribbon/components/RibbonGroupContent.vue +61 -0
  24. package/src/ribbon/components/RibbonItemHost.vue +221 -0
  25. package/src/ribbon/components/RibbonTab.vue +44 -0
  26. package/src/ribbon/components/RibbonTabs.vue +49 -0
  27. package/src/ribbon/composables/useRibbonState.ts +272 -0
  28. package/src/ribbon/context.ts +4 -0
  29. package/src/ribbon/index.ts +99 -0
  30. package/src/ribbon/items/RibbonGallery.vue +78 -0
  31. package/src/ribbon/items/RibbonGroupButton.vue +85 -0
  32. package/src/ribbon/items/RibbonTemplateItem.vue +38 -0
  33. package/src/ribbon/modules/RibbonBackstage.vue +69 -0
  34. package/src/ribbon/modules/RibbonContextualTabs.vue +65 -0
  35. package/src/ribbon/modules/RibbonFileMenu.vue +88 -0
  36. package/src/ribbon/modules/RibbonKeyTips.vue +114 -0
  37. package/src/ribbon/styles/ribbon.css +925 -0
  38. package/src/ribbon/types.ts +162 -0
  39. package/src/style.css +328 -0
  40. package/src/tests/ribbon.spec.ts +830 -0
  41. package/src/tests/setup.ts +4 -0
  42. package/tools/release.mjs +107 -0
  43. package/tsconfig.app.json +14 -0
  44. package/tsconfig.json +7 -0
  45. package/tsconfig.node.json +24 -0
  46. package/vite.config.ts +38 -0
@@ -0,0 +1,162 @@
1
+ import type { Component } from 'vue'
2
+ import type { ComponentSize } from 'element-plus'
3
+
4
+ export type RibbonLayout = 'classic' | 'simplified'
5
+ export type RibbonItemSize = 'large' | 'medium' | 'small'
6
+ export type RibbonCollectionLayout = 'row' | 'column'
7
+ export type RibbonGroupOrientation = 'row' | 'column'
8
+ export type RibbonComponentSize = ComponentSize
9
+
10
+ export type RibbonItemType =
11
+ | 'button'
12
+ | 'dropdown'
13
+ | 'splitButton'
14
+ | 'checkbox'
15
+ | 'colorPicker'
16
+ | 'comboBox'
17
+ | 'groupButton'
18
+ | 'gallery'
19
+ | 'template'
20
+
21
+ export interface KeyTipModel {
22
+ id: string
23
+ key: string
24
+ targetId: string
25
+ sequence?: string[]
26
+ scope?: 'tab' | 'group' | 'item' | 'global'
27
+ }
28
+
29
+ export interface FileMenuItemModel {
30
+ id: string
31
+ label: string
32
+ disabled?: boolean
33
+ }
34
+
35
+ export interface BackstageItemModel {
36
+ id: string
37
+ label: string
38
+ description?: string
39
+ }
40
+
41
+ export interface RibbonLocaleTexts {
42
+ layoutSwitcherTooltip?: string
43
+ minimizeTooltip?: string
44
+ keyTipsToggleText?: string
45
+ overflowTriggerAriaLabel?: string
46
+ groupOverflowTriggerAriaLabel?: string
47
+ fileMenuLabel?: string
48
+ fileMenuOpenBackstageLabel?: string
49
+ backstageBackLabel?: string
50
+ backstageTitle?: string
51
+ backstageDescription?: string
52
+ keyTipsSequencePrefix?: string
53
+ keyTipsEmptySequence?: string
54
+ contextualTabDefaultTitle?: string
55
+ galleryPreviewFallback?: string
56
+ }
57
+
58
+ export interface RibbonItemModel {
59
+ id: string
60
+ type: RibbonItemType
61
+ label?: string
62
+ hideLabel?: boolean
63
+ icon?: string | Component
64
+ disabled?: boolean
65
+ size?: RibbonItemSize
66
+ keyTip?: string
67
+ props?: Record<string, unknown>
68
+ }
69
+
70
+ export interface RibbonCollectionModel {
71
+ id: string
72
+ items: RibbonItemModel[]
73
+ layout?: RibbonCollectionLayout
74
+ rows?: number
75
+ }
76
+
77
+ export interface RibbonGroupModel {
78
+ id: string
79
+ title: string
80
+ icon?: string | Component
81
+ groupIconCss?: string
82
+ orientation?: RibbonGroupOrientation
83
+ enableGroupOverflow?: boolean
84
+ autoWidth?: boolean
85
+ priority?: number
86
+ visible?: boolean
87
+ launcher?: boolean
88
+ showLauncherIcon?: boolean
89
+ footerMenuItems?: RibbonItemModel[]
90
+ collections?: RibbonCollectionModel[]
91
+ }
92
+
93
+ export interface RibbonTabModel {
94
+ id: string
95
+ title: string
96
+ visible?: boolean
97
+ contextual?: boolean
98
+ contextualColor?: string
99
+ contextualTitle?: string
100
+ groups?: RibbonGroupModel[]
101
+ }
102
+
103
+ export interface RibbonDynamicApi {
104
+ /** Adds a new tab to the ribbon. */
105
+ addTab: (tab: RibbonTabModel) => void
106
+ /** Removes a tab by id. */
107
+ removeTab: (tabId: string) => void
108
+ /** Marks a tab as visible. */
109
+ showTab: (tabId: string) => void
110
+ /** Marks a tab as hidden. */
111
+ hideTab: (tabId: string) => void
112
+ /** Sets the active tab id. */
113
+ selectTab: (tabId: string) => void
114
+ /** Adds a group to a tab. */
115
+ addGroup: (tabId: string, group: RibbonGroupModel) => void
116
+ /** Removes a group from a tab by group id. */
117
+ removeGroup: (tabId: string, groupId: string) => void
118
+ /** Marks a group as visible. */
119
+ showGroup: (tabId: string, groupId: string) => void
120
+ /** Marks a group as hidden. */
121
+ hideGroup: (tabId: string, groupId: string) => void
122
+ /** Adds an item to a target collection. */
123
+ addItem: (tabId: string, groupId: string, collectionId: string, item: RibbonItemModel) => void
124
+ /** Removes an item from a target collection by id. */
125
+ removeItem: (tabId: string, groupId: string, collectionId: string, itemId: string) => void
126
+ /** Applies a partial patch to an existing item. */
127
+ updateItem: (
128
+ tabId: string,
129
+ groupId: string,
130
+ collectionId: string,
131
+ itemId: string,
132
+ patch: Partial<RibbonItemModel>,
133
+ ) => void
134
+ /** Enables a target item. */
135
+ enableItem: (tabId: string, groupId: string, collectionId: string, itemId: string) => void
136
+ /** Disables a target item. */
137
+ disableItem: (tabId: string, groupId: string, collectionId: string, itemId: string) => void
138
+ /** Requests a layout refresh pass. */
139
+ refreshLayout: () => void
140
+ /** Sets minimized state explicitly. */
141
+ minimize: (value: boolean) => void
142
+ /** Toggles between classic and simplified layouts. */
143
+ toggleSimplified: () => void
144
+ }
145
+
146
+ export interface RibbonContextValue {
147
+ id: string
148
+ layout: import('vue').Ref<RibbonLayout>
149
+ minimized: import('vue').Ref<boolean>
150
+ activeTab: import('vue').Ref<string>
151
+ tabs: import('vue').Ref<RibbonTabModel[]>
152
+ overflowOpen: import('vue').Ref<boolean>
153
+ backdropOpen: import('vue').Ref<boolean>
154
+ keyTipsOpen: import('vue').Ref<boolean>
155
+ keyTips: import('vue').Ref<KeyTipModel[]>
156
+ keyTipsSequence: import('vue').Ref<string>
157
+ /** Registers a key tip for the current ribbon scope. */
158
+ registerKeyTip: (tip: KeyTipModel) => void
159
+ /** Unregisters a key tip by id. */
160
+ unregisterKeyTip: (id: string) => void
161
+ api: RibbonDynamicApi
162
+ }
package/src/style.css ADDED
@@ -0,0 +1,328 @@
1
+ :root {
2
+ --text: #6b6375;
3
+ --text-h: #08060d;
4
+ --bg: #fff;
5
+ --border: #e5e4e7;
6
+ --code-bg: #f4f3ec;
7
+ --accent: #aa3bff;
8
+ --accent-bg: rgba(170, 59, 255, 0.1);
9
+ --accent-border: rgba(170, 59, 255, 0.5);
10
+ --social-bg: rgba(244, 243, 236, 0.5);
11
+ --shadow:
12
+ rgba(0, 0, 0, 0.1) 0 10px 15px -3px, rgba(0, 0, 0, 0.05) 0 4px 6px -2px;
13
+
14
+ --sans: system-ui, 'Segoe UI', Roboto, sans-serif;
15
+ --heading: system-ui, 'Segoe UI', Roboto, sans-serif;
16
+ --mono: ui-monospace, Consolas, monospace;
17
+
18
+ font: 18px/145% var(--sans);
19
+ letter-spacing: 0.18px;
20
+ color-scheme: light dark;
21
+ color: var(--text);
22
+ background: var(--bg);
23
+ font-synthesis: none;
24
+ text-rendering: optimizeLegibility;
25
+ -webkit-font-smoothing: antialiased;
26
+ -moz-osx-font-smoothing: grayscale;
27
+
28
+ @media (max-width: 1024px) {
29
+ font-size: 16px;
30
+ }
31
+ }
32
+
33
+ @media (prefers-color-scheme: dark) {
34
+ :root {
35
+ --text: #9ca3af;
36
+ --text-h: #f3f4f6;
37
+ --bg: #16171d;
38
+ --border: #2e303a;
39
+ --code-bg: #1f2028;
40
+ --accent: #c084fc;
41
+ --accent-bg: rgba(192, 132, 252, 0.15);
42
+ --accent-border: rgba(192, 132, 252, 0.5);
43
+ --social-bg: rgba(47, 48, 58, 0.5);
44
+ --shadow:
45
+ rgba(0, 0, 0, 0.4) 0 10px 15px -3px, rgba(0, 0, 0, 0.25) 0 4px 6px -2px;
46
+ }
47
+
48
+ #social .button-icon {
49
+ filter: invert(1) brightness(2);
50
+ }
51
+ }
52
+
53
+ html.ml-theme-dark {
54
+ --text: #9ca3af;
55
+ --text-h: #f3f4f6;
56
+ --bg: #16171d;
57
+ --border: #2e303a;
58
+ --code-bg: #1f2028;
59
+ --accent: #c084fc;
60
+ --accent-bg: rgba(192, 132, 252, 0.15);
61
+ --accent-border: rgba(192, 132, 252, 0.5);
62
+ --social-bg: rgba(47, 48, 58, 0.5);
63
+ --shadow:
64
+ rgba(0, 0, 0, 0.4) 0 10px 15px -3px, rgba(0, 0, 0, 0.25) 0 4px 6px -2px;
65
+ }
66
+
67
+ html.ml-theme-dark #social .button-icon {
68
+ filter: invert(1) brightness(2);
69
+ }
70
+
71
+ html.ml-theme-light {
72
+ --text: #6b6375;
73
+ --text-h: #08060d;
74
+ --bg: #fff;
75
+ --border: #e5e4e7;
76
+ --code-bg: #f4f3ec;
77
+ --accent: #aa3bff;
78
+ --accent-bg: rgba(170, 59, 255, 0.1);
79
+ --accent-border: rgba(170, 59, 255, 0.5);
80
+ --social-bg: rgba(244, 243, 236, 0.5);
81
+ --shadow:
82
+ rgba(0, 0, 0, 0.1) 0 10px 15px -3px, rgba(0, 0, 0, 0.05) 0 4px 6px -2px;
83
+ }
84
+
85
+ body {
86
+ margin: 0;
87
+ }
88
+
89
+ h1,
90
+ h2 {
91
+ font-family: var(--heading);
92
+ font-weight: 500;
93
+ color: var(--text-h);
94
+ }
95
+
96
+ h1 {
97
+ font-size: 56px;
98
+ letter-spacing: -1.68px;
99
+ margin: 32px 0;
100
+ @media (max-width: 1024px) {
101
+ font-size: 36px;
102
+ margin: 20px 0;
103
+ }
104
+ }
105
+ h2 {
106
+ font-size: 24px;
107
+ line-height: 118%;
108
+ letter-spacing: -0.24px;
109
+ margin: 0 0 8px;
110
+ @media (max-width: 1024px) {
111
+ font-size: 20px;
112
+ }
113
+ }
114
+ p {
115
+ margin: 0;
116
+ }
117
+
118
+ code,
119
+ .counter {
120
+ font-family: var(--mono);
121
+ display: inline-flex;
122
+ border-radius: 4px;
123
+ color: var(--text-h);
124
+ }
125
+
126
+ code {
127
+ font-size: 15px;
128
+ line-height: 135%;
129
+ padding: 4px 8px;
130
+ background: var(--code-bg);
131
+ }
132
+
133
+ .counter {
134
+ font-size: 16px;
135
+ padding: 5px 10px;
136
+ border-radius: 5px;
137
+ color: var(--accent);
138
+ background: var(--accent-bg);
139
+ border: 2px solid transparent;
140
+ transition: border-color 0.3s;
141
+ margin-bottom: 24px;
142
+
143
+ &:hover {
144
+ border-color: var(--accent-border);
145
+ }
146
+ &:focus-visible {
147
+ outline: 2px solid var(--accent);
148
+ outline-offset: 2px;
149
+ }
150
+ }
151
+
152
+ .hero {
153
+ position: relative;
154
+
155
+ .base,
156
+ .framework,
157
+ .vite {
158
+ inset-inline: 0;
159
+ margin: 0 auto;
160
+ }
161
+
162
+ .base {
163
+ width: 170px;
164
+ position: relative;
165
+ z-index: 0;
166
+ }
167
+
168
+ .framework,
169
+ .vite {
170
+ position: absolute;
171
+ }
172
+
173
+ .framework {
174
+ z-index: 1;
175
+ top: 34px;
176
+ height: 28px;
177
+ transform: perspective(2000px) rotateZ(300deg) rotateX(44deg) rotateY(39deg)
178
+ scale(1.4);
179
+ }
180
+
181
+ .vite {
182
+ z-index: 0;
183
+ top: 107px;
184
+ height: 26px;
185
+ width: auto;
186
+ transform: perspective(2000px) rotateZ(300deg) rotateX(40deg) rotateY(39deg)
187
+ scale(0.8);
188
+ }
189
+ }
190
+
191
+ #app {
192
+ width: 1126px;
193
+ max-width: 100%;
194
+ margin: 0 auto;
195
+ text-align: center;
196
+ border-inline: 1px solid var(--border);
197
+ min-height: 100svh;
198
+ display: flex;
199
+ flex-direction: column;
200
+ box-sizing: border-box;
201
+ }
202
+
203
+ #center {
204
+ display: flex;
205
+ flex-direction: column;
206
+ gap: 25px;
207
+ place-content: center;
208
+ place-items: center;
209
+ flex-grow: 1;
210
+
211
+ @media (max-width: 1024px) {
212
+ padding: 32px 20px 24px;
213
+ gap: 18px;
214
+ }
215
+ }
216
+
217
+ #next-steps {
218
+ display: flex;
219
+ border-top: 1px solid var(--border);
220
+ text-align: left;
221
+
222
+ & > div {
223
+ flex: 1 1 0;
224
+ padding: 32px;
225
+ @media (max-width: 1024px) {
226
+ padding: 24px 20px;
227
+ }
228
+ }
229
+
230
+ .icon {
231
+ margin-bottom: 16px;
232
+ width: 22px;
233
+ height: 22px;
234
+ }
235
+
236
+ @media (max-width: 1024px) {
237
+ flex-direction: column;
238
+ text-align: center;
239
+ }
240
+ }
241
+
242
+ #docs {
243
+ border-right: 1px solid var(--border);
244
+
245
+ @media (max-width: 1024px) {
246
+ border-right: none;
247
+ border-bottom: 1px solid var(--border);
248
+ }
249
+ }
250
+
251
+ #next-steps ul {
252
+ list-style: none;
253
+ padding: 0;
254
+ display: flex;
255
+ gap: 8px;
256
+ margin: 32px 0 0;
257
+
258
+ .logo {
259
+ height: 18px;
260
+ }
261
+
262
+ a {
263
+ color: var(--text-h);
264
+ font-size: 16px;
265
+ border-radius: 6px;
266
+ background: var(--social-bg);
267
+ display: flex;
268
+ padding: 6px 12px;
269
+ align-items: center;
270
+ gap: 8px;
271
+ text-decoration: none;
272
+ transition: box-shadow 0.3s;
273
+
274
+ &:hover {
275
+ box-shadow: var(--shadow);
276
+ }
277
+ .button-icon {
278
+ height: 18px;
279
+ width: 18px;
280
+ }
281
+ }
282
+
283
+ @media (max-width: 1024px) {
284
+ margin-top: 20px;
285
+ flex-wrap: wrap;
286
+ justify-content: center;
287
+
288
+ li {
289
+ flex: 1 1 calc(50% - 8px);
290
+ }
291
+
292
+ a {
293
+ width: 100%;
294
+ justify-content: center;
295
+ box-sizing: border-box;
296
+ }
297
+ }
298
+ }
299
+
300
+ #spacer {
301
+ height: 88px;
302
+ border-top: 1px solid var(--border);
303
+ @media (max-width: 1024px) {
304
+ height: 48px;
305
+ }
306
+ }
307
+
308
+ .ticks {
309
+ position: relative;
310
+ width: 100%;
311
+
312
+ &::before,
313
+ &::after {
314
+ content: '';
315
+ position: absolute;
316
+ top: -4.5px;
317
+ border: 5px solid transparent;
318
+ }
319
+
320
+ &::before {
321
+ left: 0;
322
+ border-left-color: var(--border);
323
+ }
324
+ &::after {
325
+ right: 0;
326
+ border-right-color: var(--border);
327
+ }
328
+ }