How to write an at-rule visitor #634
Unanswered
mattpilott
asked this question in
Q&A
Replies: 1 comment
-
I got to here, which works: export const breakpoints = {
Rule: {
custom: {
breakpoints({ loc, body: { value: { declarations } } }) {
const ret = declarations.map(({ value: { name, value } }) => {
const val = value[0].value.value
return [
{
type: 'custom-media',
value: {
name: `--from-${name}`,
loc,
query: { mediaQueries: [{ raw: `(min-width: ${val / 16}em)` }] }
}
},
{
type: 'custom-media',
value: {
name: `--until-${name}`,
loc,
query: { mediaQueries: [{ raw: `(max-width: ${(val - 1) / 16}em)` }] }
}
}
]
})
return ret.flat()
}
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I'd like to make an at-rule like this:
which outputs the following:
I have started writing a visitor but cannot figure out from docs etc how to get the above, here's what i have at the moment:
How can i achieve this?
Beta Was this translation helpful? Give feedback.
All reactions