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

[] lookup does not handle property merging #3369

Open
seven-phases-max opened this issue Feb 22, 2019 · 3 comments
Open

[] lookup does not handle property merging #3369

seven-phases-max opened this issue Feb 22, 2019 · 3 comments

Comments

@seven-phases-max
Copy link
Member

Minimal example:

@list: {
    x+: 1;
    x+: 2;
}

div {
    result: @list[x]; // -> `2`, but expected `1, 2`
}
@matthew-dean
Copy link
Member

Hmm, there's nothing explicit about it supporting this variant, but you're probably right it should be supported because of:

.box {
  a+: 1;
  a+: 2;
  b: $a;
}

Outputs:

.box {
  a: 1, 2;
  b: 1, 2;
}

@stale
Copy link

stale bot commented Jul 20, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 20, 2019
@Maluscat
Copy link

This would be really useful for helper functions that work with lists, for example:

.shift-list(@list, @offset, @it: 0) {
  & when (@it < length(@list)) {
    return+: extract(@list, mod(@it + @offset - 1, length(@list)) + 1);
    .shift-list(@list, @offset, @it + 1);
  }
}

body {
  @colors: red, orange, yellow, green, blue;
  @shifted-colors: .shift-list(@colors, 2)[return];
  background: linear-gradient(to right, @shifted-colors);
}

Outputs:

body {
  background: linear-gradient(to right, yellow, green, blue, red, orange);
}

Which then could, for example, be combined with iterations over multiple elements, giving each element a different list offset.

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

No branches or pull requests

3 participants