@momentum-design/components 0.62.2 → 0.62.4
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/dist/browser/index.js +804 -536
- package/dist/browser/index.js.map +4 -4
- package/dist/components/card/card.component.d.ts +100 -0
- package/dist/components/card/card.component.js +197 -0
- package/dist/components/card/card.constants.d.ts +22 -0
- package/dist/components/card/card.constants.js +26 -0
- package/dist/components/card/card.styles.d.ts +2 -0
- package/dist/components/card/card.styles.js +79 -0
- package/dist/components/card/card.types.d.ts +5 -0
- package/dist/components/card/card.types.js +1 -0
- package/dist/components/card/index.d.ts +9 -0
- package/dist/components/card/index.js +6 -0
- package/dist/components/cardbutton/cardbutton.component.d.ts +37 -0
- package/dist/components/cardbutton/cardbutton.component.js +61 -0
- package/dist/components/cardbutton/cardbutton.constants.d.ts +2 -0
- package/dist/components/cardbutton/cardbutton.constants.js +3 -0
- package/dist/components/cardbutton/cardbutton.styles.d.ts +2 -0
- package/dist/components/cardbutton/cardbutton.styles.js +26 -0
- package/dist/components/cardbutton/cardbutton.types.d.ts +7 -0
- package/dist/components/cardbutton/cardbutton.types.js +1 -0
- package/dist/components/cardbutton/index.d.ts +9 -0
- package/dist/components/cardbutton/index.js +6 -0
- package/dist/components/cardcheckbox/cardcheckbox.component.d.ts +76 -0
- package/dist/components/cardcheckbox/cardcheckbox.component.js +159 -0
- package/dist/components/cardcheckbox/cardcheckbox.constants.d.ts +15 -0
- package/dist/components/cardcheckbox/cardcheckbox.constants.js +16 -0
- package/dist/components/cardcheckbox/cardcheckbox.styles.d.ts +2 -0
- package/dist/components/cardcheckbox/cardcheckbox.styles.js +57 -0
- package/dist/components/cardcheckbox/cardcheckbox.types.d.ts +11 -0
- package/dist/components/cardcheckbox/cardcheckbox.types.js +1 -0
- package/dist/components/cardcheckbox/index.d.ts +10 -0
- package/dist/components/cardcheckbox/index.js +7 -0
- package/dist/components/cardradio/cardradio.component.d.ts +76 -0
- package/dist/components/cardradio/cardradio.component.js +155 -0
- package/dist/components/cardradio/cardradio.constants.d.ts +2 -0
- package/dist/components/cardradio/cardradio.constants.js +3 -0
- package/dist/components/cardradio/cardradio.styles.d.ts +2 -0
- package/dist/components/cardradio/cardradio.styles.js +53 -0
- package/dist/components/cardradio/cardradio.types.d.ts +8 -0
- package/dist/components/cardradio/cardradio.types.js +1 -0
- package/dist/components/cardradio/index.d.ts +10 -0
- package/dist/components/cardradio/index.js +7 -0
- package/dist/components/listitem/index.d.ts +1 -1
- package/dist/components/listitem/index.js +1 -1
- package/dist/components/listitem/listitem.component.d.ts +4 -4
- package/dist/components/listitem/listitem.component.js +2 -2
- package/dist/components/menuitem/index.d.ts +8 -0
- package/dist/components/menuitem/index.js +5 -0
- package/dist/components/menuitem/menuitem.component.d.ts +25 -0
- package/dist/components/menuitem/menuitem.component.js +29 -0
- package/dist/components/menuitem/menuitem.constants.d.ts +2 -0
- package/dist/components/menuitem/menuitem.constants.js +3 -0
- package/dist/components/menuitem/menuitem.types.d.ts +6 -0
- package/dist/components/menuitem/menuitem.types.js +1 -0
- package/dist/components/option/option.component.js +0 -4
- package/dist/components/radiogroup/radiogroup.component.js +2 -1
- package/dist/custom-elements.json +6221 -3340
- package/dist/index.d.ts +12 -7
- package/dist/index.js +12 -7
- package/dist/react/card/index.d.ts +47 -0
- package/dist/react/card/index.js +56 -0
- package/dist/react/cardbutton/index.d.ts +32 -0
- package/dist/react/cardbutton/index.js +40 -0
- package/dist/react/cardcheckbox/index.d.ts +40 -0
- package/dist/react/cardcheckbox/index.js +48 -0
- package/dist/react/cardradio/index.d.ts +40 -0
- package/dist/react/cardradio/index.js +48 -0
- package/dist/react/index.d.ts +7 -2
- package/dist/react/index.js +7 -2
- package/dist/react/menuitem/index.d.ts +27 -0
- package/dist/react/menuitem/index.js +35 -0
- package/dist/utils/mixins/CardComponentMixin.d.ts +20 -0
- package/dist/utils/mixins/CardComponentMixin.js +130 -0
- package/package.json +1 -1
@@ -0,0 +1,100 @@
|
|
1
|
+
import { CSSResult, nothing, PropertyValues } from 'lit';
|
2
|
+
import { Component } from '../../models';
|
3
|
+
declare const Card_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/CardComponentMixin").CardComponentMixinInterface> & typeof Component;
|
4
|
+
/**
|
5
|
+
* The card component allows users to organize information in a structured and tangible
|
6
|
+
* format that is visually appealing. `mdc-card` is a static component that supports
|
7
|
+
* the following features:
|
8
|
+
* - Image
|
9
|
+
* - Header
|
10
|
+
* - Icon
|
11
|
+
* - Title
|
12
|
+
* - Subtitle
|
13
|
+
* - Body
|
14
|
+
*
|
15
|
+
* The card can either be vertically or horizontally oriented.
|
16
|
+
*
|
17
|
+
* There are 2 variants for the card that represent the border styling - 'border' and 'ghost'.
|
18
|
+
*
|
19
|
+
* To make this card interactive, use the following slots:
|
20
|
+
* - `icon-button`: This slot supports action icon buttons in the header section (maximum of 3 buttons).
|
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.
|
24
|
+
* - `footer-button-secondary`: This slot is for passing secondary variant of `mdc-button` component
|
25
|
+
* within the footer section.
|
26
|
+
*
|
27
|
+
* Interactive card additionally supports 'promotional' variant that represents the border styling - 'promotional'.
|
28
|
+
*
|
29
|
+
* @slot before-body - This slot is for passing the content before the body
|
30
|
+
* @slot body - This slot is for passing the text content for the card
|
31
|
+
* @slot after-body - This slot is for passing the content after the body
|
32
|
+
* @slot footer-link - This slot is for passing `mdc-link` component within the footer section.
|
33
|
+
* @slot footer-button-primary - This slot is for passing primary variant of
|
34
|
+
* `mdc-button` component within the footer section.
|
35
|
+
* @slot footer-button-secondary - This slot is for passing secondary variant of `mdc-button` component
|
36
|
+
* within the footer section.
|
37
|
+
*
|
38
|
+
* @tagname mdc-card
|
39
|
+
*
|
40
|
+
* @dependency mdc-icon
|
41
|
+
* @dependency mdc-text
|
42
|
+
*
|
43
|
+
* @slot before-body - This slot is for passing the content before the body
|
44
|
+
* @slot body - This slot is for passing the text content for the card
|
45
|
+
* @slot after-body - This slot is for passing the content after the body
|
46
|
+
*
|
47
|
+
*/
|
48
|
+
declare class Card extends Card_base {
|
49
|
+
/**
|
50
|
+
* The icon buttons in the header section
|
51
|
+
* @internal
|
52
|
+
*/
|
53
|
+
iconButtons?: Array<HTMLElement>;
|
54
|
+
/**
|
55
|
+
* The links in the footer section
|
56
|
+
* @internal
|
57
|
+
*/
|
58
|
+
footerLink?: Array<HTMLElement>;
|
59
|
+
/**
|
60
|
+
* The primary buttons in the footer section
|
61
|
+
* @internal
|
62
|
+
*/
|
63
|
+
footerButtonPrimary?: Array<HTMLElement>;
|
64
|
+
/**
|
65
|
+
* The secondary buttons in the footer section
|
66
|
+
* @internal
|
67
|
+
*/
|
68
|
+
footerButtonSecondary?: Array<HTMLElement>;
|
69
|
+
update(changedProperties: PropertyValues<Card>): void;
|
70
|
+
/**
|
71
|
+
* Handles the icon buttons in the header section and sets its variant for styling.
|
72
|
+
* It also limits the number of buttons to 3.
|
73
|
+
* @internal
|
74
|
+
*/
|
75
|
+
private handleIconButtons;
|
76
|
+
/**
|
77
|
+
* Filters and renders only the following content into the footer section and removes anything other than it
|
78
|
+
* - One mdc-link element in the footer-link slot
|
79
|
+
* - One secondary variant of the mdc-button element in the footer-button-secondary slot
|
80
|
+
* - One primary variant of the mdc-button element in the footer-button-primary slot
|
81
|
+
*
|
82
|
+
* @internal
|
83
|
+
*/
|
84
|
+
private handleFooterSlot;
|
85
|
+
/**
|
86
|
+
* Updates the color of the footer buttons based on the variant.
|
87
|
+
* If the variant is promotional, the color is promotional, else default.
|
88
|
+
*
|
89
|
+
* @internal
|
90
|
+
*/
|
91
|
+
private updateFooterButtonColors;
|
92
|
+
/**
|
93
|
+
* Renders the header of the card if title is provided
|
94
|
+
* @returns The header element
|
95
|
+
*/
|
96
|
+
protected renderHeader(): import("lit-html").TemplateResult<1> | typeof nothing;
|
97
|
+
render(): import("lit-html").TemplateResult<1>;
|
98
|
+
static styles: Array<CSSResult>;
|
99
|
+
}
|
100
|
+
export default Card;
|
@@ -0,0 +1,197 @@
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
|
+
};
|
10
|
+
import { html, nothing } from 'lit';
|
11
|
+
import { queryAssignedElements } from 'lit/decorators.js';
|
12
|
+
import styles from './card.styles';
|
13
|
+
import { Component } from '../../models';
|
14
|
+
import { VARIANTS, DEFAULTS } from './card.constants';
|
15
|
+
import { BUTTON_COLORS, BUTTON_VARIANTS } from '../button/button.constants';
|
16
|
+
import { CardComponentMixin } from '../../utils/mixins/CardComponentMixin';
|
17
|
+
/**
|
18
|
+
* The card component allows users to organize information in a structured and tangible
|
19
|
+
* format that is visually appealing. `mdc-card` is a static component that supports
|
20
|
+
* the following features:
|
21
|
+
* - Image
|
22
|
+
* - Header
|
23
|
+
* - Icon
|
24
|
+
* - Title
|
25
|
+
* - Subtitle
|
26
|
+
* - Body
|
27
|
+
*
|
28
|
+
* The card can either be vertically or horizontally oriented.
|
29
|
+
*
|
30
|
+
* There are 2 variants for the card that represent the border styling - 'border' and 'ghost'.
|
31
|
+
*
|
32
|
+
* To make this card interactive, use the following slots:
|
33
|
+
* - `icon-button`: This slot supports action icon buttons in the header section (maximum of 3 buttons).
|
34
|
+
* - `footer-link`: This slot is for passing `mdc-link` component within the footer section.
|
35
|
+
* - `footer-button-primary`: This slot is for passing primary variant of
|
36
|
+
* `mdc-button` component within the footer section.
|
37
|
+
* - `footer-button-secondary`: This slot is for passing secondary variant of `mdc-button` component
|
38
|
+
* within the footer section.
|
39
|
+
*
|
40
|
+
* Interactive card additionally supports 'promotional' variant that represents the border styling - 'promotional'.
|
41
|
+
*
|
42
|
+
* @slot before-body - This slot is for passing the content before the body
|
43
|
+
* @slot body - This slot is for passing the text content for the card
|
44
|
+
* @slot after-body - This slot is for passing the content after the body
|
45
|
+
* @slot footer-link - This slot is for passing `mdc-link` component within the footer section.
|
46
|
+
* @slot footer-button-primary - This slot is for passing primary variant of
|
47
|
+
* `mdc-button` component within the footer section.
|
48
|
+
* @slot footer-button-secondary - This slot is for passing secondary variant of `mdc-button` component
|
49
|
+
* within the footer section.
|
50
|
+
*
|
51
|
+
* @tagname mdc-card
|
52
|
+
*
|
53
|
+
* @dependency mdc-icon
|
54
|
+
* @dependency mdc-text
|
55
|
+
*
|
56
|
+
* @slot before-body - This slot is for passing the content before the body
|
57
|
+
* @slot body - This slot is for passing the text content for the card
|
58
|
+
* @slot after-body - This slot is for passing the content after the body
|
59
|
+
*
|
60
|
+
*/
|
61
|
+
class Card extends CardComponentMixin(Component) {
|
62
|
+
constructor() {
|
63
|
+
super(...arguments);
|
64
|
+
/**
|
65
|
+
* Handles the icon buttons in the header section and sets its variant for styling.
|
66
|
+
* It also limits the number of buttons to 3.
|
67
|
+
* @internal
|
68
|
+
*/
|
69
|
+
this.handleIconButtons = () => {
|
70
|
+
var _a;
|
71
|
+
(_a = this.iconButtons) === null || _a === void 0 ? void 0 : _a.forEach((element) => {
|
72
|
+
if (!element.matches(DEFAULTS.BUTTON) && element.getAttribute('data-btn-type') !== 'icon') {
|
73
|
+
element.remove();
|
74
|
+
}
|
75
|
+
else {
|
76
|
+
element.setAttribute('variant', BUTTON_VARIANTS.TERTIARY);
|
77
|
+
element.setAttribute('size', '32');
|
78
|
+
}
|
79
|
+
});
|
80
|
+
// limit to show only first 3 buttons defined in the slot
|
81
|
+
if (this.iconButtons && this.iconButtons.length > 3) {
|
82
|
+
for (let i = 3; i < this.iconButtons.length; i += 1) {
|
83
|
+
this.iconButtons[i].remove();
|
84
|
+
}
|
85
|
+
}
|
86
|
+
};
|
87
|
+
/**
|
88
|
+
* Filters and renders only the following content into the footer section and removes anything other than it
|
89
|
+
* - One mdc-link element in the footer-link slot
|
90
|
+
* - One secondary variant of the mdc-button element in the footer-button-secondary slot
|
91
|
+
* - One primary variant of the mdc-button element in the footer-button-primary slot
|
92
|
+
*
|
93
|
+
* @internal
|
94
|
+
*/
|
95
|
+
this.handleFooterSlot = (tagname, variant = '') => {
|
96
|
+
var _a, _b, _c;
|
97
|
+
let arrayItems = [];
|
98
|
+
if (tagname === DEFAULTS.LINK && ((_a = this.footerLink) === null || _a === void 0 ? void 0 : _a.length)) {
|
99
|
+
arrayItems = this.footerLink;
|
100
|
+
}
|
101
|
+
else if (tagname === DEFAULTS.BUTTON && variant === BUTTON_VARIANTS.PRIMARY && ((_b = this.footerButtonPrimary) === null || _b === void 0 ? void 0 : _b.length)) {
|
102
|
+
arrayItems = this.footerButtonPrimary;
|
103
|
+
}
|
104
|
+
else if (tagname === DEFAULTS.BUTTON
|
105
|
+
&& variant === BUTTON_VARIANTS.SECONDARY && ((_c = this.footerButtonSecondary) === null || _c === void 0 ? void 0 : _c.length)) {
|
106
|
+
arrayItems = this.footerButtonSecondary;
|
107
|
+
}
|
108
|
+
// if there are more than one instance, remove them.
|
109
|
+
for (let i = 1; i < arrayItems.length; i += 1) {
|
110
|
+
arrayItems[i].remove();
|
111
|
+
}
|
112
|
+
arrayItems.forEach((element) => {
|
113
|
+
// remove the element if it doesn't match with the tagname
|
114
|
+
if (!element.matches(tagname)) {
|
115
|
+
element.remove();
|
116
|
+
}
|
117
|
+
// set the variant if it is provided
|
118
|
+
if (variant) {
|
119
|
+
element.setAttribute('variant', variant);
|
120
|
+
}
|
121
|
+
});
|
122
|
+
};
|
123
|
+
/**
|
124
|
+
* Updates the color of the footer buttons based on the variant.
|
125
|
+
* If the variant is promotional, the color is promotional, else default.
|
126
|
+
*
|
127
|
+
* @internal
|
128
|
+
*/
|
129
|
+
this.updateFooterButtonColors = () => {
|
130
|
+
const footerButtons = [...(this.footerButtonPrimary || []), ...(this.footerButtonSecondary || [])];
|
131
|
+
footerButtons === null || footerButtons === void 0 ? void 0 : footerButtons.forEach((button) => {
|
132
|
+
if (this.variant === VARIANTS.PROMOTIONAL) {
|
133
|
+
button.setAttribute('color', BUTTON_COLORS.PROMOTIONAL);
|
134
|
+
}
|
135
|
+
else {
|
136
|
+
button.setAttribute('color', BUTTON_COLORS.DEFAULT);
|
137
|
+
}
|
138
|
+
});
|
139
|
+
};
|
140
|
+
}
|
141
|
+
update(changedProperties) {
|
142
|
+
super.update(changedProperties);
|
143
|
+
if (changedProperties.has('variant')) {
|
144
|
+
this.updateFooterButtonColors();
|
145
|
+
}
|
146
|
+
}
|
147
|
+
/**
|
148
|
+
* Renders the header of the card if title is provided
|
149
|
+
* @returns The header element
|
150
|
+
*/
|
151
|
+
renderHeader() {
|
152
|
+
if (!this.cardTitle) {
|
153
|
+
return nothing;
|
154
|
+
}
|
155
|
+
return html `<div part="header">
|
156
|
+
${this.renderIcon()}
|
157
|
+
${this.renderTitle()}
|
158
|
+
<div part="icon-button"><slot name="icon-button" @slotchange=${this.handleIconButtons}></slot></div>
|
159
|
+
</div>`;
|
160
|
+
}
|
161
|
+
render() {
|
162
|
+
return html `
|
163
|
+
${this.renderImage()}
|
164
|
+
<div part="body">
|
165
|
+
${this.renderHeader()}
|
166
|
+
<slot name="before-body"></slot>
|
167
|
+
<slot name="body"></slot>
|
168
|
+
<slot name="after-body"></slot>
|
169
|
+
<div part="footer">
|
170
|
+
<slot name="footer-link" @slotchange=${() => this.handleFooterSlot(DEFAULTS.LINK)}></slot>
|
171
|
+
<slot name="footer-button-secondary"
|
172
|
+
@slotchange=${() => this.handleFooterSlot(DEFAULTS.BUTTON, BUTTON_VARIANTS.SECONDARY)}></slot>
|
173
|
+
<slot name="footer-button-primary"
|
174
|
+
@slotchange=${() => this.handleFooterSlot(DEFAULTS.BUTTON, BUTTON_VARIANTS.PRIMARY)}></slot>
|
175
|
+
</div>
|
176
|
+
</div>
|
177
|
+
`;
|
178
|
+
}
|
179
|
+
}
|
180
|
+
Card.styles = [...Component.styles, ...styles];
|
181
|
+
__decorate([
|
182
|
+
queryAssignedElements({ slot: 'icon-button' }),
|
183
|
+
__metadata("design:type", Array)
|
184
|
+
], Card.prototype, "iconButtons", void 0);
|
185
|
+
__decorate([
|
186
|
+
queryAssignedElements({ slot: 'footer-link' }),
|
187
|
+
__metadata("design:type", Array)
|
188
|
+
], Card.prototype, "footerLink", void 0);
|
189
|
+
__decorate([
|
190
|
+
queryAssignedElements({ slot: 'footer-button-primary' }),
|
191
|
+
__metadata("design:type", Array)
|
192
|
+
], Card.prototype, "footerButtonPrimary", void 0);
|
193
|
+
__decorate([
|
194
|
+
queryAssignedElements({ slot: 'footer-button-secondary' }),
|
195
|
+
__metadata("design:type", Array)
|
196
|
+
], Card.prototype, "footerButtonSecondary", void 0);
|
197
|
+
export default Card;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
declare const TAG_NAME: "mdc-card";
|
2
|
+
declare const VARIANTS: {
|
3
|
+
readonly BORDER: "border";
|
4
|
+
readonly GHOST: "ghost";
|
5
|
+
readonly PROMOTIONAL: "promotional";
|
6
|
+
};
|
7
|
+
declare const ORIENTATIONS: {
|
8
|
+
readonly HORIZONTAL: "horizontal";
|
9
|
+
readonly VERTICAL: "vertical";
|
10
|
+
};
|
11
|
+
declare const DEFAULTS: {
|
12
|
+
VARIANT: "border";
|
13
|
+
ORIENTATION: "vertical";
|
14
|
+
TITLE_TYPE: "heading-small-bold";
|
15
|
+
SUBTITLE_TYPE: "body-midsize-medium";
|
16
|
+
TAGNAME: "span";
|
17
|
+
ICON_SIZE: number;
|
18
|
+
ICON_LENGTH_UNIT: string;
|
19
|
+
LINK: "mdc-link";
|
20
|
+
BUTTON: "mdc-button";
|
21
|
+
};
|
22
|
+
export { TAG_NAME, DEFAULTS, VARIANTS, ORIENTATIONS };
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import utils from '../../utils/tag-name';
|
2
|
+
import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
|
3
|
+
import { TAG_NAME as BUTTON_TAG } from '../button/button.constants';
|
4
|
+
import { TAG_NAME as LINK_TAG } from '../link/link.constants';
|
5
|
+
const TAG_NAME = utils.constructTagName('card');
|
6
|
+
const VARIANTS = {
|
7
|
+
BORDER: 'border',
|
8
|
+
GHOST: 'ghost',
|
9
|
+
PROMOTIONAL: 'promotional', // This is applicable only on interactive-card
|
10
|
+
};
|
11
|
+
const ORIENTATIONS = {
|
12
|
+
HORIZONTAL: 'horizontal',
|
13
|
+
VERTICAL: 'vertical',
|
14
|
+
};
|
15
|
+
const DEFAULTS = {
|
16
|
+
VARIANT: VARIANTS.BORDER,
|
17
|
+
ORIENTATION: ORIENTATIONS.VERTICAL,
|
18
|
+
TITLE_TYPE: TYPE.HEADING_SMALL_BOLD,
|
19
|
+
SUBTITLE_TYPE: TYPE.BODY_MIDSIZE_MEDIUM,
|
20
|
+
TAGNAME: VALID_TEXT_TAGS.SPAN,
|
21
|
+
ICON_SIZE: 1.5,
|
22
|
+
ICON_LENGTH_UNIT: 'rem',
|
23
|
+
LINK: LINK_TAG,
|
24
|
+
BUTTON: BUTTON_TAG,
|
25
|
+
};
|
26
|
+
export { TAG_NAME, DEFAULTS, VARIANTS, ORIENTATIONS };
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import { css } from 'lit';
|
2
|
+
import { hostFitContentStyles } from '../../utils/styles';
|
3
|
+
const styles = css `
|
4
|
+
:host {
|
5
|
+
align-items: flex-start;
|
6
|
+
border-radius: 0.5rem;
|
7
|
+
border: 1px solid var(--mds-color-theme-outline-primary-normal);
|
8
|
+
box-shadow: none;
|
9
|
+
transition: box-shadow 0.2s;
|
10
|
+
}
|
11
|
+
:host([variant='ghost']){
|
12
|
+
border-color: transparent;
|
13
|
+
}
|
14
|
+
:host([orientation="horizontal"]){
|
15
|
+
width: 40rem;
|
16
|
+
}
|
17
|
+
|
18
|
+
:host([orientation="vertical"]){
|
19
|
+
width: 20rem;
|
20
|
+
flex-direction: column;
|
21
|
+
}
|
22
|
+
|
23
|
+
:host([orientation="vertical"])::part(image){
|
24
|
+
height: 12.5rem;
|
25
|
+
width: 100%;
|
26
|
+
border-top-left-radius: 0.5rem;
|
27
|
+
border-top-right-radius: 0.5rem;
|
28
|
+
}
|
29
|
+
|
30
|
+
:host([orientation="horizontal"])::part(image){
|
31
|
+
width: 10rem;
|
32
|
+
height: 100%;
|
33
|
+
border-top-left-radius: 0.5rem;
|
34
|
+
border-bottom-left-radius: 0.5rem;
|
35
|
+
}
|
36
|
+
|
37
|
+
:host::part(header){
|
38
|
+
display: flex;
|
39
|
+
gap: 0.5rem;
|
40
|
+
}
|
41
|
+
|
42
|
+
:host::part(icon){
|
43
|
+
margin-top: 0.25rem;
|
44
|
+
}
|
45
|
+
|
46
|
+
:host::part(body){
|
47
|
+
width: 100%;
|
48
|
+
padding: 1.5rem;
|
49
|
+
display: flex;
|
50
|
+
flex-direction: column;
|
51
|
+
}
|
52
|
+
|
53
|
+
::slotted([slot='body']){
|
54
|
+
padding-bottom: 0.5rem;
|
55
|
+
margin-top: 0.75rem;
|
56
|
+
}
|
57
|
+
|
58
|
+
:host([variant='promotional']){
|
59
|
+
border-color: var(--mds-color-theme-outline-promotion-normal);
|
60
|
+
}
|
61
|
+
|
62
|
+
:host::part(icon-button), :host::part(footer) {
|
63
|
+
margin-left: auto;
|
64
|
+
display: flex;
|
65
|
+
gap: 0.5rem;
|
66
|
+
align-items: center;
|
67
|
+
justify-content: center;
|
68
|
+
}
|
69
|
+
:host::part(footer){
|
70
|
+
gap: 1rem;
|
71
|
+
}
|
72
|
+
::slotted([slot='footer-link']),
|
73
|
+
::slotted([slot='footer-button-primary']),
|
74
|
+
::slotted([slot='footer-button-secondary']){
|
75
|
+
margin-bottom: 0.5rem;
|
76
|
+
}
|
77
|
+
|
78
|
+
`;
|
79
|
+
export default [hostFitContentStyles, styles];
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { CSSResult, nothing } from 'lit';
|
2
|
+
import Buttonsimple from '../buttonsimple/buttonsimple.component';
|
3
|
+
declare const CardButton_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/CardComponentMixin").CardComponentMixinInterface> & typeof Buttonsimple;
|
4
|
+
/**
|
5
|
+
* cardbutton component looks like a card and behaves as a button component.
|
6
|
+
*
|
7
|
+
* **Note**: This is a single selection card i.e. interacting anywhere on the card would trigger the click event.
|
8
|
+
* Make sure to pass only non-interactable elements within the slots.
|
9
|
+
*
|
10
|
+
* @tagname mdc-cardbutton
|
11
|
+
*
|
12
|
+
* @dependency mdc-icon
|
13
|
+
* @dependency mdc-text
|
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
|
+
* @event click - (React: onClick) Event that gets dispatched when the card is clicked.
|
20
|
+
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the card.
|
21
|
+
* It fires the click event when enter key is used.
|
22
|
+
* @event keyup - (React: onKeyUp) This event is dispatched when a key is released on the card.
|
23
|
+
* It fires the click event when space key is used.
|
24
|
+
* @event focus - (React: onFocus) Event that gets dispatched when the card receives focus.
|
25
|
+
*
|
26
|
+
*/
|
27
|
+
declare class CardButton extends CardButton_base {
|
28
|
+
connectedCallback(): void;
|
29
|
+
/**
|
30
|
+
* Renders the header of the card if title is provided
|
31
|
+
* @returns The header element
|
32
|
+
*/
|
33
|
+
protected renderHeader(): import("lit-html").TemplateResult<1> | typeof nothing;
|
34
|
+
render(): import("lit-html").TemplateResult<1>;
|
35
|
+
static styles: Array<CSSResult>;
|
36
|
+
}
|
37
|
+
export default CardButton;
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import { html, nothing } from 'lit';
|
2
|
+
import styles from './cardbutton.styles';
|
3
|
+
import Buttonsimple from '../buttonsimple/buttonsimple.component';
|
4
|
+
import Card from '../card/card.component';
|
5
|
+
import { CardComponentMixin } from '../../utils/mixins/CardComponentMixin';
|
6
|
+
/**
|
7
|
+
* cardbutton component looks like a card and behaves as a button component.
|
8
|
+
*
|
9
|
+
* **Note**: This is a single selection card i.e. interacting anywhere on the card would trigger the click event.
|
10
|
+
* Make sure to pass only non-interactable elements within the slots.
|
11
|
+
*
|
12
|
+
* @tagname mdc-cardbutton
|
13
|
+
*
|
14
|
+
* @dependency mdc-icon
|
15
|
+
* @dependency mdc-text
|
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
|
+
* @event click - (React: onClick) Event that gets dispatched when the card is clicked.
|
22
|
+
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the card.
|
23
|
+
* It fires the click event when enter key is used.
|
24
|
+
* @event keyup - (React: onKeyUp) This event is dispatched when a key is released on the card.
|
25
|
+
* It fires the click event when space key is used.
|
26
|
+
* @event focus - (React: onFocus) Event that gets dispatched when the card receives focus.
|
27
|
+
*
|
28
|
+
*/
|
29
|
+
class CardButton extends CardComponentMixin(Buttonsimple) {
|
30
|
+
connectedCallback() {
|
31
|
+
super.connectedCallback();
|
32
|
+
this.active = undefined;
|
33
|
+
this.size = undefined;
|
34
|
+
}
|
35
|
+
/**
|
36
|
+
* Renders the header of the card if title is provided
|
37
|
+
* @returns The header element
|
38
|
+
*/
|
39
|
+
renderHeader() {
|
40
|
+
if (!this.cardTitle) {
|
41
|
+
return nothing;
|
42
|
+
}
|
43
|
+
return html `<div part="header">
|
44
|
+
${this.renderIcon()}
|
45
|
+
${this.renderTitle()}
|
46
|
+
</div>`;
|
47
|
+
}
|
48
|
+
render() {
|
49
|
+
return html `
|
50
|
+
${this.renderImage()}
|
51
|
+
<div part="body">
|
52
|
+
${this.renderHeader()}
|
53
|
+
<slot name="before-body"></slot>
|
54
|
+
<slot name="body"></slot>
|
55
|
+
<slot name="after-body"></slot>
|
56
|
+
</div>
|
57
|
+
`;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
CardButton.styles = [...Card.styles, ...styles];
|
61
|
+
export default CardButton;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { css } from 'lit';
|
2
|
+
import { hostFocusRingStyles } from '../../utils/styles';
|
3
|
+
const styles = css `
|
4
|
+
:host {
|
5
|
+
cursor: pointer;
|
6
|
+
user-select: none;
|
7
|
+
}
|
8
|
+
|
9
|
+
:host(:hover) {
|
10
|
+
background-color: var(--mds-color-theme-background-primary-hover);
|
11
|
+
}
|
12
|
+
|
13
|
+
:host(:active) {
|
14
|
+
background-color: var(--mds-color-theme-background-primary-active);
|
15
|
+
}
|
16
|
+
|
17
|
+
:host([disabled]) {
|
18
|
+
background-color: var(--mds-color-theme-background-primary-ghost);
|
19
|
+
color: var(--mds-color-theme-text-primary-disabled);
|
20
|
+
}
|
21
|
+
|
22
|
+
:host([disabled])::part(image){
|
23
|
+
opacity: 0.5;
|
24
|
+
}
|
25
|
+
`;
|
26
|
+
export default [styles, ...hostFocusRingStyles()];
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|