SASS/SCSS nest selector with parent - node.js

in SCSS
we can do nest seletor like htis
div
{
&[id*='gemini-ad-']
{
#content;
}
}
will return div[id*='gemini-ad-']
but any way can make something like this?
[id*='gemini-ad-']
{
div&
{
#content;
}
}
return div[id*='gemini-ad-'] too?
body:hover {}
a:hover {}
div:hover {}
:hover a {}
vs
:hover
{
body& {}
a& {}
div& {}
a {}
}

You can achieve what you want like this:
[id*='gemini-ad-']{
#at-root div#{&}{
/* CSS rules */
}
}
Outputs:
div[id*='gemini-ad-'] {
/* CSS rules */
}

Related

GraphQL fragment on a collection?

I want to make a fragment on a collection, but am unable to do so. Currently I have a collection called, componentCollection, that I would like as a separate fragment.
`
pageCollection {
items {
name
contentCollection {
hero {
... heroFrag
}
cards {
... cardsFrag
}
}
${HERO_FRAG}
${CARD_FRAG}
}
}
`
What I want to do is something like:
`
fragment contentCollectionFragment on ContentCollection {
hero {
... heroFrag
}
cards {
... cardsFrag
}
${HERO_FRAG}
${CARD_FRAG}
}
`
So I can reuse this 'content collection'. But it is saying ContentCollection is not available. I can do this though See below ( I basically have to use page collection. why can't I use the fragment directly on content collection?. Content collection is currently a field on my page that I can reference to various content/blocks I've made):
`
fragment contentCollectionFragment on PageCollection {
items {
contentcollection {
items {
hero {
... heroFrag
}
cards {
... cardsFrag
}
${HERO_FRAG}
${CARD_FRAG}
}
}
}
}
`

Is there anyway in styled-components to extend createGlobalStyle

I am importing GlobalStyle from a library which has been created using createGlobalStyle.
Is there any way to extend like ...
cont { GlobalStyle } from "another-library";
const exetendGlobal = styled(GlobalStyle)`
select {
background-color: #f60;
}`
I believe createGlobalStyle as a method is NOT extendable.
However, you could abstract the css from the other global style and include to get the desired effect...
SomeGlobalCss.js
import { css } from "styled-components"
Const SomeGlobalCss = css`
body {
background: red;
}
`
export { SomeGlobalCss }
Then import and include in global file:
App.js
import { SomeGlobalCss } from "another-library"
const GlobalStyle = createGlobalStyle`
${ SomeGlobalCss }
body {
background: green;
}
`
export { GlobalStyle }
Here, you can then include SomeGlobalCss.js, wherever you wish...

how to insert layout macro above thumbnail

I want to insert tiny type above the answer set providing a bit of metadata, but can't figure out how to do it. I just want the layout macro content-answer-set-info to say something like "results in reverse chronological order" in Legal or Detail_S. I want it to appear below altbrains workshop and above the first item in the list.
render {
if (size(this) > 1) {
list-of (this) {
has-details (true)
where-each (item) {
layout-macro (content-thumbnail-card) {
param (content) {
expression (item)
}
}
}
}
}
else-if (size(this) == 1) {
layout-match (this) {
mode (Details)
}
}
else {layout-macro (content-zero-results) {}
}
I would recommend wrapping this layout macro in a section and using the section-title (documentation) key to give it the text above the list.
There is an alternative solution that use section -> title but not with list-of
render {
layout {
section {
title {
template ("Voice command Add One")
}
content {
for-each (this) {
as (item) {
title-card {
title-area {
slot2 {
single-line {
text {
value {
template ("Integer: #{value(item.number)}")
}
style (Detail_L)
}
}
}
}
}
}
}
}
}
}

Groovy : add root closure if condition

A little bit confuse about this simple use case :
I want to add a closure around an other one only with conditions.
For the moment, I only succeed to do this :
if(condition) {
my_root_closure {
my_main_closure {
do_stuff()
}
}
} else {
my_main_closure {
do_stuff()
}
}
I would like to do this without repeat the my_main_closure bloc.
To avoid repetition, you could create new closure that calls my_main_closure and store it in a variable:
def mmc = {
my_main_closure {
do_stuff()
}
}
if(condition) {
my_root_closure( mmc )
} else {
mmc()
}

How do I get rid of all the "Warn this.name might be empty" warnings?

In my Cat.view.bxb file, I have some UI elements that are based on optional properties in the structure that have warnings attached to them.
WARN this.name might be empty
result-view{
match {
Cat (this)
}
render {
layout {
section {
content {
paragraph {
style (Title_XS)
value ("#{value(this.name)}")
}
}
}
}
}
}
The warnings serve to remind you that the UI elements you've defined will not be displayed if the optional properties are not present.
You should define an if(exists(this.name)) and define UI elements for when the optional elements are not available.
For example, your code would look something like the following:
result-view{
match {
Cat (this)
}
render {
layout {
section {
content {
if(exists(this.name)) {
paragraph {
style (Title_XS)
value ("#{value(this.name)}")
}
} else {
paragraph {
style (Title_XS)
value("No name!")
}
}
}
}
}
}
}
By doing so, you are addressing the root cause of the warning and creating a more responsive output for your users.
if (exists) works and is one way as articulated already and provides excellent context for the user. Another way that may be preferable in certain circumstances is to use the [] square brackets notation - if a section within square brackets renders null then the section is skipped. So for your example:
result-view{
match {
Cat (this)
}
render {
layout {
section {
content {
paragraph {
style (Title_XS)
value ("[#{value(this.name)}]")
}
}
}
}
}
}

Resources