@descope-ui/descope-timer-button 3.4.0 → 3.5.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [3.5.0](https://github.com/descope/web-components-ui/compare/web-components-ui-3.4.0...web-components-ui-3.5.0) (2026-05-07)
6
+
7
+
8
+ ### Features
9
+
10
+ * **timer-button:** add timer-reversed and timer-inside options ([#1017](https://github.com/descope/web-components-ui/issues/1017)) ([bf99f17](https://github.com/descope/web-components-ui/commit/bf99f1742bbe44639e4630661dfbf2ef6418d563))
11
+
5
12
  ## [3.4.0](https://github.com/descope/web-components-ui/compare/web-components-ui-3.3.5...web-components-ui-3.4.0) (2026-05-07)
6
13
 
7
14
  ## [3.3.5](https://github.com/descope/web-components-ui/compare/web-components-ui-3.3.4...web-components-ui-3.3.5) (2026-05-06)
@@ -6,6 +6,8 @@ const componentAttributes = {
6
6
  size: ['xs', 'sm', 'md', 'lg'],
7
7
  horizontal: ['true', 'false'],
8
8
  'timer-hide-icon': ['true', 'false'],
9
+ 'timer-position': ['start', 'end'],
10
+ 'timer-inside': ['true', 'false'],
9
11
  'full-width': ['true', 'false'],
10
12
  'button-variant': ['contained', 'outline', 'link'],
11
13
  'button-mode': ['primary', 'secondary'],
@@ -20,6 +22,28 @@ const presets = {
20
22
  'full width horizontal': { 'full-width': 'true', horizontal: 'true' },
21
23
  'full width vertical': { 'full-width': 'true' },
22
24
  'horizontal with gap': { horizontal: 'true', 'st-gap': '35' },
25
+ 'timer reversed horizontal': { 'timer-position': 'end', horizontal: 'true' },
26
+ 'timer inside reversed': {
27
+ 'timer-inside': 'true',
28
+ 'timer-position': 'end',
29
+ },
30
+ 'timer inside full width': {
31
+ 'timer-inside': 'true',
32
+ 'full-width': 'true',
33
+ },
34
+ 'timer inside full width reversed': {
35
+ 'timer-inside': 'true',
36
+ 'full-width': 'true',
37
+ 'timer-position': 'end',
38
+ },
39
+ 'timer inside outline': {
40
+ 'timer-inside': 'true',
41
+ 'button-variant': 'outline',
42
+ },
43
+ 'timer inside link': {
44
+ 'timer-inside': 'true',
45
+ 'button-variant': 'link',
46
+ },
23
47
  };
24
48
 
25
49
  test.describe('theme', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope-ui/descope-timer-button",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "exports": {
5
5
  ".": {
6
6
  "import": "./src/component/index.js"
@@ -14,15 +14,15 @@
14
14
  },
15
15
  "devDependencies": {
16
16
  "@playwright/test": "1.58.2",
17
- "e2e-utils": "3.4.0",
18
- "test-drivers": "3.4.0",
19
- "test-assets": "3.4.0"
17
+ "e2e-utils": "3.5.0",
18
+ "test-drivers": "3.5.0",
19
+ "test-assets": "3.5.0"
20
20
  },
21
21
  "dependencies": {
22
- "@descope-ui/common": "3.4.0",
23
- "@descope-ui/theme-globals": "3.4.0",
24
- "@descope-ui/descope-timer": "3.4.0",
25
- "@descope-ui/descope-button": "3.4.0"
22
+ "@descope-ui/common": "3.5.0",
23
+ "@descope-ui/theme-globals": "3.5.0",
24
+ "@descope-ui/descope-timer": "3.5.0",
25
+ "@descope-ui/descope-button": "3.5.0"
26
26
  },
27
27
  "publishConfig": {
28
28
  "link-workspace-packages": false
@@ -10,6 +10,8 @@ import {
10
10
  getComponentName,
11
11
  injectStyle,
12
12
  } from '@descope-ui/common/components-helpers';
13
+ import { TimerClass } from '@descope-ui/descope-timer/class';
14
+ import { ButtonClass } from '@descope-ui/descope-button/class';
13
15
 
14
16
  export const componentName = getComponentName('timer-button');
15
17
 
@@ -67,26 +69,85 @@ class RawTimerButton extends BaseClass {
67
69
  .wrapper {
68
70
  display: flex;
69
71
  flex-direction: column;
70
- gap: 0.5em;
71
72
  align-items: center;
72
73
  width: 100%;
73
74
  }
74
- .timer {
75
+ /* allow timer to grow along the main axis in the wrapper flex container */
76
+ :host(:not([timer-inside="true"])) .timer {
75
77
  flex: 1;
76
78
  }
79
+ :host([timer-inside="true"]) .timer {
80
+ flex: 0 0 auto;
81
+ }
77
82
  `,
78
83
  this,
79
84
  );
80
85
 
86
+ this.wrapper = this.shadowRoot.querySelector('.wrapper');
81
87
  this.timer = this.shadowRoot.querySelector('.timer');
82
88
  this.button = this.shadowRoot.querySelector('.button');
89
+ this.forwardingSlot = this.shadowRoot.querySelector('.button slot');
83
90
 
84
91
  this.timer.addEventListener('timer-started', () => this.onTimerStarted());
85
92
  this.timer.addEventListener('timer-ended', () => this.onTimerEnded());
86
93
 
94
+ this.syncTimerPlacement();
95
+
87
96
  this.button.addEventListener('click', this.onClick.bind(this));
88
97
  }
89
98
 
99
+ static get observedAttributes() {
100
+ return [
101
+ ...(super.observedAttributes || []),
102
+ 'timer-inside',
103
+ 'timer-position',
104
+ ];
105
+ }
106
+
107
+ attributeChangedCallback(name, oldValue, newValue) {
108
+ super.attributeChangedCallback?.(name, oldValue, newValue);
109
+ if (name === 'timer-inside' || name === 'timer-position') {
110
+ this.syncTimerPlacement();
111
+ }
112
+ }
113
+
114
+ get #isTimerInside() {
115
+ return this.getAttribute('timer-inside') === 'true';
116
+ }
117
+
118
+ get #isReversed() {
119
+ return this.getAttribute('timer-position') === 'end';
120
+ }
121
+
122
+ syncTimerPlacement() {
123
+ if (this.#isTimerInside) {
124
+ this.#placeTimerInsideButton(this.#isReversed);
125
+ } else {
126
+ this.#placeTimerOutsideButton();
127
+ }
128
+ }
129
+
130
+ #placeTimerInsideButton(reversed) {
131
+ if (reversed) {
132
+ // timer after label text (right)
133
+ if (this.timer.previousSibling !== this.forwardingSlot) {
134
+ this.button.appendChild(this.timer);
135
+ }
136
+ } else {
137
+ // timer before label text (left) — matches default outside position (above/before button)
138
+ if (this.timer.nextSibling !== this.forwardingSlot) {
139
+ this.button.insertBefore(this.timer, this.forwardingSlot);
140
+ }
141
+ }
142
+ }
143
+
144
+ #placeTimerOutsideButton() {
145
+ // move timer back as a wrapper sibling, before the button so flex-column puts it above
146
+ if (this.timer.parentElement !== this.wrapper) {
147
+ this.wrapper.insertBefore(this.timer, this.button);
148
+ }
149
+ }
150
+
90
151
  set onclick(val) {
91
152
  this.button.onclick = val;
92
153
  }
@@ -134,10 +195,25 @@ class RawTimerButton extends BaseClass {
134
195
  }
135
196
  }
136
197
 
137
- const { host } = {
198
+ const {
199
+ host,
200
+ nestedTimer,
201
+ nestedButton,
202
+ timerInsideNotReversed,
203
+ timerInsideReversed,
204
+ } = {
138
205
  host: { selector: () => ':host' },
139
- icon: { selector: '.icon' },
140
- timer: { selector: '.timer' },
206
+ nestedTimer: { selector: () => ':host([timer-inside="true"]) .timer' },
207
+ nestedButton: {
208
+ selector: () => ':host([timer-inside="true"]) .button',
209
+ },
210
+ timerInsideNotReversed: {
211
+ selector: () =>
212
+ ':host([timer-inside="true"]:not([timer-position="end"])) .timer',
213
+ },
214
+ timerInsideReversed: {
215
+ selector: () => ':host([timer-inside="true"][timer-position="end"]) .timer',
216
+ },
141
217
  };
142
218
 
143
219
  export const TimerButtonClass = compose(
@@ -147,6 +223,30 @@ export const TimerButtonClass = compose(
147
223
  flexDirection: {},
148
224
  hostWidth: { ...host, property: 'width' },
149
225
  hostDirection: { ...host, property: 'direction' },
226
+ timerTextColor: {
227
+ ...nestedTimer,
228
+ property: TimerClass.cssVarList.textColor,
229
+ },
230
+ timerIconColor: {
231
+ ...nestedTimer,
232
+ property: TimerClass.cssVarList.iconColor,
233
+ },
234
+ timerHostWidth: {
235
+ ...nestedTimer,
236
+ property: TimerClass.cssVarList.hostWidth,
237
+ },
238
+ buttonLabelSpacing: {
239
+ ...nestedButton,
240
+ property: ButtonClass.cssVarList.labelSpacing,
241
+ },
242
+ timerInsideGapEnd: {
243
+ ...timerInsideNotReversed,
244
+ property: 'margin-inline-end',
245
+ },
246
+ timerInsideGapStart: {
247
+ ...timerInsideReversed,
248
+ property: 'margin-inline-start',
249
+ },
150
250
  },
151
251
  }),
152
252
  draggableMixin,
package/src/theme.js CHANGED
@@ -11,11 +11,35 @@ const timerButton = {
11
11
 
12
12
  _horizontal: {
13
13
  [vars.flexDirection]: 'row',
14
+ timerPosition: {
15
+ end: {
16
+ [vars.flexDirection]: 'row-reverse',
17
+ },
18
+ },
19
+ },
20
+
21
+ timerPosition: {
22
+ end: {
23
+ [vars.flexDirection]: 'column-reverse',
24
+ },
14
25
  },
15
26
 
16
27
  _fullWidth: {
17
28
  [vars.hostWidth]: '100%',
18
29
  },
30
+
31
+ _timerInside: {
32
+ [vars.timerTextColor]: 'currentColor',
33
+ [vars.timerIconColor]: 'currentColor',
34
+ [vars.timerHostWidth]: 'auto',
35
+ [vars.buttonLabelSpacing]: '0',
36
+ [vars.timerInsideGapEnd]: `var(${vars.gap})`,
37
+ timerPosition: {
38
+ end: {
39
+ [vars.timerInsideGapStart]: `var(${vars.gap})`,
40
+ },
41
+ },
42
+ },
19
43
  };
20
44
 
21
45
  export default timerButton;
@@ -13,6 +13,8 @@ const Template = ({
13
13
  'timer-seconds': timerSeconds,
14
14
  'timer-hide-icon': timerHideIcon,
15
15
  'timer-paused': timerPaused,
16
+ 'timer-position': timerPosition,
17
+ 'timer-inside': timerInside,
16
18
  size,
17
19
  direction,
18
20
  horizontal,
@@ -28,6 +30,8 @@ const Template = ({
28
30
  timer-seconds="${timerSeconds}"
29
31
  timer-hide-icon="${timerHideIcon || false}"
30
32
  timer-paused="${timerPaused || false}"
33
+ timer-position="${timerPosition || 'start'}"
34
+ timer-inside="${timerInside || false}"
31
35
  size="${size}"
32
36
  horizontal="${horizontal || false}"
33
37
  full-width="${fullWidth || false}"
@@ -76,6 +80,19 @@ export default {
76
80
  type: 'boolean',
77
81
  },
78
82
  },
83
+ 'timer-position': {
84
+ name: 'Timer Position',
85
+ options: ['start', 'end'],
86
+ control: {
87
+ type: 'radio',
88
+ },
89
+ },
90
+ 'timer-inside': {
91
+ name: 'Timer Inside Button',
92
+ control: {
93
+ type: 'boolean',
94
+ },
95
+ },
79
96
  'st-gap': {
80
97
  name: 'Gap',
81
98
  control: { type: 'text' },
@@ -94,6 +111,8 @@ Default.args = {
94
111
  'timer-seconds': 5,
95
112
  'timer-hide-icon': false,
96
113
  'timer-paused': false,
114
+ 'timer-position': 'start',
115
+ 'timer-inside': false,
97
116
  horizontal: false,
98
117
  'text-align': 'center',
99
118
  'button-variant': 'contained',