Skip to content

docs(ObjectPage): add DomRefTable #6500

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

Merged
merged 1 commit into from
Oct 16, 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
8 changes: 4 additions & 4 deletions .storybook/components/DomRefTable.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { DocsContext, Heading } from '@storybook/blocks';
import { Tag, Link, MessageStrip, Popover } from '@ui5/webcomponents-react';
import TagDesign from '@ui5/webcomponents/dist/types/TagDesign.js';
import { Tag, Link, MessageStrip, Popover } from '@ui5/webcomponents-react';
import type * as CEM from '@ui5/webcomponents-tools/lib/cem/types';
import type { ReactNode } from 'react';
import { Fragment, useContext, useRef } from 'react';
import { createPortal } from 'react-dom';
import { useGetCem } from '../utils';
import classes from './DomRefTable.module.css';

function CodeBlock(props: { children: ReactNode }) {
export function CodeBlock(props: { children: ReactNode }) {
return (
<pre className={classes.domRefCodeBlock}>
<code className={classes.domRefCode}>{props.children}</code>
Expand Down Expand Up @@ -57,7 +57,7 @@ export function DomRefTable() {
const knownAttributes = new Set(Object.keys(docsContext.primaryStory?.argTypes ?? {}));
const cem = useGetCem();

let moduleName = cemModuleName ? cemModuleName.split(':')[1] : componentName;
const moduleName = cemModuleName ? cemModuleName.split(':')[1] : componentName;

const componentMembers =
cem?.modules
Expand Down Expand Up @@ -119,7 +119,7 @@ export function DomRefTable() {
)}
</td>
<td>
{!!row.parameters ? (
{row.parameters ? (
row.parameters.map((parameter) => {
return (
<div key={parameter.name} className={classes.parameters}>
Expand Down
42 changes: 42 additions & 0 deletions packages/main/src/components/ObjectPage/ObjectPage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ObjectPageTitle } from '../ObjectPageTitle';
import { ObjectPageHeader } from '../ObjectPageHeader';
import { ObjectPageSection } from '../ObjectPageSection';
import { ObjectPageSubSection } from '../ObjectPageSubSection';
import { CodeBlock } from '@sb/components/DomRefTable';

<Meta of={ComponentStories} />

Expand All @@ -19,6 +20,47 @@ import { ObjectPageSubSection } from '../ObjectPageSubSection';

<ControlsWithNote of={ComponentStories.Default} />

## Methods

This component exposes public methods. You can use them directly on the instance of the component, e.g. by using React Refs.

<table>
<thead>
<tr>
<th>Name</th>
<th>Parameters</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<CodeBlock>
<span style={{ color: 'rgb(64, 120, 242)' }}>toggleHeaderArea</span>
<span style={{ color: 'rgb(56, 58, 66)' }}>(</span>
<span style={{ color: 'rgb(56, 58, 66)' }}>snapped</span>
<span style={{ color: 'rgb(64, 120, 242)' }}>?</span>
<span style={{ color: 'rgb(64, 120, 242)' }}>: </span>
<span style={{ color: 'rgb(80, 161, 79)' }}>boolean</span>
<span style={{ color: 'rgb(56, 58, 66)' }}>)</span>
<span style={{ color: 'rgb(64, 120, 242)' }}>: </span>
<span style={{ color: 'rgb(80, 161, 79)' }}>void</span>
</CodeBlock>
</td>
<td>
<div>
<p style={{ fontWeight: 'bold' }}>snapped</p>
<p style={{ paddingInline: '1rem' }}>
Defines if the header should be snapped or expanded. <br /> If the argument is not provided, the header is
toggled.
</p>
</div>
</td>
<td>Toggles the `headerArea` of the `ObjectPage`.</td>
</tr>
</tbody>
</table>

# More Examples

## ObjectPage with IllustratedMessage (`UnableToLoad`) placeholder
Expand Down
Loading