Skip to content

Commit 67eb0d2

Browse files
Add code-block in What is Turing.jl? Section
1 parent 8a9ebbc commit 67eb0d2

File tree

4 files changed

+214
-34
lines changed

4 files changed

+214
-34
lines changed

index.qmd

Lines changed: 85 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,105 @@ listing:
3131
:::
3232
<!-- Header End Here -->
3333

34-
<!-- Feature Boxes -->
35-
:::: {.section-start-space}
34+
<!-- What is Turing.jl Section -->
35+
:::: {.section-start-space .section-end-space}
3636

37+
::: {.text-center}
3738
### What is Turing.jl?
38-
<p>Turing.jl is a Julia library for general-purpose probabilistic programming.</p>
39+
Turing.jl is a Julia library for general-purpose probabilistic programming.
40+
:::
3941

40-
::::
42+
::: {.what-is-turing-grid .section-start-space}
4143

42-
::::: {.d-flex .flex-row .flex-wrap .panel-wrapper .gap-4 .section-end-space}
44+
::: {.feature-text-column}
45+
46+
::: {.feature-item}
47+
::: {.feature-item-header}
48+
49+
```{=html}
50+
<span class="feature-icon icon-expressive"></span>
51+
```
52+
53+
##### Expressive
54+
55+
:::
4356

44-
::: {.panel .box}
45-
##### Expressive {.panel-title .pb-1}
4657
Turing models are easy to write and communicate, with syntax that is close to the mathematical specification of the model.
58+
59+
:::
60+
61+
::: {.feature-item}
62+
::: {.feature-item-header}
63+
64+
```{=html}
65+
<span class="feature-icon icon-general-purpose"></span>
66+
```
67+
68+
##### General-purpose
69+
4770
:::
4871

49-
::: {.panel .box}
50-
##### General-purpose {.panel-title .pb-1}
5172
Turing supports models with discrete parameters and stochastic control flow.
73+
74+
:::
75+
76+
::: {.feature-item}
77+
::: {.feature-item-header}
78+
79+
```{=html}
80+
<span class="feature-icon icon-composable"></span>
81+
```
82+
83+
##### Composable
84+
5285
:::
5386

54-
::: {.panel .box}
55-
##### Composable {.panel-title .pb-1}
5687
Turing is written entirely in Julia, and is interoperable with its powerful ecosystem.
88+
5789
:::
5890

59-
:::::
60-
<!-- Feature Boxes Ends Here -->
91+
:::
92+
93+
::: {.code-example-column}
94+
::: {.code-window .box}
95+
::: {.code-window-header}
96+
::: {.code-window-dots}
97+
98+
```{=html}
99+
<span class="dot red"></span><span class="dot yellow"></span><span class="dot green"></span>
100+
```
101+
102+
:::
103+
:::
104+
105+
```{.julia .code-overflow-scroll}
106+
using Turing
107+
108+
@model function linear_regression(x)
109+
# Priors
110+
α ~ Normal(0, 1)
111+
β ~ Normal(0, 1)
112+
σ² ~ truncated(Normal(0, 1), lower=0)
113+
114+
# Likelihood
115+
μ = α .+ β .* x
116+
y ~ MvNormal(μ, σ² * I)
117+
118+
return (; y, α, β, σ², μ)
119+
end
120+
121+
x, y = rand(10), rand(10)
122+
posterior = linear_regression(x) | (;y = y)
123+
chains = sample(posterior, NUTS(), 1000, progress=false)
124+
```
125+
126+
:::
127+
:::
128+
129+
:::
130+
::::
131+
<!-- What is Turing.jl Section Ends Here -->
132+
61133

62134
<!-- Start Your Journey Section -->
63135
:::: {.section-header .section-start-space}

theming/rules/_layouts.scss

Lines changed: 113 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
flex-wrap: wrap;
3434
}
3535

36-
// Not hoverable? Maybe have to move? Maybe not.
36+
/* General Layout Styles */
3737
.btn-lg {
3838
padding: 14px 32px;
3939
font-size: 1.1rem;
@@ -59,14 +59,6 @@
5959
min-width: 300px;
6060
max-width: 31%;
6161

62-
/* Does this bit achieve anything? I think it's inherited?
63-
p {
64-
color: $text-muted;
65-
font-size: 17px;
66-
font-weight: 400;
67-
}
68-
*/
69-
7062
.panel-title {
7163
color: $text-color !important;
7264
font-size: 1.4rem;
@@ -116,15 +108,121 @@
116108
padding-right: 4rem;
117109
}
118110

119-
.example-code {
120-
flex: 0 1 45%;
111+
/* What is Turing.jl Section */
112+
.what-is-turing-grid {
113+
display: grid;
114+
grid-template-columns: 1fr 1.25fr;
115+
gap: 3rem;
116+
align-items: center;
117+
}
118+
119+
.feature-text-column {
120+
display: flex;
121+
flex-direction: column;
122+
gap: 2rem;
123+
}
124+
125+
.feature-item-header {
126+
display: flex;
127+
align-items: center;
128+
gap: 0.75rem;
129+
margin-bottom: 0.5rem;
130+
}
131+
132+
/* Base styles for all feature icons */
133+
.feature-icon {
134+
display: inline-block;
135+
width: 24px;
136+
height: 24px;
137+
background-repeat: no-repeat;
138+
background-position: center;
139+
background-size: contain;
140+
}
141+
142+
/* background image for each icon */
143+
.icon-expressive {
144+
background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 19C3 19.5304 3.21071 20.0391 3.58579 20.4142C3.96086 20.7893 4.46957 21 5 21C7 21 7 17 8 12C9 7 9 3 11 3C11.5304 3 12.0391 3.21071 12.4142 3.58579C12.7893 3.96086 13 4.46957 13 5' stroke='%234DB6AC' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M13.9999 12L19.9999 18' stroke='%234DB6AC' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M13.9999 18L19.9999 12' stroke='%234DB6AC' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
145+
}
146+
147+
.icon-general-purpose {
148+
background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7.99988 8H15.9999V16H7.99988V8Z' stroke='%234DB6AC' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M4.00012 6C4.00012 5.46957 4.21084 4.96086 4.58591 4.58579C4.96098 4.21071 5.46969 4 6.00012 4H18.0001C18.5306 4 19.0393 4.21071 19.4143 4.58579C19.7894 4.96086 20.0001 5.46957 20.0001 6V18C20.0001 18.5304 19.7894 19.0391 19.4143 19.4142C19.0393 19.7893 18.5306 20 18.0001 20H6.00012C5.46969 20 4.96098 19.7893 4.58591 19.4142C4.21084 19.0391 4.00012 18.5304 4.00012 18V6Z' stroke='%234DB6AC' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
121149
}
122150

123-
.example-text {
124-
flex: 0 1 53%;
151+
.icon-composable {
152+
background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11.9999 3L7.99988 10H15.9999L11.9999 3Z' stroke='%234DB6AC' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M13.9999 17C13.9999 17.7956 14.3159 18.5587 14.8786 19.1213C15.4412 19.6839 16.2042 20 16.9999 20C17.7955 20 18.5586 19.6839 19.1212 19.1213C19.6838 18.5587 19.9999 17.7956 19.9999 17C19.9999 16.2044 19.6838 15.4413 19.1212 14.8787C18.5586 14.3161 17.7955 14 16.9999 14C16.2042 14 15.4412 14.3161 14.8786 14.8787C14.3159 15.4413 13.9999 16.2044 13.9999 17Z' stroke='%234DB6AC' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M4.00012 15C4.00012 14.7348 4.10548 14.4804 4.29302 14.2929C4.48055 14.1054 4.73491 14 5.00012 14H9.00012C9.26534 14 9.51969 14.1054 9.70723 14.2929C9.89477 14.4804 10.0001 14.7348 10.0001 15V19C10.0001 19.2652 9.89477 19.5196 9.70723 19.7071C9.51969 19.8946 9.26534 20 9.00012 20H5.00012C4.73491 20 4.48055 19.8946 4.29302 19.7071C4.10548 19.5196 4.00012 19.2652 4.00012 19V15Z' stroke='%234DB6AC' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
153+
}
154+
155+
156+
.feature-item {
157+
h5 {
158+
font-weight: 700;
159+
font-size: 1.2rem;
160+
color: $text-color;
161+
margin-bottom: 0;
162+
}
163+
p {
164+
font-size: 1rem;
165+
line-height: 1.6;
166+
margin-bottom: 0;
167+
}
168+
}
169+
170+
.code-example-column {
171+
.code-window {
172+
padding: 0;
173+
overflow: hidden;
174+
175+
&:hover {
176+
transform: translateY(-2px);
177+
box-shadow: 0 6px 22px darken($box-shadow-color, 40%);
178+
border: 1px solid $btn-border-color;
179+
}
180+
}
181+
182+
.code-window-header {
183+
background-color: $panel-bg;
184+
padding: 0.9rem 1.2rem;
185+
display: flex;
186+
align-items: center;
187+
border-bottom: 1px solid lighten($btn-border-color, 5%);
188+
position: relative;
189+
}
190+
191+
.code-window-dots {
192+
display: flex;
193+
gap: 0.55rem;
194+
}
195+
196+
.dot {
197+
width: 13px;
198+
height: 13px;
199+
border-radius: 50%;
200+
display: inline-block;
201+
&.red { background-color: #ff5f56; }
202+
&.yellow { background-color: #ffbd2e; }
203+
&.green { background-color: #27c93f; }
204+
}
205+
206+
.sourceCode {
207+
border: none !important;
208+
border-radius: 0 0 $border-radius-sm $border-radius-sm !important;
209+
margin: 0 !important;
210+
background-color: $code-block-bg !important;
211+
212+
pre {
213+
padding: 1.5rem !important;
214+
margin: 0;
215+
}
216+
}
217+
218+
.quarto-code-tools {
219+
background-color: transparent !important;
220+
top: 0.5rem !important;
221+
right: 0.5rem !important;
222+
}
125223
}
126224

127-
/* === Core Packages Section === */
225+
/* Core Packages Section */
128226
.core-packages-grid {
129227
display: grid;
130228
grid-template-columns: repeat(4, 1fr);
@@ -161,7 +259,7 @@
161259
display: none;
162260
}
163261

164-
// UNIFIED CARD GRID
262+
/* Unified Card Grid Layout */
165263
.unified-card-grid {
166264
display: flex;
167265
flex-wrap: wrap;

theming/rules/_responsive.scss

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
}
66

77
@media (max-width: 992px) {
8+
.what-is-turing-grid {
9+
grid-template-columns: 1fr;
10+
gap: 2rem;
11+
}
12+
13+
/* This prevents the code block's column from overflowing the page on mobile */
14+
.code-example-column {
15+
min-width: 0;
16+
}
17+
818
.custom-footer {
919
.footer-links-wrapper {
1020
flex-basis: 100%;
@@ -50,7 +60,6 @@
5060
display: block;
5161
margin-top: 0.3rem;
5262
text-align: center;
53-
5463
.button {
5564
display: inline-block;
5665
width: auto;

theming/variables/_colors-dark.scss

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
$teal: #4db6ac;
22
$green: #229954;
3-
4-
// This is very similar to the "normal" teal. Can we collapse those into the same?
53
$teal-license: #34b8bf;
64

75
$links: $teal-license;
86
$links-hover: lighten($links, 10%);
97

108
$box-shadow-color: rgba(0, 0, 0, 0.4);
119

12-
$code-block-bg: #212529;
10+
// Set the main page background color
11+
$background-body: #1c2128;
1312

14-
$panel-bg: $gray-900;
13+
// Use the main page background for code blocks to ensure consistency
14+
$code-block-bg: $background-body;
1515

16-
$background-body: #1c2128;
16+
// Define the background for panels, making them stand out slightly
17+
$panel-bg: $gray-900;
1718

1819
$body-bg: $background-body;
1920
$navbar-bg: lighten($background-body, 2%);

0 commit comments

Comments
 (0)