Skip to content

Latest commit

 

History

History
133 lines (94 loc) · 3.43 KB

README.md

File metadata and controls

133 lines (94 loc) · 3.43 KB

<oscd-component>

Renaming the component

After instantiating this template repository, you will want to rename your component and then remove this section from the README.md file.

To find places where you have to search for and replace the string oscd-component you can use

$ git grep oscd-component
=>
README.md:# \<oscd-component>
README.md:npm i oscd-component
README.md:  import 'oscd-component';
README.md:<oscd-component></oscd-component>
index.html:    import './dist/oscd-component.js';
index.html:        <oscd-component .title=${title}>
index.html:        </oscd-component>
oscd-component.stories.ts:import './oscd-component.js';
oscd-component.stories.ts:  component: 'oscd-component',
oscd-component.stories.ts:  <oscd-component
oscd-component.stories.ts:    style="--oscd-component-text-color: ${textColor || 'black'}"
oscd-component.stories.ts:  </oscd-component>
oscd-component.spec.ts:import './oscd-component.js';
oscd-component.spec.ts:import type { OscdComponent } from './oscd-component.js';
oscd-component.spec.ts:      html`<oscd-component></oscd-component>`
oscd-component.spec.ts:      html`<oscd-component></oscd-component>`
oscd-component.spec.ts:      html`<oscd-component title="attribute title"></oscd-component>`
oscd-component.spec.ts:      html`<oscd-component></oscd-component>`
oscd-component.ts:@customElement('oscd-component')
oscd-component.ts:      color: var(--oscd-component-text-color, #000);
package.json:  "name": "oscd-component",
package.json:  "description": "Webcomponent oscd-component following open-wc recommendations",
package.json:  "main": "dist/oscd-component.js",
package.json:  "module": "dist/oscd-component.js",
package.json:    ".": "./dist/oscd-component.js"

In order to replace all instances of the string oscd-component in your repository at once, you can use a tool like git sed in order to execute a substitute expression on all files in the worktree:

git sed s/oscd-component/my-widget/g

Make sure to use a dash - in the new component name and to rename all files with names starting with oscd-component:

oscd-component.stories.ts
oscd-component.spec.ts
oscd-component.ts

This webcomponent follows the open-wc recommendation.

Installation

npm i oscd-component

Usage

<script type="module">
  import 'oscd-component';
</script>

<oscd-component></oscd-component>

Linting and formatting

To scan the project for linting and formatting errors, run

npm run lint

To automatically fix linting and formatting errors, run

npm run format

Testing with Web Test Runner

To execute a single test run:

npm run test

To run the tests in interactive watch mode run:

npm run test:watch

Demoing with Storybook

To run a local instance of Storybook for your component, run

npm run storybook

To build a production version of Storybook, run

npm run storybook:build

Tooling configs

For most of the tools, the configuration is in the package.json to reduce the amount of files in your project.

If you customize the configuration a lot, you can consider moving them to individual files.

Local Demo with web-dev-server

npm start

To run a local development server that serves the basic demo located in demo/index.html