One of the people studying the course pointed out that aspect-ratio is fully supported everywhere, so I've made a change to test it and see how well it's working.

main
Zed A. Shaw 2 years ago
parent 47f4e0c7e9
commit 8f515bf094
  1. 27
      client/components/IconImage.svelte
  2. 6
      rendered/Header.svelte
  3. 2
      rendered/pages/docs/howto/index.svelte
  4. 4
      static/blockstart.css
  5. 24
      static/global.css

@ -27,10 +27,11 @@
<style> <style>
.iconimage-container { .iconimage-container {
text-align: center;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
align-content: center;
text-align: center;
} }
.feather { .feather {
@ -39,20 +40,18 @@
} }
</style> </style>
<div style="--aspect-ratio: { aspect_ratio }; color: {pattern_color || random_pattern}; background-color: {background || random_background}; width: { width }; height: { height }; filter: grayscale({ grayscale });"> <div style="aspect-ratio: { aspect_ratio }; color: {pattern_color || random_pattern}; background-color: {background || random_background}; width: { width }; height: { height }; filter: grayscale({ grayscale });" data-testid={testid} class="pattern-{pattern} iconimage-container">
<div data-testid={testid} class="pattern-{ pattern } iconimage-container">
{#if name} {#if name}
<svg class="icon-{name} feather" <svg class="icon-{name} feather"
fill="{fill_color}" fill="{fill_color}"
stroke="{color}" stroke="{color}"
stroke-width="{thickness}" stroke-width="{thickness}"
stroke-linecap="{linecap}" stroke-linecap="{linecap}"
stroke-linejoin="{linejoin}" stroke-linejoin="{linejoin}"
> >
<use href="/icon-sprites.svg#{name}"/> <use href="/icon-sprites.svg#{name}"/>
</svg> </svg>
{:else} {:else}
<slot></slot> <slot></slot>
{/if} {/if}
</div>
</div> </div>

@ -1,7 +1,5 @@
<script> <script>
import { logout_user } from '$/client/api.js';
import Icon from '$/client/components/Icon.svelte'; import Icon from '$/client/components/Icon.svelte';
import {link} from 'svelte-spa-router';
import { register_enabled } from "$/client/config.js"; import { register_enabled } from "$/client/config.js";
export let fixed = false; export let fixed = false;
@ -46,7 +44,7 @@
<header class:fixed> <header class:fixed>
<nav> <nav>
<a href="/intro/" use:link id="logo">The Bandolier</a> <a href="/client/#/intro/" id="logo">The Bandolier</a>
<ul> <ul>
{#if register_enabled} {#if register_enabled}
<li><a id="register-button" href="/client/#/register/"> <li><a id="register-button" href="/client/#/register/">
@ -60,7 +58,7 @@
</a> </a>
</li> </li>
{/if} {/if}
<li><a href="/login/" use:link><Icon color="var(--value7)" name="log-in" tooltip="Log in." /></a></li> <li><a href="/client/#/login/"><Icon color="var(--value7)" name="log-in" tooltip="Log in." /></a></li>
<li><a href="/client/#/"><Icon color="var(--value7)" name="book" tooltip="Docs" /></a></li> <li><a href="/client/#/"><Icon color="var(--value7)" name="book" tooltip="Docs" /></a></li>
</ul> </ul>
</nav> </nav>

@ -49,7 +49,7 @@
<tile> <tile>
<left> <left>
<a href="/docs/howto/{ post.metadata.slug }/"> <a href="/docs/howto/{ post.metadata.slug }/">
<IconImage width="100%" height="100%" name={ post.metadata.icon } pattern={ false }/> <IconImage name={ post.metadata.icon } pattern={ false }/>
</a> </a>
</left> </left>
<middle> <middle>

@ -238,3 +238,7 @@ button {
button:hover { button:hover {
filter: brightness(90%); filter: brightness(90%);
} }
[style*="--aspect-ratio"] {
aspect-ratio: var(--aspect-ratio);
}

@ -1310,27 +1310,11 @@ breadcrumb {
z-index: 10; z-index: 10;
} }
/* Taken from https://css-tricks.com/aspect-ratio-boxes/#using-custom-properties */ /* Testing if this is actually available everywhere. This will go away after a while unless
[style*="--aspect-ratio"] > img { * I have to fix aspect-ratio. For now it's just for backward compatibility.
height: auto; */
}
[style*="--aspect-ratio"] { [style*="--aspect-ratio"] {
position: relative; aspect-ratio: var(--aspect-ratio);
}
[style*="--aspect-ratio"]::before {
content: "";
display: block;
padding-bottom: calc(100% / (var(--aspect-ratio)));
}
[style*="--aspect-ratio"] > :first-child {
width: 100%;
position: absolute;
top: 0;
left: 0;
height: 100%;
} }
main.centered { main.centered {

Loading…
Cancel
Save