Files
lila/ui/lib/css/component/_markdown.scss

239 lines
3.4 KiB
SCSS

@mixin rendered-markdown(
$element-margin: 1em,
$img-max-height: 50vh,
$table: true,
$list: true,
$img: true,
$h1: true,
$h2: true
) {
@extend %break-word;
strong {
font-weight: bold;
}
em {
font-style: italic;
}
p,
pre {
margin: $element-margin 0;
}
@if $list {
ol,
ul {
margin: $element-margin 0;
padding-inline-start: 2em;
}
li ol,
li ul {
margin: 0;
}
ol > li {
list-style: decimal;
}
ul > li {
list-style: disc;
}
li p {
display: inline-block;
vertical-align: top;
margin-top: 0;
}
}
@if $h1 {
/* should not be used */
h1 {
font-size: 1em;
margin: 0;
}
}
@if $h2 {
h2 {
&:not(:first-child) {
margin-top: calc(0.9 * #{$element-margin});
}
border-bottom: 1px solid $c-brag;
line-height: 1.5em;
padding-bottom: calc(0.25 * #{$element-margin});
}
}
h3 {
@include fluid-size('font-size', 18px, 27px);
font-weight: bold;
margin: calc(0.8 * #{$element-margin}) 0 calc(0.5 * #{$element-margin}) 0;
&:first-child {
margin-top: 0;
}
}
h4 {
@include fluid-size('font-size', 17px, 23px);
}
h2,
h3,
h4 {
a[id] {
opacity: 0;
&::before {
color: $c-font-dimmer;
content: $licon-Link;
font-family: lichess;
margin-left: -3rem;
width: 3rem;
position: absolute;
}
}
&:hover {
a[id] {
opacity: 1;
}
}
}
@if $img {
img {
display: block;
max-width: 100%;
max-height: $img-max-height;
margin: auto;
}
}
@if $table {
table {
margin: $element-margin 0;
}
th,
td {
&[align='left'] {
text-align: left;
}
&[align='center'] {
text-align: center;
}
&[align='right'] {
text-align: right;
}
}
}
p {
time {
border-bottom: 1px dashed $c-font-dim;
cursor: help;
font-size: 100%;
}
a {
& > time {
border-color: $c-link;
}
&:hover > time {
border-color: $c-link-hover;
}
}
}
}
@mixin rendered-markdown-code {
$c-code-bg: $c-bg-zebra;
$c-code-font: $c-font-clear;
code {
@extend %box-radius;
font-family: monospace;
padding: 0.2em 0.5em;
background: $c-code-bg;
color: $c-code-font;
font-size: 0.9em;
white-space: pre-wrap;
}
pre {
@extend %box-neat;
background: $c-code-bg;
padding: 1em 1.5em;
line-height: 1.4em;
code {
background: none;
padding: 0;
}
}
}
@mixin rendered-markdown-quote {
blockquote {
color: $c-font-dim;
border-inline-start: 0.3em solid $c-font-dimmer;
padding-inline-start: 1em;
}
}
@mixin rendered-markdown-img {
img {
@extend %box-neat;
max-width: 100%;
}
/* image caption */
img + br:has(+ em) {
display: none;
}
img + em,
img + br + em {
color: $c-font-dim;
margin-top: 10px;
display: block;
font-size: 0.8em;
text-align: center;
}
}
@mixin rendered-markdown-embed {
.embed {
@extend %video;
margin: $block-gap auto;
> iframe {
left: 0;
}
}
.twitter-tweet {
color-scheme: normal;
margin: auto;
}
.private-study {
color: $c-brag;
font-size: 1.2em;
}
}