@ons/design-system 60.0.0 → 60.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.
@@ -2,7 +2,9 @@ $pagination-item-padding: 0.5rem;
2
2
  $pagination-item-width: 2.5rem;
3
3
 
4
4
  .ons-pagination {
5
- $ctx: &;
5
+ &__position {
6
+ margin: 0 0 0.4rem;
7
+ }
6
8
 
7
9
  &__items {
8
10
  margin: 0 $pagination-item-padding * -1;
@@ -25,6 +27,12 @@ $pagination-item-width: 2.5rem;
25
27
  }
26
28
  }
27
29
 
30
+ &__items > & {
31
+ &__item--current {
32
+ margin: 0 0 0 $pagination-item-padding;
33
+ }
34
+ }
35
+
28
36
  &__item,
29
37
  &__link {
30
38
  height: $pagination-item-width;
@@ -43,7 +51,7 @@ $pagination-item-width: 2.5rem;
43
51
  }
44
52
 
45
53
  &__item--current &__link {
46
- background: var(--ons-color-text-link-hover);
54
+ background: var(--ons-color-text-link-active);
47
55
  color: var(--ons-color-white);
48
56
  outline: 2px solid transparent; // Add transparent outline because Windows High Contrast Mode doesn't show backgrounds
49
57
  text-decoration: none;
@@ -53,8 +53,7 @@
53
53
  "id": radio.other.id,
54
54
  "name": radio.other.name,
55
55
  "type": radio.other.type,
56
- "required": radio.other.required,
57
- "classes": ("ons-input--error " if params.error else "") + radio.other.classes | default(''),
56
+ "classes": ("ons-input--error " if params.error and radio.checked else "") + radio.other.classes | default(''),
58
57
  "width": radio.other.width | default('auto'),
59
58
  "attributes": radio.other.attributes,
60
59
  "label": {
@@ -73,7 +72,7 @@
73
72
  "id": radio.other.id,
74
73
  "name": radio.other.name,
75
74
  "options": radio.other.options,
76
- "classes": ("ons-input--error " if params.error else "") + radio.other.classes | default(''),
75
+ "classes": ("ons-input--error " if params.error and radio.checked else "") + radio.other.classes | default(''),
77
76
  "label": {
78
77
  "id": radio.other.id + "-label",
79
78
  "text": radio.other.label.text,
@@ -35,7 +35,6 @@ const EXAMPLE_RADIO_ITEM_INPUT = {
35
35
  label: {
36
36
  text: 'Enter your own answer',
37
37
  },
38
- required: false,
39
38
  classes: 'extra-textbox-class',
40
39
  width: 42,
41
40
  value: '42',
@@ -462,7 +461,6 @@ describe('macro: radios', () => {
462
461
  text: 'Enter your own answer',
463
462
  classes: 'ons-u-fw-n',
464
463
  },
465
- required: false,
466
464
  classes: 'extra-textbox-class',
467
465
  width: 42,
468
466
  attributes: EXAMPLE_RADIO_ITEM_INPUT.other.attributes,
@@ -93,8 +93,8 @@ $hub-row-spacing: 1.3rem;
93
93
  &__spacer {
94
94
  background: var(--ons-color-black);
95
95
  display: inline-block;
96
- height: 1rem;
97
- margin: 0 0.25rem;
96
+ height: 1.15rem;
97
+ margin: 0.18rem 0.25rem 0;
98
98
  vertical-align: middle;
99
99
  width: 1px;
100
100
  }
@@ -81,8 +81,9 @@ export default class Tabs {
81
81
  this.hideTab(tab);
82
82
  });
83
83
 
84
- if (!this.noInitialActiveTab) {
85
- const activeTab = this.getTab(window.location.hash) || this.tabs[0];
84
+ const hashTab = this.getTab(window.location.hash);
85
+ if (!this.noInitialActiveTab || !!hashTab) {
86
+ const activeTab = hashTab || this.tabs[0];
86
87
  this.showTab(activeTab);
87
88
  }
88
89
 
@@ -138,6 +138,39 @@ describe('script: tabs', () => {
138
138
  });
139
139
  });
140
140
 
141
+ describe('when a hash for a tab is in the url', () => {
142
+ beforeEach(async () => {
143
+ await setViewport(page, { width: 1650, height: 1050 });
144
+ await setTestPage('/test#tab.id.2', renderComponent('tabs', EXAMPLE_TABS));
145
+ });
146
+
147
+ it('is assigned a "tabindex" value', async () => {
148
+ const tabIndexValues = await page.$$eval('.ons-tab', nodes => nodes.map(node => node.getAttribute('tabindex')));
149
+
150
+ expect(tabIndexValues).toEqual(['-1', '0', '-1']);
151
+ });
152
+
153
+ it('has the "aria-selected" attribute', async () => {
154
+ const ariaSelectedValue = await page.$eval('a[href="#tab.id.2"]', node => node.getAttribute('aria-selected'));
155
+
156
+ expect(ariaSelectedValue).toBe('true');
157
+ });
158
+
159
+ it('has the "ons-tab--selected" class assigned', async () => {
160
+ const hasClass = await page.$eval('a[href="#tab.id.2"]', node => node.classList.contains('ons-tab--selected'));
161
+
162
+ expect(hasClass).toBe(true);
163
+ });
164
+
165
+ it('shows the corresponding panel', async () => {
166
+ const panelHiddenStates = await page.$$eval('.ons-tabs__panel', nodes =>
167
+ nodes.map(node => node.classList.contains('ons-tabs__panel--hidden')),
168
+ );
169
+
170
+ expect(panelHiddenStates).toEqual([true, false, true]);
171
+ });
172
+ });
173
+
141
174
  describe('when the viewport is small', () => {
142
175
  beforeEach(async () => {
143
176
  await page.emulate(puppeteer.devices['iPhone X']);
@@ -168,7 +201,7 @@ describe('script: tabs', () => {
168
201
  });
169
202
  });
170
203
 
171
- describe('when `data-no-initial-active-tab` is not present', () => {
204
+ describe('when `data-no-initial-active-tab` is present', () => {
172
205
  beforeEach(async () => {
173
206
  await setViewport(page, { width: 1650, height: 1050 });
174
207
  await setTestPage('/test', renderComponent('tabs', EXAMPLE_TABS_WITH_NO_INITIAL_ACTIVE_TAB));
@@ -253,4 +286,37 @@ describe('script: tabs', () => {
253
286
  });
254
287
  });
255
288
  });
289
+
290
+ describe('when a hash for a tab is in the url and `data-no-initial-active-tab` is present', () => {
291
+ beforeEach(async () => {
292
+ await setViewport(page, { width: 1650, height: 1050 });
293
+ await setTestPage('/test#tab.id.2', renderComponent('tabs', EXAMPLE_TABS_WITH_NO_INITIAL_ACTIVE_TAB));
294
+ });
295
+
296
+ it('is assigned a "tabindex" value', async () => {
297
+ const tabIndexValues = await page.$$eval('.ons-tab', nodes => nodes.map(node => node.getAttribute('tabindex')));
298
+
299
+ expect(tabIndexValues).toEqual(['-1', '0', '-1']);
300
+ });
301
+
302
+ it('has the "aria-selected" attribute', async () => {
303
+ const ariaSelectedValue = await page.$eval('a[href="#tab.id.2"]', node => node.getAttribute('aria-selected'));
304
+
305
+ expect(ariaSelectedValue).toBe('true');
306
+ });
307
+
308
+ it('has the "ons-tab--selected" class assigned', async () => {
309
+ const hasClass = await page.$eval('a[href="#tab.id.2"]', node => node.classList.contains('ons-tab--selected'));
310
+
311
+ expect(hasClass).toBe(true);
312
+ });
313
+
314
+ it('shows the corresponding panel', async () => {
315
+ const panelHiddenStates = await page.$$eval('.ons-tabs__panel', nodes =>
316
+ nodes.map(node => node.classList.contains('ons-tabs__panel--hidden')),
317
+ );
318
+
319
+ expect(panelHiddenStates).toEqual([true, false, true]);
320
+ });
321
+ });
256
322
  });