Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
qq15725 committed Jan 19, 2024
1 parent f51f1e6 commit bc8d363
Show file tree
Hide file tree
Showing 9 changed files with 517 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

### Before submitting the PR, please make sure you do the following

- [ ] Read the [Pull Request Guidelines](https://github.com/qq15725/starter-ts/blob/main/.github/pull-request-guidelines.md) and follow the [PR Title Convention](https://github.com/qq15725/starter-ts/blob/main/.github/commit-convention.md).
- [ ] Read the [Pull Request Guidelines](https://github.com/qq15725/modern-text/blob/main/.github/pull-request-guidelines.md) and follow the [PR Title Convention](https://github.com/qq15725/modern-text/blob/main/.github/commit-convention.md).
- [ ] Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
- [ ] Provide a description in this PR that addresses **what** the PR is solving, or reference the issue that it solves (e.g. `fixes #123`).
- [ ] Ideally, include relevant tests that fail without this PR but pass with it.
2 changes: 1 addition & 1 deletion .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
with:
tag_name: ${{ github.ref }}
body: |
Please refer to [CHANGELOG.md](https://github.com/qq15725/starter-ts/blob/${{ github.ref_name }}/CHANGELOG.md) for details.
Please refer to [CHANGELOG.md](https://github.com/qq15725/modern-text/blob/${{ github.ref_name }}/CHANGELOG.md) for details.
56 changes: 35 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,49 @@
<h1 align="center">starter-ts</h1>
<h1 align="center">modern-text</h1>

<p align="center">
<a href="https://unpkg.com/starter-ts">
<img src="https://img.shields.io/bundlephobia/minzip/starter-ts" alt="Minzip">
<a href="https://unpkg.com/modern-text">
<img src="https://img.shields.io/bundlephobia/minzip/modern-text" alt="Minzip">
</a>
<a href="https://www.npmjs.com/package/starter-ts">
<img src="https://img.shields.io/npm/v/starter-ts.svg" alt="Version">
<a href="https://www.npmjs.com/package/modern-text">
<img src="https://img.shields.io/npm/v/modern-text.svg" alt="Version">
</a>
<a href="https://www.npmjs.com/package/starter-ts">
<img src="https://img.shields.io/npm/dm/starter-ts" alt="Downloads">
<a href="https://www.npmjs.com/package/modern-text">
<img src="https://img.shields.io/npm/dm/modern-text" alt="Downloads">
</a>
<a href="https://github.com/qq15725/starter-ts/issues">
<img src="https://img.shields.io/github/issues/qq15725/starter-ts" alt="Issues">
<a href="https://github.com/qq15725/modern-text/issues">
<img src="https://img.shields.io/github/issues/qq15725/modern-text" alt="Issues">
</a>
<a href="https://github.com/qq15725/starter-ts/blob/main/LICENSE">
<img src="https://img.shields.io/npm/l/starter-ts.svg" alt="License">
<a href="https://github.com/qq15725/modern-text/blob/main/LICENSE">
<img src="https://img.shields.io/npm/l/modern-text.svg" alt="License">
</a>
</p>

## Try it now!
## Usage

### GitHub Template
```ts
import { Text } from 'modern-text'

[Create a repo from this template on GitHub](https://github.com/qq15725/starter-ts/generate).
const text = new Text({
style: {
width: 100,
height: 200,
fontSize: 22,
backgroundColor: '#0000FF',
textDecoration: 'underline',
},
content: [
{
fragments: [
{ content: 'He', style: { color: 'red', fontSize: 12 } },
{ content: 'llo', style: { color: 'black' } },
],
},
{ content: ', ', style: { color: 'grey' } },
{ content: 'World!', style: { color: 'black' } },
],
})

### Clone to local
document.body.append(text.view) // canvas 2d

If you prefer to do it manually with the cleaner git history

```bash
npx degit qq15725/starter-ts my-ts-lib
cd my-ts-lib
pnpm i # If you don't have pnpm installed, run: npm install -g pnpm
console.log(text.measure()) // boundingBox with paragraphs
```
6 changes: 6 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
<head>
<meta charset="utf-8">
<title>Docs</title>
<style>
html, body {
margin: 0;
}
</style>
</head>
<body>
<script src="./src/main.ts" type="module"></script>
</body>
</html>
25 changes: 25 additions & 0 deletions docs/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Text } from '../../src'

const text = new Text({
style: {
width: 100,
height: 200,
fontSize: 22,
backgroundColor: '#0000FF',
textDecoration: 'underline',
},
content: [
{
fragments: [
{ content: 'He', style: { color: 'red', fontSize: 12 } },
{ content: 'llo', style: { color: 'black' } },
],
},
{ content: ', ', style: { color: 'grey' } },
{ content: 'World!', style: { color: 'black' } },
],
})

document.body.append(text.view)

console.log(text.measure())
16 changes: 0 additions & 16 deletions index.html

This file was deleted.

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
{
"name": "starter-ts",
"name": "modern-text",
"type": "module",
"version": "0.0.0",
"packageManager": "[email protected]",
"description": "Starter template for TypeScript library",
"author": "wxm",
"license": "MIT",
"homepage": "https://github.com/qq15725/starter-ts",
"homepage": "https://github.com/qq15725/modern-text",
"repository": {
"type": "git",
"url": "git+https://github.com/qq15725/starter-ts.git"
"url": "git+https://github.com/qq15725/modern-text.git"
},
"bugs": {
"url": "https://github.com/qq15725/starter-ts/issues"
"url": "https://github.com/qq15725/modern-text/issues"
},
"keywords": [
"starter",
"template",
"text",
"measure",
"canvas-text",
"typescript"
],
"sideEffects": false,
Expand Down Expand Up @@ -44,7 +45,7 @@
"types"
],
"scripts": {
"dev": "vite",
"dev": "vite docs",
"lint": "eslint src",
"test": "vitest",
"build": "vite build && tsc --project tsconfig.build.json",
Expand Down
Loading

0 comments on commit bc8d363

Please sign in to comment.