Skip to content

Commit 2aad5ce

Browse files
committed
Merge branch 'master' of github.com:nativescript-community/ui-canvas
2 parents 09cc730 + baaa3dc commit 2aad5ce

File tree

6 files changed

+43
-7
lines changed

6 files changed

+43
-7
lines changed

packages/ui-canvas/blueprint.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,30 @@ Vue.use(CanvasPlugin);
5454
<CanvasView width="100" height="100" @draw="draw"/>
5555
```
5656
57+
## NativeScript + Svelte
58+
59+
```ts
60+
// app/app.ts
61+
import { registerNativeViewElement } from 'svelte-native/dom';
62+
registerNativeViewElement('canvasView', () => require('@nativescript-community/ui-canvas').CanvasView);
63+
```
64+
65+
```svelte
66+
<!-- app/components/Foo.svelte -->
67+
<stackLayout>
68+
<canvasView width="300" height="300" on:draw={draw} />
69+
</stackLayout>
70+
```
71+
5772
## Draw Method
58-
```typescript
73+
74+
```ts
75+
import type { Canvas } from '@nativescript-community/ui-canvas';
76+
import { Paint, createRect } from '@nativescript-community/ui-canvas';
77+
import { Color } from '@nativescript/core';
78+
5979
function draw(event: { canvas: Canvas }) {
80+
const canvas = event.canvas;
6081
const paint = new Paint();
6182
paint.setColor(new Color('black'));
6283
paint.strokeWidth = 10;
@@ -78,4 +99,4 @@ function draw(event: { canvas: Canvas }) {
7899
- An example of animating a shape
79100
80101
{{ load:../../tools/readme/demos-and-development.md }}
81-
{{ load:../../tools/readme/questions.md }}
102+
{{ load:../../tools/readme/questions.md }}

packages/ui-canvas/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"scripts": {
1515
"build": "npm run tsc",
1616
"build.all": "npm run build",
17-
"build.angular": "ng-packagr -p ../../src/ui-canvas/angular/ng-package.json -c ../../src/ui-canvas/angular/tsconfig.json",
17+
"build.angular": "ng-packagr -p ../../src/ui-canvas/angular/ng-package.json -c ../../src/ui-canvas/angular/tsconfig.json && rm angular/.npmignore",
1818
"readme": "readme generate -c ../../tools/readme/blueprint.json",
1919
"tsc": "cpy '**/*.d.ts' '../../packages/ui-canvas' --parents --cwd=../../src/ui-canvas && tsc -skipLibCheck -d",
2020
"clean": "rimraf ./*.d.ts ./*.js ./*.js.map"

packages/ui-canvaslabel/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"scripts": {
1515
"build": "npm run tsc",
1616
"build.all": "npm run build",
17-
"build.angular": "ng-packagr -p ../../src/ui-canvaslabel/angular/ng-package.json -c ../../src/ui-canvaslabel/angular/tsconfig.json",
17+
"build.angular": "ng-packagr -p ../../src/ui-canvaslabel/angular/ng-package.json -c ../../src/ui-canvaslabel/angular/tsconfig.json && rm angular/.npmignore",
1818
"readme": "readme generate -c ../../tools/readme/blueprint.json",
1919
"tsc": "cpy '**/*.d.ts' '../../packages/ui-canvaslabel' --parents --cwd=../../src/ui-canvaslabel && tsc -skipLibCheck -d",
2020
"clean": "rimraf ./*.d.ts ./*.js ./*.js.map"

packages/ui-svg/blueprint.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Run the following command from the root of your project:
1414

1515
For now only `vue` (and core) is supported.
1616

17+
### NativeScript + Vue
18+
1719
```ts
1820
import CanvasSVG from '@nativescript-community/ui-svg/vue';
1921
Vue.use(CanvasSVG);
@@ -47,10 +49,23 @@ Or within and Canvas View extending `CanvasView` like `CanvasLabel`
4749
</CanvasSVG>
4850
```
4951

52+
### NativeScript + Svelte
53+
54+
```ts
55+
// app/app.ts
56+
import { registerNativeViewElement } from 'svelte-native/dom';
57+
registerNativeViewElement('svgView', () => require('@nativescript-community/ui-svg').SVGView);
58+
```
59+
60+
```svelte
61+
<!-- app/components/Foo.svelte -->
62+
<svgView src="~/assets/foo.svg" aspectFit="stretch" />
63+
```
64+
5065
### Examples:
5166

5267
- [Basic](demo-snippets/vue/SVG.vue)
5368
- A basic SVG example
5469

5570
{{ load:../../tools/readme/demos-and-development.md }}
56-
{{ load:../../tools/readme/questions.md }}
71+
{{ load:../../tools/readme/questions.md }}

packages/ui-svg/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"scripts": {
1919
"build": "npm run tsc",
2020
"build.all": "npm run build",
21-
"build.angular": "ng-packagr -p ../../src/ui-svg/angular/ng-package.json -c ../../src/ui-svg/angular/tsconfig.json",
21+
"build.angular": "ng-packagr -p ../../src/ui-svg/angular/ng-package.json -c ../../src/ui-svg/angular/tsconfig.json && rm angular/.npmignore",
2222
"readme": "readme generate -c ../../tools/readme/blueprint.json",
2323
"tsc": "cpy '**/*.d.ts' '../../packages/ui-svg' --parents --cwd=../../src/ui-svg && tsc -skipLibCheck -d",
2424
"clean": "rimraf ./*.d.ts ./*.js ./*.js.map"

tools

0 commit comments

Comments
 (0)