🛠️ Create shared UI styles for buttons & inputs

This commit is contained in:
pheralb 2024-01-24 11:01:38 +00:00
parent 37b457ddf1
commit 49e1927e7e
5 changed files with 22 additions and 15 deletions

View File

@ -57,7 +57,7 @@
<div class="flex items-center space-x-2 hover:opacity-80 transition-opacity"> <div class="flex items-center space-x-2 hover:opacity-80 transition-opacity">
<svelte:component this={Logo} /> <svelte:component this={Logo} />
<span class="text-[19px] font-medium tracking-wide hidden md:block">svgl</span> <span class="text-[19px] font-medium tracking-wide hidden md:block">svgl</span>
<p class="text-neutral-400 hidden md:block font-mono">v4.0</p> <p class="text-neutral-400 hidden md:block font-mono">v4.1</p>
</div> </div>
</a> </a>
</div> </div>

View File

@ -1,4 +1,5 @@
<script lang="ts"> <script lang="ts">
import { buttonStyles } from '@/ui/styles';
export let notFoundTerm: string; export let notFoundTerm: string;
import { PackageOpen, ArrowUpRight } from 'lucide-svelte'; import { PackageOpen, ArrowUpRight } from 'lucide-svelte';
</script> </script>
@ -11,15 +12,15 @@
<a <a
href="https://github.com/pheralb/svgl?tab=readme-ov-file#-getting-started" href="https://github.com/pheralb/svgl?tab=readme-ov-file#-getting-started"
target="_blank" target="_blank"
class="flex items-center space-x-2 rounded-md border border-neutral-300 p-2 duration-100 hover:bg-neutral-200 dark:border-neutral-700 dark:hover:bg-neutral-700/40" class={buttonStyles}
> >
<span>Submit logo</span> <span>Submit logo</span>
<ArrowUpRight size={16} /> <ArrowUpRight size={16} />
</a> </a>
<a <a
href="https://github.com/pheralb/svgl/issues/new" href="https://github.com/pheralb/svgl/issues/new?assignees=pheralb&labels=request&projects=&template=request-svg-.md&title=%5BRequest%5D%3A"
target="_blank" target="_blank"
class="flex items-center space-x-2 rounded-md border border-neutral-300 p-2 duration-100 hover:bg-neutral-200 dark:border-neutral-700 dark:hover:bg-neutral-700/40" class={buttonStyles}
> >
<span>Request SVG</span> <span>Request SVG</span>
<ArrowUpRight size={16} /> <ArrowUpRight size={16} />

View File

@ -1,4 +1,5 @@
<script lang="ts"> <script lang="ts">
import { inputStyles } from '@/ui/styles';
import { Command, SearchIcon } from 'lucide-svelte'; import { Command, SearchIcon } from 'lucide-svelte';
export let searchTerm: string; export let searchTerm: string;
export let placeholder: string = 'Search...'; export let placeholder: string = 'Search...';
@ -36,7 +37,7 @@
type="text" type="text"
{placeholder} {placeholder}
autocomplete="off" autocomplete="off"
class="w-full border-b border-neutral-300 bg-white p-3 px-11 placeholder-neutral-500 focus:outline-none focus:ring-1 focus:ring-neutral-300 dark:border-neutral-800 dark:bg-neutral-900 dark:focus:ring-neutral-700" class={inputStyles}
bind:value={searchTerm} bind:value={searchTerm}
on:input on:input
use:focusInput use:focusInput

View File

@ -15,6 +15,7 @@
// Icons: // Icons:
import { ArrowDown, ArrowDownUpIcon, ArrowUpDownIcon } from 'lucide-svelte'; import { ArrowDown, ArrowDownUpIcon, ArrowUpDownIcon } from 'lucide-svelte';
import { buttonStyles } from '@/ui/styles';
let sorted: boolean = false; let sorted: boolean = false;
let isFirstLoad: boolean = true; let isFirstLoad: boolean = true;
@ -117,15 +118,14 @@
</Grid> </Grid>
{#if filteredSvgs.length > 30 && !showAll} {#if filteredSvgs.length > 30 && !showAll}
<div class="flex items-center justify-center mt-4"> <div class="flex items-center justify-center mt-4">
<button <button class={buttonStyles} on:click={() => (showAll = true)}>
class="flex items-center space-x-2 rounded-md border border-neutral-300 p-2 duration-100 hover:bg-neutral-200 dark:border-neutral-700 dark:hover:bg-neutral-700/40" <div class="flex items-center space-x-2 relative">
on:click={() => (showAll = true)}
>
<ArrowDown size={16} strokeWidth={2} /> <ArrowDown size={16} strokeWidth={2} />
<span>Load All SVGs</span> <span>Load All SVGs</span>
<span class="opacity-70"> <span class="opacity-70">
({filteredSvgs.length - 30} more) ({filteredSvgs.length - 30} more)
</span> </span>
</div>
</button> </button>
</div> </div>
{/if} {/if}

5
src/ui/styles.ts Normal file
View File

@ -0,0 +1,5 @@
export const buttonStyles =
'flex items-center space-x-2 relative h-10 overflow-hidden rounded-md border border-neutral-200 dark:border-neutral-800 bg-transparent px-4 text-neutral-950 dark:text-white hover:bg-neutral-200/50 dark:hover:bg-neutral-800/50 focus:outline-none focus:ring-1 focus:ring-neutral-300 dark:focus:ring-neutral-700 transition-colors duration-200';
export const inputStyles =
'w-full border-b border-neutral-300 bg-white p-3 px-11 placeholder-neutral-500 focus:outline-none focus:ring-1 focus:ring-neutral-300 dark:border-neutral-800 dark:bg-neutral-900 dark:focus:ring-neutral-700';