From 707a209424f3a82868935dd46591c318e700355c Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Sun, 25 Aug 2024 00:12:00 +0800 Subject: [PATCH] refactor: improve heading layout --- _sass/addon/commons.scss | 21 +++++++++++++++------ _sass/addon/module.scss | 11 ----------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/_sass/addon/commons.scss b/_sass/addon/commons.scss index 5412b92..2735eb8 100644 --- a/_sass/addon/commons.scss +++ b/_sass/addon/commons.scss @@ -42,20 +42,29 @@ body { @extend %heading; @if $i > 1 { - @extend %section; @extend %anchor; } @if $i < 5 { - $factor: 0.18rem; + $size-factor: 0.25rem; - @if $i == 1 { - $factor: 0.23rem; + @if $i > 1 { + $size-factor: 0.18rem; + + main & { + @if $i == 2 { + margin: 2.5rem 0 1.25rem; + } @else { + margin: 2rem 0 1rem; + } + } } - font-size: 1rem + (5 - $i) * $factor; + & { + font-size: 1rem + (5 - $i) * $size-factor; + } } @else { - font-size: 1rem; + font-size: 1.05rem; } } } diff --git a/_sass/addon/module.scss b/_sass/addon/module.scss index 9e85adc..77fecca 100644 --- a/_sass/addon/module.scss +++ b/_sass/addon/module.scss @@ -10,17 +10,6 @@ font-family: $font-family-heading; } -%section { - main & { - margin-top: 2.5rem; - margin-bottom: 1.25rem; - - &:focus { - outline: none; /* avoid outline in Safari */ - } - } -} - %anchor { .anchor { font-size: 80%;