tabby-glass-menu 0.1.1 → 0.2.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 (3) hide show
  1. package/README.md +2 -0
  2. package/index.js +71 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -36,6 +36,8 @@ It's plain JavaScript, there is nothing to build.
36
36
  - background opacity (default 0.55)
37
37
  - blur of the window content behind the menu (default 12 px)
38
38
  - corner radius (default 20 px)
39
+ - border: width (default 1 px, 0 for none), style (solid, dashed, dotted,
40
+ double), color and opacity (default white at 0.06)
39
41
  - show a sample menu to try the settings
40
42
 
41
43
  The background takes the color of the Tabby theme.
package/index.js CHANGED
@@ -44,8 +44,15 @@ const DEFAULTS = {
44
44
  blur: 12,
45
45
  // corner radius, px
46
46
  radius: 20,
47
+ // border: width in px (0 for none), CSS style, color and its opacity
48
+ borderWidth: 1,
49
+ borderStyle: 'solid',
50
+ borderColor: '#ffffff',
51
+ borderOpacity: 0.06,
47
52
  }
48
53
 
54
+ const BORDER_STYLES = ['solid', 'dashed', 'dotted', 'double']
55
+
49
56
  const FALLBACK_BG = '#1d201e'
50
57
  const FALLBACK_FG = '#e3e2be'
51
58
 
@@ -58,7 +65,7 @@ const CSS = `
58
65
  position: fixed;
59
66
  z-index: 2147483000;
60
67
  box-sizing: border-box;
61
- min-width: 180px;
68
+ min-width: 200px;
62
69
  max-width: 440px;
63
70
  max-height: calc(100vh - ${2 * EDGE_MARGIN}px);
64
71
  overflow-x: hidden;
@@ -74,7 +81,7 @@ const CSS = `
74
81
  font-family: system-ui, sans-serif;
75
82
  font-size: 13px;
76
83
  line-height: 1.35;
77
- border: 1px solid rgba(255, 255, 255, 0.06);
84
+ border: var(--tgm-border-width) var(--tgm-border-style) var(--tgm-border-color);
78
85
  box-shadow: 0 2px 3px -1px rgba(0, 0, 0, 0.15), 0 4px 3px 0 rgba(0, 0, 0, 0.18),
79
86
  0 1px 6px 0 rgba(0, 0, 0, 0.12);
80
87
  user-select: none;
@@ -92,7 +99,7 @@ const CSS = `
92
99
  display: flex;
93
100
  align-items: center;
94
101
  gap: 12px;
95
- padding: 5px 10px;
102
+ padding: 5px 14px;
96
103
  border-radius: calc(var(--tgm-radius) * 0.6);
97
104
  white-space: nowrap;
98
105
  cursor: default;
@@ -201,7 +208,9 @@ class GlassMenu {
201
208
  this.applySettings(el)
202
209
 
203
210
  const panel = { el, rows: [], active: -1, parentRow }
204
- if (items.some(i => ['checkbox', 'radio'].includes(itemType(i)))) {
211
+ // the check column only when something is checked: an empty one would
212
+ // push every label to the right
213
+ if (items.some(i => ['checkbox', 'radio'].includes(itemType(i)) && i.checked)) {
205
214
  el.classList.add('tgm-has-checks')
206
215
  }
207
216
 
@@ -289,6 +298,14 @@ class GlassMenu {
289
298
  el.style.setProperty('--tgm-fg', fg)
290
299
  el.style.setProperty('--tgm-blur', `${clamp(num(s.blur, DEFAULTS.blur), 0, 100)}px`)
291
300
  el.style.setProperty('--tgm-radius', `${clamp(num(s.radius, DEFAULTS.radius), 0, 40)}px`)
301
+ const borderColor = /^#[0-9a-f]{3}([0-9a-f]{3})?$/i.test(s.borderColor)
302
+ ? s.borderColor : DEFAULTS.borderColor
303
+ const borderPct = Math.round(clamp(num(s.borderOpacity, DEFAULTS.borderOpacity), 0, 1) * 100)
304
+ el.style.setProperty('--tgm-border-width', `${clamp(num(s.borderWidth, DEFAULTS.borderWidth), 0, 8)}px`)
305
+ el.style.setProperty('--tgm-border-style',
306
+ BORDER_STYLES.includes(s.borderStyle) ? s.borderStyle : DEFAULTS.borderStyle)
307
+ el.style.setProperty('--tgm-border-color',
308
+ `color-mix(in srgb, ${borderColor} ${borderPct}%, transparent)`)
292
309
  }
293
310
 
294
311
  viewport () {
@@ -642,11 +659,58 @@ const SETTINGS_TEMPLATE = `
642
659
  </div>
643
660
  </div>
644
661
 
662
+ <h4 class="tgm-section">Border</h4>
663
+
664
+ <div class="form-line">
665
+ <div class="header">
666
+ <div class="title">Width</div>
667
+ <div class="description">In pixels, 0 for no border</div>
668
+ </div>
669
+ <div class="tgm-range">
670
+ <input type="range" class="form-range" min="0" max="8" step="1"
671
+ [(ngModel)]="config.store.glassMenu.borderWidth" (ngModelChange)="save()">
672
+ <span>{{ config.store.glassMenu.borderWidth }} px</span>
673
+ </div>
674
+ </div>
675
+
676
+ <div class="form-line">
677
+ <div class="header">
678
+ <div class="title">Style</div>
679
+ </div>
680
+ <select class="form-control tgm-select"
681
+ [(ngModel)]="config.store.glassMenu.borderStyle" (ngModelChange)="save()">
682
+ <option *ngFor="let style of borderStyles" [ngValue]="style">{{ style }}</option>
683
+ </select>
684
+ </div>
685
+
686
+ <div class="form-line">
687
+ <div class="header">
688
+ <div class="title">Color</div>
689
+ </div>
690
+ <input type="color" class="tgm-color"
691
+ [(ngModel)]="config.store.glassMenu.borderColor" (ngModelChange)="save()">
692
+ </div>
693
+
694
+ <div class="form-line">
695
+ <div class="header">
696
+ <div class="title">Opacity</div>
697
+ <div class="description">0 is invisible, 1 is the full color</div>
698
+ </div>
699
+ <div class="tgm-range">
700
+ <input type="range" class="form-range" min="0" max="1" step="0.01"
701
+ [(ngModel)]="config.store.glassMenu.borderOpacity" (ngModelChange)="save()">
702
+ <span>{{ config.store.glassMenu.borderOpacity | number:'1.2-2' }}</span>
703
+ </div>
704
+ </div>
705
+
645
706
  <button class="btn btn-secondary" (click)="preview($event)">Show a sample menu</button>
646
707
  `
647
708
 
648
709
  const SETTINGS_STYLES = [`
649
710
  .tgm-intro { opacity: 0.8; }
711
+ .tgm-section { margin-top: 1.5rem; }
712
+ .tgm-select { width: auto; min-width: 140px; }
713
+ .tgm-color { width: 48px; height: 32px; padding: 0; border: none; background: none; cursor: pointer; }
650
714
  .tgm-range { display: flex; align-items: center; gap: 12px; min-width: 260px; }
651
715
  .tgm-range input { flex: 1; }
652
716
  .tgm-range span { min-width: 3.5em; text-align: right; font-variant-numeric: tabular-nums; }
@@ -656,6 +720,7 @@ class GlassMenuSettingsComponent {
656
720
  constructor (config, menu) {
657
721
  this.config = config
658
722
  this.menu = menu
723
+ this.borderStyles = BORDER_STYLES
659
724
  }
660
725
 
661
726
  save () {
@@ -663,6 +728,8 @@ class GlassMenuSettingsComponent {
663
728
  s.opacity = num(s.opacity, DEFAULTS.opacity)
664
729
  s.blur = num(s.blur, DEFAULTS.blur)
665
730
  s.radius = num(s.radius, DEFAULTS.radius)
731
+ s.borderWidth = num(s.borderWidth, DEFAULTS.borderWidth)
732
+ s.borderOpacity = num(s.borderOpacity, DEFAULTS.borderOpacity)
666
733
  this.config.save()
667
734
  }
668
735
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabby-glass-menu",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "description": "Translucent, blurred context menus for Tabby instead of Electron's opaque native ones",
5
5
  "keywords": [
6
6
  "tabby-plugin",