Skip to content

Commit

Permalink
Use CSS conic gradient to create rainbow ring instead of SVG
Browse files Browse the repository at this point in the history
  • Loading branch information
AVGVSTVS96 committed Mar 9, 2024
1 parent 4433cc8 commit 44ef17d
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions src/components/subComponents/ThemeSwitcher.astro
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ const themeOptions = [
---

<div class="theme-switcher">
<DropdownMenu
name="color"
links={themeOptions}
showCaret={true}
icon={true}
/>
<DropdownMenu name="" links={themeOptions} showCaret={true} icon={false}>
<slot name="icon" slot="icon">
<div
class="rainbow-ring before:ring-[0.7px] before:ring-primary-300 before:dark:ring-primary-950">
</div>
</slot>
</DropdownMenu>
</div>

<script is:inline>
Expand All @@ -47,7 +48,29 @@ const themeOptions = [
});
</script>
<style is:global>
[data-icon='color'] {
@apply text-accent-400;
:root {
--ring-size: 26px;
--rainbow-width: 19px;
}
</style>

.rainbow-ring {
display: inline-block;
width: var(--ring-size);
height: var(--ring-size);
border-radius: 50%;
background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
position: relative;
}

.rainbow-ring::before {
content: '';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: var(--rainbow-width);
height: var(--rainbow-width);
border-radius: 50%;
background: var(--accent-500);
}
</style>

0 comments on commit 44ef17d

Please sign in to comment.