Skip to content

Commit 55bccf9

Browse files
keithamuslangermank
andcommitted
prepare for release
Co-authored-by: langermank <[email protected]>
1 parent 23aae0e commit 55bccf9

File tree

7 files changed

+72
-54
lines changed

7 files changed

+72
-54
lines changed

README.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# &lt;custom-element&gt; element
1+
# &lt;marquee-text&gt; element
22

3-
Boilerplate for creating a custom element.
3+
An elemen which scrolls the text inside it like the traditional [marquee](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/marquee) element found in the browsers of yesteryear.
44

55
## Installation
6-
Available on [npm](https://www.npmjs.com/) as [**@github/custom-element-element**](https://www.npmjs.com/package/@github/custom-element-element).
6+
Available on [npm](https://www.npmjs.com/) as [**marquee-text-element**](https://www.npmjs.com/package/marquee-text-element).
77
```
8-
$ npm install --save @github/custom-element-element
8+
$ npm install --save marquee-text-element
99
```
1010

1111
## Usage
@@ -15,22 +15,19 @@ $ npm install --save @github/custom-element-element
1515
Import as ES modules:
1616

1717
```js
18-
import '@github/custom-element-element'
18+
import 'marquee-text-element'
1919
```
2020

2121
Include with a script tag:
2222

2323
```html
24-
<script type="module" src="./node_modules/@github/custom-element-element/dist/index.js">
24+
<script type="module" src="./node_modules/marquee-text-element/dist/index.js">
2525
```
2626
27-
An example Custom Element. This documentation ends up in the
28-
README so describe how this elements works here.
29-
30-
You can event add examples on the element is used with Markdown.
31-
32-
```
33-
<custom-element></custom-element>
27+
```html
28+
<marquee-text duration="2s">
29+
This text will scroll across the page over 2s
30+
</marquee-text>
3431
```
3532
3633
## Browser support

custom-elements.json

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,32 @@
44
"modules": [
55
{
66
"kind": "javascript-module",
7-
"path": "src/custom-element.ts",
7+
"path": "src/marquee-text-element.ts",
88
"declarations": [
99
{
1010
"kind": "class",
11-
"description": "An example Custom Element. This documentation ends up in the\nREADME so describe how this elements works here.\n\nYou can event add examples on the element is used with Markdown.\n\n```\n<custom-element></custom-element>\n```",
12-
"name": "CustomElementElement",
11+
"description": "```html\n<marquee-text duration=\"2s\">\n This text will scroll across the page over 2s\n</marquee-text>\n```",
12+
"name": "MarqueeTextElement",
13+
"members": [
14+
{
15+
"kind": "field",
16+
"name": "#renderRoot",
17+
"privacy": "private"
18+
},
19+
{
20+
"kind": "field",
21+
"name": "duration"
22+
}
23+
],
24+
"attributes": [
25+
{
26+
"name": "duration"
27+
}
28+
],
1329
"superclass": {
1430
"name": "HTMLElement"
1531
},
16-
"tagName": "custom-element",
32+
"tagName": "marquee-text",
1733
"customElement": true
1834
}
1935
],
@@ -22,16 +38,16 @@
2238
"kind": "js",
2339
"name": "default",
2440
"declaration": {
25-
"name": "CustomElementElement",
26-
"module": "src/custom-element.ts"
41+
"name": "MarqueeTextElement",
42+
"module": "src/marquee-text-element.ts"
2743
}
2844
},
2945
{
3046
"kind": "custom-element-definition",
31-
"name": "custom-element",
47+
"name": "marquee-text",
3248
"declaration": {
33-
"name": "CustomElementElement",
34-
"module": "src/custom-element.ts"
49+
"name": "MarqueeTextElement",
50+
"module": "src/marquee-text-element.ts"
3551
}
3652
}
3753
]

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
{
2-
"name": "@github/custom-element-element",
3-
"version": "0.0.1",
4-
"description": "Boilerplate for creating a custom element.",
5-
"main": "dist/custom-element.js",
6-
"module": "dist/custom-element.js",
2+
"name": "marquee-text-element",
3+
"version": "0.0.0-development",
4+
"description": "An elemen which scrolls the text inside it like the traditional [marquee](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/marquee) element found in the browsers of yesteryear.",
5+
"main": "dist/marquee-text-element.js",
6+
"module": "dist/marquee-text-element.js",
77
"type": "module",
8-
"types": "dist/custom-elements.d.ts",
8+
"types": "dist/marquee-text-elements.d.ts",
99
"license": "MIT",
10-
"repository": "github/custom-element-boilerplate",
10+
"repository": "24webcomponents/marquee-text-element",
1111
"files": [
1212
"dist"
1313
],
1414
"scripts": {
15+
"meta": "custom-elements-manifest analyze",
1516
"clean": "rm -rf dist",
1617
"lint": "eslint . --ext .ts,.js",
1718
"prebuild": "npm run clean && npm run lint && mkdir dist",

src/marquee-text-element.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
1+
const DEFAULT_DURATION = '5s'
2+
3+
/**
4+
* ```html
5+
* <marquee-text duration="2s">
6+
* This text will scroll across the page over 2s
7+
* </marquee-text>
8+
* ```
9+
*/
110
class MarqueeTextElement extends HTMLElement {
211
static observedAttributes = ['duration']
312

4-
513
#renderRoot = this.attachShadow({mode: 'open'})
614

715
get duration() {
816
const value = this.getAttribute('duration')
9-
return value
17+
return value ?? DEFAULT_DURATION
1018
}
1119

1220
set duration(value: string) {
1321
this.setAttribute('duration', value)
1422
}
1523

16-
attributeChangedCallback(name: 'duration', oldValue: null|string, newValue: null|string) {
24+
attributeChangedCallback(name: 'duration', oldValue: null | string, newValue: null | string) {
1725
if (oldValue === newValue) return
1826
if (newValue === null) return
1927
if (newValue) this.style.setProperty('--animation-duration', newValue)
2028
}
2129

2230
connectedCallback(): void {
31+
// eslint-disable-next-line github/no-inner-html
2332
this.#renderRoot.innerHTML = `
2433
<style>
2534
@keyframes marqueeeee {
@@ -31,7 +40,7 @@ class MarqueeTextElement extends HTMLElement {
3140
}
3241
}
3342
:host slot {
34-
animation: var(--animation-duration, 5s) linear infinite marqueeeee;
43+
animation: var(--animation-duration, ${DEFAULT_DURATION}) linear infinite marqueeeee;
3544
display: inline-block;
3645
}
3746
:host {

test/test.ts

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
1-
import {assert, fixture, html} from '@open-wc/testing'
2-
import '../src/custom-element'
1+
import {assert} from '@open-wc/testing'
2+
import '../src/marquee-text-element'
33

4-
describe('custom-element', function () {
4+
describe('marquee-text-element', function () {
55
describe('element creation', function () {
66
it('creates from document.createElement', function () {
7-
const el = document.createElement('custom-element')
8-
assert.equal('CUSTOM-ELEMENT', el.nodeName)
7+
const el = document.createElement('marquee-text')
8+
assert.equal('MARQUEE-TEXT', el.nodeName)
99
})
1010

1111
it('creates from constructor', function () {
12-
const el = new window.CustomElementElement()
13-
assert.equal('CUSTOM-ELEMENT', el.nodeName)
14-
})
15-
})
16-
17-
describe('after tree insertion', function () {
18-
beforeEach(async function () {
19-
await fixture(html` <custom-element></custom-element>`)
20-
})
21-
22-
it('initiates', function () {
23-
const ce = document.querySelector('custom-element')
24-
assert.equal(ce?.textContent, ':wave:')
12+
const el = new window.MarqueeTextElement()
13+
assert.equal('MARQUEE-TEXT', el.nodeName)
2514
})
2615
})
2716
})

vscode.css-custom-data.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"version": 1.1,
3+
"properties": [],
4+
"pseudoElements": []
5+
}

vscode.html-custom-data.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
2+
"version": 1.1,
23
"tags": [
34
{
4-
"name": "custom-element",
5-
"description": "An example Custom Element. This documentation ends up in the\nREADME so describe how this elements works here.\n\nYou can event add examples on the element is used with Markdown.\n\n```\n<custom-element></custom-element>\n```",
6-
"attributes": []
5+
"name": "marquee-text",
6+
"description": "```html\n<marquee-text duration=\"2s\">\n This text will scroll across the page over 2s\n</marquee-text>\n```",
7+
"attributes": [{ "name": "duration", "values": [] }]
78
}
89
]
910
}

0 commit comments

Comments
 (0)