-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved all test routes files to the demo package so they are out of th…
…e example directory.
- Loading branch information
Showing
14 changed files
with
248 additions
and
111 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@graphcommerce/demo-magento-graphcommerce': patch | ||
--- | ||
|
||
Moved all test routes files to the demo package so they are out of the example directory. |
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
12 changes: 7 additions & 5 deletions
12
...agento-graphcms/pages/test/[[...url]].tsx → ...phcommerce/copy/pages/test/[[...url]].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
20 changes: 10 additions & 10 deletions
20
...s/magento-graphcms/pages/test/buttons.tsx → ...graphcommerce/copy/pages/test/buttons.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
164 changes: 164 additions & 0 deletions
164
packages/demo-magento-graphcommerce/copy/pages/test/form-elements.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,164 @@ | ||
import { | ||
ActionCardListForm, | ||
CheckboxButtonGroup, | ||
NumberFieldElement, | ||
RadioButtonGroup, | ||
SelectElement, | ||
TextFieldElement, | ||
} from '@graphcommerce/ecommerce-ui' | ||
import type { PageOptions } from '@graphcommerce/framer-next-pages' | ||
import { StoreConfigDocument } from '@graphcommerce/magento-store' | ||
import type { GetStaticProps } from '@graphcommerce/next-ui' | ||
import { | ||
ActionCard, | ||
Button, | ||
Form, | ||
FormActions, | ||
FormRow, | ||
LayoutHeader, | ||
LayoutTitle, | ||
} from '@graphcommerce/next-ui' | ||
import { FormAutoSubmit, FormPersist, useForm } from '@graphcommerce/react-hook-form' | ||
import { Container, List, ListItem, TextField, Typography } from '@mui/material' | ||
import type { LayoutMinimalProps } from '../../components' | ||
import { LayoutMinimal } from '../../components' | ||
import { graphqlSharedClient } from '../../lib/graphql/graphqlSsrClient' | ||
|
||
type FormValues = { | ||
checkboxButtonGroup: string[] | ||
selectElement: string | ||
textFieldElement: string | ||
numberFieldElement: number | ||
actionCardList: string | ||
} | ||
|
||
export default function IconsPage() { | ||
const form = useForm<FormValues>() | ||
const { control, handleSubmit } = form | ||
|
||
const submit = handleSubmit((data) => { | ||
console.log(data) | ||
}) | ||
|
||
return ( | ||
<> | ||
<LayoutHeader /> | ||
|
||
<LayoutTitle variant='h1'>Form Elements</LayoutTitle> | ||
|
||
<Container maxWidth='md'> | ||
<Form onSubmit={submit} contained background='default'> | ||
<FormRow> | ||
<CheckboxButtonGroup | ||
control={control} | ||
label='Checkbox Button Group' | ||
name='checkboxButtonGroup' | ||
options={[ | ||
{ id: 'one', label: 'One' }, | ||
{ id: 'two', label: 'Two' }, | ||
]} | ||
/> | ||
</FormRow> | ||
|
||
<FormRow> | ||
<SelectElement | ||
control={control} | ||
name='selectElement' | ||
label='Select Element' | ||
options={[ | ||
{ id: 'one', label: 'One' }, | ||
{ id: 'two', label: 'Two' }, | ||
]} | ||
/> | ||
|
||
<SelectElement | ||
control={control} | ||
name='selectElement' | ||
SelectProps={{ native: true }} | ||
label='Select Element Native' | ||
options={[ | ||
{ id: 'one', label: 'One' }, | ||
{ id: 'two', label: 'Two' }, | ||
]} | ||
/> | ||
</FormRow> | ||
|
||
<FormRow> | ||
<RadioButtonGroup | ||
control={control} | ||
name='selectElement' | ||
label='Radio Button Group' | ||
options={[ | ||
{ id: 'one', label: 'Radio One' }, | ||
{ id: 'two', label: 'Radio Two' }, | ||
]} | ||
/> | ||
</FormRow> | ||
|
||
<FormRow> | ||
<TextFieldElement control={control} name='textFieldElement' label='TextFieldElement' /> | ||
<NumberFieldElement | ||
defaultValue={0} | ||
control={control} | ||
name='numberFieldElement' | ||
label='Number' | ||
variant='standard' | ||
inputProps={{ min: 1 }} | ||
InputProps={{ disableUnderline: true }} | ||
/> | ||
</FormRow> | ||
|
||
<Typography variant='h6'>Action Card List</Typography> | ||
|
||
<FormRow> | ||
<ActionCardListForm | ||
control={control} | ||
name='actionCardList' | ||
layout='grid' | ||
items={[ | ||
{ value: 'one', title: 'One' }, | ||
{ value: 'two', title: 'Two' }, | ||
]} | ||
render={ActionCard} | ||
/> | ||
</FormRow> | ||
|
||
<FormActions> | ||
<Button type='submit' variant='pill' color='primary' size='large'> | ||
Submit | ||
</Button> | ||
</FormActions> | ||
|
||
<List> | ||
<ListItem>Form is persisted with FormPersist</ListItem> | ||
<ListItem> | ||
Form is automatically submitted with FormAutoSubmit when the Number field changes | ||
</ListItem> | ||
</List> | ||
|
||
<FormAutoSubmit control={control} submit={submit} name={['numberFieldElement']} /> | ||
<FormPersist<FormValues> form={form} name='form-elements' /> | ||
</Form> | ||
</Container> | ||
</> | ||
) | ||
} | ||
|
||
const pageOptions: PageOptions<LayoutMinimalProps> = { | ||
Layout: LayoutMinimal, | ||
layoutProps: {}, | ||
} | ||
IconsPage.pageOptions = pageOptions | ||
|
||
type GetPageStaticProps = GetStaticProps<LayoutMinimalProps> | ||
|
||
export const getStaticProps: GetPageStaticProps = async (context) => { | ||
const client = graphqlSharedClient(context) | ||
const conf = client.query({ query: StoreConfigDocument }) | ||
|
||
return { | ||
props: { | ||
apolloState: await conf.then(() => client.cache.extract()), | ||
}, | ||
} | ||
} |
16 changes: 8 additions & 8 deletions
16
...les/magento-graphcms/pages/test/icons.tsx → ...o-graphcommerce/copy/pages/test/icons.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
10 changes: 6 additions & 4 deletions
10
...es/test/minimal-page-shell/[[...url]].tsx → ...es/test/minimal-page-shell/[[...url]].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
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
4 changes: 2 additions & 2 deletions
4
...les/magento-graphcms/pages/test/sheet.tsx → ...o-graphcommerce/copy/pages/test/sheet.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
Oops, something went wrong.