@descope-ui/descope-badge 0.1.0
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/CHANGELOG.md +19 -0
- package/e2e/descope-badge.spec.ts +37 -0
- package/package.json +32 -0
- package/project.json +17 -0
- package/src/component/BadgeClass.js +75 -0
- package/src/component/index.js +5 -0
- package/src/theme.js +72 -0
- package/stories/descope-badge.stories.js +60 -0
- package/testDriver/badgeTestDriver.ts +10 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
|
+
|
|
5
|
+
## 0.1.0 (2025-09-02)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `e2e-utils` updated to version `0.1.0`
|
|
10
|
+
* `test-assets` updated to version `0.0.1`
|
|
11
|
+
* `test-drivers` updated to version `0.0.1`
|
|
12
|
+
* `@descope-ui/common` updated to version `0.1.0`
|
|
13
|
+
* `@descope-ui/theme-globals` updated to version `0.0.20`
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* Trusted Devices ([#697](https://github.com/descope/web-components-ui/issues/697)) ([fb2f0eb](https://github.com/descope/web-components-ui/commit/fb2f0eb6773ed624354ed9f0b97d713bb8b10fce))
|
|
18
|
+
|
|
19
|
+
# Changelog
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { test, expect } from '@playwright/test';
|
|
2
|
+
import { getStoryUrl, loopConfig } from 'e2e-utils';
|
|
3
|
+
|
|
4
|
+
import createBadgeTestDriver from '../testDriver/badgeTestDriver';
|
|
5
|
+
|
|
6
|
+
const componentAttributes = {
|
|
7
|
+
bordered: ['true', 'false'],
|
|
8
|
+
mode: ['default', 'primary', 'secondary', 'success', 'error'],
|
|
9
|
+
size: ['xs', 'sm', 'md', 'lg'],
|
|
10
|
+
'full-width': ['true', 'false'],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const storyName = 'descope-badge';
|
|
14
|
+
const componentName = 'descope-badge';
|
|
15
|
+
|
|
16
|
+
test.describe('theme', () => {
|
|
17
|
+
loopConfig(componentAttributes, (attr, value) => {
|
|
18
|
+
test(`${attr}: ${value}`, async ({ page }) => {
|
|
19
|
+
await page.goto(getStoryUrl(storyName, { [attr]: value }), {
|
|
20
|
+
waitUntil: 'networkidle',
|
|
21
|
+
});
|
|
22
|
+
const component = createBadgeTestDriver(page.locator(componentName));
|
|
23
|
+
expect(await component.screenshot()).toMatchSnapshot();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test(`direction: rtl`, async ({ page }) => {
|
|
28
|
+
await page.goto(
|
|
29
|
+
getStoryUrl(storyName, { direction: 'rtl', text: `-Label` }),
|
|
30
|
+
{
|
|
31
|
+
waitUntil: 'networkidle',
|
|
32
|
+
},
|
|
33
|
+
);
|
|
34
|
+
const component = createBadgeTestDriver(page.locator(componentName));
|
|
35
|
+
expect(await component.screenshot()).toMatchSnapshot();
|
|
36
|
+
});
|
|
37
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@descope-ui/descope-badge",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"exports": {
|
|
5
|
+
".": {
|
|
6
|
+
"import": "./src/component/index.js"
|
|
7
|
+
},
|
|
8
|
+
"./theme": {
|
|
9
|
+
"import": "./src/theme.js"
|
|
10
|
+
},
|
|
11
|
+
"./class": {
|
|
12
|
+
"import": "./src/component/BadgeClass.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@playwright/test": "1.38.1",
|
|
17
|
+
"e2e-utils": "0.0.1",
|
|
18
|
+
"test-assets": "0.0.1",
|
|
19
|
+
"test-drivers": "0.0.1"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@descope-ui/common": "0.1.0",
|
|
23
|
+
"@descope-ui/theme-globals": "0.0.20"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"link-workspace-packages": false
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"test": "echo 'No tests defined' && exit 0",
|
|
30
|
+
"test:e2e": "echo 'No e2e tests defined' && exit 0"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/project.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@descope-ui/descope-badge",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "packages/web-components/components/descope-badge/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"targets": {
|
|
7
|
+
"version": {
|
|
8
|
+
"executor": "@jscutlery/semver:version",
|
|
9
|
+
"options": {
|
|
10
|
+
"trackDeps": true,
|
|
11
|
+
"push": false,
|
|
12
|
+
"preset": "conventional"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"tags": []
|
|
17
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
componentNameValidationMixin,
|
|
3
|
+
createStyleMixin,
|
|
4
|
+
draggableMixin,
|
|
5
|
+
} from '@descope-ui/common/components-mixins';
|
|
6
|
+
import { createBaseClass } from '@descope-ui/common/base-classes';
|
|
7
|
+
import { getComponentName } from '@descope-ui/common/components-helpers';
|
|
8
|
+
import { compose } from '@descope-ui/common/utils';
|
|
9
|
+
import { injectStyle } from '@descope-ui/common/components-helpers';
|
|
10
|
+
|
|
11
|
+
export const componentName = getComponentName('badge');
|
|
12
|
+
|
|
13
|
+
class RawBadge extends createBaseClass({
|
|
14
|
+
componentName,
|
|
15
|
+
baseSelector: ':host > div',
|
|
16
|
+
}) {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
|
|
20
|
+
this.attachShadow({ mode: 'open' }).innerHTML = `
|
|
21
|
+
<div>
|
|
22
|
+
<slot></slot>
|
|
23
|
+
</div>
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
injectStyle(
|
|
27
|
+
`
|
|
28
|
+
:host {
|
|
29
|
+
display: inline-flex;
|
|
30
|
+
}
|
|
31
|
+
:host > div {
|
|
32
|
+
width: 100%;
|
|
33
|
+
text-overflow: ellipsis;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
white-space: nowrap;
|
|
36
|
+
}
|
|
37
|
+
`,
|
|
38
|
+
this,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const BadgeClass = compose(
|
|
44
|
+
createStyleMixin({
|
|
45
|
+
mappings: {
|
|
46
|
+
hostWidth: [{ selector: () => ':host', property: 'width' }],
|
|
47
|
+
hostDirection: { property: 'direction' },
|
|
48
|
+
|
|
49
|
+
fontFamily: {},
|
|
50
|
+
fontSize: {},
|
|
51
|
+
fontWeight: {},
|
|
52
|
+
textTransform: {},
|
|
53
|
+
verticalPadding: [
|
|
54
|
+
{ property: 'padding-top' },
|
|
55
|
+
{ property: 'padding-bottom' },
|
|
56
|
+
],
|
|
57
|
+
horizontalPadding: [
|
|
58
|
+
{ property: 'padding-left' },
|
|
59
|
+
{ property: 'padding-right' },
|
|
60
|
+
],
|
|
61
|
+
|
|
62
|
+
borderWidth: {},
|
|
63
|
+
borderStyle: {},
|
|
64
|
+
borderColor: {},
|
|
65
|
+
borderRadius: {},
|
|
66
|
+
|
|
67
|
+
backgroundColor: {},
|
|
68
|
+
|
|
69
|
+
textColor: { property: 'color' },
|
|
70
|
+
textAlign: {},
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
draggableMixin,
|
|
74
|
+
componentNameValidationMixin,
|
|
75
|
+
)(RawBadge);
|
package/src/theme.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import globals from '@descope-ui/theme-globals';
|
|
2
|
+
import { getThemeRefs } from '@descope-ui/common/theme-helpers';
|
|
3
|
+
import { BadgeClass } from './component/BadgeClass';
|
|
4
|
+
|
|
5
|
+
const globalRefs = getThemeRefs(globals);
|
|
6
|
+
|
|
7
|
+
const vars = BadgeClass.cssVarList;
|
|
8
|
+
|
|
9
|
+
const badge = {
|
|
10
|
+
[vars.hostWidth]: 'fit-content',
|
|
11
|
+
[vars.hostDirection]: globalRefs.direction,
|
|
12
|
+
|
|
13
|
+
[vars.textAlign]: 'center',
|
|
14
|
+
|
|
15
|
+
[vars.fontFamily]: globalRefs.fonts.font1.family,
|
|
16
|
+
[vars.fontWeight]: '400',
|
|
17
|
+
|
|
18
|
+
[vars.verticalPadding]: '0.25em',
|
|
19
|
+
[vars.horizontalPadding]: '0.5em',
|
|
20
|
+
|
|
21
|
+
[vars.borderWidth]: globalRefs.border.xs,
|
|
22
|
+
[vars.borderRadius]: globalRefs.radius.xs,
|
|
23
|
+
[vars.borderColor]: 'transparent',
|
|
24
|
+
[vars.borderStyle]: 'solid',
|
|
25
|
+
|
|
26
|
+
_fullWidth: {
|
|
27
|
+
[vars.hostWidth]: '100%',
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
size: {
|
|
31
|
+
xs: { [vars.fontSize]: '12px' },
|
|
32
|
+
sm: { [vars.fontSize]: '14px' },
|
|
33
|
+
md: { [vars.fontSize]: '16px' },
|
|
34
|
+
lg: { [vars.fontSize]: '18px' },
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
mode: {
|
|
38
|
+
default: {
|
|
39
|
+
[vars.textColor]: globalRefs.colors.surface.dark,
|
|
40
|
+
_bordered: {
|
|
41
|
+
[vars.borderColor]: globalRefs.colors.surface.light,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
primary: {
|
|
45
|
+
[vars.textColor]: globalRefs.colors.primary.main,
|
|
46
|
+
_bordered: {
|
|
47
|
+
[vars.borderColor]: globalRefs.colors.primary.light,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
secondary: {
|
|
51
|
+
[vars.textColor]: globalRefs.colors.secondary.main,
|
|
52
|
+
_bordered: {
|
|
53
|
+
[vars.borderColor]: globalRefs.colors.secondary.light,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
error: {
|
|
57
|
+
[vars.textColor]: globalRefs.colors.error.main,
|
|
58
|
+
_bordered: {
|
|
59
|
+
[vars.borderColor]: globalRefs.colors.error.light,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
success: {
|
|
63
|
+
[vars.textColor]: globalRefs.colors.success.main,
|
|
64
|
+
_bordered: {
|
|
65
|
+
[vars.borderColor]: globalRefs.colors.success.light,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default badge;
|
|
72
|
+
export { vars };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { componentName } from '../src/component';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
textContentControl,
|
|
5
|
+
modeControl,
|
|
6
|
+
fullWidthControl,
|
|
7
|
+
sizeControl,
|
|
8
|
+
borderedControl,
|
|
9
|
+
directionControl,
|
|
10
|
+
} from '@descope-ui/common/sb-controls';
|
|
11
|
+
|
|
12
|
+
const Template = ({
|
|
13
|
+
mode,
|
|
14
|
+
'full-width': fullWidth,
|
|
15
|
+
size,
|
|
16
|
+
bordered,
|
|
17
|
+
text,
|
|
18
|
+
direction,
|
|
19
|
+
}) => `
|
|
20
|
+
<descope-badge
|
|
21
|
+
mode="${mode}"
|
|
22
|
+
size="${size}"
|
|
23
|
+
bordered="${bordered}"
|
|
24
|
+
full-width="${fullWidth || false}"
|
|
25
|
+
st-host-direction="${direction ?? ''}"
|
|
26
|
+
>
|
|
27
|
+
${text}
|
|
28
|
+
</descope-badge>
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
component: componentName,
|
|
33
|
+
title: 'descope-badge',
|
|
34
|
+
parameters: {
|
|
35
|
+
panelPosition: 'right',
|
|
36
|
+
controls: { expanded: true },
|
|
37
|
+
},
|
|
38
|
+
argTypes: {
|
|
39
|
+
...textContentControl,
|
|
40
|
+
...modeControl,
|
|
41
|
+
...fullWidthControl,
|
|
42
|
+
...sizeControl,
|
|
43
|
+
...directionControl,
|
|
44
|
+
...borderedControl,
|
|
45
|
+
mode: {
|
|
46
|
+
...modeControl.mode,
|
|
47
|
+
options: ['none', 'default', 'primary', 'secondary', 'success', 'error'],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const Default = Template.bind({});
|
|
53
|
+
|
|
54
|
+
Default.args = {
|
|
55
|
+
text: 'Label',
|
|
56
|
+
mode: 'primary',
|
|
57
|
+
size: 'md',
|
|
58
|
+
bordered: 'true',
|
|
59
|
+
'full-width': 'false',
|
|
60
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Locator } from '@playwright/test';
|
|
2
|
+
import { createComponentTestDriver } from 'test-drivers';
|
|
3
|
+
|
|
4
|
+
const createBadgeTestDriver = (locator: Locator) => {
|
|
5
|
+
return {
|
|
6
|
+
...createComponentTestDriver(locator),
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default createBadgeTestDriver;
|