Skip to content

Commit 9ab2036

Browse files
committed
chore: improve docs
1 parent 500b4ac commit 9ab2036

File tree

9 files changed

+179
-175
lines changed

9 files changed

+179
-175
lines changed
Lines changed: 48 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<script setup lang="ts">
22
import { CreditCardType } from 'ts-inputs'
3-
import { BaseInput, CreditCardInput } from 'ts-inputs-vue'
3+
import { BaseInput } from 'ts-inputs-vue'
44
import { computed, ref } from 'vue'
55
6-
const baseInputCardNumber = ref('')
7-
const creditCardInputNumber = ref('')
6+
const cardNumber = ref('')
7+
const delimiter = ref(' ')
88
const cardType = ref<CreditCardType | null>(null)
99
10+
const creditCardOptions = computed(() => ({
11+
delimiter: delimiter.value,
12+
}))
13+
1014
function handleCardTypeChange(type: CreditCardType) {
1115
cardType.value = type
1216
}
@@ -45,83 +49,70 @@ const cardTypeName = computed(() => {
4549

4650
<template>
4751
<div class="demo-container">
48-
<div class="demo-section">
49-
<h3>Using BaseInput</h3>
50-
<div class="input-wrapper">
52+
<div class="input-section">
53+
<div class="input-group">
54+
<label class="block text-sm font-medium text-gray-700">Credit Card Input</label>
5155
<BaseInput
52-
v-model="baseInputCardNumber"
56+
v-model="cardNumber"
5357
type="credit-card"
54-
class-name="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6"
58+
:credit-card-options="creditCardOptions"
59+
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
5560
placeholder="Enter card number"
5661
@card-type="handleCardTypeChange"
5762
/>
5863
</div>
59-
</div>
6064

61-
<div class="demo-section">
62-
<h3>Using CreditCardInput</h3>
63-
<div class="input-wrapper">
64-
<CreditCardInput
65-
v-model="creditCardInputNumber"
66-
class-name="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6"
67-
placeholder="Enter card number"
68-
@card-type="handleCardTypeChange"
69-
/>
65+
<div class="options-grid">
66+
<div class="option-group">
67+
<label class="block text-sm font-medium text-gray-700">Delimiter</label>
68+
<select
69+
v-model="delimiter"
70+
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
71+
>
72+
<option value=" ">
73+
Space ( )
74+
</option>
75+
<option value="-">
76+
Hyphen (-)
77+
</option>
78+
<option value=".">
79+
Dot (.)
80+
</option>
81+
</select>
82+
</div>
7083
</div>
7184
</div>
7285

73-
<div v-if="cardType" class="card-info">
74-
<img v-if="cardIcon" :src="cardIcon" :alt="cardTypeName" class="card-icon">
75-
<span class="card-type">{{ cardTypeName }}</span>
86+
<div v-if="cardType" class="result-section">
87+
<h3 class="text-lg font-medium text-gray-900">
88+
Card Information
89+
</h3>
90+
<div class="mt-2 flex items-center gap-2">
91+
<img v-if="cardIcon" :src="cardIcon" :alt="cardTypeName" class="w-6 h-6">
92+
<span class="text-sm text-gray-500">{{ cardTypeName }}</span>
93+
</div>
7694
</div>
7795
</div>
7896
</template>
7997

8098
<style scoped>
8199
.demo-container {
82-
display: flex;
83-
flex-direction: column;
84-
gap: 2rem;
85-
padding: 1rem;
86-
max-width: 600px;
87-
margin: 0 auto;
88-
}
89-
90-
.demo-section {
91-
display: flex;
92-
flex-direction: column;
93-
gap: 0.5rem;
94-
}
95-
96-
.demo-section h3 {
97-
font-size: 1.125rem;
98-
font-weight: 600;
99-
color: #374151;
100+
@apply max-w-4xl mx-auto p-6 bg-white rounded-lg shadow;
100101
}
101102
102-
.input-wrapper {
103-
position: relative;
103+
.input-section {
104+
@apply space-y-6;
104105
}
105106
106-
.card-info {
107-
display: flex;
108-
align-items: center;
109-
gap: 0.5rem;
110-
padding: 0.5rem;
111-
background-color: #f3f4f6;
112-
border-radius: 0.375rem;
113-
margin-top: 1rem;
107+
.options-grid {
108+
@apply grid grid-cols-1 md:grid-cols-2 gap-4;
114109
}
115110
116-
.card-icon {
117-
width: 24px;
118-
height: 24px;
119-
object-fit: contain;
111+
.option-group {
112+
@apply space-y-1;
120113
}
121114
122-
.card-type {
123-
font-size: 0.875rem;
124-
color: #4b5563;
125-
font-weight: 500;
115+
.result-section {
116+
@apply mt-6 p-4 bg-gray-50 rounded-lg;
126117
}
127118
</style>

docs/vue/credit-card.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ function handleCardTypeChange(type: CreditCardType) {
6666
| `placeholder` | `string` | - | Input placeholder text |
6767
| `creditCardOptions` | `object` | - | Credit card formatting options |
6868

69+
### creditCardOptions
70+
71+
| Option | Type | Default | Description |
72+
|--------|------|---------|-------------|
73+
| `delimiter` | `string` | `' '` | Character used to separate card number groups |
74+
6975
### CreditCardInput Props
7076

7177
| Prop | Type | Default | Description |
@@ -102,4 +108,4 @@ The component automatically formats the card number based on the card type:
102108
- American Express: XXXX XXXXXX XXXXX
103109
- Other cards: XXXX XXXX XXXX XXXX
104110

105-
You can customize the delimiter used for formatting by setting the `delimiter` prop or `creditCardOptions.delimiter`.
111+
You can customize the delimiter used for formatting by setting the `creditCardOptions.delimiter` prop.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
"test": "bun test",
4545
"dev:docs": "bun --bun vitepress dev docs",
4646
"build:docs": "bun --bun vitepress build docs",
47-
"preview:docs": "bun --bun vitepress preview docs",
48-
"typecheck": "bun --bun tsc --noEmit"
47+
"preview:docs": "bun --bun vitepress preview docs"
4948
},
5049
"devDependencies": {
5150
"@stacksjs/docs": "^0.70.23",

packages/ts-inputs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"dist"
4040
],
4141
"scripts": {
42-
"build": "bun --bun build.ts",
42+
"build": "bun --bun build.ts && bun run typecheck",
4343
"lint": "bunx --bun eslint .",
4444
"lint:fix": "bunx --bun eslint . --fix",
4545
"prepublishOnly": "bun --bun run build",

packages/vue/src/components/BaseInput.vue

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,31 @@ import { computed, onMounted, ref, watch } from 'vue'
66
import DateTimePicker from './datetime-picker/DateTimePicker.vue'
77
import NumeralInput from './numeral/NumeralInput.vue'
88
9+
// Add Google Maps type declaration
10+
declare global {
11+
namespace google {
12+
namespace maps {
13+
namespace places {
14+
class Autocomplete {
15+
constructor(input: HTMLInputElement, options?: AutocompleteOptions)
16+
addListener(eventName: string, handler: Function): void
17+
getPlace(): any
18+
}
19+
}
20+
}
21+
}
22+
interface Window {
23+
google: typeof google
24+
}
25+
}
26+
27+
interface AutocompleteOptions {
28+
types?: string[]
29+
componentRestrictions?: {
30+
country: string | string[]
31+
}
32+
}
33+
934
const props = defineProps<TSInputsProps>()
1035
1136
const emit = defineEmits<{
@@ -409,27 +434,3 @@ interface FormatNumeralOptions {
409434
display: inline-block;
410435
}
411436
</style>
412-
413-
declare global {
414-
namespace google {
415-
namespace maps {
416-
namespace places {
417-
class Autocomplete {
418-
constructor(input: HTMLInputElement, options?: AutocompleteOptions)
419-
addListener(eventName: string, handler: Function): void
420-
getPlace(): any
421-
}
422-
}
423-
}
424-
}
425-
interface Window {
426-
google: typeof google
427-
}
428-
}
429-
430-
interface AutocompleteOptions {
431-
types?: string[]
432-
componentRestrictions?: {
433-
country: string | string[]
434-
}
435-
}

0 commit comments

Comments
 (0)