-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ede9e21
Showing
48 changed files
with
6,276 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = false | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* text=auto | ||
*.* text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: jsr Publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write # The OIDC ID token is used for authentication with JSR. | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: npx jsr publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Lint | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
|
||
- name: Set Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
|
||
- name: Install | ||
run: pnpm i | ||
|
||
- name: Lint | ||
run: pnpm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Release | ||
|
||
permissions: | ||
contents: write | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
|
||
- run: npx changelogithub | ||
env: | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Test | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
|
||
- name: Set Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
|
||
- name: Install | ||
run: pnpm i | ||
|
||
- name: Test | ||
run: pnpm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
node_modules | ||
dist | ||
|
||
.idea | ||
|
||
# Mac | ||
.DS_Store | ||
|
||
# Log files | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 pengzhanbo | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# GeoPattern | ||
|
||
[![jsr](https://jsr.io/badges/@raise/geo-pattern)](https://jsr.io/@raise/geo-pattern) | ||
![jsr score](https://jsr.io/badges/@raise/geo-pattern/score) | ||
![gzip size](https://img.badgesize.io/https:/unpkg.com/geo-pattern-ts/dist/index.js?label=gzip%20size&compression=gzip) | ||
![License](https://github.com/pengzhanbo/geo-pattern-ts/blob/main/LICENSE) | ||
|
||
This is a TypeScript port of [jasonlong/geo_pattern](https://github.com/jasonlong/geo_pattern) with a | ||
[live preview page](http://btmills.github.io/geopattern/). | ||
|
||
## Install | ||
|
||
```bash | ||
# pnpm | ||
pnpm add geo-pattern-ts | ||
# yarn | ||
yarn add geo-pattern-ts | ||
# npm | ||
npm install geo-pattern-ts | ||
``` | ||
|
||
You can also use JSR: | ||
|
||
```bash | ||
# pnpm | ||
pnpm dlx jsr add @raise/geo-pattern | ||
# yarn | ||
yarn dlx jsr add @raise/geo-pattern | ||
# npm | ||
npx jsr add @raise/geo-pattern | ||
# Deno | ||
deno add @raise/geo-pattern | ||
``` | ||
|
||
## Usage | ||
|
||
```ts | ||
import { generate } from 'geo-pattern-ts' // jsr package name: @raise/geo-pattern | ||
const pattern = generate('GitHub') | ||
pattern.toDataUrl() // url("data:image/svg+xml;... | ||
``` | ||
|
||
## API | ||
|
||
### pattern = generate(input, options) | ||
|
||
Returns a newly-generated, tiling SVG Pattern. | ||
|
||
- `input` Will be hashed using the SHA1 algorithm, and the resulting hash will be used as the seed for generation. | ||
- `options.color` Specify an exact background color. This is a CSS hexadecimal color value. | ||
- `options.baseColor` Controls the relative background color of the generated image. The color is not identical to that used in the pattern because the hue is rotated by the generator. This is a CSS hexadecimal color value, which defaults to `#933c3c`. | ||
- `options.generator` Determines the pattern. [All of the original patterns](https://github.com/jasonlong/geo_pattern#available-patterns) are available in this port, and their names are camelCased. | ||
|
||
### pattern.color | ||
|
||
Gets the pattern's background color as a hexadecimal string. | ||
|
||
```ts | ||
const pattern = generate('GitHub') | ||
pattern.color // => "#455e8a" | ||
``` | ||
|
||
### pattern.toString() and pattern.toSvg() | ||
|
||
Gets the SVG string representing the pattern. | ||
|
||
### pattern.toBase64() | ||
|
||
Gets the SVG as a Base64-encoded string. | ||
|
||
### pattern.toDataUri() | ||
|
||
Gets the pattern as a data URI, i.e. `data:image/svg+xml;base64,PHN2ZyB....` | ||
|
||
### pattern.toDataUrl() | ||
|
||
Gets the pattern as a data URL suitable for use as a CSS background-image, | ||
i.e. `url("data:image/svg+xml;base64,PHN2ZyB...").` | ||
|
||
## License | ||
|
||
Licensed under the terms of the MIT License, the full text of which can be read in [LICENSE](/LICENSE). | ||
|
||
<!-- https://github.com/btmills/geopattern --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import config from '@pengzhanbo/eslint-config' | ||
|
||
export default config() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "@raise/geo-pattern", | ||
"version": "0.1.0", | ||
"exports": "./src/index.ts", | ||
"publish": { | ||
"include": [ | ||
"src/**/*.ts", | ||
"LICENSE", | ||
"README.md", | ||
"tsconfig.json" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[build] | ||
publish = "preview/dist" | ||
command = "pnpm install && pnpm preview:build" | ||
|
||
[build.environment] | ||
NODE_VERSION = "18" # prevent Netlify npm install | ||
NPM_FLAGS = "--version" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"name": "geo-pattern-ts", | ||
"type": "module", | ||
"version": "0.1.0", | ||
"description": "Generate beautiful SVG patterns", | ||
"author": "pengzhanbo <q942450674@outlook.com> (https://github.com/pengzhanbo)", | ||
"license": "MIT", | ||
"homepage": "https://github.com/pengzhanbo/geo-pattern-ts#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/pengzhanbo/geo-pattern-ts" | ||
}, | ||
"keywords": [ | ||
"svg", | ||
"pattern", | ||
"geometric", | ||
"background" | ||
], | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"main": "dist/index.js", | ||
"module": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"preview:dev": "vite dev preview --config ./preview/vite.config.ts", | ||
"preview:build": "vite build preview --config ./preview/vite.config.ts", | ||
"build": "tsup", | ||
"lint": "eslint .", | ||
"prepublishOnly": "pnpm run build", | ||
"test": "vitest run --reporter verbose", | ||
"release": "bumpp package.json --commit --push --tag && npm publish --access public" | ||
}, | ||
"devDependencies": { | ||
"@pengzhanbo/eslint-config": "^1.7.0", | ||
"@types/node": "^20.11.29", | ||
"bumpp": "^9.4.0", | ||
"eslint": "^8.57.0", | ||
"tsup": "^8.0.2", | ||
"typescript": "^5.4.2", | ||
"vite": "^5.1.6", | ||
"vitest": "^1.4.0" | ||
} | ||
} |
Oops, something went wrong.