Skip to content

Commit eff0bc5

Browse files
authored
Merge pull request #260 from easyops-cn/steve/ai-portal-730
Steve/ai-portal-730
2 parents 008cf9c + 7c6c275 commit eff0bc5

File tree

4 files changed

+107
-33
lines changed

4 files changed

+107
-33
lines changed
12.5 KB
Loading

bricks/ai-portal/src/show-cases/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import "@next-core/theme";
55
import { initializeI18n } from "@next-core/i18n";
66
import type { Link, LinkProps } from "@next-bricks/basic/link";
77
import { get } from "lodash";
8-
import { K, NS, locales, t } from "./i18n.js";
9-
import styleText from "./styles.shadow.css";
108
import classNames from "classnames";
119
import { getBasePath } from "@next-core/runtime";
10+
import { K, NS, locales, t } from "./i18n.js";
11+
import styleText from "./styles.shadow.css";
1212

1313
initializeI18n(NS, locales);
1414

@@ -109,7 +109,11 @@ function ShowCasesComponent({ list, taskUrlTemplate }: ShowCasesProps) {
109109
}}
110110
/>
111111
) : (
112-
<span>{item.summary}</span>
112+
<span className="summary-1">
113+
<span className="summary-2">
114+
<span>{item.summary}</span>
115+
</span>
116+
</span>
113117
)}
114118
</span>
115119
<span className="title">

bricks/ai-portal/src/show-cases/styles.shadow.css

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,14 @@
5252
.cases {
5353
display: grid;
5454
width: 100%;
55-
grid-template-columns: repeat(auto-fill, minmax(284px, 1fr));
56-
gap: 20px;
55+
grid-template-columns: repeat(auto-fill, minmax(276px, 1fr));
56+
gap: 24px;
5757
margin-top: 2em;
5858
}
5959

6060
.link {
61-
background: rgba(255, 255, 255, 0.9);
62-
box-shadow:
63-
0px 1px 2px rgba(46, 41, 51, 0.08),
64-
0px 2px 4px rgba(71, 63, 79, 0.08);
61+
background: #fefefe;
62+
border: 1px solid #e8e9ec;
6563
border-radius: 12px;
6664
overflow: hidden;
6765
display: block;
@@ -71,19 +69,18 @@
7169
display: flex;
7270
gap: 0;
7371
flex-direction: column;
74-
height: 200px;
72+
height: 218px;
7573
}
7674

7775
.title {
78-
font-size: 16px;
79-
line-height: 24px;
8076
width: 100%;
81-
height: 80px;
82-
padding: 16px 15px 15px;
77+
height: 76px;
78+
padding: 16px 16px 15px;
8379
color: #262626;
84-
border: 1px solid rgba(35, 33, 41, 0.05);
85-
border-top: 0;
86-
border-radius: 0 0 12px 12px;
80+
border-top: 1px solid #e8e9ec;
81+
font-weight: 500;
82+
font-size: 15px;
83+
line-height: 22px;
8784

8885
span {
8986
display: -webkit-box;
@@ -96,23 +93,14 @@
9693

9794
.placeholder {
9895
width: 100%;
99-
background: #f8f8f8;
100-
border: 1px solid rgba(35, 33, 41, 0.05);
101-
border-radius: 12px 12px 0 0;
102-
height: 120px;
96+
height: 142px;
97+
background: linear-gradient(308deg, #dee9fc 0%, #fcfbfd 100%, #fbf9fe 100%);
98+
overflow: hidden;
10399
}
104100

105101
.summary {
106102
color: rgba(0, 0, 0, 0.65);
107-
padding: 15px;
108-
109-
span {
110-
display: -webkit-box;
111-
-webkit-line-clamp: 4;
112-
line-clamp: 4;
113-
-webkit-box-orient: vertical;
114-
overflow: hidden;
115-
}
103+
padding: 27px 0 0 24px;
116104
}
117105

118106
.thumbnail span {
@@ -125,9 +113,37 @@
125113
}
126114

127115
.link:hover {
128-
box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.1);
116+
box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.06);
129117

130118
.title {
131119
color: var(--elevo-color-brand);
132120
}
133121
}
122+
123+
.summary-1 {
124+
display: block;
125+
background-image: url("./images/[email protected]");
126+
background-size: 237px 115px;
127+
background-repeat: no-repeat;
128+
background-position: 0 0;
129+
padding: 10px 0 0 10px;
130+
}
131+
132+
.summary-2 {
133+
display: block;
134+
background: linear-gradient(90deg, #ffffff 0%, #e4ecfc 100%);
135+
padding: 12px 15px 5px 15px;
136+
border-top-left-radius: 12px;
137+
138+
span {
139+
display: -webkit-box;
140+
-webkit-line-clamp: 4;
141+
line-clamp: 4;
142+
-webkit-box-orient: vertical;
143+
overflow: hidden;
144+
font-size: 15px;
145+
color: #525971;
146+
line-height: 22px;
147+
height: 88px;
148+
}
149+
}

shared/markdown/src/rehypeMermaid.ts

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@ let count = 0;
99

1010
mermaid.initialize({
1111
startOnLoad: false,
12+
theme: "base",
1213
themeVariables: {
1314
fontSize: "14px",
15+
lineColor: "#979797",
16+
primaryColor: "#DCD2F3",
17+
primaryBorderColor: "#0000001A",
1418
},
1519
});
1620

21+
const parser = new DOMParser();
22+
const serializer = new XMLSerializer();
23+
1724
// Reference https://github.com/remcohaszing/rehype-mermaid
1825
export function rehypeMermaid() {
1926
return async (tree: RefractorElement) => {
@@ -39,8 +46,55 @@ export function rehypeMermaid() {
3946
const id = `mermaid-${count++}`;
4047

4148
const { svg } = await mermaid.render(id, toString(node));
42-
const replacements = fromHtmlIsomorphic(svg, { fragment: true })
43-
.children as RefractorElement[];
49+
const root = parser.parseFromString(svg, "text/html");
50+
const svgElement = root.querySelector("svg") as SVGSVGElement;
51+
52+
const defs = root.createElementNS(
53+
"http://www.w3.org/2000/svg",
54+
"defs"
55+
);
56+
defs.innerHTML = `<linearGradient id="linear-gradient-${id}" x1="0%" y1="0%" x2="0%" y2="100%">
57+
<stop offset="0%" stop-color="#F0EBFA" />
58+
<stop offset="75%" stop-color="#DED4F4" />
59+
<stop offset="100%" stop-color="#C5C7FA" />
60+
</linearGradient>`;
61+
svgElement.prepend(defs);
62+
63+
const style = root.createElementNS(
64+
"http://www.w3.org/2000/svg",
65+
"style"
66+
);
67+
style.textContent = `
68+
#${id} .node rect,
69+
#${id} .node circle,
70+
#${id} .node ellipse,
71+
#${id} .node polygon,
72+
#${id} .node path {
73+
fill: url(#linear-gradient-${id});
74+
}
75+
#${id} .node rect {
76+
rx: 4;
77+
ry: 4;
78+
}
79+
#${id} .labelBkg {
80+
background-color: #f5f8ff;
81+
}
82+
#${id} .edgeLabel,
83+
#${id} .edgeLabel p {
84+
background-color: transparent;
85+
}
86+
#${id} .edgeLabel {
87+
color: #8c8c8c;
88+
font-size: 12px;
89+
}
90+
`;
91+
svgElement.appendChild(style);
92+
93+
const modifiedSvg = serializer.serializeToString(svgElement);
94+
95+
const replacements = fromHtmlIsomorphic(modifiedSvg, {
96+
fragment: true,
97+
}).children as RefractorElement[];
4498
parent.children.splice(index!, 1, ...replacements);
4599
parent.properties.className = (
46100
(parent.properties.className as string[]) || []

0 commit comments

Comments
 (0)