Skip to content

Commit

Permalink
docs: add image float css idea
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasheartman committed Oct 19, 2022
1 parent 4f99823 commit 69f27d3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 5 additions & 2 deletions website/src/components/Figure/Figure.tsx
Expand Up @@ -67,6 +67,7 @@ import React from 'react';
import useBaseUrl from '@docusaurus/useBaseUrl';

import './styles.module.css';
import styles from './styles.module.css';

type Props = {
// An optional alt text, if the caption does not already convey all relevant
Expand All @@ -76,11 +77,13 @@ type Props = {
caption: string;
// the path to the image, starting with `/img/`. Example: /img/image.png
img: string;
// whether the image should be floated to one side on larger setups
float?: boolean;
};

const Component: React.FC<Props> = ({ img, alt, caption }) => {
const Component: React.FC<Props> = ({ img, alt, caption, float }) => {
return (
<figure>
<figure className={float ? styles.float : ''}>
<img alt={alt} src={useBaseUrl(img)} />
<figcaption>{caption}</figcaption>
</figure>
Expand Down
12 changes: 12 additions & 0 deletions website/src/components/Figure/styles.module.css
Expand Up @@ -7,6 +7,12 @@ figure {
margin-inline: 0;
}

.float {
float: right;
max-width: 50%;
margin-left: var(--ifm-pre-padding);
}

figure img {
box-shadow: none;
border: none;
Expand All @@ -21,3 +27,9 @@ figcaption {
padding-inline: var(--ifm-pre-padding);
border-inline-start: 5px solid var(--ifm-color-primary);
}


/* clear floating figures for everything but paragraphs and lists */
:global(.markdown) :is(:not(p):not(ol):not(ul):not(li)) {
clear: both;
}

0 comments on commit 69f27d3

Please sign in to comment.