npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-sidenotes

v1.0.4

Published

Implementation sidenotes for angular

Downloads

1

Readme

ngx-sidenotes

Goals

  • Place notes/comments to the side of one or more documents with inline references.
  • When an inline reference is clicked, animate the relevant sidenote to be as close as possible and move non-relevant sidenotes out of the way without overlapping.
  • Do not provide UI or impose any styling, only placement.

Use cases

  • Comment streams next to a document. This is showing Curvenote, which is a scientific writing platform that connects to Jupyter.

Choices

  • Use Angular, Redux
  • Used Redux rather than a hook approach (open to discussion if people are passionate!)

Constraints

  • Multiple documents on the page, currently based on the wrapping <article> ID
  • Multiple inline references per sidenote, wrapped in <lib-ngx-sidenotes-anchor>; lib-ngx-sidenotes-anchor is a span
  • Have fallback placements to a <lib-ngx-sidenotes-anchor-base>; lib-ngx-sidenotes-anchor-base is a div
  • Provide actions to attach non-react bases, anchors or reposition sidenotes
  • All positioning is based on the article, and works with relative, fixed or absolute positioning.

Getting Started:

npm i ngx-sidenotes

Angular Setup:

in tsconfig.json > compilerOptions > paths:

...
"@angular/*": [
  "./node_modules/@angular/*"
],
"@ngrx/*": [
  "./node_modules/@ngrx/*"
]

in module (for example, app.module.ts):

import {NgxSidenotesModule} from 'ngx-sidenotes';

@NgModule({
  imports: [
    ...
    NgxSidenotesModule,
  ],
  exports: [
    ...
    NgxSidenotesModule,
  ],
})

in component (for example, app.component.ts)

import {NgxSidenotesService} from 'ngx-sidenotes';
...
export class AppComponent {
  constructor(
    ...
    private sidenoteService: NgxSidenotesService
  ) {}
  deselectSidenote(docId: string): void {
    this.sidenoteService.deselectSidenote(docId);
  }

in component template (for example, app.component.html)

<button (click)="deselectSidenote('article-main')">Deselect Sidenote</button>
<article id="article-main">
  <lib-ngx-sidenotes-anchor-base [anchor]="'anchor'">
    <div class="main-text">
      <p><lib-ngx-sidenotes-anchor [sidenoteId]="'blue'" class="blue">'Lorem Ipsum</lib-ngx-sidenotes-anchor>
        - это <lib-ngx-sidenotes-anchor [sidenoteId]="'red'" class="red">текст</lib-ngx-sidenotes-anchor>-"рыба", часто используемый в печати и вэб-дизайне.',</p>
      <p>'Lorem Ipsum - это текст-"рыба", часто используемый в печати и вэб-дизайне.',</p>
      <p>'Lorem <lib-ngx-sidenotes-anchor [sidenoteId]="'red'" class="red">Ipsum</lib-ngx-sidenotes-anchor>
        - это <lib-ngx-sidenotes-anchor [sidenoteId]="'red'" class="red">текст</lib-ngx-sidenotes-anchor>
        -"рыба", часто используемый в печати и вэб-дизайне.',</p>
      <p>'Lorem Ipsum - это текст-"рыба", часто используемый в печати и вэб-дизайне.',</p>
      <p>'Lorem Ipsum - это текст-"рыба", часто используемый в печати и вэб-дизайне.',</p>
      <p><lib-ngx-sidenotes-anchor [sidenoteId]="'blue'" class="blue">
        'Lorem Ipsum - это текст-"рыба",</lib-ngx-sidenotes-anchor> часто используемый в печати и вэб-дизайне.',</p>
      <p>'Lorem Ipsum - это текст-"рыба", часто используемый в печати и вэб-дизайне.',</p>
      <p>'Lorem Ipsum - это текст-"рыба", часто используемый в печати и вэб-дизайне.',</p>
      <p>'Lorem Ipsum - это текст-"рыба", часто используемый в
        <lib-ngx-sidenotes-anchor [sidenoteId]="'blue'" class="blue">печати и</lib-ngx-sidenotes-anchor>
        вэб-дизайне.',</p>
      <p>'Lorem Ipsum - это текст-"рыба", часто используемый в печати и вэб-дизайне.',</p>
      <p>'Lorem Ipsum - это текст-"рыба", часто используемый в печати и вэб-дизайне.',</p>
      <p>'Lorem Ipsum - это текст-"рыба", часто используемый в печати и вэб-дизайне.',</p>
      <p>'Lorem Ipsum - <lib-ngx-sidenotes-anchor [sidenoteId]="'red'" class="red">
        это</lib-ngx-sidenotes-anchor> текст-"рыба", часто используемый в печати и вэб-дизайне.',</p>
    </div>
  </lib-ngx-sidenotes-anchor-base>

  <div class="sidenotes">
    <lib-ngx-sidenotes-block-item [sidenoteId]="'blue'" [base]="'anchor'">
      <div [style.background-color]="'blue'"></div>
    </lib-ngx-sidenotes-block-item>
    <lib-ngx-sidenotes-block-item [sidenoteId]="'red'" [base]="'anchor'">
      <div [style.background-color]="'red'"></div>
    </lib-ngx-sidenotes-block-item>
    <lib-ngx-sidenotes-block-item [sidenoteId]="'green'" [base]="'anchor'">
      <div [style.background-color]="'green'">Some text</div>
    </lib-ngx-sidenotes-block-item>
  </div>
</article>

some styles, if you need (app.component.css)

article {
  position: relative;
}
.sidenotes {
  position: absolute;
  top: 0;
  right: 0;
  width: 300px;
}