Skip to content

Commit

Permalink
docs: Add AvailableFrom label (#6523)
Browse files Browse the repository at this point in the history
This PR introduces the `AvailableFrom` label (a standard version and a
full-sized version). The purpose of this label is to inform users that
feature is available starting from a specified version and in all
subsequent versions.



https://github.com/user-attachments/assets/172c4930-75fd-41f1-8616-845e0832cdd1
  • Loading branch information
patrycjakalinska authored Sep 19, 2024
1 parent e51bc9c commit ec712d6
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
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

0 comments on commit ec712d6

Please sign in to comment.