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

ducky-css

v1.0.18

Published

Write CSS faster with a modification of the CSS syntax combined with the camelCase for property names that JS uses, and apply multiple styles to an element using only 1 line of code.

Downloads

10

Readme

ducky-css

ducky lets you use the js version of css properties and shortens the amount you need to write, as well as providing shorter alternatives.

For example, instead of doing:

.class {
    background-color: blue;
}

You can instead do:

.class:
bgColor = blue

Note: All the CSS values you use are the same as in standard CSS


Setup

Note: If you don't want to read all this, there's an Example folder in the repository that has the setup and example usage there for you

Install ducky-css with the following command in a terminal in your project's root directory:

npm i ducky-css

Then add a script module to your HTML file just before the ending <body> tag:

...
<script src="index.js" type="module"></script>
</body>

Then create a file you will write ducky-css in. *You can write ducky-css in basically any type of file as the quack parser merely takes in the text content of whatever file you link, but if you'd like to stay on the theme of ducks (🦆), feel free to use file extensions such as .quack or .duck to keep it organized in your project.

Then, in the JS file you just linked in your HTML, send the content of the file you're writing ducky-css in:

import QuackParser from './node_modules/ducky-css/quack.js';

document.addEventListener('DOMContentLoaded', function() {
    const duck = new QuackParser();
    fetch('main.quack') //file path here
    .then(response => response.text())
    .then(data => {
        duck.quack(data);
    })
    .catch(error => {
      console.error('Error fetching file:', error);
    });
});

Usage/Syntax

CSS groups are still started using .class or #id, but rather than using curly braces, simply add a colon at the end,

.class:
#id:

You don't have to worry about any ending symbols to mark the end of a group, the parser knows when a group ends, but if you want to visually keep it organized simply add an empty line or two between each group.

ducky-css properties have their names as camelCase, just like the JS property names, e.g.,

.class:
alignItems = center
justifyContent = center

But I have also added shorter alternatives you can use; as a rule of thumb, any properties with the words background, image, or bottom all have shortend versions of those words within the property name

e.g., bg, img, btm


Shorthand Properties

I have also added shorthand properties that combine commonly used groups of CSS into one line.

For example the shorthand property centered;; centers an element absolutely within its parent container:

.parent:
positon = relative

#child:
centered;;

This is equivalent to the following standard CSS:

.parent {
    position: relative;
}

#child {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

For more detail into the syntax, short-form, and shorthand properties, visit the Wiki