@descope-ui/descope-timer-button 0.0.1 → 0.0.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/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.0.2](https://github.com/descope/web-components-ui/compare/@descope-ui/descope-timer-button-0.0.1...@descope-ui/descope-timer-button-0.0.2) (2025-03-13)
6
+
7
+ ### Dependency Updates
8
+
9
+ * `@descope-ui/descope-timer` updated to version `0.0.2`
5
10
  ## 0.0.1 (2025-03-11)
6
11
 
7
12
  ### Dependency Updates
@@ -5,11 +5,12 @@ import { createTimerButtonTestDriver } from 'test-drivers';
5
5
  const componentAttributes = {
6
6
  size: ['xs', 'sm', 'md', 'lg'],
7
7
  horizontal: ['true', 'false'],
8
- 'hide-icon': ['true', 'false'],
8
+ 'timer-hide-icon': ['true', 'false'],
9
9
  'full-width': ['true', 'false'],
10
10
  'button-variant': ['contained', 'outline', 'link'],
11
11
  'button-mode': ['primary', 'secondary'],
12
12
  icon: ['true', 'false'],
13
+ 'st-gap': ['0', '10', '20'],
13
14
  };
14
15
 
15
16
  const storyName = 'descope-timer-button';
@@ -18,6 +19,7 @@ const componentName = 'descope-timer-button';
18
19
  const presets = {
19
20
  'full width horizontal': { 'full-width': 'true', horizontal: 'true' },
20
21
  'full width vertical': { 'full-width': 'true' },
22
+ 'horizontal with gap': { horizontal: 'true', 'st-gap': '35' },
21
23
  };
22
24
 
23
25
  test.describe('theme', () => {
@@ -56,7 +58,7 @@ test.describe('logic', () => {
56
58
  test(`button restarts timer`, async ({ page }) => {
57
59
  await page.goto(
58
60
  getStoryUrl(storyName, {
59
- seconds: '2',
61
+ 'timer-seconds': '2',
60
62
  }),
61
63
  {
62
64
  waitUntil: 'load',
@@ -65,18 +67,18 @@ test.describe('logic', () => {
65
67
  const component = createTimerButtonTestDriver(page.locator(componentName));
66
68
 
67
69
  await component.timer.stop();
68
- expect(await component.screenshot()).toMatchSnapshot();
70
+ expect(await component.screenshot({ delay: 3000 })).toMatchSnapshot();
69
71
 
70
- await component.timer.reset();
71
- await page.waitForTimeout(3000);
72
+ await component.button.click();
73
+ await component.timer.pause();
72
74
 
73
- expect(await component.screenshot()).toMatchSnapshot();
75
+ expect(await component.screenshot({ delay: 3000 })).toMatchSnapshot();
74
76
  });
75
77
 
76
78
  test(`disable button if timer is running`, async ({ page }) => {
77
79
  await page.goto(
78
80
  getStoryUrl(storyName, {
79
- seconds: '3',
81
+ 'timer-seconds': '3',
80
82
  }),
81
83
  {
82
84
  waitUntil: 'load',
@@ -95,7 +97,7 @@ test.describe('logic', () => {
95
97
  });
96
98
 
97
99
  test(`enable button if timer finished`, async ({ page }) => {
98
- await page.goto(getStoryUrl(storyName, { seconds: '2' }), {
100
+ await page.goto(getStoryUrl(storyName, { 'timer-seconds': '2' }), {
99
101
  waitUntil: 'load',
100
102
  });
101
103
 
@@ -104,7 +106,7 @@ test.describe('logic', () => {
104
106
  await component.timer.stop();
105
107
  await component.timer.reset();
106
108
  await component.timer.pause();
107
- expect(await component.screenshot({ delay: 3000 })).toMatchSnapshot();
109
+ expect(await component.screenshot()).toMatchSnapshot();
108
110
 
109
111
  await component.timer.resume();
110
112
  await page.waitForTimeout(4000);
@@ -131,7 +133,7 @@ test.describe('presets', () => {
131
133
  ['ltr', 'rtl'].forEach((direction) => {
132
134
  loopPresets(presets, (preset, name) => {
133
135
  test(`${name} - ${direction}`, async ({ page }) => {
134
- await page.goto(getStoryUrl(storyName, preset));
136
+ await page.goto(getStoryUrl(storyName, { ...preset, direction }));
135
137
 
136
138
  const component = createTimerButtonTestDriver(
137
139
  page.locator(componentName),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope-ui/descope-timer-button",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "exports": {
5
5
  ".": {
6
6
  "import": "./src/component/index.js"
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@descope-ui/common": "0.0.9",
23
23
  "@descope-ui/theme-globals": "0.0.9",
24
- "@descope-ui/descope-timer": "0.0.1",
24
+ "@descope-ui/descope-timer": "0.0.2",
25
25
  "@descope-ui/descope-button": "0.0.4"
26
26
  },
27
27
  "publishConfig": {
@@ -29,6 +29,7 @@ const mapButtonAttrs = {
29
29
  const timerAttrs = [
30
30
  'timer-seconds',
31
31
  'timer-hide-icon',
32
+ 'timer-paused',
32
33
  'size',
33
34
  'text-align',
34
35
  'full-width',
@@ -37,6 +38,7 @@ const timerAttrs = [
37
38
  const mapTimerAttrs = {
38
39
  'timer-seconds': 'seconds',
39
40
  'timer-hide-icon': 'hide-icon',
41
+ 'timer-paused': 'paused',
40
42
  };
41
43
 
42
44
  const BaseClass = createBaseClass({
@@ -51,7 +53,7 @@ class RawTimerButton extends BaseClass {
51
53
  this.attachShadow({ mode: 'open' }).innerHTML = `
52
54
  <div class="wrapper">
53
55
  <descope-timer class="timer"></descope-timer>
54
- <descope-button class="button">
56
+ <descope-button class="button" disabled="true">
55
57
  <slot></slot>
56
58
  </descope-button>
57
59
  </div>
@@ -97,6 +99,14 @@ class RawTimerButton extends BaseClass {
97
99
  includeAttrs: timerAttrs,
98
100
  mapAttrs: mapTimerAttrs,
99
101
  });
102
+
103
+ // When we sync attributes, the `disabled` attribute is being compared to the attribute
104
+ // on Vaadin component; since the Vaadin component has no `disabled` attribute, we sync
105
+ // that back to our component.
106
+ // This is pending a more generic fix in the way we sync attibutes.
107
+ this.button.shadowRoot
108
+ .querySelector('vaadin-button')
109
+ .setAttribute('disabled', 'true');
100
110
  }
101
111
 
102
112
  onTimerStarted() {
@@ -112,9 +122,11 @@ class RawTimerButton extends BaseClass {
112
122
  }
113
123
 
114
124
  toggleButtonDisable(isDisabled) {
115
- isDisabled
116
- ? this.button.setAttribute('disabled', 'true')
117
- : this.button.removeAttribute('disabled');
125
+ setTimeout(() => {
126
+ isDisabled
127
+ ? this.button.setAttribute('disabled', 'true')
128
+ : this.button.removeAttribute('disabled');
129
+ });
118
130
  }
119
131
  }
120
132
 
@@ -12,6 +12,7 @@ import { base64svg } from 'test-assets';
12
12
  const Template = ({
13
13
  'timer-seconds': timerSeconds,
14
14
  'timer-hide-icon': timerHideIcon,
15
+ 'timer-paused': timerPaused,
15
16
  size,
16
17
  direction,
17
18
  horizontal,
@@ -21,10 +22,12 @@ const Template = ({
21
22
  'button-mode': buttonMode,
22
23
  label,
23
24
  icon,
25
+ 'st-gap': gap,
24
26
  }) => `
25
27
  <descope-timer-button
26
28
  timer-seconds="${timerSeconds}"
27
29
  timer-hide-icon="${timerHideIcon || false}"
30
+ timer-paused="${timerPaused || false}"
28
31
  size="${size}"
29
32
  horizontal="${horizontal || false}"
30
33
  full-width="${fullWidth || false}"
@@ -32,6 +35,7 @@ const Template = ({
32
35
  button-variant="${buttonVariant}"
33
36
  button-mode="${buttonMode}"
34
37
  st-host-direction="${direction ?? ''}"
38
+ st-gap="${gap ? `${gap}px` : ''}"
35
39
  >
36
40
  ${icon ? `<descope-icon src=${base64svg}></descope-icon>` : ''}
37
41
  ${label}
@@ -66,6 +70,16 @@ export default {
66
70
  type: 'boolean',
67
71
  },
68
72
  },
73
+ 'timer-paused': {
74
+ name: 'Paused',
75
+ control: {
76
+ type: 'boolean',
77
+ },
78
+ },
79
+ 'st-gap': {
80
+ name: 'Gap',
81
+ control: { type: 'text' },
82
+ },
69
83
  icon: {
70
84
  control: { type: 'boolean' },
71
85
  },
@@ -79,6 +93,7 @@ Default.args = {
79
93
  direction: '',
80
94
  'timer-seconds': 5,
81
95
  'timer-hide-icon': false,
96
+ 'timer-paused': false,
82
97
  horizontal: false,
83
98
  'text-align': 'center',
84
99
  'button-variant': 'contained',