Skip to content

Commit a27b7e2

Browse files
committed
chore(demo): restyle demo output for the accessible markup
1 parent 7dab69c commit a27b7e2

2 files changed

Lines changed: 80 additions & 15 deletions

File tree

docs/anatomy.html

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ <h1>Anatomy of a Friendly Error Message</h1>
3939
<div class="anatomy__zone-tag">Explain &amp; Suggest - Title &amp; Summary</div>
4040
</div>
4141
<div class="anatomy__zone-body">
42-
<div class="pfem__title">This variable doesn't exist yet</div>
43-
<div class="pfem__summary">Your code uses the variable "<em>firstname</em>", but it hasn't been created
42+
<p class="pfem__title">This variable doesn't exist yet</p>
43+
<p class="pfem__summary">Your code uses the variable <code class="pfem__var">firstname</code>, but it
44+
hasn't been created
4445
yet.
45-
Check line 2. If you meant to print the text <em>firstname</em>, put it in double quotes.</div>
46+
Check <span class="pfem__line">line 2</span>. If you meant to print the text <code
47+
class="pfem__var">firstname</code>, put it in double quotes.</p>
4648
</div>
4749
</div>
4850

@@ -53,9 +55,10 @@ <h1>Anatomy of a Friendly Error Message</h1>
5355
<div class="anatomy__zone-tag">Hint &amp; Direct - Why it happened</div>
5456
</div>
5557
<div class="anatomy__zone-body">
56-
<div class="pfem__why">Without speech marks Python treats <em>firstname</em> as a variable, and this
58+
<p class="pfem__why">Without speech marks Python treats <code class="pfem__var">firstname</code> as a
59+
variable, and this
5760
variable
58-
does not exist yet.</div>
61+
does not exist yet.</p>
5962
</div>
6063
</div>
6164

@@ -67,7 +70,7 @@ <h1>Anatomy of a Friendly Error Message</h1>
6770
</div>
6871
<div class="anatomy__zone-body">
6972
<ul class="pfem__steps">
70-
<li>If it is meant to be text, put speech marks around <em>firstname</em>.</li>
73+
<li>If it is meant to be text, put speech marks around <code class="pfem__var">firstname</code>.</li>
7174
<li>If it is meant to be a variable, make it first (for example: <code>firstname = "Jo"</code>).</li>
7275
<li>Check spelling and capital letters.</li>
7376
</ul>
@@ -81,8 +84,11 @@ <h1>Anatomy of a Friendly Error Message</h1>
8184
<div class="anatomy__zone-tag">Solve - Suggested fix</div>
8285
</div>
8386
<div class="anatomy__zone-body">
84-
<pre class="pfem__patch">firstname = "Jo"
85-
print("Hello, " + firstname)</pre>
87+
<div class="pfem__patch">
88+
<p class="pfem__patch-label">Suggested fix</p>
89+
<pre class="pfem__patch-code"><code>firstname = "Jo"
90+
print("Hello, " + firstname)</code></pre>
91+
</div>
8692
</div>
8793
</div>
8894

docs/styles.css

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,33 +101,73 @@ h1 {
101101
color: #5b3f99;
102102
}
103103

104+
.pfem > :first-child { margin-top: 0; }
105+
.pfem > :last-child { margin-bottom: 0; }
106+
104107
.pfem__title {
105108
font-weight: 600;
106109
color: #1a1a1a;
107-
margin-bottom: 1rem;
110+
margin: 0 0 1rem;
108111
line-height: 1.4;
109112
}
110113

111114
.pfem__summary {
112115
color: #2c3e50;
113-
margin-bottom: 1rem;
116+
margin: 0 0 1rem;
114117
line-height: 1.6;
115118
font-size: 1rem;
116119
}
117120

118121
.pfem__why {
119122
color: #555;
120123
margin: 1rem 0;
121-
padding: 1rem 1rem;
122-
padding-left: 1rem;
124+
padding: 1rem;
123125
border-left: 0.5rem solid #3498db;
124126
background: #f0f7ff;
125127
border-radius: 0.5rem;
126128
line-height: 1.6;
127129
}
128130

131+
/* inline code tokens share a monospace pill; the tint varies by token type */
132+
.pfem__var,
133+
.pfem__code,
134+
.pfem__file {
135+
font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
136+
font-size: 0.9em;
137+
padding: 0.08em 0.32em;
138+
border-radius: 0.25rem;
139+
}
140+
141+
/* variable names & the offending code line — purple */
142+
.pfem__var,
143+
.pfem__code {
144+
background: #efe8ff;
145+
color: #5b3f99;
146+
}
147+
148+
/* file name — teal */
149+
.pfem__file {
150+
background: #e0f2f1;
151+
color: #00695c;
152+
}
153+
154+
/* line-number token — not code, so a proportional pill in a warm amber */
155+
.pfem__line {
156+
font-weight: 600;
157+
font-size: 0.9em;
158+
background: #fff4de;
159+
color: #8a5a00;
160+
padding: 0.08em 0.32em;
161+
border-radius: 0.25rem;
162+
white-space: nowrap;
163+
}
164+
165+
.pfem__steps {
166+
margin: 1rem 0;
167+
padding-left: 1.5rem;
168+
}
169+
129170
.pfem__steps li {
130-
margin-left: 1rem;
131171
margin-bottom: 0.5rem;
132172
color: #2c3e50;
133173
line-height: 1.6;
@@ -138,12 +178,27 @@ h1 {
138178
background: #e8f5e9;
139179
border: 1px solid #4caf50;
140180
border-radius: 0.5rem;
141-
padding: 1rem 1rem;
181+
padding: 0.75rem 1rem;
182+
margin: 1rem 0;
183+
}
184+
185+
.pfem__patch-label {
186+
margin: 0 0 0.4rem;
187+
font-size: 0.75rem;
188+
font-weight: 700;
189+
text-transform: uppercase;
190+
letter-spacing: 0.03em;
191+
color: #2e7d32;
192+
}
193+
194+
.pfem__patch-code {
195+
margin: 0;
142196
font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
143197
font-size: 0.9rem;
144198
color: #1b5e20;
145-
margin: 1rem 0;
146199
line-height: 1.5;
200+
white-space: pre-wrap;
201+
overflow-x: auto;
147202
}
148203

149204
.pfem__details {
@@ -166,6 +221,10 @@ h1 {
166221
overflow-x: auto;
167222
}
168223

224+
.pfem__details pre code {
225+
font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
226+
}
227+
169228
.demo__error {
170229
background: #ffebee;
171230
border: 1px solid #ef5350;

0 commit comments

Comments
 (0)