From f61b7b7048d37f5ff63fcc7306000d839961b09c Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Fri, 22 Mar 2024 11:29:07 +0800 Subject: [PATCH] feat: add alert.css to package. #2 --- README.md | 11 +++++-- alert.css | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 3 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 alert.css diff --git a/README.md b/README.md index 92e04d7..465ca6f 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,13 @@ The output HTML will be: ## Styling -Add the following styles to your css to mimic GitHub's styling of alerts: +You can mimic GitHub's alert style by adding the styles provided in the npm package to your CSS. + +```js +import 'remark-github-blockquote-alert/alert.css' +``` + +Or, add the following styles to your CSS to mimic GitHub's alert style: ```css @media (prefers-color-scheme: dark) { @@ -127,7 +133,8 @@ Add the following styles to your css to mimic GitHub's styling of alerts: } .markdown-alert .markdown-alert-title svg.octicon { margin-right: 8px!important; - margin-right: var(--base-size-8,8px)!important + margin-right: var(--base-size-8,8px) !important; + fill: currentColor; } .markdown-alert.markdown-alert-note { border-left-color: var(--borderColor-accent-emphasis,var(--color-accent-emphasis)) diff --git a/alert.css b/alert.css new file mode 100644 index 0000000..2bdeabe --- /dev/null +++ b/alert.css @@ -0,0 +1,89 @@ + +@media (prefers-color-scheme: dark) { + .markdown-alert { + --color-border-default: #30363d; + --color-accent-fg: #58a6ff; + --color-accent-emphasis: #1f6feb; + --color-danger-fg: #f85149; + --color-danger-emphasis: #da3633; + --color-attention-fg: #d29922; + --color-attention-emphasis: #9e6a03; + --color-done-fg: #a371f7; + --color-done-emphasis: #8957e5; + --color-success-fg: #3fb950; + --color-success-emphasis: #238636; + } +} + +@media (prefers-color-scheme: light) { + .markdown-alert { + --color-border-default: #d0d7de; + --color-accent-fg: #0969da; + --color-accent-emphasis: #0969da; + --color-danger-fg: #d1242f; + --color-danger-emphasis: #cf222e; + --color-attention-fg: #9a6700; + --color-attention-emphasis: #9a6700; + --color-done-fg: #8250df; + --color-done-emphasis: #8250df; + --color-success-fg: #1a7f37; + --color-success-emphasis: #1f883d; + } +} + +.markdown-alert { + border-left: .25em solid var(--borderColor-default, var(--color-border-default)); + color: inherit; + margin-bottom: 16px; + padding: .5rem 1em +} +.markdown-alert>:last-child { + margin-bottom: 0!important +} +.markdown-alert .markdown-alert-title { + align-items: center; + display: flex; + font-size: 14px; + font-weight: 500; + line-height: 1 +} +.markdown-alert .markdown-alert-title svg.octicon { + margin-right: 8px!important; + margin-right: var(--base-size-8,8px)!important; + fill: currentColor; +} +.markdown-alert.markdown-alert-note { + border-left-color: var(--borderColor-accent-emphasis,var(--color-accent-emphasis)) +} +.markdown-alert.markdown-alert-note .markdown-alert-title { + color: var(--color-accent-fg); + color: var(--fgColor-accent,var(--color-accent-fg)) +} +.markdown-alert.markdown-alert-tip { + border-left-color: var(--borderColor-success-emphasis,var(--color-success-emphasis)) +} +.markdown-alert.markdown-alert-tip .markdown-alert-title { + color: var(--color-success-fg); + color: var(--fgColor-success,var(--color-success-fg)) +} +.markdown-alert.markdown-alert-important { + border-left-color: var(--borderColor-done-emphasis,var(--color-done-emphasis)) +} +.markdown-alert.markdown-alert-important .markdown-alert-title { + color: var(--color-done-fg); + color: var(--fgColor-done,var(--color-done-fg)) +} +.markdown-alert.markdown-alert-warning { + border-left-color: var(--borderColor-attention-emphasis,var(--color-attention-emphasis)) +} +.markdown-alert.markdown-alert-warning .markdown-alert-title { + color: var(--color-attention-fg); + color: var(--fgColor-attention,var(--color-attention-fg)) +} +.markdown-alert.markdown-alert-caution { + border-left-color: var(--borderColor-danger-emphasis,var(--color-danger-emphasis)) +} +.markdown-alert.markdown-alert-caution .markdown-alert-title { + color: var(--color-danger-fg); + color: var(--fgColor-danger,var(--color-danger-fg)) +} \ No newline at end of file diff --git a/package.json b/package.json index c977757..cd4255e 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "url": "https://github.com/jaywcjlove/remark-github-blockquote-alert" }, "files": [ + "alert.css", "src", "lib" ],