@momentum-design/components 0.97.0 → 0.98.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.
@@ -12,15 +12,14 @@ declare const Card_base: import("../../utils/mixins/index.types").Constructor<im
12
12
  * - Subtitle
13
13
  * - Body
14
14
  *
15
- * The card can either be vertically or horizontally oriented.
15
+ * The card can either be vertically or horizontally oriented. The vertical card has a min-width of 20rem and the horizontal card has a min-width of 40rem.
16
16
  *
17
17
  * There are 2 variants for the card that represent the border styling - 'border' and 'ghost'.
18
18
  *
19
19
  * To make this card interactive, use the following slots:
20
20
  * - `icon-button`: This slot supports action icon buttons in the header section (maximum of 3 buttons).
21
21
  * - `footer-link`: This slot is for passing `mdc-link` component within the footer section.
22
- * - `footer-button-primary`: This slot is for passing primary variant of
23
- * `mdc-button` component within the footer section.
22
+ * - `footer-button-primary`: This slot is for passing primary variant of `mdc-button` component within the footer section.
24
23
  * - `footer-button-secondary`: This slot is for passing secondary variant of `mdc-button` component
25
24
  * within the footer section.
26
25
  *
@@ -37,14 +36,23 @@ declare const Card_base: import("../../utils/mixins/index.types").Constructor<im
37
36
  * @slot footer - This slot is for passing custom footer content. Only use this if really needed,
38
37
  * using the footer-link and footer-button slots is preferred.
39
38
  *
39
+ * @csspart header - The header part of the card
40
+ * @csspart icon - The icon part of the card header
41
+ * @csspart body - The body part of the card
42
+ * @csspart image - The image part of the card
43
+ * @csspart footer - The footer part of the card
44
+ * @csspart footer-link - The link part of the card footer
45
+ * @csspart footer-button-primary - The primary button part of the card footer
46
+ * @csspart footer-button-secondary - The secondary button part of the card footer
47
+ * @csspart icon-button - The icon button part of the card header
48
+ * @csspart text - The text part of the card
49
+ *
40
50
  * @tagname mdc-card
41
51
  *
42
52
  * @dependency mdc-icon
43
53
  * @dependency mdc-text
44
54
  *
45
- * @slot before-body - This slot is for passing the content before the body
46
- * @slot body - This slot is for passing the text content for the card
47
- * @slot after-body - This slot is for passing the content after the body
55
+ * @cssproperty --mdc-card-width - The width of the card
48
56
  *
49
57
  */
50
58
  declare class Card extends Card_base {
@@ -26,15 +26,14 @@ import styles from './card.styles';
26
26
  * - Subtitle
27
27
  * - Body
28
28
  *
29
- * The card can either be vertically or horizontally oriented.
29
+ * The card can either be vertically or horizontally oriented. The vertical card has a min-width of 20rem and the horizontal card has a min-width of 40rem.
30
30
  *
31
31
  * There are 2 variants for the card that represent the border styling - 'border' and 'ghost'.
32
32
  *
33
33
  * To make this card interactive, use the following slots:
34
34
  * - `icon-button`: This slot supports action icon buttons in the header section (maximum of 3 buttons).
35
35
  * - `footer-link`: This slot is for passing `mdc-link` component within the footer section.
36
- * - `footer-button-primary`: This slot is for passing primary variant of
37
- * `mdc-button` component within the footer section.
36
+ * - `footer-button-primary`: This slot is for passing primary variant of `mdc-button` component within the footer section.
38
37
  * - `footer-button-secondary`: This slot is for passing secondary variant of `mdc-button` component
39
38
  * within the footer section.
40
39
  *
@@ -51,14 +50,23 @@ import styles from './card.styles';
51
50
  * @slot footer - This slot is for passing custom footer content. Only use this if really needed,
52
51
  * using the footer-link and footer-button slots is preferred.
53
52
  *
53
+ * @csspart header - The header part of the card
54
+ * @csspart icon - The icon part of the card header
55
+ * @csspart body - The body part of the card
56
+ * @csspart image - The image part of the card
57
+ * @csspart footer - The footer part of the card
58
+ * @csspart footer-link - The link part of the card footer
59
+ * @csspart footer-button-primary - The primary button part of the card footer
60
+ * @csspart footer-button-secondary - The secondary button part of the card footer
61
+ * @csspart icon-button - The icon button part of the card header
62
+ * @csspart text - The text part of the card
63
+ *
54
64
  * @tagname mdc-card
55
65
  *
56
66
  * @dependency mdc-icon
57
67
  * @dependency mdc-text
58
68
  *
59
- * @slot before-body - This slot is for passing the content before the body
60
- * @slot body - This slot is for passing the text content for the card
61
- * @slot after-body - This slot is for passing the content after the body
69
+ * @cssproperty --mdc-card-width - The width of the card
62
70
  *
63
71
  */
64
72
  class Card extends CardComponentMixin(FooterMixin(Component)) {
@@ -72,20 +80,11 @@ class Card extends CardComponentMixin(FooterMixin(Component)) {
72
80
  this.handleIconButtons = () => {
73
81
  var _a;
74
82
  (_a = this.iconButtons) === null || _a === void 0 ? void 0 : _a.forEach(element => {
75
- if (!element.matches(DEFAULTS.BUTTON) && element.getAttribute('data-btn-type') !== 'icon') {
76
- element.remove();
77
- }
78
- else {
83
+ if (element.matches(DEFAULTS.BUTTON)) {
79
84
  element.setAttribute('variant', BUTTON_VARIANTS.TERTIARY);
80
85
  element.setAttribute('size', '32');
81
86
  }
82
87
  });
83
- // limit to show only first 3 buttons defined in the slot
84
- if (this.iconButtons && this.iconButtons.length > 3) {
85
- for (let i = 3; i < this.iconButtons.length; i += 1) {
86
- this.iconButtons[i].remove();
87
- }
88
- }
89
88
  };
90
89
  }
91
90
  update(changedProperties) {
@@ -112,9 +111,11 @@ class Card extends CardComponentMixin(FooterMixin(Component)) {
112
111
  ${this.renderImage()}
113
112
  <div part="body">
114
113
  ${this.renderHeader()}
115
- <slot name="before-body"></slot>
116
- <slot name="body"></slot>
117
- <slot name="after-body"></slot>
114
+ <div part="text-content">
115
+ <slot name="before-body"></slot>
116
+ <slot name="body"></slot>
117
+ <slot name="after-body"></slot>
118
+ </div>
118
119
  ${this.renderFooter()}
119
120
  </div>
120
121
  `;
@@ -2,25 +2,31 @@ import { css } from 'lit';
2
2
  import { hostFitContentStyles } from '../../utils/styles';
3
3
  const styles = css `
4
4
  :host {
5
+ --mdc-card-width: 20rem;
5
6
  align-items: flex-start;
6
7
  border-radius: 0.5rem;
7
8
  border: 1px solid var(--mds-color-theme-outline-primary-normal);
8
9
  box-shadow: none;
9
10
  transition: box-shadow 0.2s;
11
+ width: var(--mdc-card-width);
10
12
  }
13
+
11
14
  :host([variant='ghost']) {
12
15
  border-color: transparent;
13
16
  }
17
+
14
18
  :host([orientation='horizontal']) {
15
- max-width: 40rem;
19
+ min-width: 40rem;
20
+ --mdc-card-width: 40rem;
16
21
  }
17
22
 
18
23
  :host([orientation='vertical']) {
19
- max-width: 20rem;
24
+ min-width: 20rem;
20
25
  flex-direction: column;
21
26
  }
22
27
 
23
28
  :host([orientation='vertical'])::part(image) {
29
+ object-fit: cover;
24
30
  height: 12.5rem;
25
31
  width: 100%;
26
32
  border-top-left-radius: 0.5rem;
@@ -28,12 +34,19 @@ const styles = css `
28
34
  }
29
35
 
30
36
  :host([orientation='horizontal'])::part(image) {
37
+ object-fit: cover;
31
38
  width: 10rem;
32
39
  height: 100%;
33
40
  border-top-left-radius: 0.5rem;
34
41
  border-bottom-left-radius: 0.5rem;
35
42
  }
36
43
 
44
+ :host::part(text-content) {
45
+ display: flex;
46
+ flex-direction: column;
47
+ flex-grow: 1;
48
+ }
49
+
37
50
  :host::part(header) {
38
51
  display: flex;
39
52
  gap: 0.5rem;
@@ -45,6 +58,7 @@ const styles = css `
45
58
 
46
59
  :host::part(body) {
47
60
  width: 100%;
61
+ height: inherit;
48
62
  padding: 1.5rem;
49
63
  display: flex;
50
64
  flex-direction: column;
@@ -81,6 +95,11 @@ const styles = css `
81
95
  gap: 1rem;
82
96
  }
83
97
 
98
+ ::slotted([slot='before-body']),
99
+ ::slotted([slot='after-body']) {
100
+ margin-top: 1rem;
101
+ }
102
+
84
103
  ::slotted([slot='footer-link']),
85
104
  ::slotted([slot='footer-button-primary']),
86
105
  ::slotted([slot='footer-button-secondary']) {
@@ -12,10 +12,6 @@ declare const CardButton_base: import("../../utils/mixins/index.types").Construc
12
12
  * @dependency mdc-icon
13
13
  * @dependency mdc-text
14
14
  *
15
- * @slot before-body - This slot is for passing the content before the body
16
- * @slot body - This slot is for passing the text content for the card
17
- * @slot after-body - This slot is for passing the content after the body
18
- *
19
15
  * @event click - (React: onClick) Event that gets dispatched when the card is clicked.
20
16
  * @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the card.
21
17
  * It fires the click event when enter key is used.
@@ -23,6 +19,24 @@ declare const CardButton_base: import("../../utils/mixins/index.types").Construc
23
19
  * It fires the click event when space key is used.
24
20
  * @event focus - (React: onFocus) Event that gets dispatched when the card receives focus.
25
21
  *
22
+ * @slot before-body - This slot is for passing the content before the body
23
+ * @slot body - This slot is for passing the text content for the card
24
+ * @slot after-body - This slot is for passing the content after the body
25
+ * @slot footer-link - This slot is for passing `mdc-link` component within the footer section.
26
+ * @slot footer-button-primary - This slot is for passing primary variant of `mdc-button` component within the footer section.
27
+ *
28
+ * @csspart header - The header part of the card
29
+ * @csspart icon - The icon part of the card header
30
+ * @csspart body - The body part of the card
31
+ * @csspart image - The image part of the card
32
+ * @csspart footer - The footer part of the card
33
+ * @csspart footer-link - The link part of the card footer
34
+ * @csspart footer-button-primary - The primary button part of the card footer
35
+ * @csspart footer-button-secondary - The secondary button part of the card footer
36
+ * @csspart icon-button - The icon button part of the card header
37
+ * @csspart text - The text part of the card
38
+ *
39
+ * @cssproperty --mdc-card-width - The width of the card
26
40
  */
27
41
  declare class CardButton extends CardButton_base {
28
42
  connectedCallback(): void;
@@ -14,10 +14,6 @@ import styles from './cardbutton.styles';
14
14
  * @dependency mdc-icon
15
15
  * @dependency mdc-text
16
16
  *
17
- * @slot before-body - This slot is for passing the content before the body
18
- * @slot body - This slot is for passing the text content for the card
19
- * @slot after-body - This slot is for passing the content after the body
20
- *
21
17
  * @event click - (React: onClick) Event that gets dispatched when the card is clicked.
22
18
  * @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the card.
23
19
  * It fires the click event when enter key is used.
@@ -25,6 +21,24 @@ import styles from './cardbutton.styles';
25
21
  * It fires the click event when space key is used.
26
22
  * @event focus - (React: onFocus) Event that gets dispatched when the card receives focus.
27
23
  *
24
+ * @slot before-body - This slot is for passing the content before the body
25
+ * @slot body - This slot is for passing the text content for the card
26
+ * @slot after-body - This slot is for passing the content after the body
27
+ * @slot footer-link - This slot is for passing `mdc-link` component within the footer section.
28
+ * @slot footer-button-primary - This slot is for passing primary variant of `mdc-button` component within the footer section.
29
+ *
30
+ * @csspart header - The header part of the card
31
+ * @csspart icon - The icon part of the card header
32
+ * @csspart body - The body part of the card
33
+ * @csspart image - The image part of the card
34
+ * @csspart footer - The footer part of the card
35
+ * @csspart footer-link - The link part of the card footer
36
+ * @csspart footer-button-primary - The primary button part of the card footer
37
+ * @csspart footer-button-secondary - The secondary button part of the card footer
38
+ * @csspart icon-button - The icon button part of the card header
39
+ * @csspart text - The text part of the card
40
+ *
41
+ * @cssproperty --mdc-card-width - The width of the card
28
42
  */
29
43
  class CardButton extends CardComponentMixin(Buttonsimple) {
30
44
  connectedCallback() {
@@ -22,6 +22,24 @@ declare const CardCheckbox_base: import("../../utils/mixins/index.types").Constr
22
22
  * @slot before-body - This slot is for passing the content before the body
23
23
  * @slot body - This slot is for passing the text content for the card
24
24
  * @slot after-body - This slot is for passing the content after the body
25
+ * @slot footer-link - This slot is for passing `mdc-link` component within the footer section.
26
+ * @slot footer-button-primary - This slot is for passing primary variant of `mdc-button` component within the footer section.
27
+ *
28
+ * @csspart header - The header part of the card
29
+ * @csspart icon - The icon part of the card header
30
+ * @csspart body - The body part of the card
31
+ * @csspart image - The image part of the card
32
+ * @csspart footer - The footer part of the card
33
+ * @csspart footer-link - The link part of the card footer
34
+ * @csspart footer-button-primary - The primary button part of the card footer
35
+ * @csspart footer-button-secondary - The secondary button part of the card footer
36
+ * @csspart icon-button - The icon button part of the card header
37
+ * @csspart text - The text part of the card
38
+ * @csspart check - The check part of the card
39
+ * @csspart check-icon - The check icon part of the card
40
+ * @csspart check-icon-button - The check icon button part of the card
41
+ *
42
+ * @cssproperty --mdc-card-width - The width of the card
25
43
  *
26
44
  * @event click - (React: onClick) Event that gets dispatched when the card is clicked. It toggles the checked state.
27
45
  * @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the card.
@@ -36,6 +36,24 @@ import styles from './cardcheckbox.styles';
36
36
  * @slot before-body - This slot is for passing the content before the body
37
37
  * @slot body - This slot is for passing the text content for the card
38
38
  * @slot after-body - This slot is for passing the content after the body
39
+ * @slot footer-link - This slot is for passing `mdc-link` component within the footer section.
40
+ * @slot footer-button-primary - This slot is for passing primary variant of `mdc-button` component within the footer section.
41
+ *
42
+ * @csspart header - The header part of the card
43
+ * @csspart icon - The icon part of the card header
44
+ * @csspart body - The body part of the card
45
+ * @csspart image - The image part of the card
46
+ * @csspart footer - The footer part of the card
47
+ * @csspart footer-link - The link part of the card footer
48
+ * @csspart footer-button-primary - The primary button part of the card footer
49
+ * @csspart footer-button-secondary - The secondary button part of the card footer
50
+ * @csspart icon-button - The icon button part of the card header
51
+ * @csspart text - The text part of the card
52
+ * @csspart check - The check part of the card
53
+ * @csspart check-icon - The check icon part of the card
54
+ * @csspart check-icon-button - The check icon button part of the card
55
+ *
56
+ * @cssproperty --mdc-card-width - The width of the card
39
57
  *
40
58
  * @event click - (React: onClick) Event that gets dispatched when the card is clicked. It toggles the checked state.
41
59
  * @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the card.
@@ -21,6 +21,24 @@ declare const CardRadio_base: import("../../utils/mixins/index.types").Construct
21
21
  * @slot before-body - This slot is for passing the content before the body
22
22
  * @slot body - This slot is for passing the text content for the card
23
23
  * @slot after-body - This slot is for passing the content after the body
24
+ * @slot footer-link - This slot is for passing `mdc-link` component within the footer section.
25
+ * @slot footer-button-primary - This slot is for passing primary variant of `mdc-button` component within the footer section.
26
+ *
27
+ * @csspart header - The header part of the card
28
+ * @csspart icon - The icon part of the card header
29
+ * @csspart body - The body part of the card
30
+ * @csspart image - The image part of the card
31
+ * @csspart footer - The footer part of the card
32
+ * @csspart footer-link - The link part of the card footer
33
+ * @csspart footer-button-primary - The primary button part of the card footer
34
+ * @csspart footer-button-secondary - The secondary button part of the card footer
35
+ * @csspart icon-button - The icon button part of the card header
36
+ * @csspart text - The text part of the card
37
+ * @csspart check - The check part of the card
38
+ * @csspart check-icon - The check icon part of the card
39
+ * @csspart check-icon-button - The check icon button part of the card
40
+ *
41
+ * @cssproperty --mdc-card-width - The width of the card
24
42
  *
25
43
  * @event click - (React: onClick) Event that gets dispatched when the card is clicked. It toggles the checked state.
26
44
  * @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the card.
@@ -36,6 +36,24 @@ import styles from './cardradio.styles';
36
36
  * @slot before-body - This slot is for passing the content before the body
37
37
  * @slot body - This slot is for passing the text content for the card
38
38
  * @slot after-body - This slot is for passing the content after the body
39
+ * @slot footer-link - This slot is for passing `mdc-link` component within the footer section.
40
+ * @slot footer-button-primary - This slot is for passing primary variant of `mdc-button` component within the footer section.
41
+ *
42
+ * @csspart header - The header part of the card
43
+ * @csspart icon - The icon part of the card header
44
+ * @csspart body - The body part of the card
45
+ * @csspart image - The image part of the card
46
+ * @csspart footer - The footer part of the card
47
+ * @csspart footer-link - The link part of the card footer
48
+ * @csspart footer-button-primary - The primary button part of the card footer
49
+ * @csspart footer-button-secondary - The secondary button part of the card footer
50
+ * @csspart icon-button - The icon button part of the card header
51
+ * @csspart text - The text part of the card
52
+ * @csspart check - The check part of the card
53
+ * @csspart check-icon - The check icon part of the card
54
+ * @csspart check-icon-button - The check icon button part of the card
55
+ *
56
+ * @cssproperty --mdc-card-width - The width of the card
39
57
  *
40
58
  * @event click - (React: onClick) Event that gets dispatched when the card is clicked. It toggles the checked state.
41
59
  * @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the card.