Skip to content

Commit

Permalink
feat: first blood, should just work (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin authored Aug 26, 2022
1 parent e31cc53 commit 19ab908
Show file tree
Hide file tree
Showing 18 changed files with 1,650 additions and 1,114 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/pkg-size.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/size-limit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Size Limit

on:
pull_request_target:
branches:
- main

jobs:
size-limit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: latest

- name: Setup Node.js LTS
uses: actions/setup-node@v3
with:
node-version: lts/*
cache: pnpm

- name: Install Dependencies
run: pnpm i

- uses: andresz1/size-limit-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
skip_step: install
script: pnpm size-limit --json
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@

This repository is a monorepo managed by [changesets][] what means we actually publish several packages to npm from same codebase, including:

| Package | Description | Version |
| ------------------------ | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [`onii`](/packages/onii) | Hi, onii-san! Everything about web components! | [![npm](https://img.shields.io/npm/v/onii.svg)](https://www.npmjs.com/package/onii) [![View changelog](https://img.shields.io/badge/changelog-explore-brightgreen)](https://changelogs.xyz/onii) |
| Package | Description | Version |
| ---------------------------------------- | -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`onii`](/packages/onii) | Hi, onii-san! Everything about web components! | [![npm](https://img.shields.io/npm/v/onii.svg)](https://www.npmjs.com/package/onii) [![View changelog](https://img.shields.io/badge/changelog-explore-brightgreen)](https://changelogs.xyz/onii) |
| [`@onii/quill`](/packages/@oniijs/quill) | Your powerful rich text editor with Web Components | [![npm](https://img.shields.io/npm/v/@onii/quill.svg)](https://www.npmjs.com/package/@onii/quill) [![View changelog](https://img.shields.io/badge/changelog-explore-brightgreen)](https://changelogs.xyz/@onii/quill) |

## Sponsors

Expand Down
13 changes: 13 additions & 0 deletions docs/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ import {
Navigate,
} from 'react-router-dom'

import { define } from '@oniijs/quill'

import './global.scss'
import 'github-markdown-css'

export type Params = { name: string } | { orgName: string; pkgName: string }

define()

const Readme = () => {
const params = useParams<Params>() as Readonly<Params>
const Readme = lazy(() =>
Expand Down Expand Up @@ -53,6 +57,15 @@ export const App = () => (
path="/packages/:name"
element={<Readme />}
/>
<Route
path="/packages/:orgName/:pkgName"
element={
<>
<onii-quill />
<Readme />
</>
}
/>
<Route
path="/packages/:orgName/:pkgName"
element={<Readme />}
Expand Down
17 changes: 17 additions & 0 deletions docs/shim.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { OniiQuill } from '@oniijs/quill'

export type CustomElement<T> = Partial<
DOMAttributes<T> & T & { children: unknown }
>

export type CustomEvents<K extends string, T = unknown> = {
[key in K]: (event: CustomEvent<T>) => void
}

declare global {
namespace JSX {
interface IntrinsicElements {
['onii-quill']: CustomElement<OniiQuill>
}
}
}
30 changes: 25 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"license": "MIT",
"private": true,
"workspaces": [
"packages/@oniijs/*",
"packages/*"
],
"packageManager": "[email protected]",
Expand All @@ -34,32 +35,38 @@
"version": "changeset version"
},
"devDependencies": {
"@1stg/app-config": "^7.1.1",
"@1stg/lib-config": "^10.1.1",
"@1stg/app-config": "^7.2.1",
"@1stg/lib-config": "^10.2.1",
"@changesets/changelog-github": "^0.4.6",
"@changesets/cli": "^2.24.3",
"@pkgr/webpack": "^3.3.0",
"@pkgr/webpack-mdx": "^2.1.0",
"@oniijs/quill": "workspace:*",
"@pkgr/webpack": "^3.3.1",
"@pkgr/webpack-mdx": "^2.1.1",
"@size-limit/preset-small-lib": "^8.0.1",
"@types/node": "^18.7.13",
"@types/quill": "^2.0.9",
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@types/web": "^0.0.72",
"@vitest/coverage-istanbul": "^0.22.1",
"github-markdown-css": "^5.1.0",
"happy-dom": "^6.0.4",
"onii": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.3.0",
"sirv-cli": "^2.0.2",
"size-limit": "^8.0.1",
"tsx": "^3.8.2",
"type-coverage": "^2.22.0",
"typescript": "^4.7.4",
"typescript": "^4.8.2",
"unplugin-auto-import": "^0.11.2",
"vitest": "^0.22.1"
},
"resolutions": {
"prettier": "^2.7.1"
},
"browserslist": "extends @1stg/browserslist-config/modern",
"commitlint": {
"extends": "@1stg"
},
Expand Down Expand Up @@ -90,6 +97,19 @@
"@1stg"
]
},
"size-limit": [
{
"path": "packages/@oniijs/quill/lib/index.js",
"ignore": [
"quill"
],
"limit": "700B"
},
{
"path": "packages/onii/lib/index.js",
"limit": "40B"
}
],
"stylelint": {
"extends": "@1stg/stylelint-config"
},
Expand Down
1 change: 1 addition & 0 deletions packages/@oniijs/quill/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Change Log
60 changes: 60 additions & 0 deletions packages/@oniijs/quill/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# @oniijs/quill

Your powerful rich text editor with Web Components

## TOC <!-- omit in toc -->

- [Usage](#usage)
- [Install](#install)
- [API](#api)
- [Sponsors](#sponsors)
- [Backers](#backers)
- [Changelog](#changelog)
- [License](#license)

## Usage

### Install

```sh
# pnpm
pnpm add @oniijs/quill

# yarn
yarn add @oniijs/quill

# npm
npm i @oniijs/quill
```

### API

```js
import echo from '@oniijs/quill'

echo()
```

## Sponsors

| 1stG | RxTS | UnTS |
| ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| [![1stG Open Collective backers and sponsors](https://opencollective.com/1stG/organizations.svg)](https://opencollective.com/1stG) | [![RxTS Open Collective backers and sponsors](https://opencollective.com/rxts/organizations.svg)](https://opencollective.com/rxts) | [![UnTS Open Collective backers and sponsors](https://opencollective.com/unts/organizations.svg)](https://opencollective.com/unts) |

## Backers

| 1stG | RxTS | UnTS |
| -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| [![1stG Open Collective backers and sponsors](https://opencollective.com/1stG/individuals.svg)](https://opencollective.com/1stG) | [![RxTS Open Collective backers and sponsors](https://opencollective.com/rxts/individuals.svg)](https://opencollective.com/rxts) | [![UnTS Open Collective backers and sponsors](https://opencollective.com/unts/individuals.svg)](https://opencollective.com/unts) |

## Changelog

Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.md).

## License

[MIT][] © [JounQin][]@[1stG.me][]

[1stg.me]: https://www.1stg.me
[jounqin]: https://GitHub.com/JounQin
[mit]: http://opensource.org/licenses/MIT
32 changes: 32 additions & 0 deletions packages/@oniijs/quill/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@oniijs/quill",
"version": "0.0.0",
"type": "module",
"description": "Your powerful rich text editor with Web Components",
"repository": "git+https://github.com/oniijs/onii.git",
"homepage": "https://github.com/oniijs/onii/blob/main/packages/quill",
"author": "JounQin (https://www.1stG.me) <[email protected]>",
"funding": "https://opencollective.com/unts",
"license": "MIT",
"engines": {
"node": "^12.20.0 || ^14.18.0 || >=16.0.0"
},
"main": "./src/index.ts",
"files": [
"lib"
],
"dependencies": {
"quill": "^2.0.0-dev.4"
},
"publishConfig": {
"access": "public",
"main": "./lib/index.cjs",
"module": "./lib/index.js",
"exports": {
"types": "./lib/index.d.ts",
"import": "./lib/index.js",
"require": "./lib/index.cjs"
},
"types": "./lib/index.d.ts"
}
}
15 changes: 15 additions & 0 deletions packages/@oniijs/quill/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export class OniiQuill extends HTMLElement {
constructor() {
super()

const shadow = this.attachShadow({ mode: 'closed' })

const div = document.createElement('div')
div.textContent = 'Hello World, Web Components!'

shadow.append(div)
}
}

export const define = (name = 'onii-quill') =>
customElements.define(name, OniiQuill)
8 changes: 8 additions & 0 deletions packages/@oniijs/quill/test/basic.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { define, OniiQuill } from '@oniijs/quill'

test('it should just work', () => {
expect(customElements.get('onii-quill')).toBeUndefined()

define()
expect(customElements.get('onii-quill')).toBe(OniiQuill)
})
9 changes: 9 additions & 0 deletions packages/@oniijs/quill/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../tsconfig",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib"
},
"include": ["src"]
}
31 changes: 0 additions & 31 deletions packages/onii/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,6 @@
"repository": "git+https://github.com/oniijs/onii.git",
"homepage": "https://github.com/oniijs/onii/blob/main/packages/onii",
"author": "JounQin (https://www.1stG.me) <[email protected]>",
"donate": {
"recipients": [
{
"name": "unts",
"platform": "opencollective",
"address": "https://opencollective.com/unts",
"weight": 60
},
{
"name": "rxts",
"platform": "opencollective",
"address": "https://opencollective.com/rxts",
"weight": 20
},
{
"name": "1stG",
"email": "[email protected]",
"weight": 20,
"platforms": [
{
"platform": "opencollective",
"address": "https://opencollective.com/1stG"
},
{
"platform": "patreon",
"address": "https://www.patreon.com/1stG"
}
]
}
]
},
"funding": "https://opencollective.com/unts",
"license": "MIT",
"engines": {
Expand Down
Loading

0 comments on commit 19ab908

Please sign in to comment.