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 margins and spacing in grids #77

Merged
merged 1 commit into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/famous-turkeys-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'myst-to-react': patch
'@myst-theme/frontmatter': patch
'@myst-theme/styles': patch
---

Improve margins on children and balancing of callouts and equations.
5 changes: 5 additions & 0 deletions .changeset/khaki-moles-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@myst-theme/frontmatter': patch
---

Add underline on hover to DOI link.
6 changes: 3 additions & 3 deletions packages/frontmatter/src/FrontmatterBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export function DoiBadge({ doi: possibleLink, className }: { doi?: string; class
return (
<div className={classNames('flex-none', className)} title="DOI (Digital Object Identifier)">
<a
className="font-light hover:font-light no-underline text-inherit hover:text-inherit"
className="font-light hover:font-light no-underline hover:underline text-inherit hover:text-inherit"
target="_blank"
rel="noopener noreferrer"
href={url}
Expand Down Expand Up @@ -289,7 +289,7 @@ export function FrontmatterBlock({
subject || github || venue || biblio || open_access || license || hasExports || isJupyter;
const hasDateOrDoi = doi || date;
return (
<>
<div className="mb-8">
Copy link
Contributor

Choose a reason for hiding this comment

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

May I just ask about this mb-8 here? It's giving me 2rem extra space that wasn't there before -- between the title and content, or else just pushing the content down when there's no title.

If I remove the mb-8 class everything looks perfect.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, yes, if you only have a title this isn't going to be good. I was testing with a full frontmatter, and that should be on conditionally (or something). Good catch!

We want these conditionally if there is frontmatter. Or maybe better is to override the h1 here and have an explicit mb-0 and then have some margin around the stuff that comes after it which is conditionally rendered.

Are you in a place to open a PR for this? If not, I can fix my bug shortly!

The two green things stack, and they should collapse if there isn't anything in between.

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm I guess I need to think about it a bit. You may get there faster than me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I am not quite sure which solution is best. I will try and get to it by the end of today and tag you! Thanks again for pointing it out. :)

{hasHeaders && (
<div className="flex mt-3 mb-5 text-sm font-light items-center h-6">
{subject && (
Expand Down Expand Up @@ -328,6 +328,6 @@ export function FrontmatterBlock({
<DoiBadge doi={doi} />
</div>
)}
</>
</div>
);
}
2 changes: 1 addition & 1 deletion packages/myst-to-react/src/admonitions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export function Admonition({
<WrapperElement
dropdown={dropdown}
className={classNames(
'my-4 shadow-md dark:shadow-2xl dark:shadow-neutral-900',
'my-5 shadow-md dark:shadow-2xl dark:shadow-neutral-900',
'bg-gray-50 dark:bg-stone-800',
'overflow-hidden',
{
Expand Down
2 changes: 1 addition & 1 deletion packages/myst-to-react/src/code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function CodeBlock(props: Props) {
} = props;
const highlightLines = new Set(emphasizeLines);
const borderClass =
'rounded shadow-md dark:shadow-2xl dark:shadow-neutral-900 my-4 text-sm border border-l-4 border-l-blue-400 border-gray-200 dark:border-l-blue-400 dark:border-gray-800';
'rounded shadow-md dark:shadow-2xl dark:shadow-neutral-900 my-5 text-sm border border-l-4 border-l-blue-400 border-gray-200 dark:border-l-blue-400 dark:border-gray-800';
return (
<div
className={classNames('relative group not-prose overflow-auto', className, {
Expand Down
2 changes: 1 addition & 1 deletion packages/myst-to-react/src/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function Details({
return (
<details
className={classNames(
'rounded-md my-4 shadow dark:shadow-2xl dark:shadow-neutral-900 overflow-hidden',
'rounded-md my-5 shadow dark:shadow-2xl dark:shadow-neutral-900 overflow-hidden',
'bg-gray-50 dark:bg-stone-800',
)}
open={open}
Expand Down
2 changes: 1 addition & 1 deletion packages/myst-to-react/src/links/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const link: NodeRenderer<TransformedLink> = (node, children) => {
export const linkBlock: NodeRenderer<TransformedLink> = (node, children) => {
const iconClass = 'w-6 h-6 self-center transition-transform flex-none ml-3';
const containerClass =
'flex-1 p-4 my-4 block border font-normal hover:border-blue-500 dark:hover:border-blue-400 no-underline hover:text-blue-600 dark:hover:text-blue-400 text-gray-600 dark:text-gray-100 border-gray-200 dark:border-gray-500 rounded shadow-sm hover:shadow-lg dark:shadow-neutral-700';
'flex-1 p-4 my-5 block border font-normal hover:border-blue-500 dark:hover:border-blue-400 no-underline hover:text-blue-600 dark:hover:text-blue-400 text-gray-600 dark:text-gray-100 border-gray-200 dark:border-gray-500 rounded shadow-sm hover:shadow-lg dark:shadow-neutral-700';
const internal = node.internal ?? false;
const nested = (
<div className="flex align-middle h-full">
Expand Down
2 changes: 1 addition & 1 deletion packages/myst-to-react/src/math.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const mathRenderer: NodeRenderer<MathLike> = (node) => {
}
const id = node.html_id || node.identifier || node.key;
return (
<div key={node.key} id={id} className={classNames('flex group')}>
<div key={node.key} id={id} className="flex group my-5">
<div
dangerouslySetInnerHTML={{ __html: node.html }}
className="overflow-x-auto flex-grow"
Expand Down
4 changes: 2 additions & 2 deletions styles/block-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

@layer base {
.shaded {
@apply p-2 bg-slate-100;
@apply pt-5 bg-slate-100 dark:bg-slate-800 mb-3;
}
.shaded-children > * {
@apply p-2 bg-slate-100;
@apply p-2 bg-slate-100 dark:bg-slate-800;
}
.rounded-children > * {
@apply rounded;
Expand Down
8 changes: 8 additions & 0 deletions styles/figures.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ figure.quote figcaption > p:before {
figure.code > div {
margin: 0;
}
figure figcaption > p {
margin-top: 0 !important;
margin-bottom: 0 !important;
}
figure img {
margin-top: 0 !important;
margin-bottom: 0 !important;
}
2 changes: 2 additions & 0 deletions styles/grid-system.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
.article-grid > * {
/* The default is spanning the body for any child component */
@apply col-body;
/* Grids do not have margin-collapse, so each direct child needs to be addressed */
margin-top: 0 !important;
}
Comment on lines 9 to 14
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@tavin, this is basically the fix. The rest is making sure that callouts/equations are balanced and have the same margins as paragraphs.

Copy link
Contributor

Choose a reason for hiding this comment

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

understood πŸ‘

.article-grid-gap {
@apply gap-1 md:gap-2 xl:gap-3 2xl:gap-4;
Expand Down
3 changes: 3 additions & 0 deletions styles/math.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.katex-display {
margin: 0 !important;
}
/* Hide katex generated equation numbers */
.katex .eqn-num {
opacity: 0;
Expand Down