Skip to content

Commit 8fa84af

Browse files
authored
docs(Toolbar): outline part attributes (#6816)
Closes #6808
1 parent 8a39f27 commit 8fa84af

File tree

2 files changed

+55
-32
lines changed

2 files changed

+55
-32
lines changed

.storybook/components/DomRefTable.tsx

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,43 @@ function Name(props: CEM.ClassMember) {
4646
);
4747
}
4848

49+
export function ShadowPartsTable({ componentName, cssParts }: { componentName: string; cssParts: CEM.CssPart[] }) {
50+
return (
51+
<>
52+
<Heading>CSS Shadow Parts</Heading>
53+
<p>
54+
<Link target={'_blank'} href={'https://developer.mozilla.org/en-US/docs/Web/CSS/::part'}>
55+
CSS Shadow Parts
56+
</Link>{' '}
57+
allow developers to style elements inside the Shadow DOM.
58+
</p>
59+
<p>
60+
The <code>{componentName}</code> exposes the following CSS Shadow Parts:
61+
</p>
62+
<table>
63+
<thead>
64+
<tr>
65+
<th>Name</th>
66+
<th>Description</th>
67+
</tr>
68+
</thead>
69+
<tbody>
70+
{cssParts.map((part) => (
71+
<tr key={part.name}>
72+
<td>
73+
<b>{part.name}</b>
74+
</td>
75+
<td>{part.description}</td>
76+
</tr>
77+
))}
78+
</tbody>
79+
</table>
80+
</>
81+
);
82+
}
83+
84+
ShadowPartsTable.displayName = 'ShadowPartsTable';
85+
4986
export function DomRefTable() {
5087
const docsContext = useContext(DocsContext);
5188
const storyTags: string[] = docsContext.attachedCSFFile?.meta?.tags;
@@ -146,38 +183,7 @@ export function DomRefTable() {
146183
</>
147184
) : null}
148185

149-
{cssParts.length > 0 ? (
150-
<>
151-
<Heading>CSS Shadow Parts</Heading>
152-
<p>
153-
<Link target={'_blank'} href={'https://developer.mozilla.org/en-US/docs/Web/CSS/::part'}>
154-
CSS Shadow Parts
155-
</Link>{' '}
156-
allow developers to style elements inside the Shadow DOM.
157-
</p>
158-
<p>
159-
The <code>{componentName}</code> exposes the following CSS Shadow Parts:
160-
</p>
161-
<table>
162-
<thead>
163-
<tr>
164-
<th>Name</th>
165-
<th>Description</th>
166-
</tr>
167-
</thead>
168-
<tbody>
169-
{cssParts.map((part) => (
170-
<tr key={part.name}>
171-
<td>
172-
<b>{part.name}</b>
173-
</td>
174-
<td>{part.description}</td>
175-
</tr>
176-
))}
177-
</tbody>
178-
</table>
179-
</>
180-
) : null}
186+
{cssParts.length > 0 ? <ShadowPartsTable cssParts={cssParts} /> : null}
181187
</>
182188
);
183189
}

packages/main/src/components/Toolbar/Toolbar.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
ToolbarSpacer,
1111
ToolbarSeparator
1212
} from '../..';
13+
import { ShadowPartsTable } from '@sb/components/DomRefTable';
1314

1415
<Meta of={ComponentStories} />
1516

@@ -254,12 +255,28 @@ const ToolbarComponent = () => {
254255
255256
<ArgTypesWithNote of={OverflowToolbarButton} />
256257
258+
<ShadowPartsTable
259+
componentName="OverflowToolbarButton"
260+
cssParts={[
261+
{ name: 'button', description: 'Used to style the native button element' },
262+
{ name: 'icon', description: 'Used to style the ui5-icon element' }
263+
]}
264+
/>
265+
257266
## OverflowToolbarToggleButton
258267
259268
<Description of={OverflowToolbarToggleButton} />
260269
261270
<ArgTypesWithNote of={OverflowToolbarToggleButton} />
262271
272+
<ShadowPartsTable
273+
componentName="OverflowToolbarToggleButton"
274+
cssParts={[
275+
{ name: 'button', description: 'Used to style the native button element' },
276+
{ name: 'icon', description: 'Used to style the ui5-icon element' }
277+
]}
278+
/>
279+
263280
## ToolbarSpacer
264281
265282
<Description of={ToolbarSpacer} />

0 commit comments

Comments
 (0)