@brightspace-ui/core 1.220.4 → 1.222.1

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.
@@ -76,19 +76,11 @@ class CardFooterLink extends RtlMixin(LitElement) {
76
76
  return [offscreenStyles, css`
77
77
  :host {
78
78
  display: inline-block;
79
- left: 0.15rem;
80
- margin-right: 0.3rem;
81
79
  position: relative;
82
80
  }
83
81
  :host[hidden] {
84
82
  display: none;
85
83
  }
86
- :host([dir="rtl"]) {
87
- left: auto;
88
- margin-left: 0.3rem;
89
- margin-right: 0;
90
- right: 0.15rem;
91
- }
92
84
  a {
93
85
  box-sizing: border-box;
94
86
  display: inline-block;
@@ -99,13 +91,6 @@ class CardFooterLink extends RtlMixin(LitElement) {
99
91
  d2l-count-badge-icon {
100
92
  text-align: initial;
101
93
  }
102
- ::slotted(d2l-tooltip) {
103
- left: calc(-50% + 11px) !important;
104
- }
105
- :host([dir="rtl"]) ::slotted(d2l-tooltip) {
106
- left: 0;
107
- right: calc(-50% + 11px) !important;
108
- }
109
94
  `];
110
95
  }
111
96
 
@@ -29,27 +29,24 @@ class CountBadgeIcon extends CountBadgeMixin(LitElement) {
29
29
  outline: none;
30
30
  }
31
31
 
32
- .d2l-count-badge-wrapper {
33
- display: inline-block;
34
- }
35
-
36
32
  :host {
37
- padding-right: var(--d2l-count-badge-icon-padding);
38
- }
39
-
40
- :host([dir="rtl"]) {
41
- padding-left: var(--d2l-count-badge-icon-padding);
42
- padding-right: 0;
33
+ /* for long numbers, center the number on the icon */
34
+ --d2l-count-badge-icon-padding: calc(-50% + (var(--d2l-count-badge-icon-height) / 2) + 2px);
35
+ display: inline-block;
36
+ /* symmetrical padding to prevent overflows for most numbers */
37
+ padding-left: 0.5rem;
38
+ padding-right: 0.5rem;
39
+ position: relative;
43
40
  }
44
41
 
45
42
  :host([size="large"]) {
46
- --d2l-count-badge-icon-padding: calc(var(--d2l-count-badge-icon-height) - 0.7rem);
47
- margin-top: -0.7rem;
43
+ --d2l-count-badge-icon-padding-top: 0.7rem;
44
+ padding-top: var(--d2l-count-badge-icon-padding-top);
48
45
  }
49
46
 
50
47
  :host([size="small"]) {
51
- --d2l-count-badge-icon-padding: calc(var(--d2l-count-badge-icon-height) - 0.55rem);
52
- margin-top: -0.55rem;
48
+ --d2l-count-badge-icon-padding-top: 0.55rem;
49
+ padding-top: var(--d2l-count-badge-icon-padding-top);
53
50
  }
54
51
 
55
52
  :host([icon*="tier1:"]) {
@@ -63,7 +60,7 @@ class CountBadgeIcon extends CountBadgeMixin(LitElement) {
63
60
  }
64
61
 
65
62
  d2l-tooltip[_open-dir="top"] {
66
- margin-top: -0.6rem;
63
+ margin-top: calc(0px - var(--d2l-count-badge-icon-padding-top));
67
64
  }
68
65
 
69
66
  d2l-icon {
@@ -79,15 +76,30 @@ class CountBadgeIcon extends CountBadgeMixin(LitElement) {
79
76
  }
80
77
 
81
78
  render() {
82
- const numberPadding = this.size === 'small' ? '0.55rem' : '0.7rem';
83
- const numberStyles = {
79
+ let numberStyles = {
84
80
  border: '2px solid white',
85
- position: 'relative',
86
- left: this.dir === 'rtl' ? 0 : 'var(--d2l-count-badge-icon-padding)',
87
- right: this.dir === 'rtl' ? 'var(--d2l-count-badge-icon-padding)' : 0,
88
- top: numberPadding,
89
- visibility: this.skeleton ? 'hidden' : undefined
81
+ position: 'absolute',
82
+ visibility: this.skeleton ? 'hidden' : undefined,
90
83
  };
84
+
85
+ // center long number strings to prevent overflow
86
+ const centerNumber = this.getNumberString().length >= 4;
87
+
88
+ if (centerNumber) {
89
+ const xPadding = 'var(--d2l-count-badge-icon-padding)';
90
+ numberStyles = {
91
+ ... numberStyles,
92
+ transform: this.dir === 'rtl'
93
+ ? `translateY(-50%) translateX(calc(0px - ${xPadding}))`
94
+ : `translateY(-50%) translateX(${xPadding})`
95
+ };
96
+ } else {
97
+ numberStyles = {
98
+ ... numberStyles,
99
+ [this.dir === 'rtl' ? 'left' : 'right'] : '-0.1rem',
100
+ transform: 'translateY(-50%)'
101
+ };
102
+ }
91
103
  const tabbable = (this.tabStop || this.hasTooltip) && !this.skeleton;
92
104
  const innerHtml = html`
93
105
  ${this.renderCount(numberStyles)}
@@ -126,6 +126,7 @@ If the dropdown is initially empty when it's opened, the dropdown pointer will n
126
126
  | `disabled` | Boolean, default: `false` | Disables the dropdown opener |
127
127
  | `no-auto-open` | Boolean, default: `false` | Prevents the dropdown from automatically on click or on key press |
128
128
  | `open-on-hover` | Boolean, default: `false` | Optionally open dropdown on click or hover action |
129
+ | `h-align` | String | Possible values are undefined (default) or text. If text, aligns the button content to the leading edge of text |
129
130
  <!-- docs: end hidden content -->
130
131
 
131
132
  ### Accessibility Properties
@@ -17,6 +17,13 @@ class DropdownButtonSubtle extends DropdownOpenerMixin(LitElement) {
17
17
  * @type {string}
18
18
  */
19
19
  description: { type: String },
20
+
21
+ /**
22
+ * Aligns the leading edge of text if value is set to "text"
23
+ * @type {'text'|''}
24
+ */
25
+ hAlign: { type: String, reflect: true, attribute: 'h-align' },
26
+
20
27
  /**
21
28
  * REQUIRED: Text for the button
22
29
  * @type {string}
@@ -31,7 +38,7 @@ class DropdownButtonSubtle extends DropdownOpenerMixin(LitElement) {
31
38
 
32
39
  render() {
33
40
  return html`
34
- <d2l-button-subtle description="${ifDefined(this.description)}" text=${this.text} icon="tier1:chevron-down" icon-right ?disabled=${this.disabled}></d2l-button-subtle>
41
+ <d2l-button-subtle description="${ifDefined(this.description)}" h-align="${ifDefined(this.hAlign)}" text=${this.text} icon="tier1:chevron-down" icon-right ?disabled=${this.disabled}></d2l-button-subtle>
35
42
  <slot></slot>
36
43
  `;
37
44
  }
@@ -14,6 +14,8 @@ import { tryGetIfrauBackdropService } from '../../helpers/ifrauBackdropService.j
14
14
  const reduceMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
15
15
  const minBackdropHeightMobile = 42;
16
16
  const minBackdropWidthMobile = 30;
17
+ const outerMarginTopBottom = 18;
18
+ const defaultVerticalOffset = 16;
17
19
 
18
20
  export const DropdownContentMixin = superclass => class extends LocalizeCoreElement(RtlMixin(superclass)) {
19
21
 
@@ -264,6 +266,7 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
264
266
  this._hasHeader = false;
265
267
  this._hasFooter = false;
266
268
  this._showBackdrop = false;
269
+ this._verticalOffset = defaultVerticalOffset;
267
270
 
268
271
  this.__onResize = this.__onResize.bind(this);
269
272
  this.__onAutoCloseFocus = this.__onAutoCloseFocus.bind(this);
@@ -324,9 +327,10 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
324
327
  if (propName === 'verticalOffset') {
325
328
  let newVerticalOffset = parseInt(this.verticalOffset);
326
329
  if (isNaN(newVerticalOffset)) {
327
- newVerticalOffset = 20;
330
+ newVerticalOffset = defaultVerticalOffset;
328
331
  }
329
332
  this.style.setProperty('--d2l-dropdown-verticaloffset', `${newVerticalOffset}px`);
333
+ this._verticalOffset = newVerticalOffset;
330
334
  }
331
335
  });
332
336
  }
@@ -616,9 +620,9 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
616
620
  if (bounded) {
617
621
  spaceAround = this._constrainSpaceAround({
618
622
  // allow for target offset + outer margin
619
- above: targetRect.top - boundingContainerRect.top - 40,
623
+ above: targetRect.top - boundingContainerRect.top - this._verticalOffset - outerMarginTopBottom,
620
624
  // allow for target offset + outer margin
621
- below: boundingContainerRect.bottom - targetRect.bottom - 40,
625
+ below: boundingContainerRect.bottom - targetRect.bottom - this._verticalOffset - outerMarginTopBottom,
622
626
  // allow for outer margin
623
627
  left: targetRect.left - boundingContainerRect.left - 20,
624
628
  // allow for outer margin
@@ -631,9 +635,9 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
631
635
  } else {
632
636
  spaceAround = this._constrainSpaceAround({
633
637
  // allow for target offset + outer margin
634
- above: targetRect.top - 50,
638
+ above: targetRect.top - this._verticalOffset - outerMarginTopBottom,
635
639
  // allow for target offset + outer margin
636
- below: window.innerHeight - targetRect.bottom - 80,
640
+ below: window.innerHeight - targetRect.bottom - this._verticalOffset - outerMarginTopBottom,
637
641
  // allow for outer margin
638
642
  left: targetRect.left - 20,
639
643
  // allow for outer margin
@@ -16,7 +16,7 @@ export const dropdownContentStyles = css`
16
16
  left: 0;
17
17
  position: absolute;
18
18
  text-align: left;
19
- top: calc(100% + var(--d2l-dropdown-verticaloffset, 20px));
19
+ top: calc(100% + var(--d2l-dropdown-verticaloffset, 16px));
20
20
  width: 100%;
21
21
  z-index: 1000; /* position on top of floating buttons */
22
22
  }
@@ -38,7 +38,7 @@ export const dropdownContentStyles = css`
38
38
 
39
39
  :host([opened-above]) {
40
40
  animation: var(--d2l-dropdown-above-animation-name) 300ms ease;
41
- bottom: calc(100% + var(--d2l-dropdown-verticaloffset, 20px));
41
+ bottom: calc(100% + var(--d2l-dropdown-verticaloffset, 16px));
42
42
  top: auto;
43
43
  }
44
44
 
@@ -49,7 +49,7 @@ export const dropdownContentStyles = css`
49
49
 
50
50
  :host([data-mobile][opened-above]:not([mobile-tray])) {
51
51
  animation: var(--d2l-dropdown-above-animation-name) 300ms ease;
52
- bottom: calc(100% + var(--d2l-dropdown-verticaloffset, 20px));
52
+ bottom: calc(100% + var(--d2l-dropdown-verticaloffset, 16px));
53
53
  top: auto;
54
54
  }
55
55
 
@@ -1686,6 +1686,11 @@
1686
1686
  "description": "A description to be added to the opener button for accessibility when text on button does not provide enough context",
1687
1687
  "type": "string"
1688
1688
  },
1689
+ {
1690
+ "name": "h-align",
1691
+ "description": "Aligns the leading edge of text if value is set to \"text\"",
1692
+ "type": "'text'|''"
1693
+ },
1689
1694
  {
1690
1695
  "name": "text",
1691
1696
  "description": "REQUIRED: Text for the button",
@@ -1717,6 +1722,12 @@
1717
1722
  "description": "A description to be added to the opener button for accessibility when text on button does not provide enough context",
1718
1723
  "type": "string"
1719
1724
  },
1725
+ {
1726
+ "name": "hAlign",
1727
+ "attribute": "h-align",
1728
+ "description": "Aligns the leading edge of text if value is set to \"text\"",
1729
+ "type": "'text'|''"
1730
+ },
1720
1731
  {
1721
1732
  "name": "text",
1722
1733
  "attribute": "text",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "1.220.4",
3
+ "version": "1.222.1",
4
4
  "description": "A collection of accessible, free, open-source web components for building Brightspace applications",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/BrightspaceUI/core.git",