From 813ec7d294f9ed5c17d1eab52f35196a34bf011c Mon Sep 17 00:00:00 2001 From: Azalea <22280294+hykilpikonna@users.noreply.github.com> Date: Fri, 20 Dec 2024 04:37:51 -0500 Subject: [PATCH] [O] Migrate sass import --- AquaNet/src/App.svelte | 10 +- AquaNet/src/app.sass | 99 ++++++++++--------- AquaNet/src/components/ActionCard.svelte | 10 +- AquaNet/src/components/CommunityCard.svelte | 10 +- AquaNet/src/components/RankDetails.svelte | 8 +- AquaNet/src/components/RatingCompSong.svelte | 18 ++-- .../src/components/RatingComposition.svelte | 6 +- AquaNet/src/components/Tooltip.svelte | 4 +- AquaNet/src/components/UserBox.svelte | 8 +- AquaNet/src/components/UserCard.svelte | 4 +- AquaNet/src/pages/Home.svelte | 4 +- .../src/pages/Home/ImportDataAction.svelte | 8 +- AquaNet/src/pages/Home/LinkCard.svelte | 8 +- AquaNet/src/pages/Ranking.svelte | 10 +- AquaNet/src/pages/User/Settings.svelte | 4 +- AquaNet/src/pages/UserHome.svelte | 38 +++---- AquaNet/src/pages/Welcome.svelte | 10 +- AquaNet/tools/migrate.py | 76 ++++++++++++++ 18 files changed, 206 insertions(+), 129 deletions(-) create mode 100644 AquaNet/tools/migrate.py diff --git a/AquaNet/src/App.svelte b/AquaNet/src/App.svelte index 5e77378e..57a734c0 100644 --- a/AquaNet/src/App.svelte +++ b/AquaNet/src/App.svelte @@ -60,14 +60,14 @@ diff --git a/AquaNet/src/app.sass b/AquaNet/src/app.sass index c9956cf2..4df49e31 100644 --- a/AquaNet/src/app.sass +++ b/AquaNet/src/app.sass @@ -1,11 +1,12 @@ -@import "vars" +@use "sass:color" +@use "vars" @import 'lxgw-wenkai-lite-webfont/style.css' html height: 100% body - font-family: $font + font-family: vars.$font line-height: 1.5 font-weight: 400 width: 100% @@ -15,7 +16,7 @@ body color-scheme: dark color: rgba(255, 255, 255, 0.87) - background-color: $c-bg + background-color: vars.$c-bg font-synthesis: none text-rendering: optimizeLegibility @@ -24,11 +25,11 @@ body a font-weight: 500 - color: $c-main + color: vars.$c-main text-decoration: inherit a:hover - color: $c-main + color: vars.$c-main h1 font-size: 3.2em @@ -39,9 +40,9 @@ h1 display: flex flex-direction: column - border-radius: $border-radius + border-radius: vars.$border-radius padding: 12px 16px - background: $ov-light + background: vars.$ov-light blockquote @@ -51,7 +52,7 @@ blockquote padding: 10px 20px 10px 20px margin: 16px 0 border-left: solid #ff7c7c 3px - border-radius: $border-radius + border-radius: vars.$border-radius #app @@ -67,29 +68,29 @@ main:not(.no-margin) button - border-radius: $border-radius + border-radius: vars.$border-radius border: 1px solid transparent padding: 0.6em 1.2em font-size: 1em font-weight: 500 font-family: inherit - background-color: $ov-lighter + background-color: vars.$ov-lighter opacity: 0.9 cursor: pointer - transition: $transition + transition: vars.$transition button:hover - border-color: $c-main + border-color: vars.$c-main button:focus, button:focus-visible - color: $c-main + color: vars.$c-main outline: none button.error color: unset &:hover - border-color: $c-error - color: $c-error + border-color: vars.$c-error + color: vars.$c-error //background: $c-error //border-color: transparent @@ -120,29 +121,29 @@ button.icon --lv-color: 194, 153, 231 .error - color: $c-error + color: vars.$c-error input - border-radius: $border-radius + border-radius: vars.$border-radius border: 1px solid transparent padding: 0.6em 1.2em font-size: 1em font-weight: 500 font-family: inherit - background-color: $ov-lighter - transition: $transition + background-color: vars.$ov-lighter + transition: vars.$transition box-sizing: border-box // Dropdown select - border-radius: $border-radius + border-radius: vars.$border-radius border: 1px solid transparent padding: 0.6em 1.2em font-size: 1em font-weight: 500 font-family: inherit - background-color: $ov-lighter - transition: $transition + background-color: vars.$ov-lighter + transition: vars.$transition box-sizing: border-box option @@ -157,25 +158,25 @@ input[type="checkbox"] height: 1.2em margin: 0 padding: 0 - border: 1px solid $c-main - background-color: $ov-lighter + border: 1px solid vars.$c-main + background-color: vars.$ov-lighter appearance: none cursor: pointer flex-shrink: 0 &:checked - background-color: $c-main - border-color: $c-main + background-color: vars.$c-main + border-color: vars.$c-main label cursor: pointer input:focus, input:focus-visible - border: 1px solid $c-main + border: 1px solid vars.$c-main outline: none input.error - border: 1px solid $c-error + border: 1px solid vars.$c-error .flex-center display: flex @@ -201,30 +202,30 @@ input.error margin: 100px auto 0 padding: 32px 32px 128px min-height: 100% - max-width: $w-max + max-width: vars.$w-max - background-color: darken($c-bg, 3%) + background-color: color.adjust(vars.$c-bg, $lightness: -3%) border-radius: 16px 16px 0 0 - @media (max-width: #{$w-max + (64px) * 2}) + @media (max-width: #{vars.$w-max + (64px) * 2}) margin: 100px 32px 0 - @media (max-width: $w-mobile) + @media (max-width: vars.$w-mobile) margin: 100px 0 0 .fw-block margin-left: -32px margin-right: -32px padding: 12px 32px - background-color: $ov-darker + background-color: vars.$ov-darker // Inner shadow - box-shadow: inset 0 10px 10px -2px $c-shadow, inset 0 -10px 10px -2px $c-shadow + box-shadow: inset 0 10px 10px -2px vars.$c-shadow, inset 0 -10px 10px -2px vars.$c-shadow > h2.outer-title, > .outer-title-options margin-top: -5rem margin-bottom: 1rem - @media (max-width: $w-mobile) + @media (max-width: vars.$w-mobile) text-align: center > .outer-title-options @@ -238,7 +239,7 @@ input.error gap: 10px top: 4px - @media (max-width: $w-mobile) + @media (max-width: vars.$w-mobile) flex-direction: column > h2, > .outer-title-options > h2 @@ -257,15 +258,15 @@ main.content position: absolute inset: 0 top: 100px - background: rgba(darken($c-bg, 3%), 0.9) + background: rgba(color.adjust(vars.$c-bg, $lightness: -3%), 0.9) backdrop-filter: blur(5px) box-shadow: 0 0 10px 6px rgba(black, 0.4) - max-width: calc($w-max + 20px) + max-width: calc(vars.$w-max + 20px) - @media (max-width: #{$w-max + (64px) * 2}) + @media (max-width: #{vars.$w-max + (64px) * 2}) margin: 100px 22px 0 - @media (max-width: $w-mobile) + @media (max-width: vars.$w-mobile) margin: 100px 0 0 @@ -289,9 +290,9 @@ main.content margin: 0 > div - background-color: $c-bg + background-color: vars.$c-bg padding: 2rem - border-radius: $border-radius + border-radius: vars.$border-radius display: flex flex-direction: column @@ -305,7 +306,7 @@ main.content nav > div, > a cursor: pointer - transition: $transition + transition: vars.$transition text-decoration: underline 1px solid transparent text-underline-offset: 0.1em @@ -315,12 +316,12 @@ nav font-weight: unset &:hover - color: $c-main - text-decoration-color: $c-main + color: vars.$c-main + text-decoration-color: vars.$c-main text-underline-offset: 0.5em &.active - color: $c-main + color: vars.$c-main .hide-scrollbar @@ -331,11 +332,11 @@ nav .aqua-tooltip - box-shadow: 0 0 5px 0 $c-shadow - border-radius: $border-radius + box-shadow: 0 0 5px 0 vars.$c-shadow + border-radius: vars.$border-radius position: absolute padding: 4px 8px - background: $ov-lighter + background: vars.$ov-lighter backdrop-filter: blur(5px) diff --git a/AquaNet/src/components/ActionCard.svelte b/AquaNet/src/components/ActionCard.svelte index c641a850..3bb44ac7 100644 --- a/AquaNet/src/components/ActionCard.svelte +++ b/AquaNet/src/components/ActionCard.svelte @@ -30,13 +30,13 @@ diff --git a/AquaNet/src/components/RankDetails.svelte b/AquaNet/src/components/RankDetails.svelte index 2cbcd688..6696eb2f 100644 --- a/AquaNet/src/components/RankDetails.svelte +++ b/AquaNet/src/components/RankDetails.svelte @@ -35,7 +35,7 @@ diff --git a/AquaNet/src/components/RatingCompSong.svelte b/AquaNet/src/components/RatingCompSong.svelte index d1393b14..925cc585 100644 --- a/AquaNet/src/components/RatingCompSong.svelte +++ b/AquaNet/src/components/RatingCompSong.svelte @@ -66,19 +66,19 @@ diff --git a/AquaNet/src/components/RatingComposition.svelte b/AquaNet/src/components/RatingComposition.svelte index 4ed01055..57aeb1f8 100644 --- a/AquaNet/src/components/RatingComposition.svelte +++ b/AquaNet/src/components/RatingComposition.svelte @@ -25,17 +25,17 @@ {/if} diff --git a/AquaNet/src/components/Tooltip.svelte b/AquaNet/src/components/Tooltip.svelte index 7bf805f2..d5316e26 100644 --- a/AquaNet/src/components/Tooltip.svelte +++ b/AquaNet/src/components/Tooltip.svelte @@ -56,14 +56,14 @@ {/if} diff --git a/AquaNet/src/pages/User/Settings.svelte b/AquaNet/src/pages/User/Settings.svelte index 28800b53..8f1a0cb9 100644 --- a/AquaNet/src/pages/User/Settings.svelte +++ b/AquaNet/src/pages/User/Settings.svelte @@ -156,7 +156,7 @@ diff --git a/AquaNet/src/pages/UserHome.svelte b/AquaNet/src/pages/UserHome.svelte index 2ea2b8dd..c21f986d 100644 --- a/AquaNet/src/pages/UserHome.svelte +++ b/AquaNet/src/pages/UserHome.svelte @@ -294,13 +294,13 @@ diff --git a/AquaNet/src/pages/Welcome.svelte b/AquaNet/src/pages/Welcome.svelte index 4de90784..f01748c9 100644 --- a/AquaNet/src/pages/Welcome.svelte +++ b/AquaNet/src/pages/Welcome.svelte @@ -157,7 +157,7 @@ + style_pattern = re.compile(r'(.*?)', re.DOTALL) + + # Extract all matching style blocks + matches = list(style_pattern.finditer(content)) + + if not matches: + print(f"No block + sass_content = match.group(1) # The content inside the ' + + # Replace the original style block with the new one + updated_content = updated_content.replace(original_style_block, new_style_block) + + # Remove the temporary file + temp_file_path.unlink() + + # Write the updated content back to the original file + with open(file_path, 'w', encoding='utf-8') as file: + file.write(updated_content) + + print(f"Updated {file_path}") + +def process_svelte_files(directory): + """Recursively processes all .svelte files in the given directory.""" + + svelte_files = pathlib.Path(directory).rglob("*.svelte") + + for svelte_file in svelte_files: + extract_and_migrate_sass(svelte_file) + +def main(): + """Main function to process all .svelte files in the current directory.""" + + current_directory = pathlib.Path(__file__).parent + process_svelte_files(current_directory) + +if __name__ == "__main__": + main()