# cubeshop

> Mobile UI Components built on Web Components.

Latest version **0.0.25** (published 2021-09-29) · 0 weekly downloads

## Install

```sh
npm install cubeshop
pnpm add cubeshop
yarn add cubeshop
bun add cubeshop
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.25 |
| Published | 2021-09-29 |
| First published | 2021-09-16 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 1.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | allan2coder |
| Keywords | web components, vue, webpack, vite |

## Links

- npm: https://www.npmjs.com/package/cubeshop
- Repository: https://github.com/allan2coder/cubeshop
- Homepage: https://github.com/allan2coder/cubeshop#readme
- Issues: https://github.com/allan2coder/cubeshop/issues
- npm.io page: https://npm.io/package/cubeshop

## Dependencies (1)

- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.5.5

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.0.25 (latest) — 2021-09-29
- 0.0.24 — 2021-09-29
- 0.0.22 — 2021-09-24
- 0.0.21 — 2021-09-24
- 0.0.20 — 2021-09-22
- 0.0.19 — 2021-09-22
- 0.0.18 — 2021-09-22
- 0.0.17 — 2021-09-17
- 0.0.16 — 2021-09-17
- 0.0.15 — 2021-09-16
- 0.0.14 — 2021-09-16
- 0.0.13 — 2021-09-16
- 0.0.12 — 2021-09-16
- 0.0.11 — 2021-09-16

## README

# Cubeshop

[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/owner/my-element)

Cubeshop 是一个基于 Web Components 的跨框架 UI 组件库，输出标准的 Custom Element，组件可以同时在 React、Vue、Preact、Angular 或 原生 JS 等任意框架或无框架中使用。

我是使用者 developer ｜ [我是开发者 user](./README-dev.md)

## Features

- 支持Vue、React、Angular，技术栈无关
- 基于 Web Components.
- 简单、速度快


## 安装使用

具体安装使用方法请参考 Cubeshop 官网 https://allan2coder.github.io/cubeshop

## CDN 使用

```js
<script type="module" src="https://unpkg.com/cubeshop"></script>
// 或
<script type="module" src="https://cdn.jsdelivr.net/npm/cubeshop"></script>
```

## NPM 使用

### 📦 安装

```
npm install cubeshop // or yarn add cubeshop
```


### 🔨使用

#### 1、按需加载

babel.config.js 添加如下配置， 依赖 `babel-plugin-import` 插件
```tsx
plugins: [
  ['import', {
    libraryName: 'cubeshop',
    libraryDirectory: 'lib',
  }, 'cubeshop']
]
```

```tsx
import { CSButton, WCUse } from 'cubeshop'
WCUse(CSButton)

<cs-button type="primary">button</cs-button>
```

#### 2、全量加载
```js
import 'cubeshop';
```

## Vue/React 中使用

当作原生 dom 元素直接使用即可。

#### Vue 工程

```jsx
<template>
  <div>
    <cs-button type="primary">按钮</cs-button>
  </div>
</template>
```
#### React 工程

```jsx
class Demo extends React.Component {
  render() {
    return (
      <div>
        <cs-button type="primary">按钮</cs-button>
      </div>
    );
  }
}
```

##  注意

> Vue 工程中使用组件可能会出现告警 `Unknown custom element`

```html
<!-- vue2: -->
Unknown custom element: <cs-card> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
<!-- vue3 -->
[Vue warn]: Failed to resolve component: cs-icon 
```

别急，请在工程中注入如下代码即可：

```js
// VUE2.x
Vue.config.ignoredElements = [/^cs-/]

// VUE3.x
// https://v3.cn.vuejs.org/guide/migration/global-api.html#config-productiontip-%E7%A7%BB%E9%99%A4
const app = createApp({})
app.config.compilerOptions.isCustomElement = tag => tag.startsWith('cs-')
```

如果您使用的是 vite，修改 vite.config.js:

```js
import vue from '@vitejs/plugin-vue'
export default {
  plugins: [
    vue({
      template: {
        compilerOptions: {
          isCustomElement: tag => tag === 'cs-'
        }
      }
    })
  ]
}
```

## License

[cubeshop](https://github.com/allan2coder/cubeshop) is released
under the MIT License. See the bundled [LICENSE](./LICENSE) file for details.

---
_Source: https://npm.io/package/cubeshop · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
