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

fix(theme): codeblock buttons should be kept on the right when using RTL locale #8803

Merged
merged 4 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default function CodeBlockString({
</pre>
)}
</Highlight>
<div className={styles.buttonGroup}>
<div className={`${styles.buttonGroup} ${styles.buttonBlockSpace}`}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This extra class is not needed

{(wordWrap.isEnabled || wordWrap.isCodeScrollable) && (
<WordWrapButton
className={styles.codeButton}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,7 @@
:global(.theme-code-block:hover) .buttonGroup button {
opacity: 0.4;
}

.buttonBlockSpace {
right: calc(var(--ifm-pre-padding) / 2) !important;
}
Copy link
Collaborator

@slorber slorber Mar 22, 2023

Choose a reason for hiding this comment

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

That's not a good fix because our RTLCSS postCSS plugin will automatically transform right to left.

If you test your dev locally yarn start:website --locale fa you'll notice it doesn't work.

The solution is to add an rtl ignore directive to avoid this auto transform to happen:

.buttonGroup {
  display: flex;
  column-gap: 0.2rem;
  position: absolute;
  /* rtl:ignore */
  right: calc(var(--ifm-pre-padding) / 2);
  top: calc(var(--ifm-pre-padding) / 2);
}

See directives syntax: https://rtlcss.com/learn/usage-guide/control-directives/index.html