I am having a problem with the following code snippet: https://codepen.io/Vreesie/pen/yLxmYrQ
This code snippet shows you the following pattern:
These dots are placed in a circular pattern. However, in the SCSS file I have hard coded that the number of nodes will be 6:
.cluster {
$count: 6;
@include on-circle($item-count: $count, $circle-size: 300px, $item-size: 100px);
.node {
display: block;
position: absolute;
top: 50%;
left: 50%;
width: 100px;
height: 100px;
border-radius: 50%;
background-color: #1F1F1F;
border: #137FE3 3px solid;
}
}
What I actually want is to dynamically determine the number of nodes using a selector. So when I remove/add a node, the pattern will adjust to the number of nodes. I can't really find anything about storing the number of items in a variable. I tried stuff like this:
$count: 0;
@for $i from 1 through 10 {
.node:has(.node:nth-child(#{$i})) {
$count: $count + 1;
}
}
Here my idea was to loop 10 times (max number of nodes). If the node really does exist then add the counter, but this always returned 10 and not 6 in my case. How can I get this to work in SCSS so that I only need to modify my HTML?