Skip to content

Commit

Permalink
Refactor node styles to use sass control flow
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispyles committed Jul 2, 2024
1 parent 98e7bf0 commit 6a77be3
Showing 1 changed file with 19 additions and 30 deletions.
49 changes: 19 additions & 30 deletions src/app/node/node.component.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@use 'sass:list';

$wall: 1px solid var(--border-color);
$size: 2rem;

Expand All @@ -12,42 +14,29 @@ $size: 2rem;
text-transform: uppercase;
width: $size;

&.up {
border-top: $wall;
}

&.right {
border-right: $wall;
}

&.down {
border-bottom: $wall;
}

&.left {
border-left: $wall;
@each $class,
$dir in ('up': 'top', 'right': 'right', 'down': 'bottom', 'left': 'left')
{
// Set a border in the direction indicated by the class.
&.#{$class} {
border-#{$dir}: $wall;
}

// Move the span's text content outside of the element in the direction indicated by which edge
// it's on, so that the endpoint arrows are rendered outside the maze edge.
&.endpoint-edge-#{$class} span {
@if list.index(('top', 'bottom'), $dir) {
#{$dir}: -95%;
} @else {
#{$dir}: -90%;
}
}
}

span {
position: absolute;
}

&.endpoint-edge-up span {
top: -95%;
}

&.endpoint-edge-right span {
right: -90%;
}

&.endpoint-edge-down span {
bottom: -95%;
}

&.endpoint-edge-left span {
left: -90%;
}

span.current-position,
span.historical-position {
background: var(--current-position-color);
Expand Down

0 comments on commit 6a77be3

Please sign in to comment.