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

docs: Add AvailableFrom label #6523

Merged
merged 6 commits into from
Sep 19, 2024
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
43 changes: 43 additions & 0 deletions packages/docs-reanimated/src/components/AvailableFrom/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react';
import clsx from 'clsx';
import { useColorMode } from '@docusaurus/theme-common';

import styles from './styles.module.css';
import Danger from '/static/img/danger.svg';
import DangerDark from '/static/img/danger-dark.svg';

interface Props {
version?: string;
isFull?: boolean;
}

export default function AvailableFrom({ version, isFull }: Props) {
const { colorMode } = useColorMode();
const isLightMode = colorMode === 'light';
const badgeThemeStyles = isLightMode ? styles.light : styles.dark;

const getBadgeContent = () => {
if (isFull) {
return (
<>
<div className={styles.infoIcon}>
{isLightMode ? <Danger /> : <DangerDark />}
</div>
<span>Available from Reanimated {version}</span>
</>
);
}

return <>Available from {version}</>;
};

return (
<div
className={clsx(
isFull ? styles.fullBadge : styles.badge,
badgeThemeStyles
)}>
{getBadgeContent()}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.badge {
display: inline-block;
border-radius: 8px;
font-size: 12px;
font-weight: 500;
padding: 0.25rem 0.5rem;
white-space: nowrap;
margin: 0 0.25rem;
}

.fullBadge {
padding: 1rem;
width: '100%';
border-radius: 8px;
display: flex !important;
flex-direction: row;
margin-bottom: 1rem;
}

.light {
background-color: var(--swm-yellow-light-40);
color: var(--swm-navy-light-100);
}

.dark {
background-color: var(--swm-yellow-dark-120);
color: var(--swm-off-white);
}

.infoIcon {
margin-right: 1rem;
}

.infoIcon > svg {
width: 14px;
height: 14px;
}

.version {
font-weight: 500;
}
2 changes: 2 additions & 0 deletions packages/docs-reanimated/src/theme/MDXComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import PlatformCompatibility from '@site/src/components/PlatformCompatibility';
import ExampleVideo from '@site/src/components/ExampleVideo';
import { Yes, No, Version, Spacer } from '@site/src/components/Compatibility';
import Optional from '@site/src/components/Optional';
import AvailableFrom from '@site/src/components/AvailableFrom';
import Indent from '@site/src/components/Indent';
import Row from '@site/src/components/Row';
import Grid from '@site/src/components/Grid';
Expand All @@ -27,6 +28,7 @@ export default {
Version,
Spacer,
Optional,
AvailableFrom,
Indent,
Row,
Grid,
Expand Down