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

Improve mixin and extend docs in https://sass-lang.com/guide #473

Closed
meatnordrink opened this issue Sep 16, 2020 · 4 comments · Fixed by #550
Closed

Improve mixin and extend docs in https://sass-lang.com/guide #473

meatnordrink opened this issue Sep 16, 2020 · 4 comments · Fixed by #550

Comments

@meatnordrink
Copy link

Hi,

I'd like to suggest that the example used in the Mixin example on the tutorial contains a complication that impedes quickly grasping the concept. Here's the example I mean:

@mixin transform($property) {
  -webkit-transform: $property;
  -ms-transform: $property;
  transform: $property;
}

Using a mixin with a name that's the same as one of the properties it contains is confusing, for someone who is new to the concept.

I understand that this example was chosen to demonstrate using a function where you can pass in a variable; but I think it would aid comprehension to lead with a more straightforward example, and follow with this, so the reader has less barrier to understanding basic function before moving on to understanding of full functionality.

Thank you.

@Awjin
Copy link
Contributor

Awjin commented Sep 17, 2020

Thanks for bringing this up. I think that example is useful for demonstrating how mixins can clean up browser prefixes. However, I do agree that we could add a simpler explanation of mixins and possibly more context around its usage. I'm going to retarget this issue more broadly to address that.

Also, after the mixin section, there is a section that stresses the importance of extend. Modern best practices recommend mixins over extend, so that section should also be updated.

@Awjin Awjin changed the title Suggestion: Mixin explanation in tutorial could be cleaner. Improve mixin and extend docs in https://sass-lang.com/guide Sep 17, 2020
@stof
Copy link
Contributor

stof commented May 25, 2021

Also, adding browser prefixes might not be the best example for using mixins. Most modern frameworks have stopped using mixins for that in favor of autoprefixer

@nex3
Copy link
Contributor

nex3 commented May 26, 2021

Any suggested replacements would be appreciated 😃.

@jina
Copy link
Member

jina commented May 26, 2021

How about:

@mixin theme($theme: DarkGray) {
  background: $theme;
  box-shadow: 0 0 1px rgba($theme, .25);
  color: #fff;
}

.info    { @include theme;                    }
.alert   { @include theme($theme: DarkRed);   }
.success { @include theme($theme: DarkGreen); }

(I used regular named CSS colors to avoid also introducing extra variables into the code but we can switch them to variabled colors if we prefer).

nex3 added a commit that referenced this issue May 26, 2021
@nex3 nex3 closed this as completed in #550 May 26, 2021
asaf400 pushed a commit to asaf400/ass-site that referenced this issue Apr 18, 2024
asaf400 pushed a commit to asaf400/ass-site that referenced this issue Apr 18, 2024
Friendly-users added a commit to Friendly-users/sass-site that referenced this issue Jun 27, 2024
-----
It is inappropriate to include political and offensive content in public code repositories.

Public code repositories should be neutral spaces for collaboration and community, free from personal or political views that could alienate or discriminate against others. Political content, especially that which targets or disparages minority groups, can be harmful and divisive. It can make people feel unwelcome and unsafe, and it can create a hostile work environment.

Please refrain from adding such content to public code repositories.
---

 sass#400 sass#401 sass#402 sass#403 sass#404 sass#405 sass#406 sass#407 sass#408 sass#409 sass#410 sass#411 sass#412 sass#413 sass#414 sass#415 sass#416 sass#417 sass#418 sass#419 sass#420 sass#421 sass#422 sass#423 sass#424 sass#425 sass#426 sass#427 sass#428 sass#429 sass#430 sass#431 sass#432 sass#433 sass#434 sass#435 sass#436 sass#437 sass#438 sass#439 sass#440 sass#441 sass#442 sass#443 sass#444 sass#445 sass#446 sass#447 sass#448 sass#449 sass#450 sass#451 sass#452 sass#453 sass#454 sass#455 sass#456 sass#457 sass#458 sass#459 sass#460 sass#461 sass#462 sass#463 sass#464 sass#465 sass#466 sass#467 sass#468 sass#469 sass#470 sass#471 sass#472 sass#473 sass#474 sass#475 sass#476 sass#477 sass#478 sass#479 sass#480 sass#481 sass#482 sass#483 sass#484 sass#485 sass#486 sass#487 sass#488 sass#489 sass#490 sass#491 sass#492 sass#493 sass#494 sass#495 sass#496 sass#497 sass#498 sass#498 sass#499
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants