New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@flourish/pocket-knife

Package Overview
Dependencies
Maintainers
14
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@flourish/pocket-knife

Flourish module with handy tools

  • 0.7.0
  • npm
  • Socket score

Version published
Weekly downloads
301
increased by12.73%
Maintainers
14
Weekly downloads
 
Created
Source

Flourish pocket knife

A module with handy tools that you can use in Flourish templates.

import { isUrl, isImage } from "@flourish/pocket-knife"

Functions

isUrl(string)

Checks if string looks like valid URL. Returns true or false

isImage(string)

Checks if string looks like valid image URL. Returns true or false

getTextWidth(string, font)

Gets width of text. First argument contains the text you want to calculate the width for. The second argument is optional and lets you set font settings for the text in the standard css font property, eg. 16px arial bold. If font is empty, it uses 10px sans-serif.

hexToColor(hex_string, opacity)

Converts hex to d3 color object as described here

hexToColor("#00ff00", 0.5); // {r: 0, g: 255, b: 0, a: 0.5}

hexToRgba(hex_string, opacity)

Converts hex to rgba string

hexToRgba("#00ff00", 0.5); // rgba(0, 255, 0, 0.5)

isPale(color_value)

Returns if color is pale or not

wrapStringToLines(label, label_styles, text_max_lines, max_width)

Takes a string, and returns an array of strings where each string is one lines worth of text.

  • Label is a string, that you want to be broken up into lines
  • label_styles is a string that can include font weight, font size and font family in the structure: 'bold 48px serif'. it is what is given to the canvas context font method, and is used to measure the text.
  • text_max_lines is a number that says the maximum amount of lines you want (if you dont have a maximum you can give it null)
  • max_width is a number that states in px the maximum width for the label.

FAQs

Package last updated on 26 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc