Skip to content

Commit

Permalink
fix lines for lower resolution screens
Browse files Browse the repository at this point in the history
  • Loading branch information
meodai committed Jun 11, 2024
1 parent f707f5f commit b194275
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 6 deletions.
17 changes: 14 additions & 3 deletions site/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import Cube from './lib/Cube.svelte';
import NamedSwatches from './lib/NamedSwatches.svelte';
import Sphere from './lib/Sphere.svelte';
import Donut from './lib/Donut.svelte';
import { getColorsHSL } from './lib/fn/getColorsHSL';
import { colorsToGradient } from './lib/fn/colorsToGradient';
Expand Down Expand Up @@ -111,7 +112,7 @@
title="Presets"
>
<svg class="navicon" viewBox="0 0 100 100">
<g stroke="currentColor" transform-origin="50 50" transform="rotate(-22.5)">
<g stroke="var(--line, currentColor)" transform-origin="50 50" transform="rotate(-22.5)">
<circle cx="50" cy="50" r="50" vector-effect="non-scaling-stroke" />
<line x1="0" y1="50" x2="100" y2="50" transform="rotate(-45)" transform-origin="50 50" vector-effect="non-scaling-stroke"/>
<line x1="0" y1="50" x2="100" y2="50" transform="rotate(45)" transform-origin="50 50" vector-effect="non-scaling-stroke"/>
Expand Down Expand Up @@ -267,6 +268,8 @@
</g>
</svg>
</a>

<Donut />

<!--h2>Current Colors</h2-->
<code><pre>{cubeString}</pre></code>
Expand All @@ -290,7 +293,8 @@
.layout {
--bg: var(--white);
--onBg: var(--black);
--line: var(--onBg);
--line: color-mix(in srgb, var(--onBg) 40%, var(--bg));
--lineInverse: var(--bg);
height: 100dvh;
Expand All @@ -304,6 +308,13 @@
color: var(--onBg);
}
@media (min-resolution: 2dppx) {
.layout {
--line: var(--onBg);
}
}
.layout--dev {
--bg: var(--black);
Expand Down Expand Up @@ -682,7 +693,7 @@
.navicon g,
.navicon line,
.navicon circle {
stroke: currentColor;
stroke: var(--line, currentColor);
stroke-width: calc(var(--lineWidth) * .6);
fill: none;
}
Expand Down
8 changes: 7 additions & 1 deletion site/src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,13 @@ h6 {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;

--lineWidth: min(.51px, 0.05rem);
--lineWidth: 1px;
}

@media (min-resolution: 2dppx) {
:root {
--lineWidth: min(.51px, 0.05rem);
}
}

h1, h2, h3, h4, h5, h6 {
Expand Down
4 changes: 2 additions & 2 deletions site/src/lib/Cube.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@
}
.cube g {
stroke: currentColor;
stroke: var(--line, currentColor);
stroke-width: var(--lineWidth);
fill: none;
}
Expand All @@ -429,7 +429,7 @@
.cube__coverline {
fill: none;
stroke: var(--black);
stroke: var(--line);
stroke-dasharray: 1.5 1.5;
}
</style>
47 changes: 47 additions & 0 deletions site/src/lib/Donut.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<script lang="ts">
export let hasPerspective = true;
</script>

<div class="donut{ hasPerspective ? ' donut--perspective' : ''}">
<div class="donut__segments">
</div>
</div>

<style>
.donut {
position: relative;
width: 100%;
aspect-ratio: 1;
}
.donut--perspective {
perspective: 10000px;
}
.donut__segments {
position: absolute;
inset: 0;
background: conic-gradient(var(--stops-48));
border-radius: 50%;
}
.donut--perspective .donut__segments {
transform-style: preserve-3d;
transform: rotateX(45deg);
}
.donut__segments::after {
content: '';
inset: 0;
position: absolute;
background: var(--bg);
transform: scale(.7);
border-radius: 50%;
transition: 200ms transform cubic-bezier(0.3, 0.7, 0, 1);
}
.donut__segments:hover::after {
transform: scale(.35);
}
</style>

0 comments on commit b194275

Please sign in to comment.