Skip to content

Commit c17fe79

Browse files
chore: wip
* feat:stepper component * chore: wip * chore: wip * chore: remove scss * fix: remove unused package * chore: wip * chore: wip * chore: wip * chore: wip * chore: wip * fix: bun conflict * fix: remove bun file due to conflict * chore: wip * chore: wip * chore: wip --------- chore: wip Co-Authored-By: chrisbbreuer <chrisbreuer93@gmail.com> Co-Authored-By: Michael Vincent Caballero <mike.cabz32@gmail.com>
1 parent 6d2f0ec commit c17fe79

File tree

8 files changed

+112
-177
lines changed

8 files changed

+112
-177
lines changed

app/Notifications/Welcome.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default new Email({
66
// or Sms or Push or Webhook or Chat
77
name: 'welcome', // optional, defaults to the file name
88
subject: 'Welcome to Stacks', // optional, but recommended
9-
to: 'some@email.com', // required
9+
to: 'some@email.com', // optional, has to be defined here or set when sending
1010
from: config.email.from, // optional, defaults to the config value
1111
template: 'Welcome', // resources/emails/Welcome.stx
1212

storage/framework/core/components/stepper/components.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@ declare module 'vue' {
1313
StarportCarrier: typeof import('vue-starport')['StarportCarrier']
1414
Step: typeof import('./src/components/Step.vue')['default']
1515
Stepper: typeof import('./src/components/Stepper.vue')['default']
16-
StepperRoot: typeof import('./src/components/StepperRoot.vue')['default']
1716
}
1817
}

storage/framework/core/components/stepper/src/App.vue

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,36 @@ const reset = () => {
1717
stepperRef.value.reset()
1818
}
1919
}
20+
21+
22+
const previous = () => {
23+
if(stepperRef.value) {
24+
stepperRef.value.previous()
25+
}
26+
}
27+
2028
</script>
2129

2230
<template>
23-
<div class="bg-neutral-100/66 dark:bg-neutral-900 px-4 ">
31+
<div class="bg-neutral-100/66 dark:bg-neutral-900 px-4">
2432
<div class="container mx-auto max-w-full sm:max-w-2xl relative">
25-
<Stepper ref='stepperRef' :steps="steps" v-model="step"/>
33+
<header class="py-20 flex-center flex-col">
34+
Stacks Stepper
35+
</header>
36+
<main
37+
class="grid grid-cols-1 gap-8 text-xs 2xl:text-sm text-primary pb-20"
38+
>
39+
40+
<Stepper ref='stepperRef' :steps="steps" v-model="step"/>
41+
<div class="w-full mx-auto text-center">
42+
<button class="mx-5 rounded-md bg-indigo-50 px-3.5 py-2.5 text-sm font-semibold text-indigo-600 shadow-sm hover:bg-indigo-100" type="button" @click="next()">Next</button>
43+
<button class="text-sm font-semibold mx-5" type="button" @click="reset()">Reset</button>
44+
<button class="mx-5 rounded-md bg-indigo-50 px-3.5 py-2.5 text-sm font-semibold text-indigo-600 shadow-sm hover:bg-indigo-100" type="button" @click="previous()">Previous</button>
45+
</div>
46+
47+
48+
</main>
2649
</div>
27-
<!-- <button type="button" @click="next">Next</button>
28-
<button type="button" @click="reset">Reset</button> -->
50+
2951
</div>
3052
</template>

storage/framework/core/components/stepper/src/components/Step.vue

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ interface Props {
1414
disabled: boolean
1515
withDivider: boolean
1616
debug: boolean
17+
isLastStep: boolean
1718
}
1819
1920
const props = defineProps<Props>()
@@ -46,13 +47,22 @@ const scope = computed(() => ({
4647
}))
4748
4849
const classes = computed(() => ({
49-
'is-active': props.active,
50-
'is-visited': props.visited,
51-
'is-disabled': props.disabled,
50+
'is-active': props.active,
51+
'is-visited': props.visited,
52+
'is-disabled': props.disabled
5253
}))
5354
55+
const indexClasses = computed(() => {
56+
57+
const defaultClass = ' '
58+
const additionalClass = props.active ? 'text-blue-500 bg-blue-500' : 'text-gray-500 bg-gray-300'
59+
60+
return defaultClass + additionalClass
61+
})
62+
63+
64+
5465
function handleChange() {
55-
console.log('step handle changed')
5666
emit('change', props.index)
5767
}
5868
</script>
@@ -70,7 +80,10 @@ function handleChange() {
7080
>
7181
<label class="label flex flex-row items-center" :for="id">
7282
<slot name="index-root" v-bind="scope">
73-
<span class="index w-14 h-14 flex flex-shrink-0 text-xl rounded-full mr-2 text-white items-center justify-center bg-transparent border border-gray-200">
83+
<span :class="[
84+
'w-14 h-14 flex flex-shrink-0 text-xl rounded-full mr-2 text-white items-center justify-center border border-gray-200',
85+
props.active ? 'text-blue-500 bg-blue-500' : 'text-gray-500 bg-gray-300'
86+
]">
7487
<slot name="index" v-bind="scope">
7588
{{ scope.displayIndex }}
7689
</slot>
@@ -79,7 +92,7 @@ function handleChange() {
7992
<span class="title text-white" v-if="defaultSlot">
8093
<slot v-bind="scope"></slot>
8194
</span>
82-
<span class="w-full ml-2 border-b border-white shadow-md" v-if="withDivider"></span>
95+
<span class="w-full ml-2 border-b border-gray shadow-md" v-if="withDivider && !isLastStep"></span>
8396
</label>
8497
</div>
8598
</template>
@@ -105,23 +118,10 @@ function handleChange() {
105118
cursor: pointer;
106119
}
107120
108-
.step.is-active .index {
109-
color: #4b5563;
110-
}
111-
112121
.step.is-active {
113122
opacity: 1;
114123
}
115124
116-
.step.is-active .title {
117-
color: #1e6b73;
118-
}
119-
120-
.step.is-active .label .index {
121-
border-color: rgba(244, 244, 244, 0.2);
122-
background-color: #12525e;
123-
}
124-
125125
.step.is-visited .index {
126126
background-color: #ffffff;
127127
}

storage/framework/core/components/stepper/src/components/Stepper.vue

Lines changed: 59 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
watch,
1313
withDefaults,
1414
} from 'vue'
15-
import type { OptionParams, StepperEmitValue, StepperProps, StepperValue } from '../types'
15+
import type { StepperProps, OptionParams } from '../types'
1616
import Step from './Step.vue'
1717
1818
defineOptions({
@@ -21,10 +21,7 @@ defineOptions({
2121
})
2222
2323
const props = withDefaults(defineProps<StepperProps>(), {
24-
value: {
25-
value: 2,
26-
id: undefined,
27-
},
24+
stepperId: undefined,
2825
steps: 0,
2926
linear: true,
3027
persist: false,
@@ -33,70 +30,34 @@ const props = withDefaults(defineProps<StepperProps>(), {
3330
debug: false,
3431
})
3532
36-
const emit = defineEmits(['input', 'reset'])
33+
const modelValue = defineModel()
34+
35+
const emit = defineEmits(['reset'])
3736
3837
const namespace = { kebab: 'stepper', capitalize: 'Stepper' }
3938
const stepsArr = ref(getStepsArr())
40-
const index = ref(toIndex(props.value.value))
39+
const currentIndex = ref(toIndex(modelValue.value))
40+
4141
const slots = useSlots()
42-
const id = computed(() => `${namespace.kebab}-${Math.random().toString(36).substr(2, 9)}`)
43-
const lastIndex = computed(() => stepsArr.value.length - 1)
44-
const random = computed(() => props.linear === false)
45-
46-
const queries = computed(() => {
47-
const { steps } = props
48-
49-
return Array.from(Array(steps)).reduce(
50-
(queries, step, $index) => {
51-
const query = `isStep${$index + 1}`
52-
queries[query] = index.value === $index
53-
return queries
54-
},
55-
{} as Record<string, boolean>,
56-
)
57-
})
42+
const id = computed(() => `${namespace.kebab}-${Math.random().toString(36).substring(2, 9)}`)
5843
59-
watch(
60-
() => props.value,
61-
(newValue) => {
62-
index.value = toIndex(newValue.value)
63-
if (props.persist) {
64-
setStorage()
65-
}
66-
},
67-
)
68-
69-
watch(
70-
index,
71-
(newValue) => {
72-
emitValue(toValue(newValue))
73-
},
74-
{ immediate: true },
75-
)
76-
77-
const scope = computed(() => ({
78-
index: index.value,
79-
displayIndex: index.value + 1,
80-
defaultSlot: slots.default ? slots.default() : undefined,
81-
flags: {
82-
isActive: true,
83-
isVisited: false,
84-
isDisabled: false,
85-
},
86-
}))
87-
88-
const classes = computed(() => ({
89-
'is-active': true,
90-
'is-visited': false,
91-
'is-disabled': false,
92-
}))
44+
watch(() => modelValue.value, (step) => {
45+
currentIndex.value = toIndex(step)
46+
if (props.persist) {
47+
setStorage();
48+
}
49+
});
50+
51+
watch(currentIndex, (stepIndex) => {
52+
emitValue(toValue(stepIndex));
53+
}, { immediate: true });
9354
9455
onMounted(() => {
9556
if (props.persist) {
9657
const storage = getStorage()
9758
if (storage) {
9859
stepsArr.value = storage.stepsArr
99-
index.value = storage.index
60+
currentIndex.value = storage.index
10061
} else {
10162
setStorage()
10263
}
@@ -153,9 +114,9 @@ function doesStepExist(index: number) {
153114
}
154115
155116
function handleChange(stepIndex: number) {
156-
const isNext = stepIndex === index.value + 1
157-
const isPrevious = stepIndex === index.value - 1
158-
const oldIndex = toIndex(props.value.value)
117+
const isNext = stepIndex === currentIndex.value + 1
118+
const isPrevious = stepIndex === currentIndex.value - 1
119+
const oldIndex = toIndex(modelValue.value)
159120
160121
if (props.linear) {
161122
if (isNext || isPrevious) {
@@ -195,7 +156,7 @@ function getStepsArr() {
195156
}
196157
197158
function offset(offset: number) {
198-
const stepIndex = index.value + offset
159+
const stepIndex = currentIndex.value + offset
199160
if (doesStepExist(stepIndex)) {
200161
handleChange(stepIndex)
201162
}
@@ -211,7 +172,7 @@ function previous() {
211172
212173
function reset() {
213174
stepsArr.value = getStepsArr()
214-
index.value = 0
175+
currentIndex.value = 0
215176
emit('reset')
216177
}
217178
@@ -220,15 +181,15 @@ function setStep(stepIndex: number, prop: string, value: any) {
220181
}
221182
222183
function setStorage() {
223-
window[props.storekeeper].setItem(id.value, JSON.stringify({ index: index.value, stepsArr: stepsArr.value }))
184+
window[props.storekeeper].setItem(id.value, JSON.stringify({ index: currentIndex.value, stepsArr: stepsArr.value }))
224185
}
225186
226187
function getStorage() {
227188
return JSON.parse(window[props.storekeeper].getItem(id.value) || 'null')
228189
}
229190
230191
function emitValue(value: number) {
231-
emit('input', { id: id.value, value, queries: queries.value })
192+
modelValue.value = value
232193
}
233194
234195
defineExpose({
@@ -238,40 +199,39 @@ defineExpose({
238199
})
239200
</script>
240201
<template>
241-
<div class="v-stepper">
242-
<stepper-root>
243-
<step
244-
v-for="(step, $index) in stepsArr"
245-
:name="id"
246-
:key="$index"
247-
:debug="debug"
248-
:index="$index"
249-
@change="handleChange"
250-
:visited="step.visited"
251-
:disabled="step.disabled"
252-
:with-divider="withDivider"
253-
:active="step.index === toIndex(value.value)"
254-
>
255-
<template
256-
v-slot:index-root="scope"
257-
v-if="withSlot(getSlotName('index-root', $index + 1))"
258-
>
259-
<slot :name="getSlotName('index-root', scope.displayIndex)" v-bind="scope"></slot>
260-
</template>
261-
202+
<div class="flex w-full select-none box-border justify-between ">
203+
<step
204+
v-for="(step, $index) in stepsArr"
205+
:name="id"
206+
:key="$index"
207+
:debug="debug"
208+
:index="$index"
209+
@change="handleChange"
210+
:visited="step.visited"
211+
:disabled="step.disabled"
212+
:with-divider="withDivider"
213+
:active="step.index === toIndex(modelValue)"
214+
:isLastStep="steps === ($index + 1)"
215+
>
262216
<template
263-
v-if="withoutSlot(getSlotName('index-root', $index + 1))"
264-
v-slot:index="scope">
265-
<slot :name="getSlotName('index', scope.displayIndex)" v-bind="scope">
266-
{{ scope.displayIndex }}
267-
</slot>
268-
</template>
269-
270-
<template v-slot:defaultSlot="scope" >
271-
<slot :name="getSlotName('', scope.displayIndex)" v-bind="scope">2</slot>
272-
</template>
273-
274-
</step>
275-
</stepper-root>
217+
v-slot:index-root="scope"
218+
v-if="withSlot(getSlotName('index-root', $index + 1))"
219+
>
220+
<slot :name="getSlotName('index-root', scope.displayIndex)" v-bind="scope"></slot>
221+
</template>
222+
223+
<template
224+
v-if="withoutSlot(getSlotName('index-root', $index + 1))"
225+
v-slot:index="scope">
226+
<slot :name="getSlotName('index', scope.displayIndex)" v-bind="scope">
227+
{{ scope.displayIndex }}
228+
</slot>
229+
</template>
230+
231+
<template v-slot:defaultSlot="scope" >
232+
<slot :name="getSlotName('', scope.displayIndex)" v-bind="scope">2</slot>
233+
</template>
234+
235+
</step>
276236
</div>
277237
</template>

storage/framework/core/components/stepper/src/components/StepperRoot.vue

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)