Skip to content

Commit 884f9d9

Browse files
committed
U
1 parent 81899af commit 884f9d9

15 files changed

Lines changed: 372 additions & 33 deletions

File tree

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "@shilong/ui",
2+
"name": "@shilong/react",
33
"version": "0.0.0",
44
"packageManager": "pnpm@10.6.3",
5-
"description": "A starter for creating a React component library.",
5+
"description": "A simple react ui component",
66
"type": "module",
77
"license": "MIT",
88
"homepage": "https://github.com/author/library#readme",
@@ -61,9 +61,12 @@
6161
"typescript": "^5.8.3",
6262
"vite": "^7.1.1",
6363
"vite-plugin-dts": "^4.5.4",
64-
"vitest": "^3.1.3"
64+
"vitest": "^3.1.3",
65+
"prettier": "^3.6.2",
66+
"prettier-plugin-tailwindcss": "^0.6.14"
6567
},
6668
"dependencies": {
69+
"@floating-ui/react": "^0.27.15",
6770
"@shilong/utils": "^0.0.9",
6871
"sonner": "^2.0.7"
6972
},

playground/src/App.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1-
import { Button, Input, Toaster, toast } from '@shilong/ui'
1+
import { Button, Input, Popover, Toaster, Tooltip, toast } from '@shilong/ui'
22

33
export function App() {
44
return (
55
<>
66
<Input />
77
<Button onClick={() => toast('nih')}>Toast</Button>
88
<Toaster position="top-center" />
9+
<Popover trigger={<Button>Trigger</Button>}>
10+
<div>nihao</div>
11+
</Popover>
12+
13+
<Popover trigger={<Button>Trigger1</Button>}>
14+
<>nihao</>
15+
</Popover>
16+
17+
<Tooltip trigger={<Button variant="outline">E</Button>} arrow>
18+
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Maiores minus
19+
suscipit distinctio asperiores vero molestias, quos rerum aliquid? Et
20+
nulla ducimus, qui repudiandae culpa quod pariatur ipsam aut magni sint.
21+
</Tooltip>
922
</>
1023
)
1124
}

pnpm-lock.yaml

Lines changed: 132 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/activity/index.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React, { type PropsWithChildren } from 'react'
2+
3+
export const Activity = (
4+
props: PropsWithChildren<{ mode: 'visible' | 'hidden' }>,
5+
) => {
6+
const { mode, ...reset } = props
7+
8+
const Comp = Reflect.get(React, 'unstable_Activity')
9+
10+
if (Comp) {
11+
return <Comp {...props} />
12+
}
13+
14+
return (
15+
<div
16+
data-slot="sl-activity"
17+
style={{
18+
display: mode === 'visible' ? 'block' : 'none',
19+
}}
20+
{...reset}
21+
/>
22+
)
23+
}

src/components/button/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { cva, type VariantProps } from '@shilong/utils'
2-
import './index.css'
2+
import './style.css'
33

4-
const getBtnClx = cva( {
4+
const getBtnClx = cva({
55
base: 'slButtonBase',
66
variants: {
77
variant: {
@@ -32,6 +32,10 @@ export const Button = (props: ButtonProps) => {
3232
const { className, variant, size, ...reset } = props
3333

3434
return (
35-
<button {...reset} className={getBtnClx({ variant, size, className })} />
35+
<button
36+
data-slot="sl-button"
37+
className={getBtnClx({ variant, size, className })}
38+
{...reset}
39+
/>
3640
)
3741
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@reference "../../global.css";
22

33
.slButtonBase {
4-
@apply cursor-pointer inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive;
4+
@apply focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4;
55
}
66

77
.slButtonVariantDefault {
@@ -13,6 +13,7 @@
1313
}
1414

1515
.slButtonVariantOutline {
16+
/* @apply bg-background hover:bg-accent text-foreground hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 border shadow-xs; */
1617
@apply bg-background hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 border shadow-xs;
1718
}
1819

src/components/input/index.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
import { clsx } from '@shilong/utils'
22
import * as React from 'react'
3-
import './index.css'
3+
import './style.css'
4+
5+
export function Input(props: React.ComponentProps<'input'>) {
6+
const { className, ...reset } = props
47

5-
export function Input({
6-
className,
7-
type,
8-
...props
9-
}: React.ComponentProps<'input'>) {
108
return (
119
<input
12-
type={type}
13-
data-slot="input"
10+
data-slot="sl-input"
1411
className={clsx('slInput', className)}
15-
{...props}
12+
{...reset}
1613
/>
1714
)
1815
}

0 commit comments

Comments
 (0)