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

fish-tacos

v1.3.2

Published

A responsive resize system for CSS px values

Downloads

5

Readme

Fish Tacos :tropical_fish: :fish: :blowfish:

What

This module complements the react and styled-components libraries to create an API that removes the cognitive load and arduous boilerplate associated with responsive scenarios.

Build Status npm version

depends on styled-components typescript code style prettier

commitizen friendly semantic-release

Why

Setting a min-width and max-width on your elements is a great way to create fluid layouts that adhere to responsive methodologies.

Unfortunately min-* and max-* declarations are not supported natively in CSS for things like font-size, padding, margin, etc. These properties would benefit greatly from this functionality to help make content more accessible to a wider range of device sizes.

This module addresses the scenarios where:

  • Users can experience jarring layout reflows as various breakpoints are triggered forcing abrupt changes to CSS values.

  • Percentage based values (referencing things like viewport or an element container) can encounter cases where values scale to exaggerated limits (both big and small) due to the absence of Minimum and Maximum thresholds.

Demo

This demo retro fits several Bootstrap components with the fluid resizing system this module offers. Resize the window to see the responsive measurement declarations scale up / down while staying within the limits of their thresholds.

fish-tacos

Installation

Install the module from NPM .

npm install --save fish-tacos

Import the module into your project.

import ft from "fish-tacos";

Usage

The API is very simple. Specify the CSS property that you want to change and supply a Minimum and Maximum threshold to restrict scaling.

Because designers like to supply their measurements in pixel based units our API uses pixels as the base target and converts them into REM's in the final output. This gives styles an enhanced level of accessibility (with dynamic font scaling) while making design and development collaboration easier.

The result is pure, static CSS. This means the fluid scaling is based on native browser functionality and therefore performant.

Basic

ft("font-size", [20, 32]);

The above declaration will create the following vanilla CSS:

font-size: 1.25rem;

@media (min-width: 30rem) {
  font-size: 4.166666666666667vw;
}

@media (min-width: 48rem) {
  font-size: 2rem;
}

Verbose

If you want to target a property that uses top, right, bottom and left references for more granularity you can use the more verbose permutation below.

ft("margin", { top: [30, 60], bottom: [10, 30] });

The above declaration will create the following vanilla CSS:

margin-top: 1.875rem;

@media (min-width: 30rem) {
  margin-top: 6.25vw;
}

@media (min-width: 60rem) {
  margin-top: 3.75rem;
}

margin-bottom: 0.625rem;

@media (min-width: 30rem) {
  margin-bottom: 2.0833333333333335vw;
}

@media (min-width: 90rem) {
  margin-bottom: 1.875rem;
}

Static

As of release 1.2.0 you can now pass in a static number or string and have it be included as a non-fluid measurement :smiley:.

  • String: Will be included verbatim.
  • Number: Should be supplied as a pixel reference and will be converted to REM's.
ft("margin", { top: 50, right: "auto", bottom: 20, left: "auto" });

The above declaration will create the following vanilla CSS:

margin-top: 3.125rem;

margin-right: auto;

margin-bottom: 1.25rem;

margin-left: auto;

Consolidation

As of release 1.3.0 you can now consolidate verbose references that share the same values into a single declaration by comma separating their keys :thumbsup:.

ft("margin", { "top,bottom": [20, 50], "right,left": "auto" });

The above declaration will create the following vanilla CSS:

margin-top: 1.25rem;

@media (min-width: 30rem) {
  margin-top: 4.166666666666667vw;
}

@media (min-width: 75rem) {
  margin-top: 3.125rem;
}

margin-bottom: 1.25rem;

@media (min-width: 30rem) {
  margin-bottom: 4.166666666666667vw;
}

@media (min-width: 75rem) {
  margin-bottom: 3.125rem;
}

margin-right: auto;

margin-left: auto;

Example

Integrating this module into your existing workflow is as easy as swapping out a standard CSS property / value declaration for the new API.

import React from "react";
import ReactDOM from "react-dom";
import styled from "styled-components";
import ft from "fish-tacos";

const Heading1 = styled.h1`
  ${ft("font-size", [30, 50])}
  ${ft("margin", { top: [30, 60], "right,left": "auto", bottom: 20 })};
`;

ReactDOM.render(
  <Heading1>Hello World 👋</Heading1>,
  document.getElementById("app")
);

License

MIT