Skip to content

Commit 732d2ac

Browse files
authored
add Readme blockquote icons, few MD content render tweaks (#2282)
1 parent ea7efb1 commit 732d2ac

File tree

5 files changed

+179
-11
lines changed

5 files changed

+179
-11
lines changed

components/Icons/index.tsx

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,3 +1010,142 @@ export function Module({ width = 24, height = 24, style }: IconProps) {
10101010
</Svg>
10111011
);
10121012
}
1013+
1014+
export function NoteBlockquote({ width = 24, height = 24, style }: IconProps) {
1015+
return (
1016+
<Svg width={width} height={height} viewBox="0 0 256 256" style={style}>
1017+
<Circle
1018+
cx="128"
1019+
cy="128"
1020+
r="96"
1021+
fill="none"
1022+
stroke="currentColor"
1023+
strokeLinecap="round"
1024+
strokeLinejoin="round"
1025+
strokeWidth="24"
1026+
/>
1027+
<Path
1028+
d="M120,120a8,8,0,0,1,8,8v40a8,8,0,0,0,8,8"
1029+
fill="none"
1030+
stroke="currentColor"
1031+
strokeLinecap="round"
1032+
strokeLinejoin="round"
1033+
strokeWidth="24"
1034+
/>
1035+
<Circle cx="124" cy="84" r="12" fill="currentColor" />
1036+
</Svg>
1037+
);
1038+
}
1039+
1040+
export function TipBlockquote({ width = 24, height = 24, style }: IconProps) {
1041+
return (
1042+
<Svg width={width} height={height} viewBox="0 0 256 256" style={style}>
1043+
<Line
1044+
x1="88"
1045+
y1="232"
1046+
x2="168"
1047+
y2="232"
1048+
fill="none"
1049+
stroke="currentColor"
1050+
strokeLinecap="round"
1051+
strokeLinejoin="round"
1052+
strokeWidth="24"
1053+
/>
1054+
<Path
1055+
d="M78.7,167A79.87,79.87,0,0,1,48,104.45C47.76,61.09,82.72,25,126.07,24a80,80,0,0,1,51.34,142.9A24.3,24.3,0,0,0,168,186v6a8,8,0,0,1-8,8H96a8,8,0,0,1-8-8v-6A24.11,24.11,0,0,0,78.7,167Z"
1056+
fill="none"
1057+
stroke="currentColor"
1058+
strokeLinecap="round"
1059+
strokeLinejoin="round"
1060+
strokeWidth="24"
1061+
/>
1062+
<Path
1063+
d="M136,56c20,3.37,36.61,20,40,40"
1064+
fill="none"
1065+
stroke="currentColor"
1066+
strokeLinecap="round"
1067+
strokeLinejoin="round"
1068+
strokeWidth="24"
1069+
/>
1070+
</Svg>
1071+
);
1072+
}
1073+
1074+
export function WarningBlockquote({ width = 24, height = 24, style }: IconProps) {
1075+
return (
1076+
<Svg width={width} height={height} viewBox="0 0 256 256" style={style}>
1077+
<Path
1078+
d="M142.41,40.22l87.46,151.87C236,202.79,228.08,216,215.46,216H40.54C27.92,216,20,202.79,26.13,192.09L113.59,40.22C119.89,29.26,136.11,29.26,142.41,40.22Z"
1079+
fill="none"
1080+
stroke="currentColor"
1081+
strokeLinecap="round"
1082+
strokeLinejoin="round"
1083+
strokeWidth="24"
1084+
/>
1085+
<Line
1086+
x1="128"
1087+
y1="144"
1088+
x2="128"
1089+
y2="104"
1090+
fill="none"
1091+
stroke="currentColor"
1092+
strokeLinecap="round"
1093+
strokeLinejoin="round"
1094+
strokeWidth="24"
1095+
/>
1096+
<Circle cx="128" cy="180" r="12" fill="currentColor" />
1097+
</Svg>
1098+
);
1099+
}
1100+
1101+
export function CautionBlockquote({ width = 24, height = 24, style }: IconProps) {
1102+
return (
1103+
<Svg width={width} height={height} viewBox="0 0 256 256" style={style}>
1104+
<Line
1105+
x1="128"
1106+
y1="136"
1107+
x2="128"
1108+
y2="80"
1109+
fill="none"
1110+
strokeLinecap="round"
1111+
strokeLinejoin="round"
1112+
strokeWidth="24"
1113+
/>
1114+
<Path
1115+
d="M164.45,32H91.55a8,8,0,0,0-5.66,2.34L34.34,85.89A8,8,0,0,0,32,91.55v72.9a8,8,0,0,0,2.34,5.66l51.55,51.55A8,8,0,0,0,91.55,224h72.9a8,8,0,0,0,5.66-2.34l51.55-51.55a8,8,0,0,0,2.34-5.66V91.55a8,8,0,0,0-2.34-5.66L170.11,34.34A8,8,0,0,0,164.45,32Z"
1116+
fill="none"
1117+
stroke="currentColor"
1118+
strokeMiterlimit="10"
1119+
strokeWidth="24"
1120+
/>
1121+
<Circle cx="128" cy="172" r="24" fill="currentColor" />
1122+
</Svg>
1123+
);
1124+
}
1125+
1126+
export function ImportantBlockquote({ width = 24, height = 24, style }: IconProps) {
1127+
return (
1128+
<Svg width={width} height={height} viewBox="0 0 256 256" style={style}>
1129+
<path
1130+
d="M54.46,201.54c-9.2-9.2-3.1-28.53-7.78-39.85C41.82,150,24,140.5,24,128s17.82-22,22.68-33.69C51.36,83,45.26,63.66,54.46,54.46S83,51.36,94.31,46.68C106.05,41.82,115.5,24,128,24S150,41.82,161.69,46.68c11.32,4.68,30.65-1.42,39.85,7.78s3.1,28.53,7.78,39.85C214.18,106.05,232,115.5,232,128S214.18,150,209.32,161.69c-4.68,11.32,1.42,30.65-7.78,39.85s-28.53,3.1-39.85,7.78C150,214.18,140.5,232,128,232s-22-17.82-33.69-22.68C83,204.64,63.66,210.74,54.46,201.54Z"
1131+
fill="none"
1132+
stroke="currentColor"
1133+
strokeLinecap="round"
1134+
strokeLinejoin="round"
1135+
strokeWidth="24"
1136+
/>
1137+
<line
1138+
x1="128"
1139+
y1="80"
1140+
x2="128"
1141+
y2="136"
1142+
fill="none"
1143+
stroke="currentColor"
1144+
strokeLinecap="round"
1145+
strokeLinejoin="round"
1146+
strokeWidth="24"
1147+
/>
1148+
<circle cx="128" cy="172" r="12" fill="currentColor" />
1149+
</Svg>
1150+
);
1151+
}

components/Package/MarkdownContentBox/index.tsx

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,18 @@ import remarkGfm from 'remark-gfm';
1111
import useSWR from 'swr';
1212

1313
import { A, P } from '~/common/styleguide';
14-
import { CCFile, ChangelogFile, Check, ContributingFile, ReadmeFile } from '~/components/Icons';
14+
import {
15+
CautionBlockquote,
16+
CCFile,
17+
ChangelogFile,
18+
Check,
19+
ContributingFile,
20+
ImportantBlockquote,
21+
NoteBlockquote,
22+
ReadmeFile,
23+
TipBlockquote,
24+
WarningBlockquote,
25+
} from '~/components/Icons';
1526
import CopyButton from '~/components/Package/CopyButton';
1627
import ThreeDotsLoader from '~/components/Package/ThreeDotsLoader';
1728
import rndDark from '~/styles/shiki/rnd-dark.json';
@@ -285,7 +296,8 @@ export default function MarkdownContentBox({ packageName, library, loader = fals
285296
: tw`border-palette-gray4 dark:border-secondary`),
286297
}}>
287298
{blockquoteType.type && (
288-
<strong className="blockquote-title">
299+
<strong className="blockquote-title" style={tw`flex items-center gap-1.5`}>
300+
{getBlockquoteIcon(blockquoteType.type)}
289301
{capitalize(blockquoteType.type)}
290302
</strong>
291303
)}
@@ -345,3 +357,20 @@ function getTabContentUrl(library: LibraryType, fileName: string) {
345357
const { packagePath, branchName } = parseGitHubUrl(library.githubUrl);
346358
return `${library.github.urls.repo?.replace('github.com/', 'raw.githubusercontent.com/')}/${branchName ?? 'HEAD'}/${packagePath !== '.' ? `${packagePath}/` : ''}${fileName}`;
347359
}
360+
361+
function getBlockquoteIcon(type: string) {
362+
switch (type) {
363+
case 'note':
364+
return <NoteBlockquote style={tw`-ml-0.5 size-4`} />;
365+
case 'tip':
366+
return <TipBlockquote style={tw`-ml-0.5 size-4`} />;
367+
case 'warning':
368+
return <WarningBlockquote style={tw`-ml-0.5 size-4`} />;
369+
case 'caution':
370+
return <CautionBlockquote style={tw`-ml-0.5 size-4`} />;
371+
case 'important':
372+
return <ImportantBlockquote style={tw`-ml-0.5 size-4`} />;
373+
default:
374+
return null;
375+
}
376+
}

styles/shiki/rnd-dark.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@
335335
}
336336
},
337337
{
338-
"scope": ["keyword.operator", "keyword.control"],
338+
"scope": ["keyword.soft", "keyword.hard", "keyword.operator", "keyword.control"],
339339
"settings": {
340340
"foreground": "#ff7b72"
341341
}

styles/shiki/rnd-light.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@
320320
}
321321
},
322322
{
323-
"scope": ["keyword.operator", "keyword.control"],
323+
"scope": ["keyword.soft", "keyword.hard", "keyword.operator", "keyword.control"],
324324
"settings": {
325325
"foreground": "#cf222e"
326326
}

styles/styles.css

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ select {
517517

518518
.blockquote-title {
519519
font-weight: 600;
520-
margin-bottom: -4px;
520+
margin-bottom: -6px;
521521
display: block;
522522
}
523523

@@ -530,10 +530,10 @@ select {
530530
}
531531

532532
&.tip {
533-
border-left-color: #238636;
533+
border-left-color: #238a2c;
534534

535535
.blockquote-title {
536-
color: #238636;
536+
color: #238a2c;
537537
}
538538
}
539539

@@ -693,10 +693,6 @@ select {
693693
border: 1px solid var(--table-border);
694694
padding: 5px 8px;
695695

696-
&:empty {
697-
display: none;
698-
}
699-
700696
&:first-child {
701697
border-left: 0;
702698
}
@@ -706,6 +702,10 @@ select {
706702
}
707703
}
708704

705+
td:empty {
706+
display: none;
707+
}
708+
709709
th {
710710
background-color: var(--table-header-background);
711711
}

0 commit comments

Comments
 (0)