Skip to content

Commit 902c114

Browse files
committed
main ?? add tailwind for demos
1 parent 152e058 commit 902c114

File tree

17 files changed

+97
-124
lines changed

17 files changed

+97
-124
lines changed

docs/src/components/code.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<script setup>
2-
import { onMounted, ref } from 'vue';
3-
42
const props = defineProps({
53
code: String,
64
lang: String

src/hooks/useActiveElement/useActiveElement.demo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ const Demo = () => {
1010
{Array.from({ length: 6 }, (_, i) => i + 1).map((id) => (
1111
<input
1212
key={id}
13+
className='rounded border p-2'
1314
data-id={String(id)}
14-
placeholder={String(id)}
1515
type='text'
16-
className='rounded border p-2'
16+
placeholder={String(id)}
1717
/>
1818
))}
1919
</div>

src/hooks/useBluetooth/useBluetooth.demo.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useState } from 'react';
2+
23
import { useBluetooth } from './useBluetooth';
34

45
const Demo = () => {
@@ -27,22 +28,26 @@ const Demo = () => {
2728

2829
return (
2930
<>
30-
<p>
31-
Bluetooth Web API supported
32-
</p>
31+
<p>Bluetooth Web API supported</p>
3332
{bluetooth.connected && (
3433
<div className='rounded-md bg-green-500 p-3 text-white'>
3534
<p>Connected</p>
3635
</div>
3736
)}
3837

3938
{!bluetooth.connected && (
40-
<div className='bg-orange-800 text-white p-3 rounded-md'>
39+
<div className='rounded-md bg-orange-800 p-3 text-white'>
4140
<p>Not Connected</p>
4241
</div>
4342
)}
44-
<button onClick={onRequestDeviceClick}>Request device</button>
45-
{error && <p>Errors: <code className="block p-5 whitespace-pre">{error}</code></p>}
43+
<button type='button' onClick={onRequestDeviceClick}>
44+
Request device
45+
</button>
46+
{error && (
47+
<p>
48+
Errors: <code className='block p-5 whitespace-pre'>{error}</code>
49+
</p>
50+
)}
4651
</>
4752
);
4853
};

src/hooks/useClipboard/useClipboard.demo.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const Demo = () => {
1111
return (
1212
<>
1313
<p>
14-
Clipboard Permission: read <b>{clipboardReadPermission.state}</b> | write{' '}
14+
Clipboard permission: read <b>{clipboardReadPermission.state}</b> | write{' '}
1515
<b>{clipboardWritePermissionWrite.state}</b>
1616
</p>
1717

@@ -20,11 +20,9 @@ const Demo = () => {
2020
</p>
2121
<input {...textField.register()} />
2222

23-
<div style={{ display: 'flex' }}>
24-
<button type='button' onClick={() => clipboard.copy(textField.getValue())}>
25-
Copy
26-
</button>
27-
</div>
23+
<button type='button' onClick={() => clipboard.copy(textField.getValue())}>
24+
Copy
25+
</button>
2826
</>
2927
);
3028
};

src/hooks/useCssVar/useCssVar.demo.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ import { useCssVar } from './useCssVar';
33
const Demo = () => {
44
const key = '--color';
55
const colorVar = useCssVar(key, '#7fa998');
6-
const style = {
7-
color: 'var(--color)'
8-
};
96

107
const switchColor = () => {
118
if (colorVar.value === '#df8543') colorVar.set('#7fa998');
@@ -14,7 +11,7 @@ const Demo = () => {
1411

1512
return (
1613
<>
17-
<p style={style}>Sample text, {colorVar.value}</p>
14+
<p style={{ color: 'var(--color)' }}>Sample text, {colorVar.value}</p>
1815
<button type='button' onClick={switchColor}>
1916
Change Color
2017
</button>

src/hooks/useElementSize/useElementSize.demo.tsx

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
1-
import type { CSSProperties } from 'react';
2-
31
import { useElementSize } from './useElementSize';
42

53
const Demo = () => {
64
const elementSize = useElementSize<HTMLTextAreaElement>();
75

8-
const containerStyle: CSSProperties = {
9-
display: 'flex',
10-
flexDirection: 'column',
11-
gap: '15px'
12-
};
13-
14-
const textareaStyle: CSSProperties = {
15-
resize: 'both',
16-
width: '200px',
17-
height: '200px'
18-
};
19-
206
return (
21-
<div style={containerStyle}>
22-
<span>Resize the box to see changes</span>
7+
<div className='flex flex-col gap-4'>
8+
<p>Resize the box to see changes</p>
239
<textarea
2410
ref={elementSize.ref}
25-
style={textareaStyle}
11+
className='200px 200px'
12+
style={{ resize: 'both' }}
2613
value={`width: ${elementSize.value.width}\nheight: ${elementSize.value.height}`}
2714
/>
2815
</div>

src/hooks/useField/useField.demo.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ const Demo = () => {
4545

4646
<div>
4747
<input
48-
placeholder='Name'
4948
type='text'
49+
placeholder='Name'
5050
{...nameInput.register({
5151
required: 'field is required',
5252
minLength: {
@@ -55,7 +55,7 @@ const Demo = () => {
5555
}
5656
})}
5757
/>
58-
{nameInput.error && <span style={{ color: 'red' }}>{nameInput.error}</span>}
58+
{nameInput.error && <span className='text-red-400'>{nameInput.error}</span>}
5959
</div>
6060

6161
<select {...sexSelect.register()}>
@@ -66,7 +66,7 @@ const Demo = () => {
6666
<textarea placeholder='About' rows={5} {...aboutTextArea.register()} />
6767

6868
<label htmlFor='checkbox'>
69-
<div style={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
69+
<div className='flex items-center gap-3'>
7070
<input id='checkbox' type='checkbox' {...rememberThisComputerCheckbox.register()} />
7171
<span>Remember this computer?</span>
7272
</div>

src/hooks/useHash/useHash.demo.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,11 @@ const Demo = () => {
1010
<div>
1111
<p>window.location.href:</p>
1212
<p>
13-
<pre style={{ whiteSpace: 'pre-wrap' }}>{window.location.href}</pre>
13+
<pre className='whitespace-pre-wrap'>{window.location.href}</pre>
1414
</p>
1515
<p>Edit hash: </p>
1616
<p>
17-
<input
18-
style={{ width: '100%' }}
19-
value={hash}
20-
onChange={(event) => setHash(event.target.value)}
21-
/>
17+
<input className='w-full' value={hash} onChange={(event) => setHash(event.target.value)} />
2218
</p>
2319
</div>
2420
);

src/hooks/useIdle/useIdle.demo.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { cn } from '@/docs/src/utils';
2+
13
import { useIdle } from './useIdle';
24

35
const Demo = () => {
@@ -6,7 +8,12 @@ const Demo = () => {
68
return (
79
<>
810
<p>
9-
Status: <code style={{ color: idle ? 'red' : 'green' }}>{idle ? 'idle' : 'active'}</code>
11+
Status:{' '}
12+
<code>
13+
<span className={cn('text-red-300', { 'text-green-300': !idle })}>
14+
{idle ? 'idle' : 'active'}
15+
</span>
16+
</code>
1017
</p>
1118
<p>Last active: {lastActive}</p>
1219
</>

src/hooks/useImage/useImage.demo.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@ const Demo = () => {
77

88
return (
99
<p>
10-
{image.isLoading && <div style={{ width: 300, height: 200 }}>Loading...</div>}
10+
{image.isLoading && <div className='h-xs w-xs'>Loading...</div>}
1111
{!image.isLoading && image.data && (
12-
<img
13-
alt='demo'
14-
src={`https://place-hold.it/300x200/${color}`}
15-
style={{ width: 300, height: 200 }}
16-
/>
12+
<img alt='demo' className='h-xs w-xs' src={`https://place-hold.it/300x200/${color}`} />
1713
)}
1814
<button type='button' onClick={() => toggle()}>
1915
Change

0 commit comments

Comments
 (0)