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

[img-helpers] Add/Edit Image display utilities #357

Merged
merged 16 commits into from
Jun 20, 2023
Merged

[img-helpers] Add/Edit Image display utilities #357

merged 16 commits into from
Jun 20, 2023

Conversation

stacyk
Copy link
Member

@stacyk stacyk commented May 17, 2023

Description

Add/edit image helpers:

  • Fix img-shadow (and convert all ing-border to use ing shadow instead)
  • Add ability to display an image to the left of the text on large enough screens (media-pull)
  • Remove extend-small (it was the same as what the figure width is)
  • Add caption padding for images that use extend-full
  • Add examples to the Sample Pages / Placing Images page
  • Remove unused sizes and extend-left extend-right classes
  • Update some of the older embed.img macros to the embed.figure macro (especially the ones that were wrapped in a <figure> tag

Steps to test/reproduce

Review a few pages that were updated:

  • work pages ( /work/coachhub/, /work/adobe, /work/quarqnet )
  • blog posts ( 2018/01/03/introducing-herman/ )
  • review the examples on the Sample Placing images page: /sample/images/

Show me

sample-images

@github-actions
Copy link

View diff of compiled files (may take a few minutes): https://github.com/oddbird/oddleventy-built/compare/main..img-helpers

@stacyk
Copy link
Member Author

stacyk commented May 17, 2023

@stacyk stacyk requested a review from mirisuzanne May 19, 2023 13:27
@stacyk
Copy link
Member Author

stacyk commented May 19, 2023

@mirisuzanne this is ready for an initial review. I kept these "helpers" as classes instead of adding a data attribute incase we wanted to apply it to something other than the embed.figure or embed.img macros. Like the contact form uses extend-small.

I also took over what was the sample page called Responsive Images to show how these examples look when applied (I think it will be helpful to have a visual guide to know what is available.

This is not something in this PR, but it is related to this images sample page. I don't actually know what the difference is between the first 2 (one says no width and the other says 4410) but the secret sizes are the same and so is the visual display. The last one is using the "sizes" attribute but you can't tell from the page itself. It does have a different srcset size value. I feel like we should add some explanation to these images and why they are there, but I am not actually sure why they are all there.

Copy link
Member

@mirisuzanne mirisuzanne left a comment

Choose a reason for hiding this comment

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

Good stuff here! I just have a few questions about some of the details.

content/sample/images.md Outdated Show resolved Hide resolved
Comment on lines 97 to 98
access to the outer container. Also, the embed.figure macro is wider than the
content column by default, as opposed to the `embed.img` macro.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
access to the outer container. Also, the embed.figure macro is wider than the
content column by default, as opposed to the `embed.img` macro.
access to the outer container. Note that the `embed.figure` macro extends wider than the
content column by default, as opposed to the `embed.img` macro.

access to the outer container. Also, the embed.figure macro is wider than the
content column by default, as opposed to the `embed.img` macro.

### `embed.figure` without any entend class for comparison
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
### `embed.figure` without any entend class for comparison
### `embed.figure` without any extend class for comparison

Seems like this could also be called extend-small - and available to other media?


You can add the class `img-shadow` to the `embed.figure` and `embed.img` to
display a shadow around the image. This doesn't work on figure if you have a
caption as the shadow will be around that entire container.
Copy link
Member

Choose a reason for hiding this comment

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

Note that the shadows are not visible in dark mode?

Copy link
Member Author

Choose a reason for hiding this comment

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

I added an additional image for testing in both modes and upped the opacity a bit so you can see the shadow better.

.contain {
display: flow-root;
}

[class*='align-'] {
margin: var(--shim) var(--inline-margin, 0);
margin: var(--shim) var(--inline-margin-right, var(--inline-margin, 0)) var(--shim) var(--inline-margin-left, var(--inline-margin, 0));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
margin: var(--shim) var(--inline-margin-right, var(--inline-margin, 0)) var(--shim) var(--inline-margin-left, var(--inline-margin, 0));
margin-block: var(--shim);
margin-inline-start: var(--inline-margin-start, var(--inline-margin, 0));
margin-inline-end: var(--inline-margin-end, var(--inline-margin, 0));

A bit easier to follow? And not mixing logical/physical names?

Copy link
Member Author

Choose a reason for hiding this comment

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

so much easier to read when we split it out.

--inline-margin-right: var(--gutter);

float: left;
max-width: 45%;
Copy link
Member

Choose a reason for hiding this comment

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

Are we trying to approximate 50% minus some gutter? Should we do that explicitly?

Suggested change
max-width: 45%;
max-width: calc(50% - var(--inline-margin-right) / 2);

Copy link
Member Author

Choose a reason for hiding this comment

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

the width is old, but I am assuming that is what it was attempting on the previous site. Either that or a little less than half of the content column looked good 😄

@@ -47,6 +47,10 @@ figcaption,
font-size: var(--small);
font-style: italic;
margin-top: var(--shim);

.extend-full & {
padding-inline: var(--gutter-plus);
Copy link
Member

Choose a reason for hiding this comment

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

Should we use var(--page-margin) here?

Comment on lines 132 to 133
max-width: 25vw;
padding-inline: calc(var(--gutter) + 2vw);
Copy link
Member

Choose a reason for hiding this comment

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

These numbers feel a bit magical and unclear to me. Why 25vw? Right now, this doesn't align with anything else on the page - should it? Is the extra gutter space meant to avoid our hanging link icons on headings? If you use this next to a paragraph rather than a heading, does the extra space still make sense?

Copy link
Member Author

Choose a reason for hiding this comment

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

max-width: 25vw; is a magic number. We really don't need it at all so I can remove that. As far as the padding goes, I can swap this out with page-margin. I think that will work about the same and maybe be more meaningful.

src/scss/patterns/_sizes.scss Show resolved Hide resolved
Copy link
Member Author

@stacyk stacyk left a comment

Choose a reason for hiding this comment

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

@mirisuzanne I think I covered all/most of your comments minus the one I had a question about (extend-small)

--inline-margin-right: var(--gutter);

float: left;
max-width: 45%;
Copy link
Member Author

Choose a reason for hiding this comment

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

the width is old, but I am assuming that is what it was attempting on the previous site. Either that or a little less than half of the content column looked good 😄

src/scss/patterns/_sizes.scss Show resolved Hide resolved
Comment on lines 132 to 133
max-width: 25vw;
padding-inline: calc(var(--gutter) + 2vw);
Copy link
Member Author

Choose a reason for hiding this comment

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

max-width: 25vw; is a magic number. We really don't need it at all so I can remove that. As far as the padding goes, I can swap this out with page-margin. I think that will work about the same and maybe be more meaningful.

.contain {
display: flow-root;
}

[class*='align-'] {
margin: var(--shim) var(--inline-margin, 0);
margin: var(--shim) var(--inline-margin-right, var(--inline-margin, 0)) var(--shim) var(--inline-margin-left, var(--inline-margin, 0));
Copy link
Member Author

Choose a reason for hiding this comment

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

so much easier to read when we split it out.


You can add the class `img-shadow` to the `embed.figure` and `embed.img` to
display a shadow around the image. This doesn't work on figure if you have a
caption as the shadow will be around that entire container.
Copy link
Member Author

Choose a reason for hiding this comment

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

I added an additional image for testing in both modes and upped the opacity a bit so you can see the shadow better.

@stacyk stacyk requested a review from mirisuzanne May 19, 2023 20:31
@mirisuzanne
Copy link
Member

This is not something in this PR, but it is related to this images sample page. I don't actually know what the difference is between the first 2 (one says no width and the other says 4410) but the secret sizes are the same and so is the visual display. The last one is using the "sizes" attribute but you can't tell from the page itself. It does have a different srcset size value. I feel like we should add some explanation to these images and why they are there, but I am not actually sure why they are all there.

Yeah, these were for testing the responsive image stuff as I was writing it - but they're probably outdated, and were never well documented. We should add a story to actually document our responsive image handling, but these don't seem useful, so I think they can just be removed.

Copy link
Member

@mirisuzanne mirisuzanne left a comment

Choose a reason for hiding this comment

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

looks great. I would still probably vote for documenting how to extend images, and how to extend-small, while also noting that it might not work in markdown. If the has() trick even works for some browsers - it's not bad for that to be a progressive enhancement.

@stacyk stacyk requested a review from mirisuzanne June 13, 2023 22:33
@stacyk
Copy link
Member Author

stacyk commented Jun 13, 2023

@mirisuzanne I updated the sample images page to include the updated guidelines for using the img/figure macros and added that little p:has(> picture:only-child) { display: contents; } snippet along with a few styles for fallbacks. You can see it not working in Firefox and working in the others.

Firefox:
Screenshot 2023-06-13 at 5 36 45 PM

Chrome:
Screenshot 2023-06-13 at 5 38 08 PM

I removed the srcset examples and added a note to this existing image handling card: https://trello.com/c/p8iLneXl/117-document-responsive-image-handling-and-any-other-image-guidelines-that-arent-yet-on-the-sample-pages

content/sample/images.md Show resolved Hide resolved
content/sample/images.md Show resolved Hide resolved
content/sample/images.md Show resolved Hide resolved
Copy link
Member

@mirisuzanne mirisuzanne left a comment

Choose a reason for hiding this comment

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

looks great!

src/scss/patterns/_media.scss Show resolved Hide resolved
@stacyk stacyk merged commit f1e7a4c into main Jun 20, 2023
10 checks passed
@stacyk stacyk deleted the img-helpers branch June 20, 2023 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants