-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1992 from Shopify/my-datefield-timefield-docs
update timefield and datefield docs
- Loading branch information
Showing
8 changed files
with
182 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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
46 changes: 46 additions & 0 deletions
46
...ges/ui-extensions/docs/surfaces/point-of-sale/reference/examples/date-field/date-input.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { | ||
Navigator, | ||
Screen, | ||
ScrollView, | ||
Text, | ||
DateField, | ||
extension, | ||
} from '@shopify/ui-extensions/point-of-sale'; | ||
|
||
export default extension('pos.home.modal.render', (root, api) => { | ||
const clearHandler = () => { | ||
dateField.updateProps({value: ''}); | ||
textBox.replaceChildren(''); | ||
}; | ||
const dateField = root.createComponent(DateField, { | ||
label: 'Select Date', | ||
value: '', | ||
action: {label: 'Clear', onPress: clearHandler}, | ||
}); | ||
|
||
const textBox = root.createComponent(Text); | ||
|
||
const onChangeHandler = (newValue: string) => { | ||
dateField.updateProps({value: newValue}); | ||
|
||
const textContent = `Selected Date: ${newValue}`; | ||
textBox.replaceChildren(textContent); | ||
}; | ||
|
||
dateField.updateProps({onChange: onChangeHandler}); | ||
|
||
const scrollView = root.createComponent(ScrollView); | ||
scrollView.append(dateField); | ||
scrollView.append(textBox); | ||
|
||
const screen = root.createComponent(Screen, { | ||
name: 'DateField', | ||
title: 'Date Field Example', | ||
}); | ||
screen.append(scrollView); | ||
|
||
const navigator = root.createComponent(Navigator); | ||
navigator.append(screen); | ||
|
||
root.append(navigator); | ||
}); |
35 changes: 35 additions & 0 deletions
35
...es/ui-extensions/docs/surfaces/point-of-sale/reference/examples/date-field/date-input.tsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React, {useState} from 'react'; | ||
import { | ||
DateField, | ||
Screen, | ||
ScrollView, | ||
Navigator, | ||
Text, | ||
reactExtension, | ||
} from '@shopify/ui-extensions-react/point-of-sale'; | ||
|
||
const SmartGridModal = () => { | ||
const [date, setDate] = useState(''); | ||
return ( | ||
<Navigator> | ||
<Screen name="DateField" title="DateField Example"> | ||
<ScrollView> | ||
<DateField | ||
label="Date" | ||
value={date} | ||
onChange={setDate} | ||
action={{ | ||
label: 'Clear', | ||
onPress: () => setDate(''), | ||
}} | ||
/> | ||
<Text>Selected Date: {date}</Text> | ||
</ScrollView> | ||
</Screen> | ||
</Navigator> | ||
); | ||
}; | ||
|
||
export default reactExtension('pos.home.modal.render', () => ( | ||
<SmartGridModal /> | ||
)); |
41 changes: 41 additions & 0 deletions
41
...ges/ui-extensions/docs/surfaces/point-of-sale/reference/examples/time-field/time-input.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { | ||
Navigator, | ||
Screen, | ||
ScrollView, | ||
Text, | ||
TimeField, | ||
extension, | ||
} from '@shopify/ui-extensions/point-of-sale'; | ||
|
||
export default extension('pos.home.modal.render', (root, api) => { | ||
const timeField = root.createComponent(TimeField, { | ||
label: 'Select Time', | ||
value: '', | ||
}); | ||
|
||
const textBox = root.createComponent(Text); | ||
|
||
const onChangeHandler = (newValue: string) => { | ||
timeField.updateProps({value: newValue}); | ||
|
||
const textContent = `Selected Time: ${newValue}`; | ||
textBox.replaceChildren(textContent); | ||
}; | ||
|
||
timeField.updateProps({onChange: onChangeHandler}); | ||
|
||
const scrollView = root.createComponent(ScrollView); | ||
scrollView.append(timeField); | ||
scrollView.append(textBox); | ||
|
||
const screen = root.createComponent(Screen, { | ||
name: 'TimeField', | ||
title: 'Time Field Example', | ||
}); | ||
screen.append(scrollView); | ||
|
||
const navigator = root.createComponent(Navigator); | ||
navigator.append(screen); | ||
|
||
root.append(navigator); | ||
}); |
27 changes: 27 additions & 0 deletions
27
...es/ui-extensions/docs/surfaces/point-of-sale/reference/examples/time-field/time-input.tsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React, {useState} from 'react'; | ||
import { | ||
TimeField, | ||
Screen, | ||
ScrollView, | ||
Navigator, | ||
Text, | ||
reactExtension, | ||
} from '@shopify/ui-extensions-react/point-of-sale'; | ||
|
||
const SmartGridModal = () => { | ||
const [time, setTime] = useState(''); | ||
return ( | ||
<Navigator> | ||
<Screen name="TimeField" title="TimeField Example"> | ||
<ScrollView> | ||
<TimeField label="Time" value={time} onChange={setTime} /> | ||
<Text>Selected Time: {time}</Text> | ||
</ScrollView> | ||
</Screen> | ||
</Navigator> | ||
); | ||
}; | ||
|
||
export default reactExtension('pos.home.modal.render', () => ( | ||
<SmartGridModal /> | ||
)); |
This file contains 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 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