Skip to content

Commit 883b4b9

Browse files
authored
Merge pull request #227 from LuxDL/la/css_family
css family and source code css improvements.
2 parents 8a4d3b2 + cd78c54 commit 883b4b9

File tree

3 files changed

+74
-13
lines changed

3 files changed

+74
-13
lines changed

docs/src/.vitepress/theme/style.css

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@
2323
/* Disable contextual alternates (kind of like ligatures but different) in monospace,
2424
which turns `/>` to an up arrow and `|>` (the Julia pipe symbol) to an up arrow as well. */
2525
.mono-no-substitutions {
26-
font-family: "JuliaMono-Light", monospace;
26+
font-family: "JuliaMono-Regular", monospace;
2727
font-feature-settings: "calt" off;
2828
}
2929

3030
.mono-no-substitutions-alt {
31-
font-family: "JuliaMono-Light", monospace;
31+
font-family: "JuliaMono-Regular", monospace;
3232
font-variant-ligatures: none;
3333
}
3434

3535
pre, code {
36-
font-family: "JuliaMono-Light", monospace;
36+
font-family: "JuliaMono-Regular", monospace;
3737
font-feature-settings: "calt" off;
3838
}
3939

@@ -69,12 +69,14 @@ pre, code {
6969
/* Text Colors */
7070
--vp-dark-text: #e5e5e5; /* Primary text color */
7171
--vp-dark-subtext: #c1c1c1; /* Subtle text */
72+
--vp-source-text: #e5e5e5;
7273

7374
/* Backgrounds */
7475
--vp-dark-bg: #121212; /* Main background */
7576
--vp-dark-bg-alt: #1a1a1a; /* Alternative background */
7677
--vp-dark-bg-dimm: #101010;
77-
78+
--vp-source-bg: #414040;
79+
7880
/* Borders */
7981
--vp-dark-border: #3b8a65;
8082
/* custom tip */
@@ -90,6 +92,7 @@ pre, code {
9092
}
9193

9294
:root.dark {
95+
--vp-source-bg: rgb(224, 223, 223);
9396
/* custom tip */
9497
--vp-custom-block-tip-border: var(--vp-dark-green-dark);
9598
--vp-custom-block-tip-text: var(--vp-dark-subtext);
@@ -113,6 +116,7 @@ pre, code {
113116
:root.dark {
114117
--vp-dark-link: var(--vp-dark-green-lighter);
115118
--vp-dark-link-hover: var(--vp-dark-green-light);
119+
--vp-source-text: #595c5f;
116120
}
117121

118122
/* Hero Section */
@@ -203,6 +207,7 @@ mjx-container > svg {
203207
.jldocstring.custom-block {
204208
border: 1px solid var(--vp-c-gray-2);
205209
color: var(--vp-c-text-1);
210+
overflow: hidden;
206211
}
207212

208213
.jldocstring.custom-block summary {
@@ -213,4 +218,31 @@ mjx-container > svg {
213218
}
214219
.jldocstring.custom-block summary a {
215220
pointer-events: none;
221+
text-decoration: none;
222+
}
223+
224+
.jldocstring.custom-block .source-link {
225+
border-radius: 4px;
226+
text-decoration: none;
227+
background-color: var(--vp-source-bg);
228+
float: right;
229+
opacity: 0;
230+
visibility: hidden;
231+
transform: translateY(-5px);
232+
transition: all 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
233+
}
234+
235+
.jldocstring.custom-block .source-link a {
236+
text-decoration: none;
237+
color: var(--vp-source-text);
238+
}
239+
240+
.jldocstring.custom-block .source-link a:hover {
241+
text-decoration: underline;
242+
}
243+
244+
.jldocstring.custom-block:hover .source-link {
245+
opacity: 1;
246+
visibility: visible;
247+
transform: translateY(0);
216248
}

src/writer.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,7 @@ function renderdoc(io::IO, mime::MIME"text/plain", node::Documenter.MarkdownAST.
374374
if url !== nothing
375375
# This is how Documenter does it:
376376
# push!(ret.nodes, a[".docs-sourcelink", :target=>"_blank", :href=>url]("source"))
377-
# so clearly we should be inserting some form of HTML tag here,
378-
# and defining its rendering in CSS?
379-
# TODO: switch to Documenter style here
380-
println(io, "\n", "[source]($url)", "\n")
377+
println(io, "\n", """<Badge type="info" class="source-link" text="source"><a href="$url" target="_blank" rel="noreferrer">source</a></Badge>""", "\n")
381378
end
382379
end
383380
end

template/src/.vitepress/theme/style.css

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.VPHero .clip {
22
white-space: pre;
3-
max-width: 500px;
3+
max-width: 600px;
44
}
55

66
/* Fonts */
@@ -23,17 +23,17 @@
2323
/* Disable contextual alternates (kind of like ligatures but different) in monospace,
2424
which turns `/>` to an up arrow and `|>` (the Julia pipe symbol) to an up arrow as well. */
2525
.mono-no-substitutions {
26-
font-family: "JuliaMono-Light", monospace;
26+
font-family: "JuliaMono-Regular", monospace;
2727
font-feature-settings: "calt" off;
2828
}
2929

3030
.mono-no-substitutions-alt {
31-
font-family: "JuliaMono-Light", monospace;
31+
font-family: "JuliaMono-Regular", monospace;
3232
font-variant-ligatures: none;
3333
}
3434

3535
pre, code {
36-
font-family: "JuliaMono-Light", monospace;
36+
font-family: "JuliaMono-Regular", monospace;
3737
font-feature-settings: "calt" off;
3838
}
3939

@@ -69,12 +69,14 @@ pre, code {
6969
/* Text Colors */
7070
--vp-dark-text: #e5e5e5; /* Primary text color */
7171
--vp-dark-subtext: #c1c1c1; /* Subtle text */
72+
--vp-source-text: #e5e5e5;
7273

7374
/* Backgrounds */
7475
--vp-dark-bg: #121212; /* Main background */
7576
--vp-dark-bg-alt: #1a1a1a; /* Alternative background */
7677
--vp-dark-bg-dimm: #101010;
77-
78+
--vp-source-bg: #414040;
79+
7880
/* Borders */
7981
--vp-dark-border: #3b8a65;
8082
/* custom tip */
@@ -90,6 +92,7 @@ pre, code {
9092
}
9193

9294
:root.dark {
95+
--vp-source-bg: rgb(224, 223, 223);
9396
/* custom tip */
9497
--vp-custom-block-tip-border: var(--vp-dark-green-dark);
9598
--vp-custom-block-tip-text: var(--vp-dark-subtext);
@@ -113,6 +116,7 @@ pre, code {
113116
:root.dark {
114117
--vp-dark-link: var(--vp-dark-green-lighter);
115118
--vp-dark-link-hover: var(--vp-dark-green-light);
119+
--vp-source-text: #595c5f;
116120
}
117121

118122
/* Hero Section */
@@ -203,6 +207,7 @@ mjx-container > svg {
203207
.jldocstring.custom-block {
204208
border: 1px solid var(--vp-c-gray-2);
205209
color: var(--vp-c-text-1);
210+
overflow: hidden;
206211
}
207212

208213
.jldocstring.custom-block summary {
@@ -213,4 +218,31 @@ mjx-container > svg {
213218
}
214219
.jldocstring.custom-block summary a {
215220
pointer-events: none;
221+
text-decoration: none;
222+
}
223+
224+
.jldocstring.custom-block .source-link {
225+
border-radius: 4px;
226+
text-decoration: none;
227+
background-color: var(--vp-source-bg);
228+
float: right;
229+
opacity: 0;
230+
visibility: hidden;
231+
transform: translateY(-5px);
232+
transition: all 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
233+
}
234+
235+
.jldocstring.custom-block .source-link a {
236+
text-decoration: none;
237+
color: var(--vp-source-text);
238+
}
239+
240+
.jldocstring.custom-block .source-link a:hover {
241+
text-decoration: underline;
242+
}
243+
244+
.jldocstring.custom-block:hover .source-link {
245+
opacity: 1;
246+
visibility: visible;
247+
transform: translateY(0);
216248
}

0 commit comments

Comments
 (0)