Commit 506120bb by Alex Khomenko Committed by GitHub

Grafana-UI: Make Card story public (#30388)

* Grafana-ui: Enable customisable separator for metadata

* Grafana-ui: Make Card story public
parent c0dd1b6d
......@@ -67,6 +67,25 @@ Metadata also accepts HTML elements, which could be links, for example. For elem
</Card>
</Preview>
The separator for multiple metadata elements defaults to a vertical line `|`, but can be customised.
```jsx
<Card heading="Test dashboard">
<Card.Meta separator={'-'}>
Grafana
<a key='prom-link' href="https://ops-us-east4.grafana.net/api/prom">https://ops-us-east4.grafana.net/api/prom</a>
</Card.Meta>
</Card>
```
<Preview>
<Card heading="Test dashboard">
<Card.Meta separator={'-'}>
Grafana
<a key='prom-link' href="https://ops-us-east4.grafana.net/api/prom">https://ops-us-east4.grafana.net/api/prom</a>
</Card.Meta>
</Card>
</Preview>
### Tags
Tags can be rendered inside the Card, by being wrapped in `Card.Tags` component. Note that this component does not provide any tag styling and that should be handled by the children. It is recommended to use it with Grafana-UI's `TagList` component.
......
......@@ -290,15 +290,15 @@ const Figure: FC<ChildProps & { align?: 'top' | 'center' }> = ({ children, style
Figure.displayName = 'Figure';
const Meta: FC<ChildProps> = memo(({ children, styles }) => {
const Meta: FC<ChildProps & { separator?: string }> = memo(({ children, styles, separator = '|' }) => {
let meta = children;
// Join meta data elements by '|'
// Join meta data elements by separator
if (Array.isArray(children)) {
meta = React.Children.toArray(children).reduce((prev, curr, i) => [
prev,
<span key={`separator_${i}`} className={styles?.separator}>
|
{separator}
</span>,
curr,
]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment