<?xml-stylesheet href="/pretty-feed-v2.xsl" type="text/xsl"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Trys Mudford's Blog</title>
    <link>https://www.trysmudford.com/tags/tips/</link>
    <description>Posts, thoughts, links and photos from Trys</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Thu, 24 Jul 2025 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://www.trysmudford.com/blog/index.xml" rel="self" type="application/rss+xml"/>
    
    <item>
      <title>Better max-width queries</title>
      <link>https://www.trysmudford.com/blog/max-width-queries/</link>
      <pubDate>Thu, 24 Jul 2025 00:00:00 +0000</pubDate>
      
      <guid>https://www.trysmudford.com/blog/max-width-queries/</guid>
      <description><![CDATA[
<p>A friend shared this tip the other day and it was too useful not to reshare. If you&rsquo;re a mobile-up kind of developer, it&rsquo;s easy to forget that <code>max-width</code> media queries are &ldquo;less than or equal to&rdquo; by default. It can play havoc with your nice round numbers:</p>
<div class="highlight"><pre class="chroma"><code class="language-css" data-lang="css"><span class="p">@</span><span class="k">media</span> <span class="o">(</span><span class="nt">min-width</span><span class="o">:</span> <span class="nt">60em</span><span class="o">)</span> <span class="p">{</span>
  <span class="c">/* above and including 60em */</span>
<span class="p">}</span>

<span class="p">@</span><span class="k">media</span> <span class="o">(</span><span class="nt">max-width</span><span class="o">:</span> <span class="nt">59</span><span class="p">.</span><span class="nc">9375em</span><span class="o">)</span> <span class="p">{</span>
  <span class="c">/* below 60em, but not including 60em exactly */</span>
<span class="p">}</span>
</code></pre></div><p>If you want to tidy that up, and continue to <a href="https://caniuse.com/css-media-range-syntax">support &lt;= Safari 16.3</a>, you can use a query like this:</p>
<div class="highlight"><pre class="chroma"><code class="language-css" data-lang="css"><span class="p">@</span><span class="k">media</span> <span class="o">(</span><span class="nt">max-width</span><span class="o">:</span> <span class="nt">60em</span><span class="o">)</span> <span class="nt">and</span> <span class="o">(</span><span class="nt">not</span> <span class="o">(</span><span class="nt">width</span><span class="o">:</span> <span class="nt">60em</span><span class="o">))</span> <span class="p">{</span>
  <span class="c">/* below 60em, but not including 60em exactly */</span>
<span class="p">}</span>
</code></pre></div><p>However, if you&rsquo;re bought into <a href="https://caniuse.com/css-media-range-syntax">range queries</a>, it all becomes much, much simpler:</p>
<div class="highlight"><pre class="chroma"><code class="language-css" data-lang="css"><span class="p">@</span><span class="k">media</span> <span class="o">(</span><span class="nt">width</span> <span class="o">&lt;</span> <span class="nt">60em</span><span class="o">)</span> <span class="p">{}</span>
</code></pre></div>]]>
      </description>
    </item>
    
    <item>
      <title>Only show the first letter</title>
      <link>https://www.trysmudford.com/blog/only-show-the-first-letter/</link>
      <pubDate>Thu, 16 May 2019 16:00:00 +0000</pubDate>
      
      <guid>https://www.trysmudford.com/blog/only-show-the-first-letter/</guid>
      <description><![CDATA[
<p>Time for another tiny lesson! We&rsquo;re working with a third-party Vue datepicker, and there was a design decision to only show the first letter of the weekdays above the calendar. The datepicker let us specify those values via props. All plain sailing, or so we thought.</p>
<p>The problem? The library assumes you&rsquo;ll be passing unique values, and it uses them as the <code>:key</code> property in a loop. Single letter days lead to <code>T</code> and <code>S</code> collisions and Vue throws a warning for duplicate keys. We also couldn&rsquo;t change that logic without forking the plugin, nor add additional markup to the output.</p>
<p>The solution was to use full weekdays, and hide all but the first letter with CSS. Here&rsquo;s how:</p>
<div class="highlight"><pre class="chroma"><code class="language-css" data-lang="css"><span class="p">.</span><span class="nc">datepicker</span> <span class="nt">thead</span> <span class="p">{</span>
  <span class="k">font-size</span><span class="p">:</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>

<span class="p">.</span><span class="nc">datepicker</span> <span class="nt">thead</span> <span class="p">::</span><span class="nd">first-letter</span> <span class="p">{</span>
  <span class="k">font-size</span><span class="p">:</span> <span class="mi">1</span><span class="kt">rem</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div><style>
  .datepicker thead {
    font-size: 0;
  }

  .datepicker thead ::first-letter {
    font-size: 1.25rem;
  }

  .datepicker {
    font-size: 1.25rem;
    table-layout: fixed;
    width: 100%;
    border-collapse: collapse;
    text-align: center;
    box-shadow: 0 2px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--light);
  }

  .datepicker td {
    padding: 1rem 0.25rem;
    background: var(--mid);
  }

  .datepicker td + td {
    border-left: 1px solid var(--light);
  }

  .datepicker tr + tr td {
    border-top: 1px solid var(--light);
  }

  .datepicker thead th {
    background: #fff;
    border-bottom: 2px solid #ddd;
    padding: 0.5rem 0.25rem;
  }
</style>

<table class="datepicker">
  <thead>
    <tr>
      <th>Monday</th>
      <th>Tuesday</th>
      <th>Wednesday</th>
      <th>Thursday</th>
      <th>Friday</th>
      <th>Saturday</th>
      <th>Sunday</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td>2</td>
      <td>3</td>
      <td>4</td>
      <td>5</td>
      <td>6</td>
      <td>7</td>
    </tr>
    <tr>
      <td>8</td>
      <td>9</td>
      <td>10</td>
      <td>11</td>
      <td>12</td>
      <td>13</td>
      <td>14</td>
    </tr>
    <tr>
      <td>15</td>
      <td>16</td>
      <td>17</td>
      <td>18</td>
      <td>19</td>
      <td>20</td>
      <td>21</td>
    </tr>
    <tr>
      <td>22</td>
      <td>23</td>
      <td>24</td>
      <td>25</td>
      <td>26</td>
      <td>27</td>
      <td>28</td>
    </tr>
  </tbody>
</table>

]]>
      </description>
    </item>
    
    <item>
      <title>Fancy Slack metadata</title>
      <link>https://www.trysmudford.com/blog/fancy-slack-meta-tags/</link>
      <pubDate>Thu, 02 May 2019 17:00:00 +0000</pubDate>
      
      <guid>https://www.trysmudford.com/blog/fancy-slack-meta-tags/</guid>
      <description><![CDATA[
<p>Here&rsquo;s a tiny lesson on generating those fancy extra bits of metadata shown below a link in Slack.</p>
<p><img src="/images/blog/fancy-slack-meta-tags.png" alt="Slack metadata"></p>
<p>Officially they are labels for Twitter, but I&rsquo;ve never seen them used by the social network. You add them with the following meta tags:</p>
<div class="highlight"><pre class="chroma"><code class="language-html" data-lang="html"><span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">&#34;twitter:label1&#34;</span> <span class="na">value</span><span class="o">=</span><span class="s">&#34;Posted in&#34;</span> <span class="p">/&gt;</span>
<span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">&#34;twitter:data1&#34;</span> <span class="na">value</span><span class="o">=</span><span class="s">&#34;Web&#34;</span> <span class="p">/&gt;</span>
<span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">&#34;twitter:label2&#34;</span> <span class="na">value</span><span class="o">=</span><span class="s">&#34;Reading time&#34;</span> <span class="p">/&gt;</span>
<span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">&#34;twitter:data2&#34;</span> <span class="na">value</span><span class="o">=</span><span class="s">&#34;10 minutes&#34;</span> <span class="p">/&gt;</span>
</code></pre></div><hr>
<p>For an added <a href="https://gohugo.io/">Hugo</a> bonus, here&rsquo;s how I generate the blog tags on my site:</p>
<div class="highlight"><pre class="chroma"><code class="language-html" data-lang="html">{{- if (.IsPage) and eq .Section &#34;blog&#34; -}}
<span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">&#34;twitter:label1&#34;</span> <span class="na">value</span><span class="o">=</span><span class="s">&#34;Posted in&#34;</span> <span class="p">/&gt;</span>
<span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">&#34;twitter:data1&#34;</span> <span class="na">value</span><span class="o">=</span><span class="s">&#34;{{ .Params.categories }}&#34;</span> <span class="p">/&gt;</span>
<span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">&#34;twitter:label2&#34;</span> <span class="na">value</span><span class="o">=</span><span class="s">&#34;Reading time&#34;</span> <span class="p">/&gt;</span>
<span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">&#34;twitter:data2&#34;</span> <span class="na">value</span><span class="o">=</span><span class="s">&#34;{{ .ReadingTime }} minute{{ if not (eq .ReadingTime 1) }}s{{ end }}&#34;</span> <span class="p">/&gt;</span>
{{- end -}}
</code></pre></div>]]>
      </description>
    </item>
    
  </channel>
</rss>