Skip to content

Commit 33ab8ea

Browse files
authored
Add styling to the alert component (#15470)
* Add styling to the alert component * Render URLs in markdown to open in a new window
1 parent 5d8c93d commit 33ab8ea

File tree

6 files changed

+78
-9
lines changed

6 files changed

+78
-9
lines changed

packages/connect-react/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<!-- markdownlint-disable MD024 -->
22
# Changelog
33

4+
# [1.0.0-preview.27] - 2025-01-30
5+
6+
- Add styling to alerts
7+
8+
# [1.0.0-preview.26] - 2025-01-29
9+
10+
- No change
11+
412
# [1.0.0-preview.25] - 2025-01-28
513

614
- Show prop labels instead of values after selecting dynamic props

packages/connect-react/examples/nextjs/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/connect-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/connect-react",
3-
"version": "1.0.0-preview.26",
3+
"version": "1.0.0-preview.27",
44
"description": "Pipedream Connect library for React",
55
"files": [
66
"dist"
Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,65 @@
11
import type { ConfigurablePropAlert } from "@pipedream/sdk";
2+
import Markdown from "react-markdown";
23

34
type AlertProps = {
45
prop: ConfigurablePropAlert;
56
};
67

78
export function Alert({ prop }: AlertProps) {
8-
// XXX useCustomize, getClassNames
9-
return <p className={`pd-alert-${prop.alertType}`}>{prop.content}</p>;
9+
const baseStyles = {
10+
background: "#e2e3e5",
11+
borderRadius: "10px",
12+
paddingTop: "2px",
13+
paddingLeft: "10px",
14+
paddingRight: "10px",
15+
paddingBottom: "2px",
16+
}
17+
18+
const warningStyles = {
19+
...baseStyles,
20+
background: "#fff3cd",
21+
};
22+
23+
const infoStyles = {
24+
...baseStyles,
25+
background: "#d1ecf1",
26+
}
27+
28+
const errorStyles = {
29+
...baseStyles,
30+
background: "#f8d7da",
31+
}
32+
33+
const neutralStyles = {
34+
...baseStyles,
35+
background: "#fffff2",
36+
}
37+
38+
let alertStyles = {}
39+
switch (prop.alertType) {
40+
case "info":
41+
alertStyles = infoStyles
42+
break
43+
case "neutral":
44+
alertStyles = neutralStyles
45+
break
46+
case "warning":
47+
alertStyles = warningStyles
48+
break
49+
case "error":
50+
alertStyles = errorStyles
51+
break
52+
default:
53+
alertStyles = baseStyles
54+
}
55+
56+
return (<div className={`pd-alert-${prop.alertType}`} style={alertStyles}>
57+
<Markdown components={{
58+
a: ({ ...props }) => {
59+
return <a {...props} target="_blank" rel="noopener noreferrer" />;
60+
},
61+
}}>
62+
{prop.content}
63+
</Markdown>
64+
</div>)
1065
}

packages/connect-react/src/components/Description.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,11 @@ export function Description<T extends ConfigurableProps, U extends ConfigurableP
4141
if (!prop.description) {
4242
return null;
4343
}
44-
return <div className={getClassNames("description", props)} style={getStyles("description", baseStyles, props)}><Markdown>{markdown}</Markdown></div>;
44+
return <div className={getClassNames("description", props)} style={getStyles("description", baseStyles, props)}> <Markdown components={{
45+
a: ({ ...props }) => {
46+
return <a {...props} target="_blank" rel="noopener noreferrer" />;
47+
},
48+
}}>
49+
{markdown}
50+
</Markdown></div>;
4551
}

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)