@momentum-design/components 0.2.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/browser/index.js +248 -110
- package/dist/browser/index.js.map +4 -4
- package/dist/components/text/fonts.styles.js +211 -74
- package/dist/components/text/text.component.d.ts +54 -13
- package/dist/components/text/text.component.js +78 -16
- package/dist/components/text/text.constants.d.ts +8 -5
- package/dist/components/text/text.constants.js +50 -17
- package/dist/components/text/text.types.d.ts +2 -1
- package/dist/custom-elements.json +29 -14
- package/dist/react/text/index.d.ts +10 -5
- package/dist/react/text/index.js +10 -5
- package/package.json +1 -1
- package/dist/components/text/text.utils.d.ts +0 -20
- package/dist/components/text/text.utils.js +0 -50
@@ -568,39 +568,54 @@
|
|
568
568
|
"declarations": [
|
569
569
|
{
|
570
570
|
"kind": "class",
|
571
|
-
"description": "Text component
|
571
|
+
"description": "Text component for creating styled text elements.\nIt has to be mounted within the ThemeProvider to access color and font tokens.\n\nThe `type` attribute allows changing the text style.\nThe `tagname` attribute allows changing the tag name of the text element.\nThe default tag name is `p`.\n\nThe `tagname` attribute should be a valid HTML tag name.\nIf the `tagname` attribute is not a valid HTML tag name, the default tag name will be used.\n\nThe styling is applied based on the `type` attribute.",
|
572
572
|
"name": "Text",
|
573
|
+
"slots": [
|
574
|
+
{
|
575
|
+
"description": "Default slot for text content",
|
576
|
+
"name": ""
|
577
|
+
}
|
578
|
+
],
|
573
579
|
"members": [
|
574
580
|
{
|
575
581
|
"kind": "field",
|
576
582
|
"name": "type",
|
577
583
|
"type": {
|
578
|
-
"text": "FontType
|
584
|
+
"text": "FontType"
|
579
585
|
},
|
580
586
|
"privacy": "public",
|
581
|
-
"description": "
|
587
|
+
"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'",
|
582
588
|
"attribute": "type",
|
583
589
|
"reflects": true
|
584
590
|
},
|
585
591
|
{
|
586
|
-
"kind": "
|
587
|
-
"name": "
|
588
|
-
"
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
592
|
+
"kind": "field",
|
593
|
+
"name": "tagname",
|
594
|
+
"type": {
|
595
|
+
"text": "ValidTextTags | undefined"
|
596
|
+
},
|
597
|
+
"privacy": "public",
|
598
|
+
"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: 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'small', 'span', 'div', 'section'.\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.",
|
599
|
+
"attribute": "tagname",
|
600
|
+
"reflects": true
|
594
601
|
}
|
595
602
|
],
|
596
603
|
"attributes": [
|
597
604
|
{
|
598
605
|
"name": "type",
|
599
606
|
"type": {
|
600
|
-
"text": "FontType
|
607
|
+
"text": "FontType"
|
601
608
|
},
|
602
|
-
"description": "
|
609
|
+
"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'",
|
603
610
|
"fieldName": "type"
|
611
|
+
},
|
612
|
+
{
|
613
|
+
"name": "tagname",
|
614
|
+
"type": {
|
615
|
+
"text": "ValidTextTags | undefined"
|
616
|
+
},
|
617
|
+
"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: 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'small', 'span', 'div', 'section'.\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.",
|
618
|
+
"fieldName": "tagname"
|
604
619
|
}
|
605
620
|
],
|
606
621
|
"superclass": {
|
@@ -608,7 +623,7 @@
|
|
608
623
|
"module": "/src/models"
|
609
624
|
},
|
610
625
|
"tagName": "mdc-text",
|
611
|
-
"jsDoc": "/**\n * Text component
|
626
|
+
"jsDoc": "/**\n * Text component for creating styled text elements.\n * It has to be mounted within the ThemeProvider to access color and font tokens.\n *\n * The `type` attribute allows changing the text style.\n * The `tagname` attribute allows changing the tag name of the text element.\n * The default tag name is `p`.\n *\n * The `tagname` attribute should be a valid HTML tag name.\n * If the `tagname` attribute is not a valid HTML tag name, the default tag name will be used.\n *\n * The styling is applied based on the `type` attribute.\n *\n * @tagname mdc-text\n * @slot - Default slot for text content\n */",
|
612
627
|
"customElement": true
|
613
628
|
}
|
614
629
|
],
|
@@ -1,14 +1,19 @@
|
|
1
1
|
import Component from '../../components/text';
|
2
2
|
/**
|
3
|
-
* Text component
|
4
|
-
*
|
3
|
+
* Text component for creating styled text elements.
|
4
|
+
* It has to be mounted within the ThemeProvider to access color and font tokens.
|
5
5
|
*
|
6
|
-
* The `type` attribute allows changing the
|
6
|
+
* The `type` attribute allows changing the text style.
|
7
|
+
* The `tagname` attribute allows changing the tag name of the text element.
|
8
|
+
* The default tag name is `p`.
|
7
9
|
*
|
8
|
-
*
|
9
|
-
*
|
10
|
+
* The `tagname` attribute should be a valid HTML tag name.
|
11
|
+
* If the `tagname` attribute is not a valid HTML tag name, the default tag name will be used.
|
12
|
+
*
|
13
|
+
* The styling is applied based on the `type` attribute.
|
10
14
|
*
|
11
15
|
* @tagname mdc-text
|
16
|
+
* @slot - Default slot for text content
|
12
17
|
*/
|
13
18
|
declare const reactWrapper: import("@lit/react").ReactWebComponent<Component, {}>;
|
14
19
|
export default reactWrapper;
|
package/dist/react/text/index.js
CHANGED
@@ -6,15 +6,20 @@ const react_1 = require("@lit/react");
|
|
6
6
|
const text_1 = tslib_1.__importDefault(require("../../components/text"));
|
7
7
|
const text_constants_1 = require("../../components/text/text.constants");
|
8
8
|
/**
|
9
|
-
* Text component
|
10
|
-
*
|
9
|
+
* Text component for creating styled text elements.
|
10
|
+
* It has to be mounted within the ThemeProvider to access color and font tokens.
|
11
11
|
*
|
12
|
-
* The `type` attribute allows changing the
|
12
|
+
* The `type` attribute allows changing the text style.
|
13
|
+
* The `tagname` attribute allows changing the tag name of the text element.
|
14
|
+
* The default tag name is `p`.
|
13
15
|
*
|
14
|
-
*
|
15
|
-
*
|
16
|
+
* The `tagname` attribute should be a valid HTML tag name.
|
17
|
+
* If the `tagname` attribute is not a valid HTML tag name, the default tag name will be used.
|
18
|
+
*
|
19
|
+
* The styling is applied based on the `type` attribute.
|
16
20
|
*
|
17
21
|
* @tagname mdc-text
|
22
|
+
* @slot - Default slot for text content
|
18
23
|
*/
|
19
24
|
const reactWrapper = (0, react_1.createComponent)({
|
20
25
|
tagName: text_constants_1.TAG_NAME,
|
package/package.json
CHANGED
@@ -1,20 +0,0 @@
|
|
1
|
-
import { FontType } from './text.types';
|
2
|
-
/**
|
3
|
-
* Check if passed in type is a heading
|
4
|
-
* @param type - type to check
|
5
|
-
* @returns boolean, true if it is a heading
|
6
|
-
*/
|
7
|
-
declare const isHeading: (type: FontType) => boolean;
|
8
|
-
/**
|
9
|
-
* Get corresponding aria-role to type
|
10
|
-
* @param type - type to find corresponding role for
|
11
|
-
* @returns role
|
12
|
-
*/
|
13
|
-
declare const getRole: (type?: FontType) => "heading" | "paragraph" | null;
|
14
|
-
/**
|
15
|
-
* Get corresponding aria-level to type
|
16
|
-
* @param type - type to find corresponding level for
|
17
|
-
* @returns aria-level (has to be a number)
|
18
|
-
*/
|
19
|
-
declare const getAriaLevel: (type?: FontType) => string | null;
|
20
|
-
export { isHeading, getAriaLevel, getRole };
|
@@ -1,50 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getRole = exports.getAriaLevel = exports.isHeading = void 0;
|
4
|
-
/**
|
5
|
-
* Split the passed in type and return the parts
|
6
|
-
*/
|
7
|
-
const getTypeParts = (type) => {
|
8
|
-
const parts = type.split('-');
|
9
|
-
return { firstPart: parts[0], secondPart: parts[1] };
|
10
|
-
};
|
11
|
-
/**
|
12
|
-
* Check if passed in type is a heading
|
13
|
-
* @param type - type to check
|
14
|
-
* @returns boolean, true if it is a heading
|
15
|
-
*/
|
16
|
-
const isHeading = (type) => {
|
17
|
-
const { firstPart, secondPart } = getTypeParts(type);
|
18
|
-
return firstPart === 'heading' && +secondPart > 0 && +secondPart < 7;
|
19
|
-
};
|
20
|
-
exports.isHeading = isHeading;
|
21
|
-
/**
|
22
|
-
* Get corresponding aria-role to type
|
23
|
-
* @param type - type to find corresponding role for
|
24
|
-
* @returns role
|
25
|
-
*/
|
26
|
-
const getRole = (type) => {
|
27
|
-
if (type) {
|
28
|
-
if (isHeading(type)) {
|
29
|
-
return 'heading';
|
30
|
-
}
|
31
|
-
return 'paragraph';
|
32
|
-
}
|
33
|
-
return null;
|
34
|
-
};
|
35
|
-
exports.getRole = getRole;
|
36
|
-
/**
|
37
|
-
* Get corresponding aria-level to type
|
38
|
-
* @param type - type to find corresponding level for
|
39
|
-
* @returns aria-level (has to be a number)
|
40
|
-
*/
|
41
|
-
const getAriaLevel = (type) => {
|
42
|
-
if (type) {
|
43
|
-
if (isHeading(type)) {
|
44
|
-
const { secondPart } = getTypeParts(type);
|
45
|
-
return secondPart;
|
46
|
-
}
|
47
|
-
}
|
48
|
-
return null;
|
49
|
-
};
|
50
|
-
exports.getAriaLevel = getAriaLevel;
|