Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.5 global config #76

Open
wants to merge 8 commits into
base: 0.5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/Avatar.astro
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
import type { ComponentProps } from 'astro/types'
import Image from 'fulldev-ui/components/Image.astro'
import fulldevConfig from 'virtual:fulldev-ui/config'

type Props = Omit<ComponentProps<typeof Image>, 'position' | 'frame'> & {
variant?: 'subtle' | 'outline' | 'ghost'
radius?: 'none' | 'auto' | 'full'
}

const { radius = 'auto', ...rest } = Astro.props
const { radius = fulldevConfig.radius ?? 'auto', ...rest } = Astro.props
---

<Image
Expand Down
3 changes: 2 additions & 1 deletion src/components/Badge.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type { HTMLTag, Polymorphic } from 'astro/types'
import Icon from 'fulldev-ui/components/Icon.astro'
import Root from 'fulldev-ui/components/Root.astro'
import fulldevConfig from 'virtual:fulldev-ui/config'

type Props<As extends HTMLTag = 'a'> = Polymorphic<{ as: As }> & {
radius?: 'none' | 'auto' | 'full'
Expand All @@ -18,7 +19,7 @@ const {
html,
text,
as = href ? 'a' : 'div',
radius = 'full',
radius = fulldevConfig.radius ?? 'full',
icon,
...rest
} = Astro.props
Expand Down
4 changes: 2 additions & 2 deletions src/components/Button.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { HTMLTag, Polymorphic } from 'astro/types'
import Avatar from 'fulldev-ui/components/Avatar.astro'
import Icon from 'fulldev-ui/components/Icon.astro'
import Root from 'fulldev-ui/components/Root.astro'

import fulldevConfig from 'virtual:fulldev-ui/config'
type Props<As extends HTMLTag = 'a'> = Polymorphic<{ as: As }> & {
variant?: 'primary' | 'secondary' | 'tertiary'
radius?: 'none' | 'auto' | 'full'
Expand All @@ -19,7 +19,7 @@ type Props<As extends HTMLTag = 'a'> = Polymorphic<{ as: As }> & {
const {
as = 'a',
variant = 'primary',
radius = 'auto',
radius = fulldevConfig.radius ?? 'auto',
avatar,
icon,
html,
Expand Down
3 changes: 2 additions & 1 deletion src/components/Card.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Spread from 'fulldev-ui/components/Spread.astro'
import Tagline from 'fulldev-ui/components/Tagline.astro'
import Text from 'fulldev-ui/components/Text.astro'
import Wrap from 'fulldev-ui/components/Wrap.astro'
import fulldevConfig from 'virtual:fulldev-ui/config'
import Badge from './Badge.astro'

type Props<As extends HTMLTag = 'a'> = Polymorphic<{ as: As }> & {
Expand Down Expand Up @@ -54,7 +55,7 @@ const {
as = href ? 'a' : 'div',
space = 'auto',
frame = 'none',
radius = 'auto',
radius = fulldevConfig.radius ?? 'auto',
align = 'start',
variant,
level = 4,
Expand Down
4 changes: 2 additions & 2 deletions src/components/Image.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { HTMLAttributes } from 'astro/types'
import { Image as AstroImage } from 'astro:assets'
import Root from 'fulldev-ui/components/Root.astro'
import { isString } from 'remeda'

import fulldevConfig from 'virtual:fulldev-ui/config'
type Props = HTMLAttributes<'img'> & {
position?: 'background' | 'cover' | 'inset'
ratio?: 'landscape' | 'portrait' | 'square' | number
Expand All @@ -29,7 +29,7 @@ const {
position,
frame,
width,
radius = 'auto',
radius = fulldevConfig.radius ?? 'auto',
height,
...rest
} = Astro.props
Expand Down
3 changes: 2 additions & 1 deletion src/components/Input.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { HTMLAttributes } from 'astro/types'
import Icon from 'fulldev-ui/components/Icon.astro'
import Label from 'fulldev-ui/components/Label.astro'
import Root from 'fulldev-ui/components/Root.astro'
import fulldevConfig from 'virtual:fulldev-ui/config'

type Props = HTMLAttributes<'input'> & {
variant?: 'outline'
Expand All @@ -19,7 +20,7 @@ const {
value,
disabled,
required,
radius = 'auto',
radius = fulldevConfig.radius ?? 'auto',
placeholder,
name = placeholder,
type = 'text',
Expand Down
3 changes: 2 additions & 1 deletion src/components/Select.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { HTMLAttributes } from 'astro/types'
import Icon from 'fulldev-ui/components/Icon.astro'
import Label from 'fulldev-ui/components/Label.astro'
import Root from 'fulldev-ui/components/Root.astro'
import fulldevConfig from 'virtual:fulldev-ui/config'

type Props = HTMLAttributes<'select'> & {
color?: 'base' | 'brand'
Expand All @@ -21,7 +22,7 @@ const {
value,
name,
required,
radius = 'auto',
radius = fulldevConfig.radius ?? 'auto',
disabled,
variant = 'outline',
...rest
Expand Down
10 changes: 8 additions & 2 deletions src/components/Table.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import type { HTMLAttributes } from 'astro/types'
import Root from 'fulldev-ui/components/Root.astro'

import fulldevConfig from 'virtual:fulldev-ui/config'
type Props = HTMLAttributes<'table'> & {
color?: 'base' | 'brand'
size?: 'sm' | 'md' | 'lg'
Expand All @@ -11,7 +11,13 @@ type Props = HTMLAttributes<'table'> & {
radius?: 'none' | 'auto'
}

const { header, body, footer, radius = 'auto', ...rest } = Astro.props
const {
header,
body,
footer,
radius = fulldevConfig.radius ?? 'auto',
...rest
} = Astro.props
---

<Root
Expand Down
4 changes: 2 additions & 2 deletions src/components/Textarea.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { HTMLAttributes } from 'astro/types'
import Label from 'fulldev-ui/components/Label.astro'
import Root from 'fulldev-ui/components/Root.astro'

import fulldevConfig from 'virtual:fulldev-ui/config'
type Props = HTMLAttributes<'textarea'> & {
radius?: 'none' | 'auto'
color?: 'base' | 'brand'
Expand All @@ -14,7 +14,7 @@ const {
placeholder,
name = placeholder,
variant = 'outline',
radius = 'auto',
radius = fulldevConfig.radius ?? 'auto',
label,
rows,
value,
Expand Down
7 changes: 6 additions & 1 deletion src/integration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface Config {
light?: Color
dark?: Color
}
radius?: 'none' | 'auto' | 'full'
}

const defaultConfig: Config = {
Expand All @@ -28,7 +29,9 @@ const defaultConfig: Config = {
brand: '#000',
},
},
radius: 'auto',
}

export default function fulldevIntegration(
userConfig?: Partial<Config>
): AstroIntegration {
Expand Down Expand Up @@ -125,7 +128,9 @@ export default function fulldevIntegration(
plugins: [
virtual({
'virtual:astro/config': `export default ${JSON.stringify(astroConfig)}`,
'virtual:fulldev-ui/config': `export default ${JSON.stringify(config)}`,
'virtual:fulldev-ui/config': `export default ${JSON.stringify({
...config,
})}`,
'virtual:colors.css': css,
}),
],
Expand Down
5 changes: 5 additions & 0 deletions src/types/virtual-modules.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module 'virtual:*' {
import type { Config } from 'fulldev-ui/integration'
const content: Config
export default content
}