Skip to content

Commit b641af7

Browse files
Revert "ref(core): convert AlertLink to mdx (#95194)"
This reverts commit d440e79. Co-authored-by: JonasBa <9317857+JonasBa@users.noreply.github.com>
1 parent 96a57bc commit b641af7

File tree

2 files changed

+122
-182
lines changed

2 files changed

+122
-182
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import {Fragment} from 'react';
2+
3+
import {AlertLink, type AlertLinkProps} from 'sentry/components/core/alert/alertLink';
4+
import {IconMail} from 'sentry/icons';
5+
import * as Storybook from 'sentry/stories';
6+
7+
import types from '!!type-loader!sentry/components/core/alert/alertLink';
8+
9+
const DUMMY_LINK = '/stories';
10+
11+
const ALERT_LINK_VARIANTS: Array<AlertLinkProps['type']> = [
12+
'info',
13+
'warning',
14+
'success',
15+
'error',
16+
'muted',
17+
];
18+
19+
export default Storybook.story('AlertLink', (story, APIReference) => {
20+
APIReference(types.AlertLink);
21+
story('Default', () => {
22+
return (
23+
<Fragment>
24+
<p>
25+
The <Storybook.JSXNode name="AlertLink" /> component is a type of{' '}
26+
<Storybook.JSXNode name="Alert" />. The primary use case is when you want the
27+
entire alert to be a link.
28+
</p>
29+
<p>
30+
The default <Storybook.JSXNode name="AlertLink" /> looks like this:
31+
</p>
32+
<AlertLink.Container>
33+
{ALERT_LINK_VARIANTS.map(variant => (
34+
<AlertLink key={variant} type={variant} to={DUMMY_LINK}>
35+
Clicking this link will not open in a new tab!
36+
</AlertLink>
37+
))}
38+
</AlertLink.Container>
39+
</Fragment>
40+
);
41+
});
42+
43+
story('Internal, External, and Manual Links', () => {
44+
return (
45+
<Fragment>
46+
<p>
47+
The <Storybook.JSXNode name="AlertLink" /> component can be used as an external
48+
link, an internal link, or a manual link (by specifying a{' '}
49+
<Storybook.JSXProperty name="onClick" value /> prop). Currently, only the{' '}
50+
<Storybook.JSXNode name="ExternalLink" /> component supports the{' '}
51+
<Storybook.JSXProperty name="openInNewTab" value /> prop - this prop is not
52+
supported for internal or manual links.{' '}
53+
</p>
54+
<p>
55+
AlertLink as an external link using{' '}
56+
<Storybook.JSXProperty name="href" value={`https://santry.io${DUMMY_LINK}`} />
57+
and <Storybook.JSXProperty name="openInNewTab" value />:
58+
</p>
59+
<AlertLink type="info" href={`https://santry.io/${DUMMY_LINK}`} openInNewTab>
60+
Info Link
61+
</AlertLink>
62+
<p>
63+
AlertLink as an internal link using{' '}
64+
<Storybook.JSXProperty name="to" value={DUMMY_LINK} />:
65+
</p>
66+
<AlertLink type="info" to={DUMMY_LINK}>
67+
Info Link
68+
</AlertLink>
69+
<p>
70+
AlertLink as a manual link using{' '}
71+
<Storybook.JSXProperty
72+
name="onClick"
73+
value={`() => window.alert('Clicked!')`}
74+
/>
75+
:
76+
</p>
77+
{/* eslint-disable-next-line no-alert */}
78+
<AlertLink type="info" onClick={() => window.alert('Clicked!')}>
79+
Info Link
80+
</AlertLink>
81+
</Fragment>
82+
);
83+
});
84+
story('With Custom Icon', () => {
85+
return (
86+
<Fragment>
87+
<p>
88+
The <Storybook.JSXNode name="AlertLink" /> component can also be used with a
89+
custom icon. The icon can be overriden by passing a{' '}
90+
<Storybook.JSXProperty name="trailingItems" value={'<IconMail />'} /> prop.
91+
</p>
92+
<AlertLink type="info" to={DUMMY_LINK} trailingItems={<IconMail />}>
93+
Clicking this link will not open in a new tab!
94+
</AlertLink>
95+
</Fragment>
96+
);
97+
});
98+
99+
story('AlertLink.Container', () => {
100+
return (
101+
<Fragment>
102+
<p>
103+
The <Storybook.JSXNode name="AlertLink.Container" /> component is a container
104+
for one or multiple <Storybook.JSXNode name="AlertLink" /> components. It
105+
manages margins between the links.
106+
</p>
107+
<AlertLink.Container>
108+
<AlertLink type="info" to={DUMMY_LINK}>
109+
Multiple AlertLinks
110+
</AlertLink>
111+
<AlertLink type="info" href={DUMMY_LINK} openInNewTab={false}>
112+
Are nicely spaced out
113+
</AlertLink>
114+
{/* eslint-disable-next-line no-alert */}
115+
<AlertLink type="info" onClick={() => window.alert('Clicked!')}>
116+
... all of them
117+
</AlertLink>
118+
</AlertLink.Container>
119+
</Fragment>
120+
);
121+
});
122+
});

static/app/components/core/alert/alertlink.mdx

Lines changed: 0 additions & 182 deletions
This file was deleted.

0 commit comments

Comments
 (0)