Skip to content

Commit

Permalink
Update the TechPreview component to also accept custom text (#2377)
Browse files Browse the repository at this point in the history
* chore: Update the TechPreview component to also accept custom text

* chore: Fix the linter warning and clean up CSS a bit
  • Loading branch information
yuliiiah authored Mar 7, 2024
1 parent eb717d1 commit 10d31dc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/css/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ p img.markdown-image {
border-radius: 1vw;
}

.custom-admonition {
border: 1px solid var(--custom-important-color);
background-color: var(--custom-alert-bg-color);
.admonition-tech-preview {
border: 1px solid var(--custom-purple-important-color);
background-color: var(--custom-purple-alert-bg-color);
}
4 changes: 2 additions & 2 deletions src/css/dark-mode.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ html[data-theme="dark"] {
--ifm-color-warning-dark: #ffc832;
--ifm-alert-padding-horizontal: 1.5rem;
--custom-table-header-color: #1c202b;
--custom-important-color: #7d77ca;
--custom-alert-bg-color: #1a173b;
--custom-purple-important-color: #7d77ca;
--custom-purple-alert-bg-color: #1a173b;

.theme-last-updated {
color: var(--ifm-font-color-base);
Expand Down
4 changes: 2 additions & 2 deletions src/css/light-mode.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ html[data-theme="light"] {
--ifm-color-warning-dark: #a8882f;
--ifm-alert-padding-horizontal: 1.5rem;
--custom-table-header-color: #f7f7f7;
--custom-important-color: #7d77ca;
--custom-alert-bg-color: #dcdaf9;
--custom-purple-important-color: #7d77ca;
--custom-purple-alert-bg-color: #dcdaf9;

.theme-doc-sidebar-item-category-level-1 .menu__list-item {
.menu__link:hover {
Expand Down
2 changes: 1 addition & 1 deletion src/theme/Admonition/Icon/TechPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import React from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faFlag } from "@fortawesome/free-solid-svg-icons";

export default function IconTechPreview(props) {
export default function IconTechPreview() {
return <FontAwesomeIcon icon={faFlag} />;
}
9 changes: 6 additions & 3 deletions src/theme/Admonition/Type/TechPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Translate from "@docusaurus/Translate";
import AdmonitionLayout from "@theme/Admonition/Layout";
import IconTechPreview from "../Icon/TechPreview";

const infimaClassName = "alert custom-admonition";
const infimaClassName = "alert admonition-tech-preview";

const defaultProps = {
icon: <IconTechPreview />,
Expand All @@ -16,12 +16,15 @@ const defaultProps = {
tech preview
</Translate>
),
defaultText:
"This is a Tech Preview feature and is subject to change. Do not use this feature in production workloads.",
};

export default function AdmonitionTypeTechPreview(props) {
const text = props.children || defaultProps.defaultText;
return (
<AdmonitionLayout {...defaultProps} {...props} className={clsx(infimaClassName, props.className)}>
{"This is a Tech Preview feature and is subject to change. Do not use this feature in production workloads."}
<AdmonitionLayout {...defaultProps} className={clsx(infimaClassName, props.className)}>
{text}
</AdmonitionLayout>
);
}

0 comments on commit 10d31dc

Please sign in to comment.