Skip to content

Commit 9734416

Browse files
authored
fix: improve atom components & adjust components styles (#5)
* fix: use proper id for root portals * cleanup code * feat: add storybook scripts for development, building, and serving * fix: update button styles for improved visual consistency * fix: refine snippet condition and include base prop in rendering * fix: update background color for input component * fix: replace div with Input.Root for textarea component structure * bump version to 1.0.0-alpha.18
1 parent 339392e commit 9734416

File tree

8 files changed

+15
-17
lines changed

8 files changed

+15
-17
lines changed

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@svelte-atoms/core",
3-
"version": "1.0.0-alpha.17",
3+
"version": "1.0.0-alpha.18",
44
"description": "A modular, accessible, and extensible Svelte UI component library.",
55
"repository": {
66
"type": "git",
@@ -25,8 +25,9 @@
2525
"test:unit": "vitest",
2626
"test": "npm run test:unit -- --run && npm run test:e2e",
2727
"test:e2e": "playwright test",
28-
"storybook": "storybook dev -p 6006 --no-open",
29-
"build-storybook": "storybook build"
28+
"storybook:dev": "storybook dev -p 6006 --no-open",
29+
"storybook:build": "storybook build",
30+
"storybook:serve": "bunx http-server ./storybook-static"
3031
},
3132
"files": [
3233
"dist",

src/lib/components/atom/html-atom.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
...restProps
1818
}: HtmlAtomProps<E, B> & HTMLAttributes<Element> = $props();
1919
20-
const isSnippet = typeof base === 'function' && base.name !== 'wrapper';
20+
const isSnippet = $derived(typeof base === 'function' && base.length === 1 && !base.prototype);
2121
2222
const snippet = $derived(base as SnippetBase);
2323
@@ -27,7 +27,7 @@
2727
</script>
2828

2929
{#if isSnippet}
30-
{@render snippet({ class: cn(klass), as, children, ...restProps })}
30+
{@render snippet({ class: cn(klass), as, base, children, ...restProps })}
3131
{:else}
3232
<Component class={cn(klass)} {as} {...restProps}>
3333
{@render children?.()}

src/lib/components/button/button.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<HtmlAtom
2525
as="button"
2626
class={[
27-
'button text-foreground bg-foreground/10 hover:bg-foreground/15 active:bg-foreground/20 w-fit cursor-pointer rounded-md px-3 py-2 transition-colors duration-200',
27+
'button text-primary-foreground bg-primary hover:bg-primary/95 active:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground w-fit cursor-pointer rounded-md px-3 py-2 transition-colors duration-200',
2828
toClassValue.apply(null, [preset?.class]),
2929
toClassValue.apply(null, [klass])
3030
]}

src/lib/components/input/input-root.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171

7272
<HtmlAtom
7373
class={[
74-
'border-border text-foreground bg-background relative flex h-10 items-center overflow-hidden rounded-md border',
74+
'border-border text-foreground bg-input relative flex h-10 items-center overflow-hidden rounded-md border',
7575
toClassValue.apply(bond, [preset?.class]),
7676
toClassValue.apply(bond, [klass])
7777
]}

src/lib/components/portal/portal-inner.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
22
import type { HTMLAttributes } from 'svelte/elements';
33
import { PortalBond } from './bond.svelte';
4-
import { toClassValue, cn } from '$svelte-atoms/core/utils';
4+
import { toClassValue } from '$svelte-atoms/core/utils';
55
import {
66
HtmlAtom,
77
type ElementType,

src/lib/components/portal/portal-root.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
type HtmlAtomProps,
2121
type Base
2222
} from '$svelte-atoms/core/components/atom';
23-
import { toClassValue, cn, defineProperty, defineState } from '$svelte-atoms/core/utils';
23+
import { toClassValue, defineProperty, defineState } from '$svelte-atoms/core/utils';
2424
import { getPreset } from '$svelte-atoms/core/context';
2525
2626
type Element = ElementType<E>;

src/lib/components/root/root.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
)}
7474
{...restProps}
7575
>
76-
<Portals id="root fixed">
76+
<Portals id="root">
7777
{#if portals}
7878
{@render portals?.()}
7979
{:else}
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
<script>
2-
import { cn } from '$svelte-atoms/core/utils';
2+
import { Input } from '../input';
33
4-
let { class: klass = '', children, ...restProps } = $props();
4+
let { children, ...restProps } = $props();
55
</script>
66

7-
<div
8-
class={['border-stroke-0/50 bg-background-0 w-full rounded-lg border p-2', klass]}
9-
{...restProps}
10-
>
7+
<Input.Root {...restProps}>
118
{@render children?.()}
12-
</div>
9+
</Input.Root>

0 commit comments

Comments
 (0)