question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Globbing import and data-structure loop example?

See original GitHub issue

I’m testing postCSS at present (via Gulp) and much of what I see, I like. 👍

My JS/node abilities are ‘novice’ so my apologies if some of my questions seem infantile!

However, there are a couple of things I am wondering about. Could anyone shed some light?

Globbing

Firstly, globbing. Is there currently a facility to ‘glob’ import files with postCSS:

[in styles.css] @import components/**/*.css

I tend to have lots of partial files (using Sass currently); it’s one of the best things Sass brings to the table for me. I’d like the ability to process/combine lots of individual ‘partial’ CSS files into one without listing out each one in an @import statement (which https://github.com/postcss/postcss-import already allows). Only Ruby Sass has this at present and it’s very convenient.

Data structures and looping

Is there any inherent capability to define and loop through a data structure? I’m talking about this kind of thing: http://benfrain.com/looping-data-map-libsass-3-02/. If there is nothing specific plugin wise, could anyone explain how this could be achieved using a JS object and JS loop in the ‘source’ CSS? (@MoOx has detailed this partially already here: https://github.com/cssnext/cssnext/issues/60) Or perhaps philosophically how this might be approached with postCSS?

Thanks very much for any insight you can offer.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
aicommented, Feb 18, 2015

I think about something like

@loop $i 1 12 {
    &:nth-child($i) {
        transition-delay: calc($i * 100ms)
    }
}

to make animations like this. But it will not be like Sass loops, because it is only shortcut, not a real programm loop.

0reactions
benfraincommented, Feb 18, 2015

@ai - yep that example is very useful and would certainly solve the problem for me. 👍

I don’t actually need to at this point but I am curious, would there be a way of defining which point in the CSS those rules would be appended?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use Glob() function to find files recursively in Python?
In Python, the glob module is used to retrieve files/pathnames matching a ... Copy a directory recursively using Python (with examples).
Read more >
Looping Over Data Sets - GitHub Pages
Use a for loop to process files given a list of their names. A filename is a character string. And lists can contain...
Read more >
Python Glob: Filename Pattern Matching - PYnative
Python glob module to find files and folders whose names follow a specific pattern. Search files recursively with wildcard characters.
Read more >
Use the OS and Glob Python Packages to Manipulate File Paths
Import necessary packages import os from glob import glob import ... For example, if you want every file in a directory to be...
Read more >
Use Python to List Files in a Directory (Folder) with os and glob
Sample Folder Structure · Importing OS and Glob Libraries · Use os's listdir Function to Return all Files in a Directory · Use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found