@spectrum-web-components/badge 0.1.4-devmode.0 → 0.3.0-devmode.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/custom-elements.json +4 -4
- package/package.json +23 -9
- package/src/Badge.dev.js +3 -1
- package/src/Badge.dev.js.map +2 -2
- package/src/Badge.js +3 -1
- package/src/Badge.js.map +2 -2
- package/stories/badge.stories.js +1 -1
- package/stories/badge.stories.js.map +1 -1
- package/test/badge.test.js +38 -2
- package/test/badge.test.js.map +2 -2
package/custom-elements.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"modules": [
|
|
5
5
|
{
|
|
6
6
|
"kind": "javascript-module",
|
|
7
|
-
"path": "sp-badge.
|
|
7
|
+
"path": "sp-badge.js",
|
|
8
8
|
"declarations": [],
|
|
9
9
|
"exports": [
|
|
10
10
|
{
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"kind": "javascript-module",
|
|
22
|
-
"path": "src/Badge.
|
|
22
|
+
"path": "src/Badge.js",
|
|
23
23
|
"declarations": [
|
|
24
24
|
{
|
|
25
25
|
"kind": "variable",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"name": "BADGE_VARIANTS",
|
|
91
91
|
"declaration": {
|
|
92
92
|
"name": "BADGE_VARIANTS",
|
|
93
|
-
"module": "src/Badge.
|
|
93
|
+
"module": "src/Badge.js"
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
{
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"name": "Badge",
|
|
99
99
|
"declaration": {
|
|
100
100
|
"name": "Badge",
|
|
101
|
-
"module": "src/Badge.
|
|
101
|
+
"module": "src/Badge.js"
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/badge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-devmode.0+7b0ea531e",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -20,11 +20,24 @@
|
|
|
20
20
|
"module": "src/index.js",
|
|
21
21
|
"type": "module",
|
|
22
22
|
"exports": {
|
|
23
|
-
".":
|
|
24
|
-
|
|
23
|
+
".": {
|
|
24
|
+
"development": "./src/index.dev.js",
|
|
25
|
+
"default": "./src/index.js"
|
|
26
|
+
},
|
|
25
27
|
"./package.json": "./package.json",
|
|
26
|
-
"./
|
|
27
|
-
|
|
28
|
+
"./src/Badge.js": {
|
|
29
|
+
"development": "./src/Badge.dev.js",
|
|
30
|
+
"default": "./src/Badge.js"
|
|
31
|
+
},
|
|
32
|
+
"./src/badge.css.js": "./src/badge.css.js",
|
|
33
|
+
"./src/index.js": {
|
|
34
|
+
"development": "./src/index.dev.js",
|
|
35
|
+
"default": "./src/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./sp-badge.js": {
|
|
38
|
+
"development": "./sp-badge.dev.js",
|
|
39
|
+
"default": "./sp-badge.js"
|
|
40
|
+
}
|
|
28
41
|
},
|
|
29
42
|
"scripts": {
|
|
30
43
|
"test": "echo \"Error: run tests from mono-repo root.\" && exit 1"
|
|
@@ -44,8 +57,8 @@
|
|
|
44
57
|
"lit-html"
|
|
45
58
|
],
|
|
46
59
|
"dependencies": {
|
|
47
|
-
"@spectrum-web-components/base": "^0.
|
|
48
|
-
"@spectrum-web-components/shared": "^0.
|
|
60
|
+
"@spectrum-web-components/base": "^0.6.0",
|
|
61
|
+
"@spectrum-web-components/shared": "^0.15.0-devmode.0+7b0ea531e",
|
|
49
62
|
"tslib": "^2.0.0"
|
|
50
63
|
},
|
|
51
64
|
"devDependencies": {
|
|
@@ -54,7 +67,8 @@
|
|
|
54
67
|
"types": "./src/index.d.ts",
|
|
55
68
|
"customElements": "custom-elements.json",
|
|
56
69
|
"sideEffects": [
|
|
57
|
-
"./sp-*.js"
|
|
70
|
+
"./sp-*.js",
|
|
71
|
+
"./**/*.dev.js"
|
|
58
72
|
],
|
|
59
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "7b0ea531e9c7225c8964c5429bc5fd005618b80e"
|
|
60
74
|
}
|
package/src/Badge.dev.js
CHANGED
|
@@ -40,7 +40,9 @@ export class Badge extends SizedMixin(ObserveSlotText(SpectrumElement, "")) {
|
|
|
40
40
|
render() {
|
|
41
41
|
if (true) {
|
|
42
42
|
if (!BADGE_VARIANTS.includes(this.variant)) {
|
|
43
|
-
window.__swc.
|
|
43
|
+
window.__swc.warn(this, `<${this.localName}> element expect the "variant" attribute to be one of the following:`, "https://opensource.adobe.com/spectrum-web-components/components/badge/#variants", {
|
|
44
|
+
issues: [...BADGE_VARIANTS]
|
|
45
|
+
});
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
return html`
|
package/src/Badge.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Badge.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n SizedMixin,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport { ObserveSlotText } from '@spectrum-web-components/shared/src/observe-slot-text.js';\nimport styles from './badge.css.js';\n\nexport const BADGE_VARIANTS = [\n 'neutral',\n 'informative',\n 'positive',\n 'negative',\n 'fuchsia',\n 'indigo',\n 'magenta',\n 'purple',\n 'seafoam',\n 'yellow',\n] as const;\nexport type BadgeVariant = typeof BADGE_VARIANTS[number];\n\n/**\n * @element sp-badge\n *\n * @slot - Text label of the badge\n * @slot icon - Optional icon that appears to the left of the label\n */\nexport class Badge extends SizedMixin(ObserveSlotText(SpectrumElement, '')) {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: String, reflect: true })\n public variant: BadgeVariant = 'informative';\n\n protected override render(): TemplateResult {\n if (window.__swc.DEBUG) {\n if (!BADGE_VARIANTS.includes(this.variant)) {\n window.__swc.
|
|
5
|
-
"mappings": ";;;;;;;;;;;AAYA;AAAA;AAAA;AAAA;AAAA;AAOA;AAEA;AACA;AAEO,aAAM,iBAAiB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AASO,aAAM,cAAc,WAAW,gBAAgB,iBAAiB,EAAE,CAAC,EAAE;AAAA,EAArE;AAAA;AAMI,mBAAwB;AAAA;AAAA,aALJ,SAAyB;AAChD,WAAO,CAAC,MAAM;AAAA,EAClB;AAAA,EAKmB,SAAyB;AACxC,QAAI,MAAoB;AACpB,UAAI,CAAC,eAAe,SAAS,KAAK,OAAO,GAAG;AACxC,eAAO,MAAM,
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n SizedMixin,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport { ObserveSlotText } from '@spectrum-web-components/shared/src/observe-slot-text.js';\nimport styles from './badge.css.js';\n\nexport const BADGE_VARIANTS = [\n 'neutral',\n 'informative',\n 'positive',\n 'negative',\n 'fuchsia',\n 'indigo',\n 'magenta',\n 'purple',\n 'seafoam',\n 'yellow',\n] as const;\nexport type BadgeVariant = typeof BADGE_VARIANTS[number];\n\n/**\n * @element sp-badge\n *\n * @slot - Text label of the badge\n * @slot icon - Optional icon that appears to the left of the label\n */\nexport class Badge extends SizedMixin(ObserveSlotText(SpectrumElement, '')) {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: String, reflect: true })\n public variant: BadgeVariant = 'informative';\n\n protected override render(): TemplateResult {\n if (window.__swc.DEBUG) {\n if (!BADGE_VARIANTS.includes(this.variant)) {\n window.__swc.warn(\n this,\n `<${this.localName}> element expect the \"variant\" attribute to be one of the following:`,\n 'https://opensource.adobe.com/spectrum-web-components/components/badge/#variants',\n {\n issues: [...BADGE_VARIANTS]\n },\n );\n }\n }\n return html`\n <slot name=\"icon\" ?icon-only=${!this.slotHasContent}></slot>\n <div id=\"label\">\n <slot></slot>\n </div>\n `;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAYA;AAAA;AAAA;AAAA;AAAA;AAOA;AAEA;AACA;AAEO,aAAM,iBAAiB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AASO,aAAM,cAAc,WAAW,gBAAgB,iBAAiB,EAAE,CAAC,EAAE;AAAA,EAArE;AAAA;AAMI,mBAAwB;AAAA;AAAA,aALJ,SAAyB;AAChD,WAAO,CAAC,MAAM;AAAA,EAClB;AAAA,EAKmB,SAAyB;AACxC,QAAI,MAAoB;AACpB,UAAI,CAAC,eAAe,SAAS,KAAK,OAAO,GAAG;AACxC,eAAO,MAAM,KACT,MACA,IAAI,KAAK,iFACT,mFACA;AAAA,UACI,QAAQ,CAAC,GAAG,cAAc;AAAA,QAC9B,CACJ;AAAA,MACJ;AAAA,IACJ;AACA,WAAO;AAAA,2CAC4B,CAAC,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,EAK7C;AACJ;AAtBW;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAClC,AANJ,MAMI;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/Badge.js
CHANGED
|
@@ -40,7 +40,9 @@ export class Badge extends SizedMixin(ObserveSlotText(SpectrumElement, "")) {
|
|
|
40
40
|
render() {
|
|
41
41
|
if (false) {
|
|
42
42
|
if (!BADGE_VARIANTS.includes(this.variant)) {
|
|
43
|
-
window.__swc.
|
|
43
|
+
window.__swc.warn(this, `<${this.localName}> element expect the "variant" attribute to be one of the following:`, "https://opensource.adobe.com/spectrum-web-components/components/badge/#variants", {
|
|
44
|
+
issues: [...BADGE_VARIANTS]
|
|
45
|
+
});
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
return html`
|
package/src/Badge.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Badge.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n SizedMixin,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport { ObserveSlotText } from '@spectrum-web-components/shared/src/observe-slot-text.js';\nimport styles from './badge.css.js';\n\nexport const BADGE_VARIANTS = [\n 'neutral',\n 'informative',\n 'positive',\n 'negative',\n 'fuchsia',\n 'indigo',\n 'magenta',\n 'purple',\n 'seafoam',\n 'yellow',\n] as const;\nexport type BadgeVariant = typeof BADGE_VARIANTS[number];\n\n/**\n * @element sp-badge\n *\n * @slot - Text label of the badge\n * @slot icon - Optional icon that appears to the left of the label\n */\nexport class Badge extends SizedMixin(ObserveSlotText(SpectrumElement, '')) {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: String, reflect: true })\n public variant: BadgeVariant = 'informative';\n\n protected override render(): TemplateResult {\n if (window.__swc.DEBUG) {\n if (!BADGE_VARIANTS.includes(this.variant)) {\n window.__swc.
|
|
5
|
-
"mappings": ";;;;;;;;;;;AAYA;AAAA;AAAA;AAAA;AAAA;AAOA;AAEA;AACA;AAEO,aAAM,iBAAiB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AASO,aAAM,cAAc,WAAW,gBAAgB,iBAAiB,EAAE,CAAC,EAAE;AAAA,EAArE;AAAA;AAMI,mBAAwB;AAAA;AAAA,aALJ,SAAyB;AAChD,WAAO,CAAC,MAAM;AAAA,EAClB;AAAA,EAKmB,SAAyB;AACxC,QAAI,OAAoB;AACpB,UAAI,CAAC,eAAe,SAAS,KAAK,OAAO,GAAG;AACxC,eAAO,MAAM,
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n SizedMixin,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport { ObserveSlotText } from '@spectrum-web-components/shared/src/observe-slot-text.js';\nimport styles from './badge.css.js';\n\nexport const BADGE_VARIANTS = [\n 'neutral',\n 'informative',\n 'positive',\n 'negative',\n 'fuchsia',\n 'indigo',\n 'magenta',\n 'purple',\n 'seafoam',\n 'yellow',\n] as const;\nexport type BadgeVariant = typeof BADGE_VARIANTS[number];\n\n/**\n * @element sp-badge\n *\n * @slot - Text label of the badge\n * @slot icon - Optional icon that appears to the left of the label\n */\nexport class Badge extends SizedMixin(ObserveSlotText(SpectrumElement, '')) {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: String, reflect: true })\n public variant: BadgeVariant = 'informative';\n\n protected override render(): TemplateResult {\n if (window.__swc.DEBUG) {\n if (!BADGE_VARIANTS.includes(this.variant)) {\n window.__swc.warn(\n this,\n `<${this.localName}> element expect the \"variant\" attribute to be one of the following:`,\n 'https://opensource.adobe.com/spectrum-web-components/components/badge/#variants',\n {\n issues: [...BADGE_VARIANTS]\n },\n );\n }\n }\n return html`\n <slot name=\"icon\" ?icon-only=${!this.slotHasContent}></slot>\n <div id=\"label\">\n <slot></slot>\n </div>\n `;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAYA;AAAA;AAAA;AAAA;AAAA;AAOA;AAEA;AACA;AAEO,aAAM,iBAAiB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AASO,aAAM,cAAc,WAAW,gBAAgB,iBAAiB,EAAE,CAAC,EAAE;AAAA,EAArE;AAAA;AAMI,mBAAwB;AAAA;AAAA,aALJ,SAAyB;AAChD,WAAO,CAAC,MAAM;AAAA,EAClB;AAAA,EAKmB,SAAyB;AACxC,QAAI,OAAoB;AACpB,UAAI,CAAC,eAAe,SAAS,KAAK,OAAO,GAAG;AACxC,eAAO,MAAM,KACT,MACA,IAAI,KAAK,iFACT,mFACA;AAAA,UACI,QAAQ,CAAC,GAAG,cAAc;AAAA,QAC9B,CACJ;AAAA,MACJ;AAAA,IACJ;AACA,WAAO;AAAA,2CAC4B,CAAC,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,EAK7C;AACJ;AAtBW;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAClC,AANJ,MAMI;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/stories/badge.stories.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["badge.stories.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport '
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport '@spectrum-web-components/badge/sp-badge.js';\nimport { html, TemplateResult } from '@spectrum-web-components/base';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-checkmark-circle.js';\n\nexport default {\n title: 'Badge',\n component: 'sp-badge',\n};\n\nexport const Default = (): TemplateResult => {\n return html`\n <sp-badge>Badge</sp-badge>\n `;\n};\n\nexport const Icons = (): TemplateResult => {\n return html`\n <sp-badge>No icon</sp-badge>\n\n <sp-badge>\n <sp-icon-checkmark-circle slot=\"icon\"></sp-icon-checkmark-circle>\n Icon and label\n </sp-badge>\n\n <sp-badge>\n <sp-icon-checkmark-circle slot=\"icon\"></sp-icon-checkmark-circle>\n </sp-badge>\n `;\n};\n\nexport const Sizes = (): TemplateResult => {\n return html`\n <div style=\"display: flex; align-items: center; gap: 8px;\">\n <sp-badge size=\"s\">\n <sp-icon-checkmark-circle\n slot=\"icon\"\n ></sp-icon-checkmark-circle>\n Small\n </sp-badge>\n <sp-badge size=\"m\">\n <sp-icon-checkmark-circle\n slot=\"icon\"\n ></sp-icon-checkmark-circle>\n Medium\n </sp-badge>\n <sp-badge size=\"l\">\n <sp-icon-checkmark-circle\n slot=\"icon\"\n ></sp-icon-checkmark-circle>\n Large\n </sp-badge>\n <sp-badge size=\"xl\">\n <sp-icon-checkmark-circle\n slot=\"icon\"\n ></sp-icon-checkmark-circle>\n Extra-large\n </sp-badge>\n <sp-badge style=\"max-width: 180px\">\n <sp-icon-checkmark-circle\n slot=\"icon\"\n ></sp-icon-checkmark-circle>\n This long content automatically wraps, but shows no more than\n two lines\n </sp-badge>\n </div>\n `;\n};\n\nexport const Semantic = (): TemplateResult => {\n return html`\n <sp-badge variant=\"positive\">Positive</sp-badge>\n <sp-badge variant=\"informative\">Informative</sp-badge>\n <sp-badge variant=\"negative\">Negative</sp-badge>\n <sp-badge variant=\"neutral\">Neutral</sp-badge>\n `;\n};\n\nexport const NonSemantic = (): TemplateResult => {\n return html`\n <sp-badge variant=\"seafoam\">Seafoam</sp-badge>\n <sp-badge variant=\"indigo\">Indigo</sp-badge>\n <sp-badge variant=\"purple\">Purple</sp-badge>\n <sp-badge variant=\"fuchsia\">Fuchsia</sp-badge>\n <sp-badge variant=\"magenta\">Magenta</sp-badge>\n <sp-badge variant=\"yellow\">Yellow</sp-badge>\n `;\n};\n\nexport const Inline = (): TemplateResult => {\n return html`\n Badge is a simple\n <sp-badge variant=\"positive\" size=\"s\">inline</sp-badge>\n element that should\n <sp-badge variant=\"magenta\" size=\"s\">flow</sp-badge>\n with the rest of the page:\n <sp-badge variant=\"negative\">Missing</sp-badge>\n <sp-badge variant=\"positive\">Successful</sp-badge>\n <sp-badge variant=\"purple\">Purple</sp-badge>\n `;\n};\n\nexport const Fixed = (): TemplateResult => {\n return html`\n <div\n style=\"position: relative; width: 400px; height: 200px; background: #eee\"\n >\n <sp-badge>None</sp-badge>\n <sp-badge\n fixed=\"top\"\n style=\"position: absolute; top: 0; left: 200px;\"\n >\n Top\n </sp-badge>\n <sp-badge\n fixed=\"right\"\n style=\"position: absolute; right: 0; top: 100px;\"\n >\n Right\n </sp-badge>\n <sp-badge\n fixed=\"bottom\"\n style=\"position: absolute; bottom: 0; left: 200px;\"\n >\n Bottom\n </sp-badge>\n <sp-badge\n fixed=\"left\"\n style=\"position: absolute; left: 0; top: 100px;\"\n >\n Left\n </sp-badge>\n </div>\n `;\n};\n"],
|
|
5
5
|
"mappings": "AAYA;AACA;AACA;AAEA,eAAe;AAAA,EACX,OAAO;AAAA,EACP,WAAW;AACf;AAEO,aAAM,UAAU,MAAsB;AACzC,SAAO;AAAA;AAAA;AAGX;AAEO,aAAM,QAAQ,MAAsB;AACvC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYX;AAEO,aAAM,QAAQ,MAAsB;AACvC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmCX;AAEO,aAAM,WAAW,MAAsB;AAC1C,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAMX;AAEO,aAAM,cAAc,MAAsB;AAC7C,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQX;AAEO,aAAM,SAAS,MAAsB;AACxC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUX;AAEO,aAAM,QAAQ,MAAsB;AACvC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BX;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/test/badge.test.js
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { elementUpdated, expect, fixture, html } from "@open-wc/testing";
|
|
2
|
-
import "
|
|
3
|
-
import "
|
|
2
|
+
import "@spectrum-web-components/badge/sp-badge.js";
|
|
3
|
+
import "@spectrum-web-components/icons-workflow/icons/sp-icon-checkmark-circle.js";
|
|
4
|
+
import { stub } from "sinon";
|
|
5
|
+
import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
|
|
4
6
|
describe("Badge", () => {
|
|
7
|
+
testForLitDevWarnings(async () => await fixture(html`
|
|
8
|
+
<sp-badge>
|
|
9
|
+
<sp-icon-checkmark-circle
|
|
10
|
+
slot="icon"
|
|
11
|
+
></sp-icon-checkmark-circle>
|
|
12
|
+
Icon and label
|
|
13
|
+
</sp-badge>
|
|
14
|
+
`));
|
|
5
15
|
it("loads default badge accessibly", async () => {
|
|
16
|
+
const consoleWarnStub = stub(console, "warn");
|
|
6
17
|
const el = await fixture(html`
|
|
7
18
|
<sp-badge>
|
|
8
19
|
<sp-icon-checkmark-circle
|
|
@@ -13,6 +24,31 @@ describe("Badge", () => {
|
|
|
13
24
|
`);
|
|
14
25
|
await elementUpdated(el);
|
|
15
26
|
await expect(el).to.be.accessible();
|
|
27
|
+
expect(consoleWarnStub.called).to.be.false;
|
|
28
|
+
consoleWarnStub.restore();
|
|
29
|
+
});
|
|
30
|
+
it("warns in Dev Mode when sent an incorrect `variant`", async () => {
|
|
31
|
+
const consoleWarnStub = stub(console, "warn");
|
|
32
|
+
const el = await fixture(html`
|
|
33
|
+
<sp-badge variant="other">
|
|
34
|
+
<sp-icon-checkmark-circle
|
|
35
|
+
slot="icon"
|
|
36
|
+
></sp-icon-checkmark-circle>
|
|
37
|
+
Icon and label
|
|
38
|
+
</sp-badge>
|
|
39
|
+
`);
|
|
40
|
+
await elementUpdated(el);
|
|
41
|
+
expect(consoleWarnStub.called).to.be.true;
|
|
42
|
+
const spyCall = consoleWarnStub.getCall(0);
|
|
43
|
+
expect(spyCall.args.at(0).includes('"variant"'), "confirm variant-centric message").to.be.true;
|
|
44
|
+
expect(spyCall.args.at(-1), "confirm `data` shape").to.deep.equal({
|
|
45
|
+
data: {
|
|
46
|
+
localName: "sp-badge",
|
|
47
|
+
type: "api",
|
|
48
|
+
level: "default"
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
consoleWarnStub.restore();
|
|
16
52
|
});
|
|
17
53
|
});
|
|
18
54
|
//# sourceMappingURL=badge.test.js.map
|
package/test/badge.test.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["badge.test.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { elementUpdated, expect, fixture, html } from '@open-wc/testing';\n\nimport '
|
|
5
|
-
"mappings": "AAYA;AAEA;AACA;
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { elementUpdated, expect, fixture, html } from '@open-wc/testing';\n\nimport '@spectrum-web-components/badge/sp-badge.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-checkmark-circle.js';\nimport { stub } from 'sinon';\nimport { Badge } from '../src/Badge.js';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\n\ndescribe('Badge', () => {\n testForLitDevWarnings(\n async () =>\n await fixture<Badge>(\n html`\n <sp-badge>\n <sp-icon-checkmark-circle\n slot=\"icon\"\n ></sp-icon-checkmark-circle>\n Icon and label\n </sp-badge>\n `\n )\n );\n it('loads default badge accessibly', async () => {\n const consoleWarnStub = stub(console, 'warn');\n const el = await fixture<Badge>(\n html`\n <sp-badge>\n <sp-icon-checkmark-circle\n slot=\"icon\"\n ></sp-icon-checkmark-circle>\n Icon and label\n </sp-badge>\n `\n );\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n expect(consoleWarnStub.called).to.be.false;\n consoleWarnStub.restore();\n });\n it('warns in Dev Mode when sent an incorrect `variant`', async () => {\n const consoleWarnStub = stub(console, 'warn');\n const el = await fixture<Badge>(\n html`\n <sp-badge variant=\"other\">\n <sp-icon-checkmark-circle\n slot=\"icon\"\n ></sp-icon-checkmark-circle>\n Icon and label\n </sp-badge>\n `\n );\n\n await elementUpdated(el);\n\n expect(consoleWarnStub.called).to.be.true;\n const spyCall = consoleWarnStub.getCall(0);\n expect(\n spyCall.args.at(0).includes('\"variant\"'),\n 'confirm variant-centric message'\n ).to.be.true;\n expect(spyCall.args.at(-1), 'confirm `data` shape').to.deep.equal({\n data: {\n localName: 'sp-badge',\n type: 'api',\n level: 'default',\n },\n });\n consoleWarnStub.restore();\n });\n});\n"],
|
|
5
|
+
"mappings": "AAYA;AAEA;AACA;AACA;AAEA;AAEA,SAAS,SAAS,MAAM;AACpB,wBACI,YACI,MAAM,QACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAQJ,CACR;AACA,KAAG,kCAAkC,YAAY;AAC7C,UAAM,kBAAkB,KAAK,SAAS,MAAM;AAC5C,UAAM,KAAK,MAAM,QACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAQJ;AAEA,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAClC,WAAO,gBAAgB,MAAM,EAAE,GAAG,GAAG;AACrC,oBAAgB,QAAQ;AAAA,EAC5B,CAAC;AACD,KAAG,sDAAsD,YAAY;AACjE,UAAM,kBAAkB,KAAK,SAAS,MAAM;AAC5C,UAAM,KAAK,MAAM,QACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAQJ;AAEA,UAAM,eAAe,EAAE;AAEvB,WAAO,gBAAgB,MAAM,EAAE,GAAG,GAAG;AACrC,UAAM,UAAU,gBAAgB,QAAQ,CAAC;AACzC,WACI,QAAQ,KAAK,GAAG,CAAC,EAAE,SAAS,WAAW,GACvC,iCACJ,EAAE,GAAG,GAAG;AACR,WAAO,QAAQ,KAAK,GAAG,EAAE,GAAG,sBAAsB,EAAE,GAAG,KAAK,MAAM;AAAA,MAC9D,MAAM;AAAA,QACF,WAAW;AAAA,QACX,MAAM;AAAA,QACN,OAAO;AAAA,MACX;AAAA,IACJ,CAAC;AACD,oBAAgB,QAAQ;AAAA,EAC5B,CAAC;AACL,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|