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.

about dynamic attributify mode

See original GitHub issue

Hello guys,

I have a class need to use attributify mode,

pos="!fixed" it’s working

pos={isSideFixed ? '!fixed' : 'relative'} it’s not working

How do I get the corresponding css generated in advance? using the safelist ?

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
sibbngcommented, Nov 26, 2022

@Handpear I made a PR to fix this issue: #1921

In the meantime, you could use this roughly written extractor:

Test it in playground

export default defineConfig({
  extractors: [{
  name: 'ternary-extractor',
  extract(ctx) {
    let s = ctx.code
    const results = []
    const re = /<[\w.]+[^>]*?:?(?:([\w-]+)=[{'"](.+?(?:.)*?\?+(?:.)*?(?:['"]([^'"]+)['"]?(?:.)*?:(?:.)*?['"]([^'"]+)['"]?))[}'"](?:.)*?)+/gms
    let match
    while (match = re.exec(s)) {
      s = s.replace(match[2], '')
      re.lastIndex = 0
      const attr = match[1]
      if(attr === 'class' || attr === 'className') continue
      const left = match[3]
      left.split(' ').forEach(i => results.push(`[${attr}~="${i}"]`))
      const right = match[4]
      right.split(' ').forEach(i => results.push(`[${attr}~="${i}"]`))
      console.log(results)
    }
    return results
  },
}],
0reactions
Handpearcommented, Nov 28, 2022

@sibbng Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Attributify Mode with a Plugin · Issue #237 - GitHub
Is there something I can add to my plugin to make it intellisense aware with attributes? FYI it does complete dope-my-stuff inside the...
Read more >
Attributify Mode - Windi CSS
Attributify is opt-in by default, start by enabling it in your windi config. windi.config.ts. import { defineConfig } from 'windicss/helpers' ...
Read more >
WindiCSS IntelliSense - Visual Studio Marketplace
enableDynamicCompletion, boolean, true, Enable Dynamic Utilities Completion like p-{int} ... Enable Utility Completion For Attributify Mode.
Read more >
unocss - npm
Attributify Mode - group utilities in attributes; Pure CSS Icons - use any icon as a single class. Inspector - inspect and debug...
Read more >
Reimagine Atomic CSS - Anthony Fu
Value Auto Infering and Attributify Mode makes my development even ... To make it dynamic, change the matcher to a RegExp and the...
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