-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #393 from vordgi/rd-392
rd-392 support github styled blockquotes
- Loading branch information
Showing
8 changed files
with
204 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 53 additions & 2 deletions
55
packages/robindoc/src/components/ui/blockquote/blockquote.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,62 @@ | ||
.r-blockquote { | ||
background-color: var(--r-neutral-100); | ||
padding: 12px; | ||
border-left: 6px solid var(--r-primary-800); | ||
padding: 8px 12px 8px 20px; | ||
border-left: 6px solid var(--r-neutral-600); | ||
border-top-right-radius: 2px; | ||
border-bottom-right-radius: 2px; | ||
font: inherit; | ||
margin-inline: 0; | ||
margin-block-start: 1em; | ||
margin-block-end: 1em; | ||
} | ||
|
||
.r-blockquote-title { | ||
font-weight: 600; | ||
} | ||
|
||
.r-blockquote-icon { | ||
display: inline-block; | ||
vertical-align: middle; | ||
margin-top: -2px; | ||
margin-right: 8px; | ||
} | ||
|
||
.r-blockquote-note { | ||
border-left-color: var(--r-note); | ||
|
||
.r-blockquote-title { | ||
color: var(--r-note); | ||
} | ||
} | ||
|
||
.r-blockquote-tip { | ||
border-left-color: var(--r-tip); | ||
|
||
.r-blockquote-title { | ||
color: var(--r-tip); | ||
} | ||
} | ||
|
||
.r-blockquote-important { | ||
border-left-color: var(--r-important); | ||
|
||
.r-blockquote-title { | ||
color: var(--r-important); | ||
} | ||
} | ||
|
||
.r-blockquote-warning { | ||
border-left-color: var(--r-warning); | ||
|
||
.r-blockquote-title { | ||
color: var(--r-warning); | ||
} | ||
} | ||
|
||
.r-blockquote-caution { | ||
border-left-color: var(--r-caution); | ||
|
||
.r-blockquote-title { | ||
color: var(--r-caution); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { CautionIcon, ImportantIcon, NoteIcon, TipIcon, WarningIcon } from "./icons"; | ||
|
||
export const TYPES_DATA = { | ||
note: { title: "Note", icon: NoteIcon }, | ||
tip: { title: "Tip", icon: TipIcon }, | ||
important: { title: "Important", icon: ImportantIcon }, | ||
warning: { title: "Warning", icon: WarningIcon }, | ||
caution: { title: "Caution", icon: CautionIcon }, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from "react"; | ||
|
||
export const NoteIcon = () => ( | ||
<> | ||
<path d="m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2" /> | ||
<path d="M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z" /> | ||
<path d="M8 18h1" /> | ||
</> | ||
); | ||
|
||
export const TipIcon = () => ( | ||
<> | ||
<path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5" /> | ||
<path d="M9 18h6" /> | ||
<path d="M10 22h4" /> | ||
</> | ||
); | ||
|
||
export const ImportantIcon = () => ( | ||
<> | ||
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" /> | ||
<path d="M12 7v2" /> | ||
<path d="M12 13h.01" /> | ||
</> | ||
); | ||
|
||
export const WarningIcon = () => ( | ||
<> | ||
<circle cx="12" cy="12" r="10" /> | ||
<line x1="12" x2="12" y1="8" y2="12" /> | ||
<line x1="12" x2="12.01" y1="16" y2="16" /> | ||
</> | ||
); | ||
|
||
export const CautionIcon = () => ( | ||
<> | ||
<path d="m15 9-6 6" /> | ||
<path d="M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z" /> | ||
<path d="m9 9 6 6" /> | ||
</> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,41 @@ | ||
import React from "react"; | ||
import clsx from "clsx"; | ||
|
||
import { TYPES_DATA } from "./data"; | ||
|
||
import "./blockquote.scss"; | ||
|
||
export type BlockquoteType = "note" | "tip" | "important" | "warning" | "caution"; | ||
|
||
interface BlockquoteProps { | ||
className?: string; | ||
type?: BlockquoteType | null; | ||
} | ||
|
||
export const Blockquote: React.FC<React.PropsWithChildren<BlockquoteProps>> = ({ className, children }) => { | ||
return <blockquote className={clsx("r-blockquote", className)}>{children}</blockquote>; | ||
export const Blockquote: React.FC<React.PropsWithChildren<BlockquoteProps>> = ({ className, type, children }) => { | ||
const { icon: Icon, title } = type && type in TYPES_DATA ? TYPES_DATA[type] : {}; | ||
|
||
return ( | ||
<blockquote className={clsx("r-blockquote", type && `r-blockquote-${type}`, className)}> | ||
{title && Icon && ( | ||
<p className="r-blockquote-title"> | ||
<svg | ||
width="20" | ||
height="20" | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
stroke="currentColor" | ||
strokeWidth="2" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
className="r-blockquote-icon" | ||
> | ||
<Icon /> | ||
</svg> | ||
{title} | ||
</p> | ||
)} | ||
{children} | ||
</blockquote> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters