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

feat(gatsby-remark-autolink-headers): Allow after option to make icon appear after header text #19937

Merged
merged 7 commits into from
Dec 24, 2019

Conversation

guyathomas
Copy link
Contributor

@guyathomas guyathomas commented Dec 4, 2019

Description

Introduce boolean isIconAfterH prop in gatsby-remark-autolink-headers that will place the icon inline, after the header text. ( Defaults to before the title )
Also refactor to absolutely position icon relative to the header ( and make the header position: relative to make this possible. This removes the need for a float 👍 )
image

@guyathomas guyathomas requested review from a team as code owners December 4, 2019 06:56
Comment on lines +16 to +25
.${className}.before {
position: absolute;
top: 0;
left: 0;
transform: translateX(-100%);
padding-right: 4px;
margin-left: -20px;
}
.${className}.after {
display: inline-block;
padding-left: 4px;
Copy link
Contributor

@pvdz pvdz Dec 4, 2019

Choose a reason for hiding this comment

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

(I should read better)

Copy link
Contributor

Choose a reason for hiding this comment

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

@fk can you take a quick look at this?

It looks fine to me but I'm not sure if this will be a problem for anything else in the gatsby css world. Cheers

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM, but haven't built locally.

laurieontech
laurieontech previously approved these changes Dec 4, 2019
## [2.1.20](2019-12-02)

Allow `after` option where the link will appear inline after the header text

Copy link
Contributor

Choose a reason for hiding this comment

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

Changelog is autogenerated from commit messages, so please don't pre-emptively add to it (it can be edited afterwards if needed)

@pvdz pvdz requested a review from fk December 4, 2019 14:40
@@ -21,6 +21,7 @@ module.exports = (
maintainCase = false,
removeAccents = false,
enableCustomId = false,
after = true,
Copy link
Contributor

Choose a reason for hiding this comment

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

this changes default behaviour (we should not do that unless we do major version bump for the plugin)

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for not introducing a breaking change

@pvdz
Copy link
Contributor

pvdz commented Dec 4, 2019

@LekoArts raised a good point internally; this can be achieved with css without the need for an option;

.anchor {
    float: none;
    margin-left: 0px;
    position: absolute;
    right: -60px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px !important;
}

@guyathomas can you let us know whether you feel this sufficiently solves this issue for you?

@guyathomas
Copy link
Contributor Author

Thanks for taking a look! I agree about not making the breaking changes.

I'll give that CSS a whirl, but I feel it may not achieve exactly the same behaviour ( will be positioned vertically in the middle of the header, fixed on the right hand side - rather than inline (and next to ) the last letter of the header.

I'll report back!

@guyathomas guyathomas force-pushed the allow-after-header-link branch from 70320fd to 815e547 Compare December 4, 2019 17:47
@@ -58,6 +58,7 @@ Note: if you are using `gatsby-remark-prismjs`, make sure that it’s listed aft
- `maintainCase`: Boolean. Maintains the case for markdown header (optional)
- `removeAccents`: Boolean. Remove accents from generated headings IDs (optional)
- `enableCustomId`: Boolean. Enable custom header IDs with `{#id}` (optional)
- `isIconAfterH`: Boolean. Enable the anchor icon to be inline at the end of the header text
Copy link
Contributor

@muescha muescha Dec 5, 2019

Choose a reason for hiding this comment

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

i guess this is an optional option?

Suggested change
- `isIconAfterH`: Boolean. Enable the anchor icon to be inline at the end of the header text
- `isIconAfterH`: Boolean. Enable the anchor icon to be inline at the end of the header text (optional)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great idea! Made changes here 81ade36

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this is still not addressed? I mean appending (optional) to this option description?

@guyathomas guyathomas force-pushed the allow-after-header-link branch 2 times, most recently from 7782ef7 to 9872992 Compare December 11, 2019 21:04
@guyathomas
Copy link
Contributor Author

guyathomas commented Dec 11, 2019

Mind if i grab another 👀 on this?
@muescha - made your suggested changes in fbc2d1e
@pvdz - made your suggested changes in 1b1a444180e3cc982a61519d0c8400eae6bf5049
@fk - not sure if you wanted to take another pass on this? I reduced the exposure to non backward compatible changes

The surface area for possible regressions

  • Headers now all get position: relative in order to be able to absolutely position the icon to the left of the header
  • The icon is positioned to the left of the header using position absolute rather than floats

The isIconAfterHeader = true state should cause no regressions since it's just additive.

@guyathomas guyathomas requested review from muescha and pvdz December 11, 2019 23:06
@guyathomas guyathomas force-pushed the allow-after-header-link branch from 3fe151c to bd32729 Compare December 23, 2019 19:45
@guyathomas guyathomas requested review from vladar and pieh December 23, 2019 19:46
Copy link
Contributor

@vladar vladar left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for this improvement!

@vladar vladar changed the title Allow after option for plugin to make icon appear after header text feat(gatsby-remark-autolink-headers): Allow after option to make icon appear after header text Dec 24, 2019
@vladar vladar added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label Dec 24, 2019
@gatsbybot gatsbybot merged commit a6774ca into gatsbyjs:master Dec 24, 2019
@gatsbot
Copy link

gatsbot bot commented Dec 24, 2019

Holy buckets, @guyathomas — we just merged your PR to Gatsby! 💪💜

Gatsby is built by awesome people like you. Let us say “thanks” in two ways:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. We’ve got Gatsby t-shirts, stickers, hats, scrunchies, and much more. (You can also unlock even more free swag with 5 contributions — wink wink nudge nudge.) See gatsby.dev/swag for details.
  2. We just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. Accept the invite by visiting https://github.com/orgs/gatsbyjs/invitation. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again!

@muescha
Copy link
Contributor

muescha commented Dec 24, 2019

👍

i was thinking a little bit about naming, maybe would be this naming better?

headerIconPosition: "before" #default
headerIconPosition: "after"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants