@momentum-design/components 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/browser/index.js.map +1 -1
- package/package.json +4 -1
- package/.eslintrc.js +0 -16
- package/CONTRIBUTING.md +0 -5
- package/SCRIPTS.md +0 -15
- package/TESTING.md +0 -38
- package/config/api-extractor.json +0 -33
- package/config/custom-elements-manifest.config.js +0 -28
- package/config/esbuild/configs/browser.js +0 -21
- package/config/esbuild/configs/e2e.js +0 -10
- package/config/esbuild/esbuild-e2e.config.js +0 -22
- package/config/esbuild/esbuild.config.js +0 -9
- package/config/playwright/playwright.config.ts +0 -107
- package/config/playwright/public/index.css +0 -43
- package/config/playwright/public/index.html +0 -26
- package/config/playwright/setup/Components.page.ts +0 -163
- package/config/playwright/setup/constants.ts +0 -27
- package/config/playwright/setup/index.ts +0 -42
- package/config/playwright/setup/steps/accessibility.ts +0 -9
- package/config/playwright/setup/types.ts +0 -5
- package/config/playwright/setup/utils/accessibility.ts +0 -70
- package/config/playwright/setup/utils/visual-regression.ts +0 -35
- package/config/plop/actions/AddComponent.ts +0 -21
- package/config/plop/actions/AddToComponentExports.ts +0 -16
- package/config/plop/actions/AddToComponentImports.ts +0 -16
- package/config/plop/constants/index.ts +0 -31
- package/config/plop/esbuild.config.plop.js +0 -4
- package/config/plop/generators/component/index.ts +0 -25
- package/config/plop/plopfile.ts +0 -6
- package/config/plop/prompts/index.ts +0 -8
- package/config/plop/templates/add/component/index.ts.hbs +0 -12
- package/config/plop/templates/add/component/{{componentName}}.component.ts.hbs +0 -22
- package/config/plop/templates/add/component/{{componentName}}.constants.ts.hbs +0 -5
- package/config/plop/templates/add/component/{{componentName}}.e2e-test.ts.hbs +0 -67
- package/config/plop/templates/add/component/{{componentName}}.fixtures.ts.hbs +0 -13
- package/config/plop/templates/add/component/{{componentName}}.stories.ts.hbs +0 -18
- package/config/plop/templates/add/component/{{componentName}}.styles.ts.hbs +0 -8
- package/config/plop/tsconfig.plop.json +0 -11
- package/config/storybook/MomentumStorybookTheme.js +0 -41
- package/config/storybook/main.js +0 -21
- package/config/storybook/manager.js +0 -17
- package/config/storybook/preview.js +0 -63
- package/config/storybook/provider/iconProvider.js +0 -8
- package/config/storybook/provider/themeProvider.js +0 -31
- package/config/storybook/public/background-graphic.png +0 -0
- package/config/storybook/public/fonts/Inter.var.woff2 +0 -0
- package/config/storybook/public/momentum-logo.png +0 -0
- package/config/storybook/themes/index.js +0 -14
- package/config/storybook/themes/themes.css +0 -15
- package/data/custom-elements.json +0 -677
- package/jest.config.js +0 -3
- package/scripts/copyFonts.js +0 -31
- package/scripts/copyIcons.js +0 -31
- package/scripts/copyTokens.js +0 -24
- package/src/components/avatar/__screenshots__/mdc-avatar.png +0 -0
- package/src/components/avatar/avatar.component.ts +0 -74
- package/src/components/avatar/avatar.constants.ts +0 -12
- package/src/components/avatar/avatar.e2e-test.ts +0 -70
- package/src/components/avatar/avatar.stories.ts +0 -25
- package/src/components/avatar/avatar.styles.ts +0 -20
- package/src/components/avatar/avatar.types.ts +0 -1
- package/src/components/avatar/index.ts +0 -12
- package/src/components/badge/__screenshots__/mdc-badge.png +0 -0
- package/src/components/badge/badge.component.ts +0 -121
- package/src/components/badge/badge.constants.ts +0 -13
- package/src/components/badge/badge.e2e-test.ts +0 -68
- package/src/components/badge/badge.stories.ts +0 -33
- package/src/components/badge/badge.styles.ts +0 -26
- package/src/components/badge/badge.types.ts +0 -1
- package/src/components/badge/index.ts +0 -12
- package/src/components/icon/__screenshots__/mdc-icon-default.png +0 -0
- package/src/components/icon/__screenshots__/mdc-icon-scale.png +0 -0
- package/src/components/icon/icon.component.ts +0 -155
- package/src/components/icon/icon.constants.ts +0 -10
- package/src/components/icon/icon.e2e-test.ts +0 -101
- package/src/components/icon/icon.stories.ts +0 -34
- package/src/components/icon/icon.styles.ts +0 -15
- package/src/components/icon/icon.utils.ts +0 -13
- package/src/components/icon/index.ts +0 -12
- package/src/components/iconprovider/__screenshots__/mdc-iconprovider.png +0 -0
- package/src/components/iconprovider/iconprovider.component.ts +0 -76
- package/src/components/iconprovider/iconprovider.constants.ts +0 -12
- package/src/components/iconprovider/iconprovider.context.ts +0 -16
- package/src/components/iconprovider/iconprovider.e2e-test.ts +0 -65
- package/src/components/iconprovider/iconprovider.stories.ts +0 -27
- package/src/components/iconprovider/iconprovider.stories.utils.ts +0 -27
- package/src/components/iconprovider/index.ts +0 -12
- package/src/components/text/__screenshots__/mdc-text-body-large.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-body-regular.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-body-small.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-heading-1.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-heading-2.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-heading-3.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-heading-4.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-heading-5.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-heading-6.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-heading-7.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-image-title.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-label.png +0 -0
- package/src/components/text/fonts.styles.ts +0 -99
- package/src/components/text/index.ts +0 -12
- package/src/components/text/text.component.ts +0 -51
- package/src/components/text/text.constants.ts +0 -27
- package/src/components/text/text.e2e-test.ts +0 -76
- package/src/components/text/text.stories.ts +0 -29
- package/src/components/text/text.styles.ts +0 -17
- package/src/components/text/text.types.ts +0 -13
- package/src/components/text/text.utils.ts +0 -51
- package/src/components/themeprovider/__screenshots__/mdc-themeprovider-darkWebex.png +0 -0
- package/src/components/themeprovider/__screenshots__/mdc-themeprovider-lightWebex.png +0 -0
- package/src/components/themeprovider/index.ts +0 -12
- package/src/components/themeprovider/themeprovider.component.ts +0 -91
- package/src/components/themeprovider/themeprovider.constants.ts +0 -32
- package/src/components/themeprovider/themeprovider.context.ts +0 -18
- package/src/components/themeprovider/themeprovider.e2e-test.ts +0 -89
- package/src/components/themeprovider/themeprovider.stories.styles.css +0 -22
- package/src/components/themeprovider/themeprovider.stories.ts +0 -38
- package/src/components/themeprovider/themeprovider.stories.utils.ts +0 -23
- package/src/components/themeprovider/themeprovider.styles.ts +0 -13
- package/src/components/themeprovider/themeprovider.types.ts +0 -7
- package/src/components/themeprovider/themeprovider.utils.ts +0 -16
- package/src/index.ts +0 -22
- package/src/models/component/component.component.ts +0 -46
- package/src/models/component/component.types.ts +0 -16
- package/src/models/component/index.ts +0 -7
- package/src/models/index.ts +0 -11
- package/src/models/provider/index.ts +0 -3
- package/src/models/provider/provider.component.ts +0 -87
- package/src/models/provider/provider.styles.ts +0 -14
- package/src/stories/colors.mdx +0 -32
- package/src/stories/icons.mdx +0 -13
- package/src/stories/typography.mdx +0 -20
- package/src/utils/mixins/DisabledMixin.ts +0 -19
- package/src/utils/mixins/TabIndexMixin.ts +0 -19
- package/src/utils/provider/index.ts +0 -21
- package/src/utils/styles/index.ts +0 -13
- package/src/utils/tag-name/constants.ts +0 -10
- package/src/utils/tag-name/index.ts +0 -15
- package/src/utils/types.ts +0 -1
- package/tsconfig.json +0 -45
- package/tsconfig.module.json +0 -47
package/scripts/copyFonts.js
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
|
2
|
-
const fse = require('fs-extra');
|
3
|
-
const path = require('path');
|
4
|
-
const chalk = require('chalk');
|
5
|
-
|
6
|
-
const fontsFolder = path.dirname(require.resolve('@momentum-design/fonts/dist/inter/Inter.var.woff2'));
|
7
|
-
const root = process.cwd();
|
8
|
-
const playwrightPublicDist = path.join(root, 'config', 'playwright', 'public', 'dist', 'fonts');
|
9
|
-
const storybookPublicDist = path.join(root, 'config', 'storybook', 'public', 'fonts');
|
10
|
-
|
11
|
-
const copyFolderToDest = (srcDir, destDir) => {
|
12
|
-
try {
|
13
|
-
fse.copySync(srcDir, destDir, { overwrite: true })
|
14
|
-
} catch (err) {
|
15
|
-
console.error(err)
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
|
-
if (process.argv[2] === 'playwright') {
|
20
|
-
copyFolderToDest(fontsFolder, playwrightPublicDist);
|
21
|
-
console.log(chalk.gray('Fonts have been copied successfully to Playwright public!'));
|
22
|
-
return;
|
23
|
-
}
|
24
|
-
|
25
|
-
if (process.argv[2] === 'storybook') {
|
26
|
-
copyFolderToDest(fontsFolder, storybookPublicDist);
|
27
|
-
console.log(chalk.gray('Fonts have been copied successfully to Storybook public!'));
|
28
|
-
return;
|
29
|
-
}
|
30
|
-
|
31
|
-
console.log(chalk.red('No type has been provided. Use "playwright" or "storybook" as a argument!'));
|
package/scripts/copyIcons.js
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
|
2
|
-
const fse = require('fs-extra');
|
3
|
-
const path = require('path');
|
4
|
-
const chalk = require('chalk');
|
5
|
-
|
6
|
-
const iconsFolder = path.dirname(require.resolve('@momentum-design/icons/dist/manifest.json'));
|
7
|
-
const root = process.cwd();
|
8
|
-
const playwrightPublicDist = path.join(root, 'config', 'playwright', 'public', 'dist', 'icons');
|
9
|
-
const storybookPublicDist = path.join(root, 'config', 'storybook', 'public', 'icons');
|
10
|
-
|
11
|
-
const copyFolderToDest = (srcDir, destDir) => {
|
12
|
-
try {
|
13
|
-
fse.copySync(srcDir, destDir, { overwrite: true })
|
14
|
-
} catch (err) {
|
15
|
-
console.error(err)
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
|
-
if (process.argv[2] === 'playwright') {
|
20
|
-
copyFolderToDest(iconsFolder, playwrightPublicDist);
|
21
|
-
console.log(chalk.gray('Icons have been copied successfully to Playwright public!'));
|
22
|
-
return;
|
23
|
-
}
|
24
|
-
|
25
|
-
if (process.argv[2] === 'storybook') {
|
26
|
-
copyFolderToDest(iconsFolder, storybookPublicDist);
|
27
|
-
console.log(chalk.gray('Icons have been copied successfully to Storybook public!'));
|
28
|
-
return;
|
29
|
-
}
|
30
|
-
|
31
|
-
console.log(chalk.red('No type has been provided. Use "playwright" or "storybook" as a argument!'));
|
package/scripts/copyTokens.js
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
const fs = require('fs');
|
2
|
-
const path = require('path');
|
3
|
-
const chalk = require('chalk');
|
4
|
-
|
5
|
-
const complete = require.resolve('@momentum-design/tokens/dist/css/core/complete.css');
|
6
|
-
const dark = require.resolve('@momentum-design/tokens/dist/css/theme/webex/dark-stable.css');
|
7
|
-
const light = require.resolve('@momentum-design/tokens/dist/css/theme/webex/light-stable.css');
|
8
|
-
|
9
|
-
const root = process.cwd();
|
10
|
-
const playwrightPublicDist = path.join(root, 'config', 'playwright', 'public', 'dist');
|
11
|
-
|
12
|
-
|
13
|
-
const copyToFolder = (src, destFolder) => {
|
14
|
-
const dest = path.join(destFolder, path.basename(src));
|
15
|
-
fs.copyFile(src, dest, (err) => {
|
16
|
-
if (err) throw err;
|
17
|
-
});
|
18
|
-
}
|
19
|
-
|
20
|
-
copyToFolder(complete, playwrightPublicDist);
|
21
|
-
copyToFolder(dark, playwrightPublicDist);
|
22
|
-
copyToFolder(light, playwrightPublicDist);
|
23
|
-
|
24
|
-
console.log(chalk.gray('Tokens have been copied successfully!'));
|
Binary file
|
@@ -1,74 +0,0 @@
|
|
1
|
-
import { html } from 'lit';
|
2
|
-
import { property } from 'lit/decorators.js';
|
3
|
-
import { ifDefined } from 'lit/directives/if-defined.js';
|
4
|
-
import styles from './avatar.styles';
|
5
|
-
import { Component } from '../../models';
|
6
|
-
import { AvatarType } from './avatar.types';
|
7
|
-
import { DEFAULTS, LENGTH_UNIT } from './avatar.constants';
|
8
|
-
|
9
|
-
/**
|
10
|
-
* @slot - This is a default/unnamed slot
|
11
|
-
*
|
12
|
-
* @summary This is MyElement
|
13
|
-
*
|
14
|
-
* @tag mdc-avatar
|
15
|
-
* @tagname mdc-avatar
|
16
|
-
*/
|
17
|
-
class Avatar extends Component {
|
18
|
-
@property({ type: String, reflect: true })
|
19
|
-
type?: AvatarType = DEFAULTS.TYPE;
|
20
|
-
|
21
|
-
@property({ type: String })
|
22
|
-
alt?: string;
|
23
|
-
|
24
|
-
@property({ type: String })
|
25
|
-
src?: string;
|
26
|
-
|
27
|
-
/**
|
28
|
-
* Scale of the avatar
|
29
|
-
*/
|
30
|
-
@property({ type: Number })
|
31
|
-
scale?: number = DEFAULTS.SCALE;
|
32
|
-
|
33
|
-
/**
|
34
|
-
* Updates the size by setting the width and height
|
35
|
-
*/
|
36
|
-
private updateSize() {
|
37
|
-
if (this.scale) {
|
38
|
-
const value = `${this.scale}${LENGTH_UNIT}`;
|
39
|
-
this.style.width = value;
|
40
|
-
this.style.height = value;
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
override updated(changedProperties: Map<string, any>) {
|
45
|
-
super.updated(changedProperties);
|
46
|
-
|
47
|
-
if (changedProperties.has('scale')) {
|
48
|
-
this.updateSize();
|
49
|
-
}
|
50
|
-
}
|
51
|
-
|
52
|
-
photoTemplate() {
|
53
|
-
return html`
|
54
|
-
<img
|
55
|
-
src="${ifDefined(this.src)}"
|
56
|
-
alt="${ifDefined(this.alt)}"
|
57
|
-
/>
|
58
|
-
`;
|
59
|
-
}
|
60
|
-
|
61
|
-
public override render() {
|
62
|
-
let content;
|
63
|
-
if (this.type === 'photo') {
|
64
|
-
content = this.photoTemplate();
|
65
|
-
} else {
|
66
|
-
content = html``;
|
67
|
-
}
|
68
|
-
return html`${content}`;
|
69
|
-
}
|
70
|
-
|
71
|
-
public static override styles = styles;
|
72
|
-
}
|
73
|
-
|
74
|
-
export default Avatar;
|
@@ -1,70 +0,0 @@
|
|
1
|
-
import { test } from '../../../config/playwright/setup';
|
2
|
-
import steps from '../../../config/playwright/setup/steps/accessibility';
|
3
|
-
|
4
|
-
test.beforeEach(async ({ componentsPage }) => {
|
5
|
-
await componentsPage.mount({
|
6
|
-
html: `
|
7
|
-
<mdc-avatar alt="test"/>
|
8
|
-
`,
|
9
|
-
});
|
10
|
-
});
|
11
|
-
|
12
|
-
// TODO: fix e2e test
|
13
|
-
test.fixme('mdc-avatar', async ({ componentsPage }) => {
|
14
|
-
const avatar = componentsPage.page.locator('mdc-avatar');
|
15
|
-
|
16
|
-
// initial check for the avatar be visible on the screen:
|
17
|
-
await avatar.waitFor();
|
18
|
-
|
19
|
-
/**
|
20
|
-
* ACCESSIBILITY
|
21
|
-
*/
|
22
|
-
await test.step('accessibility', async () => {
|
23
|
-
await steps.automaticA11yCheckStep(componentsPage);
|
24
|
-
});
|
25
|
-
|
26
|
-
/**
|
27
|
-
* VISUAL REGRESSION
|
28
|
-
*/
|
29
|
-
|
30
|
-
// TODO: fix visual regression test on CI
|
31
|
-
// await test.step('visual-regression', async () => {
|
32
|
-
// await test.step('matches screenshot of element', async () => {
|
33
|
-
// await componentsPage.visualRegression.takeScreenshot('mdc-avatar', { element: avatar });
|
34
|
-
// });
|
35
|
-
// });
|
36
|
-
|
37
|
-
/**
|
38
|
-
* ATTRIBUTES
|
39
|
-
*/
|
40
|
-
await test.step('attributes', async () => {
|
41
|
-
await test.step('attribute X should be present on component by default', async () => {
|
42
|
-
// TODO: add test here
|
43
|
-
});
|
44
|
-
});
|
45
|
-
|
46
|
-
/**
|
47
|
-
* INTERACTIONS
|
48
|
-
*/
|
49
|
-
await test.step('interactions', async () => {
|
50
|
-
await test.step('mouse/pointer', async () => {
|
51
|
-
await test.step('component should fire callback x when clicking on it', async () => {
|
52
|
-
// TODO: add test here
|
53
|
-
});
|
54
|
-
});
|
55
|
-
|
56
|
-
await test.step('focus', async () => {
|
57
|
-
await test.step('component should be focusable with tab', async () => {
|
58
|
-
// TODO: add test here
|
59
|
-
});
|
60
|
-
|
61
|
-
// add additional tests here, like tabbing through several parts of the component
|
62
|
-
});
|
63
|
-
|
64
|
-
await test.step('keyboard', async () => {
|
65
|
-
await test.step('component should fire callback x when pressing y', async () => {
|
66
|
-
// TODO: add test here
|
67
|
-
});
|
68
|
-
});
|
69
|
-
});
|
70
|
-
});
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import type { Meta, StoryObj, Args } from '@storybook/web-components';
|
2
|
-
import '.';
|
3
|
-
import { html } from 'lit';
|
4
|
-
import { DEFAULTS } from './avatar.constants';
|
5
|
-
|
6
|
-
const render = (args: Args) => html`
|
7
|
-
<mdc-avatar src="${args.src}" scale="${args.scale}" type="${args.type}"></mdc-avatar>
|
8
|
-
`;
|
9
|
-
|
10
|
-
const meta: Meta = {
|
11
|
-
component: 'mdc-avatar',
|
12
|
-
render,
|
13
|
-
argTypes: {},
|
14
|
-
};
|
15
|
-
|
16
|
-
export default meta;
|
17
|
-
|
18
|
-
export const Primary: StoryObj = {
|
19
|
-
args: {
|
20
|
-
// eslint-disable-next-line max-len
|
21
|
-
src: 'https://images.unsplash.com/photo-1583195764036-6dc248ac07d9?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=2855&q=80',
|
22
|
-
scale: DEFAULTS.SCALE,
|
23
|
-
type: DEFAULTS.TYPE,
|
24
|
-
},
|
25
|
-
};
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import { css } from 'lit';
|
2
|
-
|
3
|
-
const styles = css`
|
4
|
-
:host {
|
5
|
-
display: flex;
|
6
|
-
justify-content: center;
|
7
|
-
align-items: center;
|
8
|
-
border-radius: 100vh;
|
9
|
-
position: relative;
|
10
|
-
width: fit-content;
|
11
|
-
}
|
12
|
-
img {
|
13
|
-
border-radius: 100vh;
|
14
|
-
height: inherit;
|
15
|
-
width: inherit;
|
16
|
-
object-fit: cover;
|
17
|
-
}
|
18
|
-
`;
|
19
|
-
|
20
|
-
export default styles;
|
@@ -1 +0,0 @@
|
|
1
|
-
export type AvatarType = 'photo' | 'text' | 'icon' | 'multiuser'
|
Binary file
|
@@ -1,121 +0,0 @@
|
|
1
|
-
import { html } from 'lit';
|
2
|
-
import { property } from 'lit/decorators.js';
|
3
|
-
import { StyleInfo, styleMap } from 'lit/directives/style-map.js';
|
4
|
-
import { Component } from '../../models';
|
5
|
-
import { DEFAULTS, WARNING_ICON_NAME } from './badge.constants';
|
6
|
-
import styles from './badge.styles';
|
7
|
-
import type { BadgeType } from './badge.types';
|
8
|
-
|
9
|
-
/**
|
10
|
-
* @slot - This is a default/unnamed slot
|
11
|
-
*
|
12
|
-
* @summary This is MyElement
|
13
|
-
*
|
14
|
-
* @tag mdc-badge
|
15
|
-
* @tagname mdc-badge
|
16
|
-
*/
|
17
|
-
class Badge extends Component {
|
18
|
-
/**
|
19
|
-
* Type of the badge
|
20
|
-
* Can be `regular`, `icon`, `text` or `warning`
|
21
|
-
*
|
22
|
-
* Default: `regular`
|
23
|
-
*/
|
24
|
-
@property({ type: String, reflect: true })
|
25
|
-
type?: BadgeType = DEFAULTS.TYPE;
|
26
|
-
|
27
|
-
/**
|
28
|
-
* Scale of the badge (works in combination with length unit)
|
29
|
-
*
|
30
|
-
* Default: `1`
|
31
|
-
*/
|
32
|
-
@property({ type: Number })
|
33
|
-
scale?: number = DEFAULTS.SCALE;
|
34
|
-
|
35
|
-
/**
|
36
|
-
* Length unit attribute for scale
|
37
|
-
*
|
38
|
-
* Default: `rem`
|
39
|
-
*/
|
40
|
-
@property({ type: String, attribute: 'length-unit' })
|
41
|
-
lengthUnit?: string = DEFAULTS.LENGTH_UNIT;
|
42
|
-
|
43
|
-
/**
|
44
|
-
* If `type` is set to `icon`, attribute `iconName` can
|
45
|
-
* be used to choose which icon should be shown
|
46
|
-
*
|
47
|
-
* If no `iconName` is provided, no icon will be rendered.
|
48
|
-
*/
|
49
|
-
@property({ type: String, attribute: 'icon-name' })
|
50
|
-
iconName?: string;
|
51
|
-
|
52
|
-
/**
|
53
|
-
* If `type` is set to `text`, attribute `text` can
|
54
|
-
* be used to pass in any text to be displayed in the badge.
|
55
|
-
*/
|
56
|
-
@property({ type: String })
|
57
|
-
text?: string;
|
58
|
-
|
59
|
-
private updateSize() {
|
60
|
-
// if (this.scale && this.lengthUnit) {
|
61
|
-
// const value = `${this.scale}${this.lengthUnit}`;
|
62
|
-
// this.style.height = value;
|
63
|
-
// if (this.type !== 'text') {
|
64
|
-
// this.style.width = value;
|
65
|
-
// }
|
66
|
-
// }
|
67
|
-
}
|
68
|
-
|
69
|
-
override updated(changedProperties: Map<string, any>) {
|
70
|
-
super.updated(changedProperties);
|
71
|
-
if (changedProperties.has('scale') || changedProperties.has('lengthUnit')) {
|
72
|
-
this.updateSize();
|
73
|
-
}
|
74
|
-
}
|
75
|
-
|
76
|
-
iconTemplate() {
|
77
|
-
return html`<div class="mdc-badge-icon-container">
|
78
|
-
<mdc-icon name="${this.iconName}" scale="100" length-unit="%"></mdc-icon>
|
79
|
-
</div>`;
|
80
|
-
}
|
81
|
-
|
82
|
-
textTemplate() {
|
83
|
-
return html`${this.text}`;
|
84
|
-
}
|
85
|
-
|
86
|
-
warningTemplate() {
|
87
|
-
return html` <mdc-icon name="${WARNING_ICON_NAME}" class="mdc-badge-warning"></mdc-icon> `;
|
88
|
-
}
|
89
|
-
|
90
|
-
public override render() {
|
91
|
-
let content;
|
92
|
-
const size = `${this.scale}${this.lengthUnit}`;
|
93
|
-
let sizeStyles: StyleInfo = { width: size, height: size };
|
94
|
-
|
95
|
-
switch (this.type) {
|
96
|
-
case 'regular':
|
97
|
-
content = html``;
|
98
|
-
break;
|
99
|
-
case 'icon':
|
100
|
-
content = this.iconTemplate();
|
101
|
-
break;
|
102
|
-
case 'text':
|
103
|
-
content = this.textTemplate();
|
104
|
-
// make width flexible when text -> only set the height:
|
105
|
-
sizeStyles = { height: sizeStyles.height };
|
106
|
-
break;
|
107
|
-
case 'warning':
|
108
|
-
content = this.warningTemplate();
|
109
|
-
break;
|
110
|
-
default:
|
111
|
-
content = html``;
|
112
|
-
break;
|
113
|
-
}
|
114
|
-
|
115
|
-
return html`<div class="mdc-badge-container" style=${styleMap(sizeStyles)}>${content}</div>`;
|
116
|
-
}
|
117
|
-
|
118
|
-
public static override styles = styles;
|
119
|
-
}
|
120
|
-
|
121
|
-
export default Badge;
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import utils from '../../utils/tag-name';
|
2
|
-
|
3
|
-
const TAG_NAME = utils.constructTagName('badge');
|
4
|
-
|
5
|
-
const WARNING_ICON_NAME = 'warning-badge-filled';
|
6
|
-
|
7
|
-
const DEFAULTS = {
|
8
|
-
TYPE: 'regular' as const,
|
9
|
-
SCALE: 1,
|
10
|
-
LENGTH_UNIT: 'rem',
|
11
|
-
};
|
12
|
-
|
13
|
-
export { TAG_NAME, DEFAULTS, WARNING_ICON_NAME };
|
@@ -1,68 +0,0 @@
|
|
1
|
-
import { test } from '../../../config/playwright/setup';
|
2
|
-
import steps from '../../../config/playwright/setup/steps/accessibility';
|
3
|
-
|
4
|
-
test.beforeEach(async ({ componentsPage }) => {
|
5
|
-
await componentsPage.mount({
|
6
|
-
html: `
|
7
|
-
<mdc-badge />
|
8
|
-
`,
|
9
|
-
});
|
10
|
-
});
|
11
|
-
|
12
|
-
test('mdc-badge', async ({ componentsPage }) => {
|
13
|
-
const badge = componentsPage.page.locator('mdc-badge');
|
14
|
-
|
15
|
-
// initial check for the badge be visible on the screen:
|
16
|
-
await badge.waitFor();
|
17
|
-
|
18
|
-
/**
|
19
|
-
* ACCESSIBILITY
|
20
|
-
*/
|
21
|
-
await test.step('accessibility', async () => {
|
22
|
-
await steps.automaticA11yCheckStep(componentsPage);
|
23
|
-
});
|
24
|
-
|
25
|
-
/**
|
26
|
-
* VISUAL REGRESSION
|
27
|
-
*/
|
28
|
-
// TODO: fix visual regression test on CI
|
29
|
-
// await test.step('visual-regression', async () => {
|
30
|
-
// await test.step('matches screenshot of element', async () => {
|
31
|
-
// await componentsPage.visualRegression.takeScreenshot('mdc-badge', { element: badge });
|
32
|
-
// });
|
33
|
-
// });
|
34
|
-
|
35
|
-
/**
|
36
|
-
* ATTRIBUTES
|
37
|
-
*/
|
38
|
-
await test.step('attributes', async () => {
|
39
|
-
await test.step('attribute X should be present on component by default', async () => {
|
40
|
-
// TODO: add test here
|
41
|
-
});
|
42
|
-
});
|
43
|
-
|
44
|
-
/**
|
45
|
-
* INTERACTIONS
|
46
|
-
*/
|
47
|
-
await test.step('interactions', async () => {
|
48
|
-
await test.step('mouse/pointer', async () => {
|
49
|
-
await test.step('component should fire callback x when clicking on it', async () => {
|
50
|
-
// TODO: add test here
|
51
|
-
});
|
52
|
-
});
|
53
|
-
|
54
|
-
await test.step('focus', async () => {
|
55
|
-
await test.step('component should be focusable with tab', async () => {
|
56
|
-
// TODO: add test here
|
57
|
-
});
|
58
|
-
|
59
|
-
// add additional tests here, like tabbing through several parts of the component
|
60
|
-
});
|
61
|
-
|
62
|
-
await test.step('keyboard', async () => {
|
63
|
-
await test.step('component should fire callback x when pressing y', async () => {
|
64
|
-
// TODO: add test here
|
65
|
-
});
|
66
|
-
});
|
67
|
-
});
|
68
|
-
});
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import type { Meta, StoryObj, Args } from '@storybook/web-components';
|
2
|
-
import '.';
|
3
|
-
import { html } from 'lit';
|
4
|
-
import { DEFAULTS } from './badge.constants';
|
5
|
-
|
6
|
-
const render = (args: Args) => html`
|
7
|
-
<mdc-badge
|
8
|
-
type="${args.type}"
|
9
|
-
icon-name="${args.iconName}"
|
10
|
-
scale="${args.scale}"
|
11
|
-
length-unit="${args.lengthUnit}"
|
12
|
-
text="${args.text}"
|
13
|
-
></mdc-badge>
|
14
|
-
`;
|
15
|
-
|
16
|
-
const meta: Meta = {
|
17
|
-
tags: ['autodocs'],
|
18
|
-
component: 'mdc-badge',
|
19
|
-
render,
|
20
|
-
argTypes: {},
|
21
|
-
};
|
22
|
-
|
23
|
-
export default meta;
|
24
|
-
|
25
|
-
export const Primary: StoryObj = {
|
26
|
-
args: {
|
27
|
-
type: DEFAULTS.TYPE,
|
28
|
-
iconName: 'accessibility-regular',
|
29
|
-
scale: 1,
|
30
|
-
lengthUnit: 'rem',
|
31
|
-
text: '99+',
|
32
|
-
},
|
33
|
-
};
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import { css } from 'lit';
|
2
|
-
import { hostFitContentStyles } from '../../utils/styles';
|
3
|
-
|
4
|
-
const styles = [
|
5
|
-
hostFitContentStyles,
|
6
|
-
css`
|
7
|
-
:host {
|
8
|
-
--mdc-badge-icon-background-color: var(--mds-color-theme-background-accent-normal);
|
9
|
-
}
|
10
|
-
|
11
|
-
.mdc-badge-container {
|
12
|
-
display: flex;
|
13
|
-
justify-content: center;
|
14
|
-
align-items: center;
|
15
|
-
border-radius: 9999px;
|
16
|
-
background-color: var(--mdc-badge-icon-background-color);
|
17
|
-
}
|
18
|
-
|
19
|
-
.mdc-badge-icon-container {
|
20
|
-
height: 80%;
|
21
|
-
width: 80%;
|
22
|
-
}
|
23
|
-
`,
|
24
|
-
];
|
25
|
-
|
26
|
-
export default styles;
|
@@ -1 +0,0 @@
|
|
1
|
-
export type BadgeType = 'regular' | 'text' | 'icon' | 'warning';
|
Binary file
|
Binary file
|