-
Notifications
You must be signed in to change notification settings - Fork 1
Update code after review (everything except jQuery) #6
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5f98383
Update code after review (everything except jQuery)
vladaskorohodova 83edd33
README auto update [skip ci]
aa4bf27
Update after review
vladaskorohodova 33a4c2d
Merge branch 'fix-code' of https://github.com/DevExpress-Examples/dev…
vladaskorohodova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,10 @@ | ||
<dx-stepper (onSelectionChanged)="onSelectionChanged($event)"> | ||
<dxi-item | ||
label="Personal Details" | ||
template="firstStep" | ||
></dxi-item> | ||
<div *dxTemplate="let data of 'firstStep'"> | ||
<div class='star dx-step-indicator'></div> | ||
<div class='dx-step-caption'> | ||
<div class='dx-step-label'>{{ data.label }}</div> | ||
<dx-stepper | ||
[items]="steps" | ||
(onSelectionChanged)="onSelectionChanged($event)"> | ||
<div *dxTemplate="let data of 'starTemplate'"> | ||
<div class="star dx-step-indicator"></div> | ||
<div class="dx-step-caption"> | ||
<div class="dx-step-label">{{ data.label }}</div> | ||
</div> | ||
</div> | ||
<dxi-item | ||
label="Program Selection" | ||
icon="detailslayout" | ||
></dxi-item> | ||
<dxi-item | ||
label="Campus and Start Dates" | ||
icon="map" | ||
></dxi-item> | ||
<dxi-item | ||
label="Supporting Documents" | ||
icon="textdocument" | ||
></dxi-item> | ||
<dxi-item | ||
label="Scholarship and Aid" | ||
icon="money" | ||
[optional]="true" | ||
></dxi-item> | ||
<dxi-item | ||
label="Review and Submit" | ||
icon="send" | ||
></dxi-item> | ||
</dx-stepper> | ||
</dx-stepper> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,41 @@ | ||
import { JSX } from 'react'; | ||
import React, { JSX, useState } from 'react'; | ||
import { Stepper, Item, StepperTypes } from 'devextreme-react/stepper'; | ||
import React from 'react'; | ||
|
||
const renderFirstItem = (data: StepperTypes.TemplateData) => | ||
<React.Fragment> | ||
const renderFirstItem = (data: StepperTypes.TemplateData) => ( | ||
<> | ||
<div className="star dx-step-indicator"></div> | ||
<div className="dx-step-caption"> | ||
<div className="dx-step-label">{data.label}</div> | ||
</div> | ||
</React.Fragment>; | ||
|
||
const onSelectionChanged = (e: StepperTypes.SelectionChangedEvent) => { | ||
const newItem = e.addedItems[0]; | ||
const items = e.component.option('items'); | ||
const newIndex = items.findIndex((item: StepperTypes.Item) => newItem.label === item.label); | ||
e.component.option(`items[${newIndex - 1}].disabled`, true); | ||
}; | ||
</> | ||
); | ||
|
||
export default function App(): JSX.Element { | ||
const [steps, setSteps] = useState([ | ||
{ label: 'Personal Details', render: renderFirstItem }, | ||
{ label: 'Program Selection', icon: 'detailslayout' }, | ||
{ label: 'Campus and Start Dates', icon: 'map' }, | ||
{ label: 'Supporting Documents', icon: 'textdocument' }, | ||
{ label: 'Scholarship and Aid', icon: 'money', optional: true }, | ||
{ label: 'Review and Submit', icon: 'send' } | ||
]); | ||
|
||
const onSelectionChanged = (e: StepperTypes.SelectionChangedEvent) => { | ||
const newItem = e.addedItems[0]; | ||
const newIndex = steps.findIndex((item) => item.label === newItem.label); | ||
|
||
if (newIndex > 0 && !steps[newIndex - 1].disabled) { | ||
const updated = [...steps]; | ||
updated[newIndex - 1] = { ...updated[newIndex - 1], disabled: true }; | ||
setSteps(updated); | ||
} | ||
}; | ||
|
||
return ( | ||
<Stepper onSelectionChanged={onSelectionChanged}> | ||
<Item label="Personal Details" render={renderFirstItem} /> | ||
<Item label="Program Selection" icon="detailslayout" /> | ||
<Item label="Campus and Start Dates" icon="map" /> | ||
<Item label="Supporting Documents" icon="textdocument" /> | ||
<Item label="Scholarship and Aid" icon="money" optional={true} /> | ||
<Item label="Review and Submit" icon="send" /> | ||
{steps.map((item, index) => ( | ||
<Item key={index} {...item} /> | ||
))} | ||
</Stepper> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,42 @@ | ||
<template> | ||
<DxStepper ref="stepperRef" @selection-changed="onSelectionChanged"> | ||
<DxItem | ||
v-for="(item, index) in items" | ||
:key="index" | ||
v-bind="item" | ||
:template="item.template" | ||
/> | ||
<template #star="{ data }"> | ||
<div class="star dx-step-indicator"></div> | ||
<div class="dx-step-caption"> | ||
<div class="dx-step-label">{{ data.label }}</div> | ||
</div> | ||
</template> | ||
</DxStepper> | ||
</template> | ||
<script setup lang="ts"> | ||
import { DxStepper, DxItem, DxStepperTypes } from 'devextreme-vue/stepper'; | ||
import { reactive } from 'vue'; | ||
const items = reactive([ | ||
{ label: 'Personal Details', template: 'star' }, | ||
{ label: 'Program Selection', icon: 'detailslayout' }, | ||
{ label: 'Campus and Start Dates', icon: 'map' }, | ||
{ label: 'Supporting Documents', icon: 'textdocument' }, | ||
{ label: 'Scholarship and Aid', icon: 'money', optional: true }, | ||
{ label: 'Review and Submit', icon: 'send' } | ||
]); | ||
const onSelectionChanged = (e: DxStepperTypes.SelectionChangedEvent) => { | ||
const newItem = e.addedItems[0]; | ||
const items = e.component.option('items'); | ||
const newIndex = items.findIndex((item) => newItem.label === item.label); | ||
e.component.option(`items[${newIndex - 1}].disabled`, true); | ||
const newIndex = items.findIndex((item) => item.label === newItem.label); | ||
if (newIndex > 0) { | ||
vladaskorohodova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
items[newIndex - 1].disabled = true; | ||
} | ||
}; | ||
</script> | ||
<template> | ||
<DxStepper @selection-changed="onSelectionChanged"> | ||
<DxItem label='Personal Details' template='star' /> | ||
<template #star="{ data }"> | ||
<div class="star dx-step-indicator"> | ||
</div> | ||
<div class="dx-step-caption"> | ||
<div class="dx-step-label">{{ data.label }}</div> | ||
</div> | ||
</template> | ||
<DxItem label="Program Selection" icon='detailslayout' /> | ||
<DxItem label="Campus and Start Dates" icon='map' /> | ||
<DxItem label="Supporting Documents" icon='textdocument' /> | ||
<DxItem label="Scholarship and Aid" icon='money' :optional='true' /> | ||
<DxItem label="Review and Submit" icon='send' /> | ||
</DxStepper> | ||
</template> | ||
<style> | ||
.star { | ||
aspect-ratio: 1; | ||
clip-path: polygon(50% 0,79% 90%,2% 35%,98% 35%,21% 90%); | ||
box-shadow: 0 0 0 8px #fafafa; | ||
} | ||
</style> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.