Skip to content

Commit

Permalink
chore: move customElement into svg-to-inline.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoporto committed Dec 1, 2024
1 parent bc190b0 commit 9721562
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ npm i svg-to-inline

```html
<script type="module">
import 'svg-to-inline/SvgToInline.js'
import 'svg-to-inline/svg-to-inline.js'
</script>

<svg-to-inline
Expand Down
7 changes: 1 addition & 6 deletions demo/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
</head>
<body>
<script type="module">
import '../dist/src/SvgToInline.js'
// import { html, render } from 'lit-html'

// const element = html``

// render(element, document.body)
import '../dist/src/svg-to-inline.js'
</script>

<svg-to-inline
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
},
"type": "module",
"customElements": "custom-elements.json",
"types": "dist/SvgToInline.d.ts",
"main": "dist/SvgToInline.js",
"module": "dist/SvgToInline.js",
"types": "dist/index.d.ts",
"main": "dist/index.js",
"module": "dist/index.js",
"exports": {
".": "./dist/SvgToInline.js",
".": "./dist/index.js",
"./svg-to-inline.js": "./dist/svg-to-inline.js",
"./customElements": "./custom-elements.json"
},
"files": [
Expand Down
11 changes: 5 additions & 6 deletions src/SvgToInline.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { html, LitElement } from 'lit'
import type { TemplateResult } from 'lit'
import { state, customElement, property } from 'lit/decorators.js'
import { state, property } from 'lit/decorators.js'
import { throttle } from 'throttle-debounce'
import { fetchFile } from './utils/fetchFile.js'
import { convertStringToNode } from './utils/convertStringToNode.js'
import { addClassNames } from './utils/addClassNames.js'

@customElement('svg-to-inline')
export class SvgToInline extends LitElement {
@state()
private _svgDOM: string | null = null
Expand All @@ -17,10 +16,10 @@ export class SvgToInline extends LitElement {
@state()
private _throttleLazyFetchSVG: (event: Event) => void

@property()
path?: string
@property({ type: String })
path = ''

@property()
@property({ type: String })
className = ''

@property()
Expand All @@ -30,7 +29,7 @@ export class SvgToInline extends LitElement {
placeholder?: TemplateResult | string

@property({ type: Boolean })
lazy: boolean = false
lazy = false

constructor() {
super()
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { SvgToInline } from './SvgToInline.js'
File renamed without changes.
4 changes: 2 additions & 2 deletions src/SvgToInline.stories.ts → src/svg-to-inline.stories.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { html } from 'lit'
import type { TemplateResult } from 'lit'
import type { Meta, StoryObj } from '@storybook/web-components'
import type { Meta } from '@storybook/web-components'

import './SvgToInline.ts'
import './svg-to-inline.js'

interface ArgTypes {
path: string
Expand Down
4 changes: 2 additions & 2 deletions src/SvgToInline.test.ts → src/svg-to-inline.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { html } from 'lit'
import { fixture, expect } from '@open-wc/testing'
import type { SvgToInline } from './SvgToInline.js'
import './SvgToInline.js'
import type { SvgToInline } from './'
import './svg-to-inline.js'

describe('SvgToInline', () => {
// it('test _ and ; value')
Expand Down
3 changes: 3 additions & 0 deletions src/svg-to-inline.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { SvgToInline } from './SvgToInline.js'

window.customElements.define('svg-to-inline', SvgToInline)

0 comments on commit 9721562

Please sign in to comment.