export contentModal and make docsLinkTitle
Signed-off-by: Reyna Nikolayev <reyna.nikolayev@autodesk.com>
This commit is contained in:
@@ -5,9 +5,22 @@
|
||||
```ts
|
||||
import { Extension } from '@backstage/core-plugin-api';
|
||||
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
||||
import { JSX as JSX_3 } from 'react';
|
||||
import { Overrides } from '@material-ui/core/styles/overrides';
|
||||
import { RJSFSchema } from '@rjsf/utils';
|
||||
import { StyleRules } from '@material-ui/core/styles/withStyles';
|
||||
import { UiSchema } from '@rjsf/utils';
|
||||
|
||||
// @public (undocumented)
|
||||
export type BackstageContentModalClassKey = 'contentModal' | 'linkText';
|
||||
|
||||
// @public (undocumented)
|
||||
export type BackstageOverrides = Overrides & {
|
||||
[Name in keyof CatalogReactComponentsNameToClassKey]?: Partial<
|
||||
StyleRules<CatalogReactComponentsNameToClassKey[Name]>
|
||||
>;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export type CardConfig = {
|
||||
layout?: CardLayout;
|
||||
@@ -39,6 +52,11 @@ export type CardSettings = {
|
||||
uiSchema?: UiSchema;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export type CatalogReactComponentsNameToClassKey = {
|
||||
BackstageContentModal: BackstageContentModalClassKey;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export type ComponentParts = {
|
||||
Content: (props?: any) => JSX.Element;
|
||||
@@ -52,6 +70,15 @@ export type ComponentRenderer = {
|
||||
Renderer?: (props: RendererProps) => JSX.Element;
|
||||
};
|
||||
|
||||
// @public
|
||||
export const ContentModal: (props: ContentModalProps) => JSX_2.Element;
|
||||
|
||||
// @public
|
||||
export type ContentModalProps = {
|
||||
modalContent: JSX_3.Element;
|
||||
linkContent: string | JSX_3.Element;
|
||||
};
|
||||
|
||||
// @public
|
||||
export function createCardExtension<T>(options: {
|
||||
title?: string;
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2025 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { JSX, useState } from 'react';
|
||||
import { Link } from '@backstage/core-components';
|
||||
import Modal from '@material-ui/core/Modal';
|
||||
import Box from '@material-ui/core/Box';
|
||||
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||
|
||||
/** @public */
|
||||
export type BackstageContentModalClassKey = 'contentModal' | 'linkText';
|
||||
|
||||
export const useStyles = makeStyles(
|
||||
(theme: Theme) => ({
|
||||
contentModal: {
|
||||
position: 'absolute',
|
||||
top: '50%',
|
||||
left: '50%',
|
||||
transform: 'translate(-50%, -50%)',
|
||||
width: '80%',
|
||||
height: 'auto',
|
||||
},
|
||||
linkText: {
|
||||
marginBottom: theme.spacing(1.5),
|
||||
},
|
||||
}),
|
||||
{ name: 'BackstageContentModal' },
|
||||
);
|
||||
|
||||
/**
|
||||
* Props customizing the <ContentModal/> component.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type ContentModalProps = {
|
||||
modalContent: JSX.Element;
|
||||
linkContent: string | JSX.Element;
|
||||
};
|
||||
|
||||
/**
|
||||
* A component to expand given content into a full screen modal.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const ContentModal = (props: ContentModalProps) => {
|
||||
const { modalContent, linkContent } = props;
|
||||
const styles = useStyles();
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<div className={styles.linkText} data-testid="content-modal-container">
|
||||
<Link
|
||||
to="#"
|
||||
component="button"
|
||||
variant="h6"
|
||||
underline="none"
|
||||
onClick={() => setOpen(true)}
|
||||
>
|
||||
{linkContent}
|
||||
</Link>
|
||||
<Modal
|
||||
open={open}
|
||||
onClose={() => setOpen(false)}
|
||||
aria-labelledby="content-modal"
|
||||
data-testid="content-modal"
|
||||
>
|
||||
<Box className={styles.contentModal} data-testid="content-modal-open">
|
||||
{modalContent}
|
||||
</Box>
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -15,3 +15,7 @@
|
||||
*/
|
||||
|
||||
export { SettingsModal } from './SettingsModal';
|
||||
export { ContentModal } from './ContentModal';
|
||||
|
||||
export type { BackstageContentModalClassKey } from './ContentModal';
|
||||
export type { ContentModalProps } from './ContentModal';
|
||||
|
||||
@@ -30,3 +30,4 @@ export type {
|
||||
CardSettings,
|
||||
CardConfig,
|
||||
} from './extensions';
|
||||
export * from './overridableComponents';
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2025 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Overrides } from '@material-ui/core/styles/overrides';
|
||||
import { StyleRules } from '@material-ui/core/styles/withStyles';
|
||||
import { BackstageContentModalClassKey } from './';
|
||||
|
||||
/** @public */
|
||||
export type CatalogReactComponentsNameToClassKey = {
|
||||
BackstageContentModal: BackstageContentModalClassKey;
|
||||
};
|
||||
|
||||
/** @public */
|
||||
export type BackstageOverrides = Overrides & {
|
||||
[Name in keyof CatalogReactComponentsNameToClassKey]?: Partial<
|
||||
StyleRules<CatalogReactComponentsNameToClassKey[Name]>
|
||||
>;
|
||||
};
|
||||
|
||||
declare module '@backstage/theme' {
|
||||
interface OverrideComponentNameToClassKeys
|
||||
extends CatalogReactComponentsNameToClassKey {}
|
||||
}
|
||||
Reference in New Issue
Block a user