Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from "li" to "&" #61

Open
LukyVj opened this issue Jun 6, 2016 · 5 comments
Open

Switch from "li" to "&" #61

LukyVj opened this issue Jun 6, 2016 · 5 comments
Assignees
Labels

Comments

@LukyVj
Copy link
Owner

LukyVj commented Jun 6, 2016

As @leonderijke pointed out, The li should be an amperstand here.

@LukyVj LukyVj added the bug label Jun 6, 2016
@LukyVj LukyVj self-assigned this Jun 6, 2016
@LukyVj
Copy link
Owner Author

LukyVj commented Jun 6, 2016

So, it turns out the proper mixin would be :

@mixin each-after($num, $offset) {
  &:nth-child(#{$offset}n) ~ :nth-child(#{$num}n) {
    @content
  }
}

Without any elements specified.

@LukyVj
Copy link
Owner Author

LukyVj commented Jun 6, 2016

The mixin is even more stable now :

@mixin each-after($num, $offset) {
  &:nth-child(#{$offset - $num}n) ~ :nth-child(#{$num}n) {
    @content;
  }
}

Let's say we have a map of 20 items.

⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️

With the previous mixin version, for a given each-after(3, 6), the output result would have been :

⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ 🔴 ⚫️ ⚫️ 🔴 ⚫️ ⚫️ 🔴 ⚫️ ⚫️ 🔴 ⚫️ ⚫️

What is happening here ? Well, the $offset number is equal to 6, so we go over the first 6 items :
⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️

But then, we want each 3 items to be highlighted, so, from the 6th, we count 3 and place the first active item on the 8. Because the 6 = 1; 7 = 2; 8 = 3;

So it was :
( the 6 first )
⚫️ ⚫️ ⚫️ ⚫️ ⚫️ [⚫️ 1, ⚫️ 2, 🔴 3]⚫️ ⚫️ 🔴 ⚫️ ⚫️ 🔴 ⚫️ ⚫️ 🔴 ⚫️ ⚫️ (and so on .. )

Now, the mixin will start at the given offset number, thanks to the #{$offset - $num}n.
We minus $num to $offset, to place the first selected item at the begining of the offset, so now, the mixin will return :

⚫️ ⚫️ ⚫️ ⚫️ ⚫️ 🔴 ⚫️ ⚫️ 🔴 ⚫️ ⚫️ 🔴 ⚫️ ⚫️ 🔴 ⚫️ ⚫️ 🔴 ⚫️ ⚫️

@LukyVj LukyVj mentioned this issue Jun 6, 2016
LukyVj added a commit that referenced this issue Jun 6, 2016
LukyVj added a commit that referenced this issue Jun 6, 2016
LukyVj added a commit that referenced this issue Jun 6, 2016
LukyVj added a commit that referenced this issue Jun 6, 2016
LukyVj added a commit that referenced this issue Jun 6, 2016
LukyVj added a commit that referenced this issue Jun 6, 2016
* Fix #56

* Fixed twitter sharing message: more mixins :) (#58)

* Update file weight

* Remove each-after() mixin; See #37 & #61

* Remove each-after() mixin; See #37 & #61
LukyVj added a commit that referenced this issue Jun 6, 2016
* Fix #56

* Fixed twitter sharing message: more mixins :) (#58)

* Update file weight

* Remove each-after() mixin; See #37 & #61

* Remove each-after() mixin; See #37 & #61

* Fix <<<
LukyVj added a commit that referenced this issue Jun 6, 2016
* Fix #56

* Fixed twitter sharing message: more mixins :) (#58)

* Update file weight

* Remove each-after() mixin; See #37 & #61

* Remove each-after() mixin; See #37 & #61

* Fix <<<

* Update version and demo

* A few fixes + updated readme
@LukyVj LukyVj mentioned this issue Jun 9, 2016
jolidog added a commit to jolidog/family.scss that referenced this issue Jul 26, 2016
jolidog added a commit to jolidog/family.scss that referenced this issue Jul 26, 2016
jolidog added a commit to jolidog/family.scss that referenced this issue Jul 26, 2016
jolidog added a commit to jolidog/family.scss that referenced this issue Jul 26, 2016
jolidog added a commit to jolidog/family.scss that referenced this issue Jul 26, 2016
@jolidog
Copy link

jolidog commented Jul 26, 2016

@LukyVj just created a PR for you to review, I believe it solves three issues, #37 #78 and the current one. Please review.

Also would like to thank you very much for starting this project.

jolidog added a commit to jolidog/family.scss that referenced this issue Jul 26, 2016
@LukyVj
Copy link
Owner Author

LukyVj commented Oct 23, 2016

Thanks a lot,
I just have to wrap my head around it again 👍 😄

@LukyVj
Copy link
Owner Author

LukyVj commented Oct 23, 2017

Still not wrapped my head around this. Will do it asap... I need more free time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants