Skip to content

Commit f670cc2

Browse files
committed
chore: project
1 parent e5eb5af commit f670cc2

File tree

7 files changed

+690
-53
lines changed

7 files changed

+690
-53
lines changed

README.md

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,264 @@ One easy solution is t modify `~/.gitconfig` and add
266266
[](#questions)
267267
268268
269+
[](#questions)
270+
271+
## Questions
272+
273+
If you have any questions/issues/comments please feel free to create an issue or start a conversation in the [NativeScript Community Discord](https://nativescript.org/discord).
274+
</details><details>
275+
<summary><b>ui-canvaslabel</b></summary>
276+
<!-- ⚠️ This README has been generated from the file(s) "blueprint.md" ⚠️-->
277+
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
278+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
279+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
280+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
281+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
282+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
283+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
284+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
285+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
286+
DO NOT EDIT THIS READEME DIRECTLY! Edit "bluesprint.md" instead.
287+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
288+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
289+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
290+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
291+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
292+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
293+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
294+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
295+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
296+
<h1 align="center">@nativescript-community/ui-canvaslabel</h1>
297+
<p align="center">
298+
<a href="https://npmcharts.com/compare/@nativescript-community/ui-canvaslabel?minimal=true"><img alt="Downloads per month" src="https://img.shields.io/npm/dm/@nativescript-community/ui-canvaslabel.svg" height="20"/></a>
299+
<a href="https://www.npmjs.com/package/@nativescript-community/ui-canvaslabel"><img alt="NPM Version" src="https://img.shields.io/npm/v/@nativescript-community/ui-canvaslabel.svg" height="20"/></a>
300+
</p>
301+
302+
<p align="center">
303+
<b>Alternative to the built-in NativeScript Label but uses canvas which allows extreme complexity and customization.</b></br>
304+
<sub><sub>
305+
</p>
306+
307+
<br />
308+
309+
310+
311+
[](#table-of-contents)
312+
313+
314+
[](#table-of-contents)
315+
316+
## Table of Contents
317+
318+
* [Installation](#installation)
319+
* [Configuration](#configuration)
320+
* [Performances](#performances)
321+
* [TODO / Limitations](#todo--limitations)
322+
* [Examples:](#examples)
323+
* [Demos and Development](#demos-and-development)
324+
* [Repo Setup](#repo-setup)
325+
* [Build](#build)
326+
* [Demos](#demos)
327+
* [Contributing](#contributing)
328+
* [Update repo ](#update-repo-)
329+
* [Update readme ](#update-readme-)
330+
* [Update doc ](#update-doc-)
331+
* [Publish](#publish)
332+
* [modifying submodules](#modifying-submodules)
333+
* [Questions](#questions)
334+
335+
A NativeScript Label widget. This widget takes a different approch from other label components. It is based on `nativescript-canvas` and allows drawing
336+
multiple labels within one single widget.
337+
It allows extreme complexity and customization.
338+
339+
340+
[](#installation)
341+
342+
343+
[](#installation)
344+
345+
## Installation
346+
Run the following command from the root of your project:
347+
348+
`ns plugin add @nativescript-community/ui-canvaslabel`
349+
350+
351+
[](#configuration)
352+
353+
354+
[](#configuration)
355+
356+
## Configuration
357+
It works almost like a normal label.
358+
You can create spans, just like with the {N} labels. However there is a big difference with the {N} component.
359+
`CSpan` do not support css class and never will! It was actually made on purpose to make to make the component much more efficient.
360+
361+
For now `CanvasLabel` do not auto size itself. I will add some way of doing it in the future but in a sense it defies the purpose of this component.
362+
363+
The `CanvasLabel` component supports most labels properties:
364+
`color`, `fontSize`,`fontFamily`,`fontStyle`, `fontWeight`,`textAlignment`. Those can be defined through css.
365+
366+
Now with `CanvasLabel` you don't set the text directly. Instead you create `CSpan` or `CGroup`
367+
368+
Here is a complex Vue layout as an example
369+
```html
370+
<CanvasLabel id="canvaslabel" fontSize="10" color="white" backgroundColor="darkgray">
371+
<CGroup fontSize="18" verticalAlignment="middle" paddingLeft="20">
372+
<CSpan :text="item.text1" fontWeight="bold" />
373+
<CSpan :text="'\n' + item.text2" color="#ccc" fontSize="16" />
374+
</CGroup>
375+
376+
<CGroup fontSize="12" verticalAlignment="bottom" paddingLeft="20" paddingBottom="1">
377+
<CSpan :text="item.icon1" fontSize="20" color="green" :fontFamily="mdiFontFamily" />
378+
<CSpan :text="' ' + item.texticon1" verticalTextAlignment="center" />
379+
<CSpan :text="' ' + item.icon2" fontSize="20" color="red" :fontFamily="mdiFontFamily" />
380+
<CSpan :text="' ' + item.texticon2" verticalTextAlignment="center" />
381+
<CSpan :text="' ' + item.icon3" fontSize="20" color="yellow" :fontFamily="mdiFontFamily" />
382+
<CSpan :text="' ' + item.texticon3" verticalTextAlignment="center" />
383+
</CGroup>
384+
385+
<CGroup fontSize="12" verticalAlignment="middle" horizontalAlignment="center" textAlignment="right" paddingRight="20" color="brown" width="60">
386+
<CSpan :text="item.icon1" fontSize="14" :fontFamily="mdiFontFamily" />
387+
<CSpan :text="'\n' + item.texticon1" paddingRight="10" />
388+
</CGroup>
389+
<CSpan :text="item.text4" color="lightgray" fontSize="14" textAlignment="right" paddingRight="20" paddingTop="4" />
390+
</CanvasLabel>
391+
```
392+
393+
For full example / doc look at the vue demo and the typings.
394+
395+
396+
[](#performances)
397+
398+
399+
[](#performances)
400+
401+
## Performances
402+
403+
`CanvasLabel` is made to be real fast. It was designed principaly to be used within list views. It uses the technique of drawing the text directly instead of using heavy native text components.
404+
That technique is used by many apps looking for the best performances. One of the best examples is Telegram.
405+
406+
407+
[](#todo--limitations)
408+
409+
410+
[](#todo--limitations)
411+
412+
## TODO / Limitations
413+
414+
* For now there is no accessibility support (but it should be possible)
415+
* The label can't size itself. I will add some ways of doing that. But possibly not in the way you are used to.
416+
* no ellipsize support yet. Will come ([this](https://github.com/lsjwzh/FastTextView/blob/5e440575539ab1f470d853b1e7462fe0251eb869/widget.FastTextView/src/main/java/android/text/EllipsisSpannedContainer.java) could be a solution)
417+
* a lot of canvas features can be added like shadows, gradient ...
418+
* transform supoort should be possible at least for groups and top spans.
419+
420+
### Examples:
421+
422+
- [Basic](demo-snippets/vue/CanvasLabel.vue)
423+
- A basic SVG example
424+
425+
426+
[](#demos-and-development)
427+
428+
429+
[](#demos-and-development)
430+
431+
## Demos and Development
432+
433+
434+
### Repo Setup
435+
436+
The repo uses submodules. If you did not clone with ` --recursive` then you need to call
437+
```
438+
git submodule update --init
439+
```
440+
441+
The package manager used to install and link dependencies must be `pnpm` or `yarn`. `npm` wont work.
442+
443+
To develop and test:
444+
if you use `yarn` then run `yarn`
445+
if you use `pnpm` then run `pnpm i`
446+
447+
**Interactive Menu:**
448+
449+
To start the interactive menu, run `npm start` (or `yarn start` or `pnpm start`). This will list all of the commonly used scripts.
450+
451+
### Build
452+
453+
```bash
454+
npm run build.all
455+
```
456+
WARNING: it seems `yarn build.all` wont always work (not finding binaries in `node_modules/.bin`) which is why the doc explicitly uses `npm run`
457+
458+
### Demos
459+
460+
```bash
461+
npm run demo.[ng|react|svelte|vue].[ios|android]
462+
463+
npm run demo.svelte.ios # Example
464+
```
465+
466+
Demo setup is a bit special in the sense that if you want to modify/add demos you dont work directly in `demo-[ng|react|svelte|vue]`
467+
Instead you work in `demo-snippets/[ng|react|svelte|vue]`
468+
You can start from the `install.ts` of each flavor to see how to register new demos
469+
470+
471+
[](#contributing)
472+
473+
474+
[](#contributing)
475+
476+
## Contributing
477+
478+
### Update repo
479+
480+
You can update the repo files quite easily
481+
482+
First update the submodules
483+
484+
```bash
485+
npm run update
486+
```
487+
488+
Then commit the changes
489+
Then update common files
490+
491+
```bash
492+
npm run sync
493+
```
494+
Then you can run `yarn|pnpm`, commit changed files if any
495+
496+
### Update readme
497+
```bash
498+
npm run readme
499+
```
500+
501+
### Update doc
502+
```bash
503+
npm run doc
504+
```
505+
506+
### Publish
507+
508+
The publishing is completely handled by `lerna` (you can add `-- --bump major` to force a major release)
509+
Simply run
510+
```shell
511+
npm run publish
512+
```
513+
514+
### modifying submodules
515+
516+
The repo uses https:// for submodules which means you won't be able to push directly into the submodules.
517+
One easy solution is t modify `~/.gitconfig` and add
518+
```
519+
[url "ssh://[email protected]/"]
520+
pushInsteadOf = https://github.com/
521+
```
522+
523+
524+
[](#questions)
525+
526+
269527
[](#questions)
270528
271529
## Questions

docs/assets/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/search.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/style.css

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,9 @@ blockquote {
483483
.has-menu .col-menu {
484484
visibility: visible;
485485
transform: translate(0, 0);
486-
display: grid;
487-
align-items: center;
488-
grid-template-rows: auto 1fr;
489-
grid-gap: 1.5rem;
486+
display: flex;
487+
flex-direction: column;
488+
gap: 1.5rem;
490489
max-height: 100vh;
491490
padding: 1rem 2rem;
492491
}
@@ -911,7 +910,7 @@ a.tsd-index-link {
911910
margin-right: 0.8rem;
912911
}
913912

914-
@media (min-width: 1024px) {
913+
@media (min-width: 1025px) {
915914
.col-content {
916915
margin: 2rem auto;
917916
}

0 commit comments

Comments
 (0)