@momentum-design/components 0.4.15 → 0.4.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,6 +12,7 @@ import { classMap } from 'lit-html/directives/class-map.js';
12
12
  import { property } from 'lit/decorators.js';
13
13
  import { ifDefined } from 'lit/directives/if-defined.js';
14
14
  import { Component } from '../../models';
15
+ import { FONT_TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
15
16
  import { BADGE_TYPE, ICON_NAMES_LIST, DEFAULTS, ICON_VARIANT, ICON_STATE } from './badge.constants';
16
17
  import styles from './badge.styles';
17
18
  /**
@@ -119,8 +120,8 @@ class Badge extends Component {
119
120
  getBadgeCounterText(maxCounter, overlay, counter) {
120
121
  return html `
121
122
  <mdc-text
122
- type="body-small-medium"
123
- tagname="div"
123
+ type="${FONT_TYPE.BODY_SMALL_MEDIUM}"
124
+ tagname="${VALID_TEXT_TAGS.DIV}"
124
125
  class="mdc-badge-text ${classMap({ 'mdc-badge-overlay': overlay })}"
125
126
  >
126
127
  ${this.getCounterText(maxCounter, counter)}
@@ -1,6 +1,5 @@
1
1
  import { CSSResult } from 'lit';
2
2
  import { Component } from '../../models';
3
- import type { FontType, ValidTextTags } from './text.types';
4
3
  /**
5
4
  * Text component for creating styled text elements.
6
5
  * It has to be mounted within the ThemeProvider to access color and font tokens.
@@ -55,7 +54,7 @@ declare class Text extends Component {
55
54
  * - 'headline-small-light'
56
55
  * - 'headline-small-regular'
57
56
  */
58
- type: FontType;
57
+ type: string;
59
58
  /**
60
59
  * Specifies the HTML tag name for the text element. The default tag name is `p`.
61
60
  * This attribute is optional. When set, it changes the tag name of the text element.
@@ -76,7 +75,7 @@ declare class Text extends Component {
76
75
  * For instance, setting this attribute to `h2` will render the text element as an `h2` element.
77
76
  * Note that the styling is determined by the `type` attribute.
78
77
  */
79
- tagname?: ValidTextTags;
78
+ tagname?: string | undefined;
80
79
  render(): import("lit-html").TemplateResult<1>;
81
80
  static styles: Array<CSSResult>;
82
81
  }
@@ -11,7 +11,7 @@ import { html } from 'lit';
11
11
  import { property } from 'lit/decorators.js';
12
12
  import styles from './text.styles';
13
13
  import { Component } from '../../models';
14
- import { DEFAULTS } from './text.constants';
14
+ import { DEFAULTS, VALID_TEXT_TAGS } from './text.constants';
15
15
  /**
16
16
  * Text component for creating styled text elements.
17
17
  * It has to be mounted within the ThemeProvider to access color and font tokens.
@@ -95,16 +95,16 @@ class Text extends Component {
95
95
  // Lit does not support dynamically changing values for the tag name of a custom element.
96
96
  // Read more: https://lit.dev/docs/templates/expressions/#invalid-locations
97
97
  switch (this.tagname) {
98
- case 'h1': return html `<h1 part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></h1>`;
99
- case 'h2': return html `<h2 part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></h2>`;
100
- case 'h3': return html `<h3 part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></h3>`;
101
- case 'h4': return html `<h4 part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></h4>`;
102
- case 'h5': return html `<h5 part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></h5>`;
103
- case 'h6': return html `<h6 part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></h6>`;
104
- case 'div': return html `<div part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></div>`;
105
- case 'span': return html `<span part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></span>`;
106
- case 'small': return html `<small part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></small>`;
107
- case 'p':
98
+ case VALID_TEXT_TAGS.H1: return html `<h1 part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></h1>`;
99
+ case VALID_TEXT_TAGS.H2: return html `<h2 part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></h2>`;
100
+ case VALID_TEXT_TAGS.H3: return html `<h3 part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></h3>`;
101
+ case VALID_TEXT_TAGS.H4: return html `<h4 part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></h4>`;
102
+ case VALID_TEXT_TAGS.H5: return html `<h5 part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></h5>`;
103
+ case VALID_TEXT_TAGS.H6: return html `<h6 part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></h6>`;
104
+ case VALID_TEXT_TAGS.DIV: return html `<div part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></div>`;
105
+ case VALID_TEXT_TAGS.SPAN: return html `<span part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></span>`;
106
+ case VALID_TEXT_TAGS.SMALL: return html `<small part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></small>`;
107
+ case VALID_TEXT_TAGS.P:
108
108
  default: return html `<p part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></p>`;
109
109
  }
110
110
  }
@@ -112,10 +112,10 @@ class Text extends Component {
112
112
  Text.styles = [...Component.styles, ...styles];
113
113
  __decorate([
114
114
  property({ attribute: 'type', reflect: true, type: String }),
115
- __metadata("design:type", String)
115
+ __metadata("design:type", Object)
116
116
  ], Text.prototype, "type", void 0);
117
117
  __decorate([
118
118
  property({ attribute: 'tagname', reflect: true, type: String }),
119
- __metadata("design:type", String)
119
+ __metadata("design:type", Object)
120
120
  ], Text.prototype, "tagname", void 0);
121
121
  export default Text;
@@ -1,12 +1,51 @@
1
- import type { FontType, ValidTextTags } from './text.types';
2
1
  declare const TAG_NAME: "mdc-text";
3
- declare const VALUES: {
4
- TYPE: Array<FontType>;
5
- TAGNAME: Array<ValidTextTags>;
2
+ declare const FONT_TYPE: {
3
+ BODY_SMALL_REGULAR: string;
4
+ BODY_SMALL_MEDIUM: string;
5
+ BODY_SMALL_BOLD: string;
6
+ BODY_MIDSIZE_REGULAR: string;
7
+ BODY_MIDSIZE_MEDIUM: string;
8
+ BODY_MIDSIZE_BOLD: string;
9
+ BODY_LARGE_REGULAR: string;
10
+ BODY_LARGE_MEDIUM: string;
11
+ BODY_LARGE_BOLD: string;
12
+ BODY_SMALL_REGULAR_UNDERLINE: string;
13
+ BODY_SMALL_MEDIUM_UNDERLINE: string;
14
+ BODY_MIDSIZE_REGULAR_UNDERLINE: string;
15
+ BODY_MIDSIZE_MEDIUM_UNDERLINE: string;
16
+ BODY_LARGE_REGULAR_UNDERLINE: string;
17
+ BODY_LARGE_MEDIUM_UNDERLINE: string;
18
+ HEADING_SMALL_REGULAR: string;
19
+ HEADING_SMALL_MEDIUM: string;
20
+ HEADING_SMALL_BOLD: string;
21
+ HEADING_MIDSIZE_REGULAR: string;
22
+ HEADING_MIDSIZE_MEDIUM: string;
23
+ HEADING_MIDSIZE_BOLD: string;
24
+ HEADING_LARGE_REGULAR: string;
25
+ HEADING_LARGE_MEDIUM: string;
26
+ HEADING_LARGE_BOLD: string;
27
+ HEADING_XLARGE_REGULAR: string;
28
+ HEADING_XLARGE_MEDIUM: string;
29
+ HEADING_XLARGE_BOLD: string;
30
+ HEADLINE_SMALL_LIGHT: string;
31
+ HEADLINE_SMALL_REGULAR: string;
32
+ };
33
+ declare const VALID_TEXT_TAGS: {
34
+ H1: string;
35
+ H2: string;
36
+ H3: string;
37
+ H4: string;
38
+ H5: string;
39
+ H6: string;
40
+ P: string;
41
+ SMALL: string;
42
+ SPAN: string;
43
+ DIV: string;
6
44
  };
7
45
  declare const DEFAULTS: {
8
- TYPE: FontType;
9
- TEXT_ELEMENT_TAGNAME: ValidTextTags;
46
+ TYPE: string;
47
+ TEXT_ELEMENT_TAGNAME: string;
10
48
  CSS_PART_TEXT: string;
49
+ CHILDREN: string;
11
50
  };
12
- export { TAG_NAME, DEFAULTS, VALUES };
51
+ export { TAG_NAME, DEFAULTS, FONT_TYPE, VALID_TEXT_TAGS };
@@ -1,53 +1,52 @@
1
1
  import utils from '../../utils/tag-name';
2
2
  const TAG_NAME = utils.constructTagName('text');
3
- const VALUES = {
4
- TYPE: [
5
- 'body-small-regular',
6
- 'body-small-medium',
7
- 'body-small-bold',
8
- 'body-midsize-regular',
9
- 'body-midsize-medium',
10
- 'body-midsize-bold',
11
- 'body-large-regular',
12
- 'body-large-medium',
13
- 'body-large-bold',
14
- 'body-small-regular-underline',
15
- 'body-small-medium-underline',
16
- 'body-midsize-regular-underline',
17
- 'body-midsize-medium-underline',
18
- 'body-large-regular-underline',
19
- 'body-large-medium-underline',
20
- 'heading-small-regular',
21
- 'heading-small-medium',
22
- 'heading-small-bold',
23
- 'heading-midsize-regular',
24
- 'heading-midsize-medium',
25
- 'heading-midsize-bold',
26
- 'heading-large-regular',
27
- 'heading-large-medium',
28
- 'heading-large-bold',
29
- 'heading-xlarge-regular',
30
- 'heading-xlarge-medium',
31
- 'heading-xlarge-bold',
32
- 'headline-small-light',
33
- 'headline-small-regular',
34
- ],
35
- TAGNAME: [
36
- 'h1',
37
- 'h2',
38
- 'h3',
39
- 'h4',
40
- 'h5',
41
- 'h6',
42
- 'p',
43
- 'small',
44
- 'span',
45
- 'div',
46
- ],
3
+ const FONT_TYPE = {
4
+ BODY_SMALL_REGULAR: 'body-small-regular',
5
+ BODY_SMALL_MEDIUM: 'body-small-medium',
6
+ BODY_SMALL_BOLD: 'body-small-bold',
7
+ BODY_MIDSIZE_REGULAR: 'body-midsize-regular',
8
+ BODY_MIDSIZE_MEDIUM: 'body-midsize-medium',
9
+ BODY_MIDSIZE_BOLD: 'body-midsize-bold',
10
+ BODY_LARGE_REGULAR: 'body-large-regular',
11
+ BODY_LARGE_MEDIUM: 'body-large-medium',
12
+ BODY_LARGE_BOLD: 'body-large-bold',
13
+ BODY_SMALL_REGULAR_UNDERLINE: 'body-small-regular-underline',
14
+ BODY_SMALL_MEDIUM_UNDERLINE: 'body-small-medium-underline',
15
+ BODY_MIDSIZE_REGULAR_UNDERLINE: 'body-midsize-regular-underline',
16
+ BODY_MIDSIZE_MEDIUM_UNDERLINE: 'body-midsize-medium-underline',
17
+ BODY_LARGE_REGULAR_UNDERLINE: 'body-large-regular-underline',
18
+ BODY_LARGE_MEDIUM_UNDERLINE: 'body-large-medium-underline',
19
+ HEADING_SMALL_REGULAR: 'heading-small-regular',
20
+ HEADING_SMALL_MEDIUM: 'heading-small-medium',
21
+ HEADING_SMALL_BOLD: 'heading-small-bold',
22
+ HEADING_MIDSIZE_REGULAR: 'heading-midsize-regular',
23
+ HEADING_MIDSIZE_MEDIUM: 'heading-midsize-medium',
24
+ HEADING_MIDSIZE_BOLD: 'heading-midsize-bold',
25
+ HEADING_LARGE_REGULAR: 'heading-large-regular',
26
+ HEADING_LARGE_MEDIUM: 'heading-large-medium',
27
+ HEADING_LARGE_BOLD: 'heading-large-bold',
28
+ HEADING_XLARGE_REGULAR: 'heading-xlarge-regular',
29
+ HEADING_XLARGE_MEDIUM: 'heading-xlarge-medium',
30
+ HEADING_XLARGE_BOLD: 'heading-xlarge-bold',
31
+ HEADLINE_SMALL_LIGHT: 'headline-small-light',
32
+ HEADLINE_SMALL_REGULAR: 'headline-small-regular',
33
+ };
34
+ const VALID_TEXT_TAGS = {
35
+ H1: 'h1',
36
+ H2: 'h2',
37
+ H3: 'h3',
38
+ H4: 'h4',
39
+ H5: 'h5',
40
+ H6: 'h6',
41
+ P: 'p',
42
+ SMALL: 'small',
43
+ SPAN: 'span',
44
+ DIV: 'div',
47
45
  };
48
46
  const DEFAULTS = {
49
- TYPE: 'body-midsize-regular',
50
- TEXT_ELEMENT_TAGNAME: 'p',
47
+ TYPE: FONT_TYPE.BODY_LARGE_REGULAR,
48
+ TEXT_ELEMENT_TAGNAME: VALID_TEXT_TAGS.P,
51
49
  CSS_PART_TEXT: 'text',
50
+ CHILDREN: 'The quick brown fox jumps over the lazy dog',
52
51
  };
53
- export { TAG_NAME, DEFAULTS, VALUES };
52
+ export { TAG_NAME, DEFAULTS, FONT_TYPE, VALID_TEXT_TAGS };
@@ -765,9 +765,6 @@
765
765
  {
766
766
  "kind": "field",
767
767
  "name": "type",
768
- "type": {
769
- "text": "FontType"
770
- },
771
768
  "privacy": "public",
772
769
  "description": "Specifies the text style to be applied.\n\nAcceptable values include:\n\n- 'body-small-regular'\n- 'body-small-medium'\n- 'body-small-bold'\n- 'body-midsize-regular'\n- 'body-midsize-medium'\n- 'body-midsize-bold'\n- 'body-large-regular'\n- 'body-large-medium'\n- 'body-large-bold'\n- 'body-small-regular-underline'\n- 'body-small-medium-underline'\n- 'body-midsize-regular-underline'\n- 'body-midsize-medium-underline'\n- 'body-large-regular-underline'\n- 'body-large-medium-underline'\n- 'heading-small-regular'\n- 'heading-small-medium'\n- 'heading-small-bold'\n- 'heading-midsize-regular'\n- 'heading-midsize-medium'\n- 'heading-midsize-bold'\n- 'heading-large-regular'\n- 'heading-large-medium'\n- 'heading-large-bold'\n- 'heading-xlarge-regular'\n- 'heading-xlarge-medium'\n- 'heading-xlarge-bold'\n- 'headline-small-light'\n- 'headline-small-regular'",
773
770
  "attribute": "type",
@@ -776,9 +773,6 @@
776
773
  {
777
774
  "kind": "field",
778
775
  "name": "tagname",
779
- "type": {
780
- "text": "ValidTextTags | undefined"
781
- },
782
776
  "privacy": "public",
783
777
  "description": "Specifies the HTML tag name for the text element. The default tag name is `p`.\nThis attribute is optional. When set, it changes the tag name of the text element.\n\nAcceptable values include:\n\n- 'h1'\n- 'h2'\n- 'h3'\n- 'h4'\n- 'h5'\n- 'h6'\n- 'p'\n- 'small'\n- 'span'\n- 'div'\n\nFor instance, setting this attribute to `h2` will render the text element as an `h2` element.\nNote that the styling is determined by the `type` attribute.",
784
778
  "attribute": "tagname",
@@ -788,17 +782,11 @@
788
782
  "attributes": [
789
783
  {
790
784
  "name": "type",
791
- "type": {
792
- "text": "FontType"
793
- },
794
785
  "description": "Specifies the text style to be applied.\n\nAcceptable values include:\n\n- 'body-small-regular'\n- 'body-small-medium'\n- 'body-small-bold'\n- 'body-midsize-regular'\n- 'body-midsize-medium'\n- 'body-midsize-bold'\n- 'body-large-regular'\n- 'body-large-medium'\n- 'body-large-bold'\n- 'body-small-regular-underline'\n- 'body-small-medium-underline'\n- 'body-midsize-regular-underline'\n- 'body-midsize-medium-underline'\n- 'body-large-regular-underline'\n- 'body-large-medium-underline'\n- 'heading-small-regular'\n- 'heading-small-medium'\n- 'heading-small-bold'\n- 'heading-midsize-regular'\n- 'heading-midsize-medium'\n- 'heading-midsize-bold'\n- 'heading-large-regular'\n- 'heading-large-medium'\n- 'heading-large-bold'\n- 'heading-xlarge-regular'\n- 'heading-xlarge-medium'\n- 'heading-xlarge-bold'\n- 'headline-small-light'\n- 'headline-small-regular'",
795
786
  "fieldName": "type"
796
787
  },
797
788
  {
798
789
  "name": "tagname",
799
- "type": {
800
- "text": "ValidTextTags | undefined"
801
- },
802
790
  "description": "Specifies the HTML tag name for the text element. The default tag name is `p`.\nThis attribute is optional. When set, it changes the tag name of the text element.\n\nAcceptable values include:\n\n- 'h1'\n- 'h2'\n- 'h3'\n- 'h4'\n- 'h5'\n- 'h6'\n- 'p'\n- 'small'\n- 'span'\n- 'div'\n\nFor instance, setting this attribute to `h2` will render the text element as an `h2` element.\nNote that the styling is determined by the `type` attribute.",
803
791
  "fieldName": "tagname"
804
792
  }
package/package.json CHANGED
@@ -37,5 +37,5 @@
37
37
  "@momentum-design/icons": "*",
38
38
  "@momentum-design/tokens": "*"
39
39
  },
40
- "version": "0.4.15"
40
+ "version": "0.4.17"
41
41
  }
@@ -1,2 +0,0 @@
1
- export type FontType = 'body-small-regular' | 'body-small-medium' | 'body-small-bold' | 'body-midsize-regular' | 'body-midsize-medium' | 'body-midsize-bold' | 'body-large-regular' | 'body-large-medium' | 'body-large-bold' | 'body-small-regular-underline' | 'body-small-medium-underline' | 'body-midsize-regular-underline' | 'body-midsize-medium-underline' | 'body-large-regular-underline' | 'body-large-medium-underline' | 'heading-small-regular' | 'heading-small-medium' | 'heading-small-bold' | 'heading-midsize-regular' | 'heading-midsize-medium' | 'heading-midsize-bold' | 'heading-large-regular' | 'heading-large-medium' | 'heading-large-bold' | 'heading-xlarge-regular' | 'heading-xlarge-medium' | 'heading-xlarge-bold' | 'headline-small-light' | 'headline-small-regular';
2
- export type ValidTextTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'small' | 'span' | 'div';
@@ -1 +0,0 @@
1
- export {};