@cfpb/cfpb-design-system 5.2.0 → 5.3.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 +70 -1
- package/dist/index.css +1 -1
- package/dist/index.js +1761 -1708
- package/package.json +1 -1
- package/src/elements/abstracts/custom-props.css +2 -1
- package/src/elements/abstracts/vars.css +1 -6
- package/src/elements/base/base.scss +3 -0
- package/src/elements/base/font.scss +1 -1
- package/src/elements/cfpb-button/cfpb-button.scss +1 -1
- package/src/elements/cfpb-button/index.js +1 -1
- package/src/elements/cfpb-checkbox-icon/index.js +1 -1
- package/src/elements/cfpb-expandable/index.js +6 -8
- package/src/elements/cfpb-expandable/{cfpb-expandable.component.scss → styles.component.scss} +1 -1
- package/src/elements/cfpb-file-upload/index.js +1 -1
- package/src/elements/cfpb-file-upload/styles.component.css +7 -0
- package/src/elements/cfpb-flag-usa/index.js +1 -1
- package/src/elements/cfpb-flag-usa/{cfpb-flag-usa.component.scss → styles.component.css} +2 -2
- package/src/elements/cfpb-form-alert/index.js +21 -11
- package/src/elements/cfpb-form-alert/styles.component.scss +14 -0
- package/src/elements/cfpb-form-choice/index.js +1 -1
- package/src/elements/cfpb-form-choice/{cfpb-form-choice.component.scss → styles.component.scss} +5 -6
- package/src/elements/cfpb-form-search/index.js +5 -5
- package/src/elements/cfpb-form-search/skeleton.css +8 -0
- package/src/elements/cfpb-form-search/{cfpb-form-search.component.scss → styles.component.scss} +3 -3
- package/src/elements/cfpb-form-search-input/index.js +6 -9
- package/src/elements/cfpb-form-search-input/{cfpb-form-search-input.component.scss → styles.component.scss} +6 -8
- package/src/elements/cfpb-icon/index.js +43 -0
- package/src/elements/cfpb-icon/styles.component.css +48 -0
- package/src/elements/cfpb-icon-text/index.js +1 -1
- package/src/elements/cfpb-icon-text/{cfpb-icon-text.component.scss → styles.component.scss} +2 -3
- package/src/elements/cfpb-label/index.js +1 -1
- package/src/elements/cfpb-label/{cfpb-label.component.scss → styles.component.scss} +5 -5
- package/src/elements/{cfpb-list → cfpb-listbox}/index.js +10 -9
- package/src/elements/{cfpb-list → cfpb-listbox}/index.spec.js +9 -9
- package/src/elements/{cfpb-list/cfpb-list.component.scss → cfpb-listbox/styles.component.scss} +1 -5
- package/src/elements/{cfpb-list-item → cfpb-listbox-item}/index.js +5 -5
- package/src/elements/{cfpb-list-item/cfpb-list-item.component.scss → cfpb-listbox-item/styles.component.scss} +2 -2
- package/src/elements/cfpb-pagination/index.js +6 -5
- package/src/elements/cfpb-pagination/{cfpb-pagination.component.scss → styles.component.scss} +6 -6
- package/src/elements/cfpb-select/index.js +9 -12
- package/src/elements/cfpb-select/multiple-select-event-proxy.js +2 -2
- package/src/elements/cfpb-select/single-select-event-proxy.js +1 -1
- package/src/elements/cfpb-select/{cfpb-select.component.scss → styles.component.scss} +5 -6
- package/src/elements/cfpb-tag-filter/index.js +1 -1
- package/src/elements/cfpb-tag-filter/{cfpb-tag-filter.component.scss → styles.component.scss} +6 -8
- package/src/elements/cfpb-tag-group/index.js +1 -1
- package/src/elements/cfpb-tag-group/{cfpb-tag-group.component.scss → styles.component.scss} +3 -4
- package/src/elements/cfpb-tag-topic/index.js +1 -1
- package/src/elements/cfpb-tag-topic/{cfpb-tag-topic.component.scss → styles.component.scss} +2 -2
- package/src/elements/cfpb-tagline/index.js +1 -1
- package/src/elements/cfpb-tagline/skeleton.css +7 -0
- package/src/elements/cfpb-tagline/{cfpb-tagline.component.scss → styles.component.scss} +3 -4
- package/src/elements/cfpb-utilities/fallback/wc-fallback.css +31 -0
- package/src/elements/cfpb-utilities/fallback/wc-fallback.js +65 -0
- package/src/elements/cfpb-utilities/shared-config.js +41 -0
- package/src/elements/cfpb-utilities/skeleton.css +33 -0
- package/src/elements/cfpb-utilities/transition/{transition.scss → transition.css} +11 -11
- package/src/elements/index.js +11 -2
- package/src/index.js +1 -5
- package/src/index.scss +1 -1
- package/src/tokens/abstracts/custom-props.json +13 -1
- package/src/utilities/functions.scss +20 -0
- package/src/elements/base/index.js +0 -2
- package/src/elements/cfpb-file-upload/cfpb-file-upload.component.scss +0 -10
- package/src/elements/cfpb-form-alert/cfpb-form-alert.component.scss +0 -36
- /package/src/elements/cfpb-button/{cfpb-button.component.scss → styles.component.scss} +0 -0
- /package/src/elements/cfpb-checkbox-icon/{cfpb-checkbox-icon.component.scss → styles.component.scss} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { LitElement, html, css, unsafeCSS } from 'lit';
|
|
2
2
|
import { ref, createRef } from 'lit/directives/ref.js';
|
|
3
|
-
import styles from './
|
|
4
|
-
import {
|
|
3
|
+
import styles from './styles.component.scss?inline';
|
|
4
|
+
import { CfpbListboxItem } from '../cfpb-listbox-item';
|
|
5
5
|
import { parseChildData } from '../cfpb-utilities/parse-child-data';
|
|
6
6
|
|
|
7
|
-
export class
|
|
7
|
+
export class CfpbListbox extends LitElement {
|
|
8
8
|
static styles = css`
|
|
9
9
|
${unsafeCSS(styles)}
|
|
10
10
|
`;
|
|
@@ -84,7 +84,7 @@ export class CfpbList extends LitElement {
|
|
|
84
84
|
|
|
85
85
|
let firstChecked = null;
|
|
86
86
|
itemsArray.forEach((data) => {
|
|
87
|
-
const item = document.createElement('cfpb-
|
|
87
|
+
const item = document.createElement('cfpb-listbox-item');
|
|
88
88
|
item.textContent = data.value ?? '';
|
|
89
89
|
if ('disabled' in data) item.disabled = data.disabled;
|
|
90
90
|
if ('hidden' in data) item.hidden = data.hidden;
|
|
@@ -109,7 +109,7 @@ export class CfpbList extends LitElement {
|
|
|
109
109
|
// -------------------------
|
|
110
110
|
#syncItems() {
|
|
111
111
|
// Collect items.
|
|
112
|
-
this.#items = [...this.querySelectorAll('cfpb-
|
|
112
|
+
this.#items = [...this.querySelectorAll('cfpb-listbox-item')];
|
|
113
113
|
|
|
114
114
|
// Ensure each item has a type.
|
|
115
115
|
this.#items.forEach((item) => {
|
|
@@ -187,7 +187,7 @@ export class CfpbList extends LitElement {
|
|
|
187
187
|
#applyTypeToItems() {
|
|
188
188
|
if (!['plain', 'check', 'checkbox'].includes(this.type)) {
|
|
189
189
|
// eslint-disable-next-line no-console
|
|
190
|
-
console.warn(`<cfpb-
|
|
190
|
+
console.warn(`<cfpb-listbox>: invalid type "${this.type}".`);
|
|
191
191
|
return;
|
|
192
192
|
}
|
|
193
193
|
this.#items.forEach((item) => (item.type = this.type));
|
|
@@ -372,9 +372,10 @@ export class CfpbList extends LitElement {
|
|
|
372
372
|
}
|
|
373
373
|
|
|
374
374
|
static init() {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
375
|
+
CfpbListboxItem.init();
|
|
376
|
+
|
|
377
|
+
if (!window.customElements.get('cfpb-listbox')) {
|
|
378
|
+
window.customElements.define('cfpb-listbox', CfpbListbox);
|
|
378
379
|
}
|
|
379
380
|
}
|
|
380
381
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jest } from '@jest/globals';
|
|
2
|
-
import {
|
|
2
|
+
import { CfpbListbox } from './index';
|
|
3
3
|
|
|
4
4
|
beforeAll(() => {
|
|
5
|
-
|
|
5
|
+
CfpbListbox.init();
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
-
describe('<cfpb-
|
|
8
|
+
describe('<cfpb-listbox> tests', () => {
|
|
9
9
|
let list;
|
|
10
10
|
|
|
11
11
|
beforeEach(() => {
|
|
12
|
-
list = document.createElement('cfpb-
|
|
12
|
+
list = document.createElement('cfpb-listbox');
|
|
13
13
|
document.body.appendChild(list);
|
|
14
14
|
});
|
|
15
15
|
|
|
@@ -123,7 +123,7 @@ describe('<cfpb-list> tests', () => {
|
|
|
123
123
|
|
|
124
124
|
const container = list.shadowRoot.querySelector('div');
|
|
125
125
|
container.focus();
|
|
126
|
-
expect(document.activeElement.tagName).toBe('CFPB-
|
|
126
|
+
expect(document.activeElement.tagName).toBe('CFPB-LISTBOX');
|
|
127
127
|
|
|
128
128
|
// ArrowDown → first visible
|
|
129
129
|
container.dispatchEvent(
|
|
@@ -141,7 +141,7 @@ describe('<cfpb-list> tests', () => {
|
|
|
141
141
|
container.dispatchEvent(
|
|
142
142
|
new KeyboardEvent('keydown', { key: 'ArrowUp', bubbles: true }),
|
|
143
143
|
);
|
|
144
|
-
expect(document.activeElement.tagName).toBe('CFPB-
|
|
144
|
+
expect(document.activeElement.tagName).toBe('CFPB-LISTBOX');
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
test('showAllItems unhides all items', async () => {
|
|
@@ -173,21 +173,21 @@ describe('<cfpb-list> tests', () => {
|
|
|
173
173
|
list.childData = JSON.stringify([{ value: 'A' }, { value: 'B' }]);
|
|
174
174
|
await list.updateComplete;
|
|
175
175
|
list.focusItemAt(-1);
|
|
176
|
-
expect(document.activeElement.tagName).toBe('CFPB-
|
|
176
|
+
expect(document.activeElement.tagName).toBe('CFPB-LISTBOX');
|
|
177
177
|
});
|
|
178
178
|
|
|
179
179
|
test('focusItemAt(null) focuses the container', async () => {
|
|
180
180
|
list.childData = JSON.stringify([{ value: 'A' }]);
|
|
181
181
|
await list.updateComplete;
|
|
182
182
|
list.focusItemAt(null);
|
|
183
|
-
expect(document.activeElement.tagName).toBe('CFPB-
|
|
183
|
+
expect(document.activeElement.tagName).toBe('CFPB-LISTBOX');
|
|
184
184
|
});
|
|
185
185
|
|
|
186
186
|
test('focusItemAt(undefined) focuses the container', async () => {
|
|
187
187
|
list.childData = JSON.stringify([{ value: 'A' }]);
|
|
188
188
|
await list.updateComplete;
|
|
189
189
|
list.focusItemAt(undefined);
|
|
190
|
-
expect(document.activeElement.tagName).toBe('CFPB-
|
|
190
|
+
expect(document.activeElement.tagName).toBe('CFPB-LISTBOX');
|
|
191
191
|
});
|
|
192
192
|
|
|
193
193
|
test('ArrowDown from container focuses first visible item', async () => {
|
package/src/elements/{cfpb-list/cfpb-list.component.scss → cfpb-listbox/styles.component.scss}
RENAMED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
@use 'sass:math';
|
|
2
|
-
@use '@cfpb/cfpb-design-system/src/elements/abstracts' as *;
|
|
3
|
-
@use '@cfpb/cfpb-design-system/src/components/cfpb-icons/icon';
|
|
4
|
-
|
|
5
1
|
:host {
|
|
6
|
-
::slotted(cfpb-
|
|
2
|
+
::slotted(cfpb-listbox-item) {
|
|
7
3
|
position: relative;
|
|
8
4
|
margin-top: 1px;
|
|
9
5
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { LitElement, html, css, unsafeCSS } from 'lit';
|
|
2
|
-
import styles from './
|
|
2
|
+
import styles from './styles.component.scss?inline';
|
|
3
3
|
import { ref, createRef } from 'lit/directives/ref.js';
|
|
4
4
|
import { CfpbCheckboxIcon } from '../cfpb-checkbox-icon';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @element cfpb-
|
|
7
|
+
* @element cfpb-listbox-item.
|
|
8
8
|
* @slot - The text for the list item.
|
|
9
9
|
*/
|
|
10
|
-
export class
|
|
10
|
+
export class CfpbListboxItem extends LitElement {
|
|
11
11
|
static styles = css`
|
|
12
12
|
${unsafeCSS(styles)}
|
|
13
13
|
`;
|
|
@@ -208,8 +208,8 @@ export class CfpbListItem extends LitElement {
|
|
|
208
208
|
static init() {
|
|
209
209
|
CfpbCheckboxIcon.init();
|
|
210
210
|
|
|
211
|
-
if (!window.customElements.get('cfpb-
|
|
212
|
-
window.customElements.define('cfpb-
|
|
211
|
+
if (!window.customElements.get('cfpb-listbox-item')) {
|
|
212
|
+
window.customElements.define('cfpb-listbox-item', CfpbListboxItem);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
@use 'sass:math';
|
|
2
1
|
@use '@cfpb/cfpb-design-system/src/elements/abstracts' as *;
|
|
3
2
|
@use '@cfpb/cfpb-design-system/src/components/cfpb-icons/icons-lib' as *;
|
|
3
|
+
@use '../../utilities/functions' as *;
|
|
4
4
|
|
|
5
5
|
:host {
|
|
6
6
|
// Theme variables.
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
display: inline-grid;
|
|
19
19
|
|
|
20
20
|
// 30px is width of checkbox/radio button plus the needed padding.
|
|
21
|
-
grid-template-columns:
|
|
21
|
+
grid-template-columns: rem-from-px(30px) auto;
|
|
22
22
|
vertical-align: top;
|
|
23
23
|
|
|
24
24
|
// Wrap long words in narrow form fields to prevent clipping
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { LitElement, html, css, unsafeCSS } from 'lit';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { leftIcon, rightIcon } from '../../components/cfpb-icons/icons-lib.js';
|
|
2
|
+
import styles from './styles.component.scss?inline';
|
|
3
|
+
import { CfpbIcon } from '../cfpb-icon';
|
|
5
4
|
import { I18nService, MediaQueryService } from '../cfpb-utilities/';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -153,7 +152,7 @@ export class CfpbPagination extends LitElement {
|
|
|
153
152
|
?disabled=${this.isAtMin}
|
|
154
153
|
@click=${() => this.#goto(this.currentPage - 1)}
|
|
155
154
|
>
|
|
156
|
-
|
|
155
|
+
<cfpb-icon name="left" color="white"></cfpb-icon> ${trans('next')}
|
|
157
156
|
</cfpb-button>
|
|
158
157
|
|
|
159
158
|
<form
|
|
@@ -193,13 +192,15 @@ export class CfpbPagination extends LitElement {
|
|
|
193
192
|
?disabled=${this.isAtMax}
|
|
194
193
|
@click=${() => this.#goto(this.currentPage + 1)}
|
|
195
194
|
>
|
|
196
|
-
${trans('previous')}
|
|
195
|
+
${trans('previous')}
|
|
196
|
+
<cfpb-icon name="right" color="white"></cfpb-icon>
|
|
197
197
|
</cfpb-button>
|
|
198
198
|
</nav>
|
|
199
199
|
`;
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
static init() {
|
|
203
|
+
CfpbIcon.init();
|
|
203
204
|
I18nService.init();
|
|
204
205
|
|
|
205
206
|
window.customElements.get('cfpb-pagination') ||
|
package/src/elements/cfpb-pagination/{cfpb-pagination.component.scss → styles.component.scss}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
@use 'sass:math';
|
|
2
1
|
@use '@cfpb/cfpb-design-system/src/elements/abstracts' as *;
|
|
3
2
|
@use '@cfpb/cfpb-design-system/src/utilities' as *;
|
|
4
3
|
@use '@cfpb/cfpb-design-system/src/components/cfpb-icons/icon' as *;
|
|
4
|
+
@use '../../utilities/functions' as *;
|
|
5
5
|
|
|
6
6
|
:host {
|
|
7
7
|
width: 100%;
|
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
grid-template-areas:
|
|
13
13
|
'pag-btn-prev . pag-btn-next'
|
|
14
14
|
'pag-form pag-form pag-form';
|
|
15
|
-
row-gap:
|
|
15
|
+
row-gap: rem-from-px(15px);
|
|
16
16
|
|
|
17
17
|
&__form {
|
|
18
18
|
grid-area: pag-form;
|
|
19
19
|
display: flex;
|
|
20
20
|
flex-flow: wrap;
|
|
21
21
|
place-content: center;
|
|
22
|
-
gap:
|
|
22
|
+
gap: rem-from-px(10px);
|
|
23
23
|
|
|
24
|
-
padding:
|
|
25
|
-
border-radius:
|
|
24
|
+
padding: rem-from-px(5px);
|
|
25
|
+
border-radius: rem-from-px(4px);
|
|
26
26
|
background: var(--gray-5);
|
|
27
27
|
color: var(--gray);
|
|
28
28
|
}
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
&__current-page {
|
|
31
31
|
// 45px is a magic number to provide enough room for three digits
|
|
32
32
|
// and the number spinners for type="number" inputs on desktop
|
|
33
|
-
width:
|
|
33
|
+
width: rem-from-px(45px);
|
|
34
34
|
|
|
35
35
|
font-weight: 500;
|
|
36
36
|
text-align: right;
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { html, LitElement, css, unsafeCSS, nothing } from 'lit';
|
|
2
2
|
import { ref, createRef } from 'lit/directives/ref.js';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
downIcon as expandIcon,
|
|
7
|
-
upIcon as collapseIcon,
|
|
8
|
-
} from '../../components/cfpb-icons/icons-lib.js';
|
|
3
|
+
import styles from './styles.component.scss?inline';
|
|
4
|
+
import { CfpbIcon } from '../cfpb-icon';
|
|
9
5
|
import { CfpbFormSearchInput } from '../cfpb-form-search-input';
|
|
10
6
|
import { SearchService } from '../cfpb-utilities/search-service.js';
|
|
11
7
|
import { MaxHeightTransition } from '../../utilities/transition/max-height-transition';
|
|
12
8
|
import { FlyoutMenu } from '../../utilities/behavior/flyout-menu';
|
|
13
|
-
import {
|
|
9
|
+
import { CfpbListbox } from '../cfpb-listbox';
|
|
14
10
|
import { CfpbTagGroup } from '../cfpb-tag-group';
|
|
15
11
|
|
|
16
12
|
import { SingleSelectEventProxy } from './single-select-event-proxy.js';
|
|
@@ -314,11 +310,11 @@ export class CfpbSelect extends LitElement {
|
|
|
314
310
|
@click=${this.#onClick}
|
|
315
311
|
>
|
|
316
312
|
<span class="o-select__cue-open" role="img" aria-label="Show">
|
|
317
|
-
|
|
313
|
+
<cfpb-icon name="down"></cfpb-icon>
|
|
318
314
|
<span class="u-visually-hidden">Show</span>
|
|
319
315
|
</span>
|
|
320
316
|
<span class="o-select__cue-close" role="img" aria-label="Hide">
|
|
321
|
-
|
|
317
|
+
<cfpb-icon name="up"></cfpb-icon>
|
|
322
318
|
<span class="u-visually-hidden">Hide</span>
|
|
323
319
|
</span>
|
|
324
320
|
</button>
|
|
@@ -327,7 +323,7 @@ export class CfpbSelect extends LitElement {
|
|
|
327
323
|
data-js-hook="behavior_flyout-menu_content"
|
|
328
324
|
${ref(this.#contentDom)}
|
|
329
325
|
>
|
|
330
|
-
<cfpb-
|
|
326
|
+
<cfpb-listbox
|
|
331
327
|
tabindex=${this.#noResults ? '-1' : '0'}
|
|
332
328
|
@item-click=${this.#onItemClick}
|
|
333
329
|
?multiple=${this.multiple}
|
|
@@ -338,7 +334,7 @@ export class CfpbSelect extends LitElement {
|
|
|
338
334
|
: 'Choose an item…'}
|
|
339
335
|
${ref(this.#list)}
|
|
340
336
|
>
|
|
341
|
-
</cfpb-
|
|
337
|
+
</cfpb-listbox>
|
|
342
338
|
<div class=${this.#noResults ? 'no-results' : 'u-hidden'}>
|
|
343
339
|
No results found
|
|
344
340
|
</div>
|
|
@@ -373,8 +369,9 @@ export class CfpbSelect extends LitElement {
|
|
|
373
369
|
}
|
|
374
370
|
|
|
375
371
|
static init() {
|
|
372
|
+
CfpbIcon.init();
|
|
376
373
|
CfpbFormSearchInput.init();
|
|
377
|
-
|
|
374
|
+
CfpbListbox.init();
|
|
378
375
|
CfpbTagGroup.init();
|
|
379
376
|
|
|
380
377
|
window.customElements.get('cfpb-select') ||
|
|
@@ -11,7 +11,7 @@ export class MultipleSelectEventProxy {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
onBlur() {
|
|
14
|
-
// In multiselect, blur happens when inside the
|
|
14
|
+
// In multiselect, blur happens when inside the listbox, so we ignore any
|
|
15
15
|
// blur actions.
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -72,7 +72,7 @@ export class MultipleSelectEventProxy {
|
|
|
72
72
|
host.isExpanded = !host.isExpanded;
|
|
73
73
|
break;
|
|
74
74
|
}
|
|
75
|
-
} else if (focused === 'CFPB-
|
|
75
|
+
} else if (focused === 'CFPB-LISTBOX-ITEM') {
|
|
76
76
|
switch (evt.key) {
|
|
77
77
|
case 'Tab':
|
|
78
78
|
if (evt.shiftKey) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
@use 'sass:math';
|
|
2
|
-
@use '@cfpb/cfpb-design-system/src/elements/abstracts' as *;
|
|
3
1
|
@use '@cfpb/cfpb-design-system/src/elements/base' as *;
|
|
4
2
|
@use '@cfpb/cfpb-design-system/src/utilities' as *;
|
|
5
3
|
@use '@cfpb/cfpb-design-system/src/components/cfpb-icons/icon';
|
|
6
|
-
@use '../cfpb-utilities/transition/transition.
|
|
4
|
+
@use '../cfpb-utilities/transition/transition.css' as *;
|
|
5
|
+
@use '../../utilities/functions' as *;
|
|
7
6
|
|
|
8
7
|
:host {
|
|
9
8
|
// Theme
|
|
@@ -51,7 +50,7 @@
|
|
|
51
50
|
button {
|
|
52
51
|
// This line-height settings is larger than base.scss to
|
|
53
52
|
// accommodate the SVG height.
|
|
54
|
-
line-height:
|
|
53
|
+
line-height: unitless-from-px(21px);
|
|
55
54
|
|
|
56
55
|
// Remove default focus ring.
|
|
57
56
|
outline: none;
|
|
@@ -133,7 +132,7 @@
|
|
|
133
132
|
justify-content: space-between;
|
|
134
133
|
align-items: center;
|
|
135
134
|
gap: 10px;
|
|
136
|
-
padding-left:
|
|
135
|
+
padding-left: rem-from-px(10px);
|
|
137
136
|
|
|
138
137
|
cursor: pointer;
|
|
139
138
|
}
|
|
@@ -151,7 +150,7 @@
|
|
|
151
150
|
padding: 0;
|
|
152
151
|
|
|
153
152
|
&::after {
|
|
154
|
-
padding-bottom:
|
|
153
|
+
padding-bottom: rem-from-px(15px);
|
|
155
154
|
width: 100%;
|
|
156
155
|
}
|
|
157
156
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LitElement, html, css, unsafeCSS } from 'lit';
|
|
2
2
|
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
3
|
-
import styles from './
|
|
3
|
+
import styles from './styles.component.scss?inline';
|
|
4
4
|
import { errorIcon as icon } from '../../components/cfpb-icons/icons-lib';
|
|
5
5
|
|
|
6
6
|
/**
|
package/src/elements/cfpb-tag-filter/{cfpb-tag-filter.component.scss → styles.component.scss}
RENAMED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
@use '
|
|
2
|
-
@use '@cfpb/cfpb-design-system/src/elements/abstracts' as *;
|
|
3
|
-
@use '@cfpb/cfpb-design-system/src/elements/cfpb-button/vars' as *;
|
|
1
|
+
@use '../../utilities/functions' as *;
|
|
4
2
|
|
|
5
3
|
:host {
|
|
6
4
|
button {
|
|
7
5
|
// This line-height isn't 19 or 22, as 20 creates a 30px high tag.
|
|
8
|
-
line-height:
|
|
6
|
+
line-height: unitless-from-px(20px);
|
|
9
7
|
|
|
10
8
|
// Filter tags appear in filtered contexts, often as part of multiselects.
|
|
11
|
-
font-size:
|
|
9
|
+
font-size: rem-from-px(16px);
|
|
12
10
|
|
|
13
11
|
display: flex;
|
|
14
|
-
gap:
|
|
12
|
+
gap: rem-from-px(10px);
|
|
15
13
|
align-items: center;
|
|
16
14
|
|
|
17
15
|
border: 1px solid var(--teal);
|
|
18
16
|
padding: 4px 6px;
|
|
19
17
|
background-color: var(--teal-20);
|
|
20
|
-
border-radius:
|
|
18
|
+
border-radius: rem-from-px(3px);
|
|
21
19
|
color: var(--black);
|
|
22
20
|
text-align: left;
|
|
23
21
|
min-width: fit-content;
|
|
@@ -43,7 +41,7 @@
|
|
|
43
41
|
// Prevent flexbox from squishing icon when tag text is long.
|
|
44
42
|
flex: none;
|
|
45
43
|
|
|
46
|
-
height:
|
|
44
|
+
height: rem-from-px(19px);
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
// If the contents are wrapped in a label, negate the label's display.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LitElement, html, css, unsafeCSS } from 'lit';
|
|
2
|
-
import styles from './
|
|
2
|
+
import styles from './styles.component.scss?inline';
|
|
3
3
|
import { parseChildData } from '../cfpb-utilities/parse-child-data';
|
|
4
4
|
|
|
5
5
|
const SUPPORTED_TAG_LIST = ['CFPB-TAG-FILTER', 'CFPB-TAG-TOPIC'];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
@use 'sass:math';
|
|
2
1
|
@use '@cfpb/cfpb-design-system/src/elements/abstracts' as *;
|
|
3
|
-
@use '
|
|
2
|
+
@use '../../utilities/functions' as *;
|
|
4
3
|
|
|
5
4
|
:host {
|
|
6
5
|
// Tag group sets the spacing between tags.
|
|
@@ -17,7 +16,7 @@
|
|
|
17
16
|
// Tablet and above.
|
|
18
17
|
@include respond-to-min($bp-sm-min) {
|
|
19
18
|
display: flex;
|
|
20
|
-
gap:
|
|
19
|
+
gap: rem-from-px(15px);
|
|
21
20
|
flex-wrap: wrap;
|
|
22
21
|
|
|
23
22
|
&[stacked] {
|
|
@@ -28,7 +27,7 @@
|
|
|
28
27
|
|
|
29
28
|
&:has(cfpb-tag-filter) {
|
|
30
29
|
display: flex;
|
|
31
|
-
gap:
|
|
30
|
+
gap: rem-from-px(15px);
|
|
32
31
|
flex-wrap: wrap;
|
|
33
32
|
}
|
|
34
33
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
@use 'sass:math';
|
|
2
1
|
@use '@cfpb/cfpb-design-system/src/elements/base' as *;
|
|
3
2
|
@use '@cfpb/cfpb-design-system/src/elements/abstracts' as *;
|
|
4
3
|
@use '@cfpb/cfpb-design-system/src/utilities' as *;
|
|
5
4
|
@use '@cfpb/cfpb-design-system/src/components/cfpb-typography/mixins' as *;
|
|
5
|
+
@use '../../utilities/functions' as *;
|
|
6
6
|
|
|
7
7
|
:host {
|
|
8
8
|
// Topic tags
|
|
9
9
|
.a-tag-topic {
|
|
10
10
|
text-decoration: none;
|
|
11
11
|
display: flex;
|
|
12
|
-
gap:
|
|
12
|
+
gap: rem-from-px(5px);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
@include u-jump-link(
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
@use '
|
|
2
|
-
@use '@cfpb/cfpb-design-system/src/elements/abstracts' as *;
|
|
1
|
+
@use '../../utilities/functions' as *;
|
|
3
2
|
|
|
4
3
|
:host {
|
|
5
4
|
.a-tagline {
|
|
6
|
-
font-size:
|
|
5
|
+
font-size: rem-from-px(12px);
|
|
7
6
|
|
|
8
7
|
display: grid;
|
|
9
8
|
grid-template-columns: 22px 1fr;
|
|
@@ -19,7 +18,7 @@
|
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
&--large {
|
|
22
|
-
font-size:
|
|
21
|
+
font-size: rem-from-px(16px);
|
|
23
22
|
|
|
24
23
|
& cfpb-flag-usa {
|
|
25
24
|
margin-top: 4px;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This fallback CSS assumes a web component that contains a <noscript> fallback,
|
|
3
|
+
as well as author-supplied content, and separately has a script to swap the
|
|
4
|
+
<noscript> with `<div class="fallback">` if JS is enabled, but the web component
|
|
5
|
+
definition is not defined.
|
|
6
|
+
|
|
7
|
+
Ex.
|
|
8
|
+
|
|
9
|
+
<cfpb-example-btn hasfallback>
|
|
10
|
+
<!-- author-supplied no-js fallback -->
|
|
11
|
+
<noscript><button>Click this basic button!</button>
|
|
12
|
+
|
|
13
|
+
<!-- author-supplied slotted content -->
|
|
14
|
+
Click this fancy button!
|
|
15
|
+
</cfpb-example-btn>
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/* 1. If JS is disabled, hide everything except <noscript> */
|
|
19
|
+
[hasfallback] > :not(noscript) {
|
|
20
|
+
display: none;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* 2. If JS is enabled, but web component definition is not defined, show fallback. */
|
|
24
|
+
[hasfallback] > .fallback {
|
|
25
|
+
display: block;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* 3. If JS is enabled and web component definition is defined, operate as normal. */
|
|
29
|
+
[hasfallback]:defined > :not(noscript) {
|
|
30
|
+
display: block;
|
|
31
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This utility IIFE function can be added to a page with web components
|
|
3
|
+
* to support the display of any fallback content in `<noscript>` tags
|
|
4
|
+
* that would otherwise not appear if JavaScript was enabled, but
|
|
5
|
+
* the Web Component APIs were not supported.
|
|
6
|
+
*/
|
|
7
|
+
(function () {
|
|
8
|
+
/**
|
|
9
|
+
* Within a custom element (web component),
|
|
10
|
+
* convert any `<noscript>` tags into `<div class="fallback">`,
|
|
11
|
+
* so that the fallback content appears in environments where
|
|
12
|
+
* JavaScript is enabled, but web component APIs are not supported.
|
|
13
|
+
* @param {HTMLElement} el - A custom element.
|
|
14
|
+
*/
|
|
15
|
+
function applyFallback(el) {
|
|
16
|
+
if (!el) return;
|
|
17
|
+
|
|
18
|
+
const tag = el.tagName.toLowerCase();
|
|
19
|
+
const isDefined = !!customElements.get(tag);
|
|
20
|
+
const noscript = el.querySelector('noscript');
|
|
21
|
+
|
|
22
|
+
// Only act if the element is NOT defined and there is a <noscript>
|
|
23
|
+
if (!isDefined && noscript) {
|
|
24
|
+
// Create a <div> with the fallback content.
|
|
25
|
+
const fallbackDiv = document.createElement('div');
|
|
26
|
+
fallbackDiv.className = 'fallback';
|
|
27
|
+
fallbackDiv.innerHTML = noscript.innerHTML;
|
|
28
|
+
|
|
29
|
+
// Insert fallback at the top.
|
|
30
|
+
el.insertBefore(fallbackDiv, el.firstChild);
|
|
31
|
+
|
|
32
|
+
// Hide the original <noscript> to avoid duplicates.
|
|
33
|
+
noscript.style.display = 'none';
|
|
34
|
+
|
|
35
|
+
/*
|
|
36
|
+
// Hide other non-fallback children (optional; wc-fallback.css handles this).
|
|
37
|
+
Array.from(el.children).forEach((child) => {
|
|
38
|
+
if (child !== fallbackDiv && child !== noscript) {
|
|
39
|
+
child.style.display = 'none';
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
*/
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Query the document for custom elements that have the "fallback" attribute,
|
|
48
|
+
* e.g. <my-custom-btn fallback>
|
|
49
|
+
* @param {string} selector - The CSS selector to search for on the page.
|
|
50
|
+
*/
|
|
51
|
+
function applyAllFallbacks(selector = '[fallback]') {
|
|
52
|
+
document.querySelectorAll(selector).forEach((el) => applyFallback(el));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Check for browser support of the Web Component APIs.
|
|
56
|
+
const supportsWC =
|
|
57
|
+
'customElements' in window &&
|
|
58
|
+
'attachShadow' in Element.prototype &&
|
|
59
|
+
'content' in document.createElement('template');
|
|
60
|
+
|
|
61
|
+
// Only run the fallback utility script globally if web components are NOT supported.
|
|
62
|
+
if (!supportsWC) {
|
|
63
|
+
document.addEventListener('DOMContentLoaded', applyAllFallbacks);
|
|
64
|
+
}
|
|
65
|
+
})();
|