0.1.6 • Published 10 months ago

wc-github-corners v0.1.6

Weekly downloads
-
License
-
Repository
github
Last release
10 months ago

wc-github-corners

Published on webcomponents.org npm npm bundle size jsDelivr hits (npm)

从零开始写一个 Web Component - GitHub Corners | 云游君的小站

A web component by lit for GitHub Corners.

The final product is an ES module, and it can be used alone.

Anywhere like Vanilla JS / Vue / React / Angular / Svelte ...

Demo

Usage

npm i wc-github-corners

By CDN

See demo/index.html.

  • jsdelivr: https://cdn.jsdelivr.net/npm/wc-github-corners@latest
  • unpkg: https://www.unpkg.com/wc-github-corners@latest
<!-- cdn -->
<script
  type="module"
  src="https://www.unpkg.com/wc-github-corners@latest"
></script>

<github-corners></github-corners>

By NPM

// main.ts
import 'wc-github-corners'
<!-- index.html -->
<github-corners></github-corners>

I successfully used it in a vue project - char-dust.

API

Example

<github-corners fill="#0078e7" position="left" reverse></github-corners>

src/index.ts:

class: GitHubCorners

Superclass
NameModulePackage
LitElementlit
Fields
NamePrivacyTypeDefaultDescriptionInherited From
blankbooleanfalsetarget="_blank" for link
colorstring'#fff'Font color
fillstring'#151513'Fill color for github corners
repostring'YunYouJun/wc-github-corners'Your GitHub Repo Name, generate url start with \https\://github.com.
urlstring''You also can custom it to override the url generated by repo.
labelstring'View source on GitHub'Hover title
reversebooleanfalseReverse color and fill
positionstring'right'Position of github corners, 'left' or 'right'

I written it as a tutorial in my Bilibili Live Room.

Thanks to my fans and sponsors.

FAQ

Vue warn: Failed to resolve component: github-corners

If you write it in vue template, you should make sure to exclude it from component resolution via compilerOptions.isCustomElement.

In vite:

import { defineConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'

export default defineConfig({
  plugins: [
    Vue({
      include: [/\.vue$/, /\.md$/],
      template: {
        compilerOptions: {
          isCustomElement: (tag) => {
            return ['github-corners'].includes(tag)
          },
        },
      },
    }),
  ],
})

Want to use by CDN in vue?

Try @vueuse/head.

<script setup lang="ts">
  import { useHead } from "@vueuse/head";

  useHead({
    script: [
      {
        src: "https://cdn.jsdelivr.net/npm/wc-github-corners@latest",
        type: "module",
      },
    ],
  });
</script>

Sponsors

0.1.6

10 months ago

0.1.4

2 years ago

0.1.5

2 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago