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

Add documentation for using multiple drop-shadows #37138

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

TheJaredWilcurt
Copy link

Description

Adds examples for how to use multiple drop-shadows.

Motivation

I assumed the SVG filter drop-shadow would work the same as the CSS box-shadow/text-shadow (comma-separated). But when that didn't work, I came to MDN, which didn't mention it and assumed it wasn't possible, but double-checked on StackOverflow and found the solution.

/* Correct */
box-shadow: 1px 1px #F00, -1px -1px #F00;
text-shadow: 1px 1px #F00, -1px -1px #F00;

/* Assumption (Wrong) */
filter: drop-shadow(1px 1px #F00, -1px -1px #F00);

/* Correct */
filter: drop-shadow(1px 1px #F00) drop-shadow(-1px -1px #F00);

This was missing from the page, had to go to SO to find it.
@TheJaredWilcurt TheJaredWilcurt requested a review from a team as a code owner December 8, 2024 21:50
@TheJaredWilcurt TheJaredWilcurt requested review from chrisdavidmills and removed request for a team December 8, 2024 21:50
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs size/s [PR only] 6-50 LoC changed labels Dec 8, 2024
Copy link
Contributor

github-actions bot commented Dec 8, 2024

Preview URLs

(comment last updated: 2024-12-08 22:11:41)

Comment on lines +71 to +73
drop-shadow(1px 1px red)
drop-shadow(1px -1px red)
drop-shadow(-1px 1px red)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[mdn-linter] reported by reviewdog 🐶

Suggested change
drop-shadow(1px 1px red)
drop-shadow(1px -1px red)
drop-shadow(-1px 1px red)
drop-shadow(1px 1px red) drop-shadow(1px -1px red) drop-shadow(-1px 1px red)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should either all be on the same line, or all be on separate lines.

  • All same lines conveys that it is all part of the same CSS property/value.
  • All on separate lines makes the repetition easier to visually parse.

All the suggestions the linter is making are bad.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @TheJaredWilcurt. Yup, the linter is really annoying sometimes. To stop it from committing linting crimes in cases like this, update the language specifier on the opening code fence to include -nolint, so for example

```css-nolint
/* CSS code here */
```

or

```js-nolint
// JS code here
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then re add, commit, and push, and it should turn the PR green.

Comment on lines 108 to 111
filter: drop-shadow(1px 1px red)
drop-shadow(1px -1px red)
drop-shadow(-1px 1px red)
drop-shadow(-1px -1px red);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[mdn-linter] reported by reviewdog 🐶

Suggested change
filter: drop-shadow(1px 1px red)
drop-shadow(1px -1px red)
drop-shadow(-1px 1px red)
drop-shadow(-1px -1px red);
filter: drop-shadow(1px 1px red) drop-shadow(1px -1px red)
drop-shadow(-1px 1px red) drop-shadow(-1px -1px red);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to make the linter shut up without making the code look like it was written by AI?

Comment on lines +108 to +112
filter:
drop-shadow(1px 1px red)
drop-shadow(1px -1px red)
drop-shadow(-1px 1px red)
drop-shadow(-1px -1px red);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[mdn-linter] reported by reviewdog 🐶

Suggested change
filter:
drop-shadow(1px 1px red)
drop-shadow(1px -1px red)
drop-shadow(-1px 1px red)
drop-shadow(-1px -1px red);
filter: drop-shadow(1px 1px red) drop-shadow(1px -1px red)
drop-shadow(-1px 1px red) drop-shadow(-1px -1px red);

Copy link
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there @TheJaredWilcurt, and thanks for your addition to MDN! I've left a few comments for you to work your way through, but nothing too major.

@@ -38,6 +38,9 @@ drop-shadow(5px 5px 15px red)
/* The order of color and length values can be changed */
/* drop-shadow( <color> <length> <length> <length> ) */
drop-shadow(#e23 0.5rem 0.5rem 1rem)

/* You can pass multiple drop-shadow's to a filter to stack them */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* You can pass multiple drop-shadow's to a filter to stack them */
/* Pass multiple drop-shadows to a filter to stack them */

@@ -94,6 +103,14 @@ div:nth-child(3) {
div:nth-child(4) {
filter: drop-shadow(-16px -16px red);
}

div:nth-child(5) {
filter:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only comment here is that I would make the four shadows a bit more different, in color and/or placement. At the moment, it is difficult to see that multiuple shadows are being applied, as they are all so close together.

drop-shadow(1px -1px red)
drop-shadow(-1px 1px red)
drop-shadow(-1px -1px red);
}
```

{{EmbedLiveSample("Setting a drop shadow", "100%", "300px")}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to update the paragraph following the example to describe your new addition. At the moment, it only describes the first four shadows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:CSS Cascading Style Sheets docs size/s [PR only] 6-50 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants