@onsvisual/svelte-components 0.1.90-component.toolbar → 0.1.91-component.toolbar

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.
@@ -10,6 +10,8 @@ declare const __propDef: {
10
10
  selected?: boolean;
11
11
  custom?: boolean;
12
12
  hasAriaControls?: boolean;
13
+ sticky?: boolean;
14
+ transient?: boolean;
13
15
  };
14
16
  events: {
15
17
  click: CustomEvent<any>;
@@ -42,6 +42,7 @@
42
42
  <style>
43
43
  .grid--flex {
44
44
  display: flex;
45
+ gap: 4px;
45
46
  }
46
47
 
47
48
  .toolbar {
@@ -59,6 +60,7 @@
59
60
  height: 100%;
60
61
  margin: 8px;
61
62
  background: white;
63
+ gap: 8px;
62
64
  }
63
65
 
64
66
  .flex-col {
@@ -12,6 +12,8 @@ export let helpText = null;
12
12
  export let selected = false;
13
13
  export let custom = false;
14
14
  export let hasAriaControls = false;
15
+ export let sticky = false;
16
+ export let transient = false;
15
17
  const dispatch = createEventDispatcher();
16
18
  let buttonElement;
17
19
  // Get activeModalId store from context
@@ -31,9 +33,17 @@ $: isActive = $activeModalId === id;
31
33
  // Subscribe to the store to determine if this modal is active
32
34
  function handleClick() {
33
35
  if (!disabled) {
36
+ if (transient) {
37
+ // If it's a transient button, just trigger the action and return
38
+ dispatch("click");
39
+ return;
40
+ }
34
41
  dispatch("click");
42
+ if ($activeModalId === id && sticky) {
43
+ // If it's already active and sticky, keep it selected
44
+ return;
45
+ }
35
46
  activeModalId.set(isActive ? null : id); // Toggle the modal
36
- // maybe something here to check if selected
37
47
  }
38
48
  }
39
49
  </script>
@@ -47,9 +57,9 @@ function handleClick() {
47
57
  <button
48
58
  type="button"
49
59
  aria-label="{label}"
50
- class="{`toolbar-button ${disabled ? 'disabled' : ''} ${
51
- isActive ? 'selected' : ''
52
- } ${classes}`}"
60
+ class="toolbar-button {disabled ? 'disabled' : ''} {isActive && !transient
61
+ ? 'selected'
62
+ : ''} {classes}"
53
63
  on:click="{handleClick}"
54
64
  disabled="{disabled}"
55
65
  bind:this="{buttonElement}"
@@ -57,7 +67,11 @@ function handleClick() {
57
67
  aria-controls="{hasAriaControls ? `panel-${id}` : undefined}"
58
68
  >
59
69
  {#if icon}
60
- <Icon type="{icon}" selected="{isActive ? true : false}" disabled="{disabled}" />
70
+ <Icon
71
+ type="{icon}"
72
+ selected="{!transient ? (isActive ? true : false) : false}"
73
+ disabled="{disabled}"
74
+ />
61
75
  {:else}
62
76
  {label}
63
77
  {/if}
@@ -77,6 +91,37 @@ function handleClick() {
77
91
  {/if}
78
92
  </div>
79
93
 
94
+ <!--
95
+
96
+ /* /* Slightly darker gray when clicked */
97
+
98
+ /*
99
+ button:active {
100
+ background-color: #d6d6d6;
101
+ }
102
+
103
+ button.active {
104
+ background-color: #ddd; /* Selected button background */
105
+ border: 2px solid #333; /* Active button border */
106
+ }
107
+
108
+ button:hover:active {
109
+ background-color: #ccc; /* Slightly more contrast when active */
110
+ }
111
+
112
+ button:disabled {
113
+ opacity: 0.5;
114
+ cursor: not-allowed;
115
+ background-color: #f2f2f2;
116
+ border: 1px solid #ddd;
117
+ }
118
+
119
+ button:hover:disabled {
120
+ background-color: #f2f2f2; /* Keep it the same so disabled buttons don’t change on hover */
121
+ border: 1px solid #ddd;
122
+ } */
123
+ -->
124
+
80
125
  <style>
81
126
  .toolbar-button-wrapper {
82
127
  position: relative;
@@ -101,4 +146,16 @@ function handleClick() {
101
146
  .selected {
102
147
  background: #e9eff4;
103
148
  border-radius: 8px;
149
+ }
150
+
151
+ button:hover {
152
+ background-color: #f5f5f6;
153
+ border-radius: 8px;
154
+ }
155
+
156
+ button:focus {
157
+ outline: 2px solid #fbc900;
158
+ outline-offset: 2px;
159
+ box-shadow: 0 0 2px 2px #222222;
160
+ border-radius: 8px;
104
161
  }</style>
@@ -18,7 +18,6 @@ orientationStore.subscribe((value) => {
18
18
 
19
19
  .toolbar-divider.horizontal {
20
20
  width: 1px;
21
- margin: 0 0.5rem;
22
21
  }
23
22
 
24
23
  .toolbar-divider.vertical {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onsvisual/svelte-components",
3
- "version": "0.1.90-component.toolbar",
3
+ "version": "0.1.91-component.toolbar",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://onsvisual.github.io/svelte-components",