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

@alanor87/tial

v0.1.13

Published

Text image anchoring library.

Downloads

78

Readme

TIAL (v0.1.12) - text image anchoring library for React.

A library, that binds certain parts of the text to certain areas of the image on the html page, using highlighting text and corresponding selected image area.

Demo page

http://tial-lib.com

Install

npm

Through npm npm install @alanor87/tial

Usage

ES6

import { AnchorWrapper, AnchorText, AnchorImage } from "@alanor87/tial";

Overview

Components

The functionality is implemented with usage of three react components :

AnchorWrapper

<AnchorWrapper>{children}</AnchorWrapper> 

A wrapper, which provides a context for the interaction of highlighting text and corresponding image parts. Accepts children compoenents in arbitrary amounts, order and nesting levels. You can arrange all the contents of the wrapper block in the desired way and pass the anchored image and text blocks in any order and in any place among onther children componenets - they are going to be bound together through the common AnchorWrapper context. AnchorWrapper must not contain more than one AnchorText or AnchorImage - an error will be thrown in such case. Every pair of AnchorTexy/AnchorImage must be wrapped inside their own AnchorWrapper container.

| Props | Type | Required | Default | Description | | ------------- | ------------- | ------------- | ------------- | ------------- | | className | string | false | none | Additional style through class name for the wrapper. | | initialAnchorsData | object (AnchorsDataType) | true | none | The object, that includes original text, imageUrl and anchors data. For the structure - see the Types section below. | | highlightColor | string | false | none | The highlighting color of anchors. Takes any CSS interpretable color value.| | onAnchorsUpdate | function | false | none | Callback that gets updated list of anchors (see Types section). If undefined - option of creating and deleting anchors is not available. | onAnchorSelect | function | false | none | Callback that gets id of selected anchor when it is being changed.

AnchorText

<AnchorText />

Container with the marked (anchored) text.

| Props | Type | Required | Default | Description | | ------------- | ------------- | ------------- | ------------- | ------------- | | className | string | false | none | Additional style through class name for the text container. | | textMarkerStyle | object | false | none | Additional styles for the highlighting text marker. See Types below for the structure. |

AnchorImage

<AnchorImage />

Container with the marked (anchored) image.

| Props | Type | Required | Default | Description | | ------------- | ------------- | ------------- | ------------- | ------------- | | className | string | false | none | Additional style through class name for the text container. | | imageFrameStyle | object | false | none | Additional styles for the highlighting image frame. See Types below for the structure. |

Types

AnchorType

 interface AnchorType {
  _id: string;
  anchorText: string;
  anchorTextStartPos: number;
  anchorFrameCoords: number[];
  anchorFrameSize: number[];
}

| Key | Description | | ----------- | ------------- | | _id | Unique id for each anchor. | | anchorText | The text that should be in the highlighted marker. | | anchorTextStartPos | The starting position of the highlighted text inside of the anchored text block. | | anchorFrameCoords | X and Y coordinates of the upper left corner of the highlighing frame on the anchored image (percentage from image display size). | | anchorFrameSize | Width and height of the highlighing frame on the anchored image (percentage from image display size). |

AnchorsDataType

 interface AnchorsDataType {
  anchorText: string;
  anchorImageUrl: string;
  anchorsArray: AnchorType[];
}

| Key | Description | | ----------- | ------------- | | anchorText | The anchored text block, should be passed a a single solid string. | | anchorImageUrl | Url of the anchored image. | | anchorsArray | Array of anchors for the coupled text and image components. |

AnchorTextMarkerFrameStyle

  interface AnchorTextMarkerFrameStyle {
  textColor?: string;
  outlineWidth?: string;
  borderRadius?: string;
}

| Key | Description | | ----------- | ------------- | | textColor | Color of the text in marker - when the marker was selected. Takes any CSS interpretable color value.| | outlineWidth | Width of the text marker outline. Takes any CSS interpretable outline-width value.| | borderRadius | Border radius for text marker. Takes any CSS interpretable border-radius value.|

AnchorImageFrameStyle

  interface AnchorImageFrameStyle {
  boxShadow?: string;
  textColor?: string;
  borderWidth?: string;
  borderRadius?: string;
}

| Key | Description | | ----------- | ------------- | | boxShadow | Box shadow for the image frame. Takes any CSS interpretable box-shadow value.| | textColor | Color of the text inside of the image frame. Takes any CSS interpretable color value.| | borderWidth | Width of the image frame border. Takes any CSS interpretable border-width value.| | borderRadius | Border radius for text marker. Takes any CSS interpretable border-radius value.|