@momentum-design/components 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. package/dist/browser/index.js.map +1 -1
  2. package/package.json +4 -1
  3. package/.eslintrc.js +0 -16
  4. package/CONTRIBUTING.md +0 -5
  5. package/SCRIPTS.md +0 -15
  6. package/TESTING.md +0 -38
  7. package/config/api-extractor.json +0 -33
  8. package/config/custom-elements-manifest.config.js +0 -28
  9. package/config/esbuild/configs/browser.js +0 -21
  10. package/config/esbuild/configs/e2e.js +0 -10
  11. package/config/esbuild/esbuild-e2e.config.js +0 -22
  12. package/config/esbuild/esbuild.config.js +0 -9
  13. package/config/playwright/playwright.config.ts +0 -107
  14. package/config/playwright/public/index.css +0 -43
  15. package/config/playwright/public/index.html +0 -26
  16. package/config/playwright/setup/Components.page.ts +0 -163
  17. package/config/playwright/setup/constants.ts +0 -27
  18. package/config/playwright/setup/index.ts +0 -42
  19. package/config/playwright/setup/steps/accessibility.ts +0 -9
  20. package/config/playwright/setup/types.ts +0 -5
  21. package/config/playwright/setup/utils/accessibility.ts +0 -70
  22. package/config/playwright/setup/utils/visual-regression.ts +0 -35
  23. package/config/plop/actions/AddComponent.ts +0 -21
  24. package/config/plop/actions/AddToComponentExports.ts +0 -16
  25. package/config/plop/actions/AddToComponentImports.ts +0 -16
  26. package/config/plop/constants/index.ts +0 -31
  27. package/config/plop/esbuild.config.plop.js +0 -4
  28. package/config/plop/generators/component/index.ts +0 -25
  29. package/config/plop/plopfile.ts +0 -6
  30. package/config/plop/prompts/index.ts +0 -8
  31. package/config/plop/templates/add/component/index.ts.hbs +0 -12
  32. package/config/plop/templates/add/component/{{componentName}}.component.ts.hbs +0 -22
  33. package/config/plop/templates/add/component/{{componentName}}.constants.ts.hbs +0 -5
  34. package/config/plop/templates/add/component/{{componentName}}.e2e-test.ts.hbs +0 -67
  35. package/config/plop/templates/add/component/{{componentName}}.fixtures.ts.hbs +0 -13
  36. package/config/plop/templates/add/component/{{componentName}}.stories.ts.hbs +0 -18
  37. package/config/plop/templates/add/component/{{componentName}}.styles.ts.hbs +0 -8
  38. package/config/plop/tsconfig.plop.json +0 -11
  39. package/config/storybook/MomentumStorybookTheme.js +0 -41
  40. package/config/storybook/main.js +0 -21
  41. package/config/storybook/manager.js +0 -17
  42. package/config/storybook/preview.js +0 -63
  43. package/config/storybook/provider/iconProvider.js +0 -8
  44. package/config/storybook/provider/themeProvider.js +0 -31
  45. package/config/storybook/public/background-graphic.png +0 -0
  46. package/config/storybook/public/fonts/Inter.var.woff2 +0 -0
  47. package/config/storybook/public/momentum-logo.png +0 -0
  48. package/config/storybook/themes/index.js +0 -14
  49. package/config/storybook/themes/themes.css +0 -15
  50. package/data/custom-elements.json +0 -677
  51. package/jest.config.js +0 -3
  52. package/scripts/copyFonts.js +0 -31
  53. package/scripts/copyIcons.js +0 -31
  54. package/scripts/copyTokens.js +0 -24
  55. package/src/components/avatar/__screenshots__/mdc-avatar.png +0 -0
  56. package/src/components/avatar/avatar.component.ts +0 -74
  57. package/src/components/avatar/avatar.constants.ts +0 -12
  58. package/src/components/avatar/avatar.e2e-test.ts +0 -70
  59. package/src/components/avatar/avatar.stories.ts +0 -25
  60. package/src/components/avatar/avatar.styles.ts +0 -20
  61. package/src/components/avatar/avatar.types.ts +0 -1
  62. package/src/components/avatar/index.ts +0 -12
  63. package/src/components/badge/__screenshots__/mdc-badge.png +0 -0
  64. package/src/components/badge/badge.component.ts +0 -121
  65. package/src/components/badge/badge.constants.ts +0 -13
  66. package/src/components/badge/badge.e2e-test.ts +0 -68
  67. package/src/components/badge/badge.stories.ts +0 -33
  68. package/src/components/badge/badge.styles.ts +0 -26
  69. package/src/components/badge/badge.types.ts +0 -1
  70. package/src/components/badge/index.ts +0 -12
  71. package/src/components/icon/__screenshots__/mdc-icon-default.png +0 -0
  72. package/src/components/icon/__screenshots__/mdc-icon-scale.png +0 -0
  73. package/src/components/icon/icon.component.ts +0 -155
  74. package/src/components/icon/icon.constants.ts +0 -10
  75. package/src/components/icon/icon.e2e-test.ts +0 -101
  76. package/src/components/icon/icon.stories.ts +0 -34
  77. package/src/components/icon/icon.styles.ts +0 -15
  78. package/src/components/icon/icon.utils.ts +0 -13
  79. package/src/components/icon/index.ts +0 -12
  80. package/src/components/iconprovider/__screenshots__/mdc-iconprovider.png +0 -0
  81. package/src/components/iconprovider/iconprovider.component.ts +0 -76
  82. package/src/components/iconprovider/iconprovider.constants.ts +0 -12
  83. package/src/components/iconprovider/iconprovider.context.ts +0 -16
  84. package/src/components/iconprovider/iconprovider.e2e-test.ts +0 -65
  85. package/src/components/iconprovider/iconprovider.stories.ts +0 -27
  86. package/src/components/iconprovider/iconprovider.stories.utils.ts +0 -27
  87. package/src/components/iconprovider/index.ts +0 -12
  88. package/src/components/text/__screenshots__/mdc-text-body-large.png +0 -0
  89. package/src/components/text/__screenshots__/mdc-text-body-regular.png +0 -0
  90. package/src/components/text/__screenshots__/mdc-text-body-small.png +0 -0
  91. package/src/components/text/__screenshots__/mdc-text-heading-1.png +0 -0
  92. package/src/components/text/__screenshots__/mdc-text-heading-2.png +0 -0
  93. package/src/components/text/__screenshots__/mdc-text-heading-3.png +0 -0
  94. package/src/components/text/__screenshots__/mdc-text-heading-4.png +0 -0
  95. package/src/components/text/__screenshots__/mdc-text-heading-5.png +0 -0
  96. package/src/components/text/__screenshots__/mdc-text-heading-6.png +0 -0
  97. package/src/components/text/__screenshots__/mdc-text-heading-7.png +0 -0
  98. package/src/components/text/__screenshots__/mdc-text-image-title.png +0 -0
  99. package/src/components/text/__screenshots__/mdc-text-label.png +0 -0
  100. package/src/components/text/fonts.styles.ts +0 -99
  101. package/src/components/text/index.ts +0 -12
  102. package/src/components/text/text.component.ts +0 -51
  103. package/src/components/text/text.constants.ts +0 -27
  104. package/src/components/text/text.e2e-test.ts +0 -76
  105. package/src/components/text/text.stories.ts +0 -29
  106. package/src/components/text/text.styles.ts +0 -17
  107. package/src/components/text/text.types.ts +0 -13
  108. package/src/components/text/text.utils.ts +0 -51
  109. package/src/components/themeprovider/__screenshots__/mdc-themeprovider-darkWebex.png +0 -0
  110. package/src/components/themeprovider/__screenshots__/mdc-themeprovider-lightWebex.png +0 -0
  111. package/src/components/themeprovider/index.ts +0 -12
  112. package/src/components/themeprovider/themeprovider.component.ts +0 -91
  113. package/src/components/themeprovider/themeprovider.constants.ts +0 -32
  114. package/src/components/themeprovider/themeprovider.context.ts +0 -18
  115. package/src/components/themeprovider/themeprovider.e2e-test.ts +0 -89
  116. package/src/components/themeprovider/themeprovider.stories.styles.css +0 -22
  117. package/src/components/themeprovider/themeprovider.stories.ts +0 -38
  118. package/src/components/themeprovider/themeprovider.stories.utils.ts +0 -23
  119. package/src/components/themeprovider/themeprovider.styles.ts +0 -13
  120. package/src/components/themeprovider/themeprovider.types.ts +0 -7
  121. package/src/components/themeprovider/themeprovider.utils.ts +0 -16
  122. package/src/index.ts +0 -22
  123. package/src/models/component/component.component.ts +0 -46
  124. package/src/models/component/component.types.ts +0 -16
  125. package/src/models/component/index.ts +0 -7
  126. package/src/models/index.ts +0 -11
  127. package/src/models/provider/index.ts +0 -3
  128. package/src/models/provider/provider.component.ts +0 -87
  129. package/src/models/provider/provider.styles.ts +0 -14
  130. package/src/stories/colors.mdx +0 -32
  131. package/src/stories/icons.mdx +0 -13
  132. package/src/stories/typography.mdx +0 -20
  133. package/src/utils/mixins/DisabledMixin.ts +0 -19
  134. package/src/utils/mixins/TabIndexMixin.ts +0 -19
  135. package/src/utils/provider/index.ts +0 -21
  136. package/src/utils/styles/index.ts +0 -13
  137. package/src/utils/tag-name/constants.ts +0 -10
  138. package/src/utils/tag-name/index.ts +0 -15
  139. package/src/utils/types.ts +0 -1
  140. package/tsconfig.json +0 -45
  141. package/tsconfig.module.json +0 -47
@@ -1,155 +0,0 @@
1
- import { html } from 'lit';
2
- import { property, state } from 'lit/decorators.js';
3
- import styles from './icon.styles';
4
- import { Component } from '../../models';
5
- import providerUtils from '../../utils/provider';
6
- import IconProvider from '../iconprovider/iconprovider.component';
7
- import { dynamicSVGImport } from './icon.utils';
8
- import { DEFAULTS } from './icon.constants';
9
-
10
- /**
11
- * Icon component, which has to be mounted inside of a `IconProvider`
12
- * component.
13
- *
14
- * The `IconProvider` component defines where icons should be consumed from (`url`).
15
- * This `Icon` component accepts the `name` attribute, which will be
16
- * the file name of the icon to be loaded from the given `url`.
17
- *
18
- * Once fetched, the icon will be mounted. If fetching wasn't successful,
19
- * nothing will be shown.
20
- *
21
- * The `scale` attribute allows scaling the icon based on the provided
22
- * `length-unit` attribute (which will either come from the IconProvider or
23
- * could be overridden per icon). For example:
24
- * if `scale = 1` and `length-unit = 'em'`, the size of the icon will be
25
- * `width: 1em; height: 1em`.
26
- *
27
- * For accessibility the `role` and `aria-label` of the icon can be set.
28
- *
29
- * @tag mdc-icon
30
- * @tagname mdc-icon
31
- */
32
- class Icon extends Component {
33
- @state()
34
- private iconData?: HTMLElement;
35
-
36
- @state()
37
- private lengthUnitFromContext?: string;
38
-
39
- /**
40
- * Name of the icon (= filename)
41
- */
42
- @property({ type: String, reflect: true })
43
- name?: string = DEFAULTS.NAME;
44
-
45
- /**
46
- * Scale of the icon (works in combination with length unit)
47
- */
48
- @property({ type: Number })
49
- scale?: number = DEFAULTS.SCALE;
50
-
51
- /**
52
- * Length unit attribute for overridding length-unit from `IconProvider`
53
- */
54
- @property({ type: String, attribute: 'length-unit' })
55
- lengthUnit?: string;
56
-
57
- /**
58
- * Role attribute to be set for accessibility
59
- */
60
- @property({ type: String })
61
- override role: string | null = null;
62
-
63
- /**
64
- * Aria-label attribute to be set for accessibility
65
- */
66
- @property({ type: String, attribute: 'aria-label' })
67
- override ariaLabel: string | null = null;
68
-
69
- private iconProviderContext = providerUtils.consume({ host: this, context: IconProvider.Context });
70
-
71
- /**
72
- * Get Icon Data function which will fetch the icon (currently only svg)
73
- * and sets state and attributes once fetched successfully
74
- */
75
- private async getIconData() {
76
- if (this.iconProviderContext.value) {
77
- const { fileExtension, url } = this.iconProviderContext.value;
78
- if (url && fileExtension && this.name) {
79
- const iconHtml = await dynamicSVGImport(url, this.name, fileExtension);
80
-
81
- // update iconData state once fetched:
82
- this.iconData = iconHtml as HTMLElement;
83
-
84
- // when icon got fetched, set role and aria-label:
85
- this.setRoleOnIcon();
86
- this.setAriaLabelOnIcon();
87
- }
88
- }
89
- }
90
-
91
- /**
92
- * Updates the size by setting the width and height
93
- */
94
- private updateSize() {
95
- if (this.scale && (this.lengthUnit || this.lengthUnitFromContext)) {
96
- const value = `${this.scale}${this.lengthUnit || this.lengthUnitFromContext}`;
97
- this.style.width = value;
98
- this.style.height = value;
99
- }
100
- }
101
-
102
- private setRoleOnIcon() {
103
- if (this.role) {
104
- // pass through role attribute to svg if set on mdc-icon
105
- this.iconData?.setAttribute('role', this.role);
106
- } else {
107
- this.iconData?.removeAttribute('role');
108
- }
109
- }
110
-
111
- private setAriaLabelOnIcon() {
112
- if (this.ariaLabel) {
113
- // pass through aria-label attribute to svg if set on mdc-icon
114
- this.iconData?.setAttribute('aria-label', this.ariaLabel);
115
- } else {
116
- this.iconData?.removeAttribute('aria-label');
117
- }
118
- }
119
-
120
- override updated(changedProperties: Map<string, any>) {
121
- super.updated(changedProperties);
122
-
123
- if (changedProperties.has('name')) {
124
- // fetch icon data if name changes:
125
- this.getIconData().catch((err) => {
126
- console.error(err);
127
- });
128
- }
129
-
130
- if (changedProperties.has('role')) {
131
- this.setRoleOnIcon();
132
- }
133
-
134
- if (changedProperties.has('ariaLabel')) {
135
- this.setAriaLabelOnIcon();
136
- }
137
-
138
- if (changedProperties.has('scale') || changedProperties.has('lengthUnit')) {
139
- this.updateSize();
140
- }
141
-
142
- if (this.lengthUnitFromContext !== this.iconProviderContext.value?.lengthUnit) {
143
- this.lengthUnitFromContext = this.iconProviderContext.value?.lengthUnit;
144
- this.updateSize();
145
- }
146
- }
147
-
148
- override render() {
149
- return html` ${this.iconData} `;
150
- }
151
-
152
- static override styles = styles;
153
- }
154
-
155
- export default Icon;
@@ -1,10 +0,0 @@
1
- import utils from '../../utils/tag-name';
2
-
3
- const TAG_NAME = utils.constructTagName('icon');
4
-
5
- const DEFAULTS = {
6
- NAME: undefined,
7
- SCALE: 1,
8
- };
9
-
10
- export { TAG_NAME, DEFAULTS };
@@ -1,101 +0,0 @@
1
- import { expect } from '@playwright/test';
2
- import { ComponentsPage, test } from '../../../config/playwright/setup';
3
- import steps from '../../../config/playwright/setup/steps/accessibility';
4
-
5
- type SetupOptions = {
6
- componentsPage: ComponentsPage;
7
- name: string;
8
- scale?: number;
9
- role?: string;
10
- ariaLabel?: string;
11
- };
12
- const setup = async (args: SetupOptions) => {
13
- const { componentsPage, ...restArgs } = args;
14
- await componentsPage.mount({
15
- html: `
16
- <mdc-icon
17
- name="${restArgs.name}"
18
- ${restArgs.scale ? `scale="${restArgs.scale}"` : ''}
19
- ${restArgs.role ? `role="${restArgs.role}"` : ''}
20
- ${restArgs.ariaLabel ? `aria-label="${restArgs.ariaLabel}"` : ''}
21
- >
22
- </mdc-icon>
23
- `,
24
- clearDocument: true,
25
- });
26
- const icon = componentsPage.page.locator('mdc-icon');
27
- await icon.waitFor();
28
- return icon;
29
- };
30
-
31
- test('mdc-icon', async ({ componentsPage }) => {
32
- const name = 'accessibility-regular';
33
- await setup({ componentsPage, name });
34
-
35
- /**
36
- * ACCESSIBILITY
37
- */
38
- await test.step('accessibility with default props', async () => {
39
- await steps.automaticA11yCheckStep(componentsPage);
40
- });
41
-
42
- const iconWithRole = await setup({
43
- componentsPage,
44
- name,
45
- role: 'graphics-document',
46
- ariaLabel: 'test aria label',
47
- });
48
-
49
- await test.step('accessibility with role / aria-label passed in', async () => {
50
- await steps.automaticA11yCheckStep(componentsPage);
51
- });
52
-
53
- /**
54
- * VISUAL REGRESSION
55
- */
56
-
57
- // TODO: fix visual regression test on CI
58
- // await test.step('visual-regression', async () => {
59
- // await test.step('matches screenshot of element with role / aria-label passed in', async () => {
60
- // await componentsPage.visualRegression.takeScreenshot('mdc-icon-default', { element: iconWithRole });
61
- // });
62
-
63
- // await test.step('matches screenshot of element with scale set to 2', async () => {
64
- // const iconScaled = await setup({
65
- // componentsPage,
66
- // name,
67
- // scale: 2,
68
- // });
69
- // await componentsPage.visualRegression.takeScreenshot('mdc-icon-scale', { element: iconScaled });
70
- // });
71
- // });
72
-
73
- /**
74
- * ATTRIBUTES
75
- */
76
- await test.step('attributes', async () => {
77
- await test.step('attributes should be present on component by default', async () => {
78
- const icon = await setup({ componentsPage, name });
79
- await expect(icon).toHaveAttribute('name', name);
80
- await expect(icon).toHaveAttribute('style', 'width: 1em; height: 1em;');
81
- });
82
-
83
- await test.step('attributes should be present on component with scale passed in', async () => {
84
- const icon = await setup({ componentsPage, name, scale: 2 });
85
- await expect(icon).toHaveAttribute('name', name);
86
- await expect(icon).toHaveAttribute('scale', '2');
87
- await expect(icon).toHaveAttribute('style', 'width: 2em; height: 2em;');
88
- });
89
-
90
- await test.step('attributes should be present on component with role / aria-label passed in', async () => {
91
- const iconWithRole = await setup({
92
- componentsPage,
93
- name,
94
- role: 'graphics-document',
95
- ariaLabel: 'test aria label',
96
- });
97
- await expect(iconWithRole).toHaveAttribute('name', name);
98
- await expect(iconWithRole).toHaveAttribute('style', 'width: 1em; height: 1em;');
99
- });
100
- });
101
- });
@@ -1,34 +0,0 @@
1
- import type { Meta, StoryObj, Args } from '@storybook/web-components';
2
- import '.';
3
- import { html } from 'lit';
4
-
5
- const render = (args: Args) => html` <mdc-icon name="${args.name}" scale="${args.scale}"></mdc-icon> `;
6
- const renderAccessibility = (args: Args) => html`
7
- <mdc-icon name="${args.name}" scale="${args.scale}" role="${args.role}" aria-label="${args['aria-label']}"></mdc-icon>
8
- `;
9
-
10
- const meta: Meta = {
11
- tags: ['autodocs'],
12
- component: 'mdc-icon',
13
- render,
14
- argTypes: {},
15
- };
16
-
17
- export default meta;
18
-
19
- export const Primary: StoryObj = {
20
- args: {
21
- name: 'accessibility-regular',
22
- scale: 1,
23
- },
24
- };
25
-
26
- export const Accessibility: StoryObj = {
27
- render: renderAccessibility,
28
- args: {
29
- name: 'accessibility-regular',
30
- scale: 1,
31
- role: 'graphics-document',
32
- 'aria-label': 'This is the accessibility icon',
33
- },
34
- };
@@ -1,15 +0,0 @@
1
- import { css } from 'lit';
2
- import { hostFitContentStyles } from '../../utils/styles';
3
-
4
- const styles = [
5
- hostFitContentStyles,
6
- css`
7
- svg {
8
- height: 100%;
9
- width: 100%;
10
- fill: currentColor;
11
- }
12
- `,
13
- ];
14
-
15
- export default styles;
@@ -1,13 +0,0 @@
1
- /* eslint-disable implicit-arrow-linebreak */
2
-
3
- const dynamicSVGImport = async (url: string, name: string, fileExtension: string): Promise<Element> =>
4
- fetch(`${url}/${name}.${fileExtension}`)
5
- .then((response) => {
6
- if (!response.ok) {
7
- throw new Error('There was a problem while fetching the icon!');
8
- }
9
- return response.text();
10
- })
11
- .then((iconResponse) => new DOMParser().parseFromString(iconResponse, 'text/html').body.children[0]);
12
-
13
- export { dynamicSVGImport };
@@ -1,12 +0,0 @@
1
- import Icon from './icon.component';
2
- import { TAG_NAME } from './icon.constants';
3
-
4
- Icon.register(TAG_NAME);
5
-
6
- declare global {
7
- interface HTMLElementTagNameMap {
8
- ['mdc-icon']: Icon
9
- }
10
- }
11
-
12
- export default Icon;
@@ -1,76 +0,0 @@
1
- import { property } from 'lit/decorators.js';
2
- import { Provider } from '../../models';
3
- import IconProviderContext from './iconprovider.context';
4
- import { ALLOWED_FILE_EXTENSIONS, DEFAULTS } from './iconprovider.constants';
5
-
6
- /**
7
- * IconProvider component, which allows to be consumed from sub components
8
- * (see `providerUtils.consume` for how to consume)
9
- *
10
- * Bundling icons will be up to the consumer of this component, such
11
- * that only a url has to be passed in from which the icons will be
12
- * fetched.
13
- *
14
- * @tag mdc-iconprovider
15
- * @tagname mdc-iconprovider
16
- */
17
- class IconProvider extends Provider<IconProviderContext> {
18
- constructor() {
19
- // initialise the context by running the Provider constructor:
20
- super({
21
- context: IconProviderContext.context,
22
- initialValue: new IconProviderContext(),
23
- });
24
- }
25
-
26
- public static get Context() {
27
- return IconProviderContext.context;
28
- }
29
-
30
- /**
31
- * Url of where icons will be fetched from
32
- */
33
- @property({ type: String })
34
- url?: string;
35
-
36
- /**
37
- * File extension of icons, default: 'svg'
38
- */
39
- @property({ type: String, attribute: 'file-extension', reflect: true })
40
- fileExtension?: string = DEFAULTS.FILE_EXTENSION;
41
-
42
- /**
43
- * Length unit used for sizing of icons, default: 'em'
44
- */
45
- @property({ type: String, attribute: 'length-unit', reflect: true })
46
- lengthUnit?: string = DEFAULTS.LENGTH_UNIT;
47
-
48
- private updateValuesInContext() {
49
- // only update fileExtension on context if its an allowed fileExtension
50
- if (this.fileExtension && ALLOWED_FILE_EXTENSIONS.includes(this.fileExtension)) {
51
- this.context.value.fileExtension = this.fileExtension;
52
- }
53
- this.context.value.url = this.url;
54
- this.context.value.lengthUnit = this.lengthUnit;
55
- }
56
-
57
- protected updateContext(): void {
58
- let shouldUpdateConsumers = false;
59
-
60
- if (
61
- this.context.value.fileExtension !== this.fileExtension
62
- || this.context.value.url !== this.url
63
- || this.context.value.lengthUnit !== this.lengthUnit
64
- ) {
65
- this.updateValuesInContext();
66
-
67
- shouldUpdateConsumers = true;
68
- }
69
-
70
- if (shouldUpdateConsumers) {
71
- this.context.updateObservers();
72
- }
73
- }
74
- }
75
-
76
- export default IconProvider;
@@ -1,12 +0,0 @@
1
- import utils from '../../utils/tag-name';
2
-
3
- const TAG_NAME = utils.constructTagName('iconprovider');
4
-
5
- const ALLOWED_FILE_EXTENSIONS = ['svg'];
6
-
7
- const DEFAULTS = {
8
- FILE_EXTENSION: 'svg',
9
- LENGTH_UNIT: 'em',
10
- };
11
-
12
- export { TAG_NAME, DEFAULTS, ALLOWED_FILE_EXTENSIONS };
@@ -1,16 +0,0 @@
1
- import { createContext } from '@lit-labs/context';
2
-
3
- import { TAG_NAME } from './iconprovider.constants';
4
-
5
- class IconProviderContext {
6
- public fileExtension?: string;
7
-
8
- public url?: string;
9
-
10
- public lengthUnit?: string;
11
-
12
- // create typed lit context as part of the IconProviderContext
13
- public static context = createContext<IconProviderContext>(TAG_NAME);
14
- }
15
-
16
- export default IconProviderContext;
@@ -1,65 +0,0 @@
1
- import { expect } from '@playwright/test';
2
- import { ComponentsPage, test } from '../../../config/playwright/setup';
3
- import steps from '../../../config/playwright/setup/steps/accessibility';
4
- import { DEFAULTS } from './iconprovider.constants';
5
-
6
- type SetupOptions = {
7
- componentsPage: ComponentsPage;
8
- url: string;
9
- fileExtension?: string;
10
- lengthUnit?: string;
11
- };
12
- const setup = async (args: SetupOptions) => {
13
- const { componentsPage, ...restArgs } = args;
14
- await componentsPage.mount({
15
- html: `
16
- <mdc-iconprovider
17
- url="${restArgs.url}"
18
- id="local"
19
- ${restArgs.fileExtension ? `file-extension="${restArgs.fileExtension}"` : ''}
20
- ${restArgs.lengthUnit ? `length-unit="${restArgs.lengthUnit}"` : ''}
21
- >
22
- <mdc-icon name="accessibility-regular" scale="2"></mdc-icon>
23
- </mdc-iconprovider>
24
- `,
25
- });
26
- };
27
-
28
- test('mdc-iconprovider', async ({ componentsPage }) => {
29
- const url = '/dist/icons/svg';
30
- await setup({ componentsPage, url });
31
- const iconprovider = componentsPage.page.locator('mdc-iconprovider#local');
32
-
33
- // initial check for the iconprovider be visible on the screen:
34
- await iconprovider.waitFor();
35
-
36
- /**
37
- * ACCESSIBILITY
38
- */
39
- await test.step('accessibility', async () => {
40
- await steps.automaticA11yCheckStep(componentsPage);
41
- });
42
-
43
- /**
44
- * VISUAL REGRESSION
45
- */
46
- // TODO: fix visual regression test on CI
47
- // await test.step('visual-regression', async () => {
48
- // await test.step('matches screenshot of element with default values', async () => {
49
- // await componentsPage.visualRegression.takeScreenshot('mdc-iconprovider', {
50
- // element: iconprovider,
51
- // });
52
- // });
53
- // });
54
-
55
- /**
56
- * ATTRIBUTES
57
- */
58
- await test.step('attributes', async () => {
59
- await test.step('attribute X should be present on component by default', async () => {
60
- await expect(iconprovider).toHaveAttribute('url', url);
61
- await expect(iconprovider).toHaveAttribute('file-extension', DEFAULTS.FILE_EXTENSION);
62
- await expect(iconprovider).toHaveAttribute('length-unit', DEFAULTS.LENGTH_UNIT);
63
- });
64
- });
65
- });
@@ -1,27 +0,0 @@
1
- import type { Meta, StoryObj, Args } from '@storybook/web-components';
2
- import '.';
3
- import './iconprovider.stories.utils';
4
- import { html } from 'lit';
5
-
6
- const render = (args: Args) => html`
7
- <mdc-iconprovider url="${args.url}" file-extension="${args.fileExtension}" length-unit="${args.lengthUnit}">
8
- <mdc-subcomponent-icon></mdc-subcomponent-icon>
9
- </mdc-iconprovider>
10
- `;
11
-
12
- const meta: Meta = {
13
- tags: ['autodocs'],
14
- component: 'mdc-iconprovider',
15
- render,
16
- argTypes: {},
17
- };
18
-
19
- export default meta;
20
-
21
- export const Primary: StoryObj = {
22
- args: {
23
- url: '/test',
24
- fileExtension: 'svg',
25
- lengthUnit: 'em',
26
- },
27
- };
@@ -1,27 +0,0 @@
1
- import { html } from 'lit';
2
- import { Component } from '../../models';
3
- import IconProvider from './iconprovider.component';
4
- import providerUtils from '../../utils/provider';
5
-
6
- // Subcomponent to be rendered in storybook, to showcase that the
7
- // theme can be consumed as a subcomponent
8
- class SubComponentIconProvider extends Component {
9
- currentTheme?: string;
10
-
11
- private iconProviderContext = providerUtils.consume({ host: this, context: IconProvider.Context });
12
-
13
- override render() {
14
- return html`
15
- <p>URL: ${this.iconProviderContext.value?.url}</p>
16
- <p>File Extension: ${this.iconProviderContext.value?.fileExtension}</p>
17
- <p>Length Unit: ${this.iconProviderContext.value?.lengthUnit}</p>
18
- `;
19
- }
20
- }
21
-
22
- SubComponentIconProvider.register('mdc-subcomponent-icon');
23
- declare global {
24
- interface HTMLElementTagNameMap {
25
- ['mdc-subcomponent-icon']: SubComponentIconProvider;
26
- }
27
- }
@@ -1,12 +0,0 @@
1
- import IconProvider from './iconprovider.component';
2
- import { TAG_NAME } from './iconprovider.constants';
3
-
4
- IconProvider.register(TAG_NAME);
5
-
6
- export default IconProvider;
7
-
8
- declare global {
9
- interface HTMLElementTagNameMap {
10
- ['mdc-iconprovider']: IconProvider
11
- }
12
- }