Skip to content
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

chore: refactoring field #981

Merged
merged 32 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b1e9bb2
chore: refactoring field
mleralec Dec 16, 2021
a6d092c
chore: some clean field
mleralec Dec 16, 2021
1e867a9
fix: rollback IconWrapper
mleralec Dec 16, 2021
714c99c
chore: refactoring select tests without ConnectedField
mleralec Dec 17, 2021
93dfef7
chore: refactoring InputText tests without ConnectedField
mleralec Dec 17, 2021
b6110c7
chore: refactoring PasswordInput tests without ConnectedField
mleralec Dec 17, 2021
906a1b2
chore: refactoring Checkbox tests without ConnectedField
mleralec Dec 17, 2021
eea2af7
chore: refactoring Search tests without ConnectedField
mleralec Dec 17, 2021
e5a28e4
chore: refactoring Picker tests without ConnectedField
mleralec Dec 17, 2021
663f70f
fix: remove forwardFieldRef type from system
mleralec Dec 17, 2021
5badf0e
chore: remove ConnectedField component
mleralec Dec 17, 2021
1b49523
chore: refactoring DateTimePicker tests without ConnectedField
mleralec Dec 17, 2021
89cddc6
fix: replace ConnectedField in documentation and use new Field api
P1X3L Dec 20, 2021
7eec4c5
chore: add some tests for Field
mleralec Dec 20, 2021
e7f0b69
fix: add hookform to fieldgroup doc
P1X3L Dec 20, 2021
d5a8545
fix: fix tests and add size props and id to field children
P1X3L Dec 20, 2021
09aeea3
fix: remove size prop from field
P1X3L Dec 20, 2021
d25f221
fix: add skipped test to handle no id no name field child
P1X3L Dec 20, 2021
7a30c6d
chore: generate random id/htmlFor if no exist
mleralec Jan 5, 2022
b7c115a
fix: @welcome-ui/system version
mleralec Jan 5, 2022
ffca9b3
chore: update input-text doc
mleralec Jan 5, 2022
ed7e95e
chore: update docs with new field on label/field/password-input/textarea
mleralec Jan 5, 2022
6e4b8e9
chore: update docs with new field on select
mleralec Jan 5, 2022
9e3cdae
chore: update docs with new field on toggle/search
mleralec Jan 5, 2022
ced3bbf
chore: update docs with new field on file-drop
mleralec Jan 5, 2022
7b3d57e
chore: update docs with new field on pickers/markdown-editor/radios
mleralec Jan 5, 2022
96c35b5
chore: update file-upload doc
mleralec Jan 5, 2022
b216540
fix: remove useless comment
mleralec Jan 6, 2022
97b0b94
fix: typo on drawer.mdx
mleralec Jan 6, 2022
c5ac969
fix: restore DatePicker tests
mleralec Jan 6, 2022
2fc987e
refactor: default fields style (#988)
mleralec Jan 6, 2022
ef20ec8
fix: polish field test with toContain instead toBe
mleralec Jan 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/components/Code.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as React from 'react'
import { LivePreview, LiveProvider } from 'react-live'
import theme from 'prism-react-renderer/themes/nightOwl'
import NextLink from 'next/link'
import { Form as FinalForm } from 'react-final-form'
import dateFR from 'date-fns/locale/fr'
import * as yup from 'yup'
import { Controller } from 'react-hook-form'
Expand All @@ -20,7 +19,6 @@ import { Breadcrumb } from '@welcome-ui/breadcrumb'
import { Button } from '@welcome-ui/button'
import { Card } from '@welcome-ui/card'
import { Checkbox } from '@welcome-ui/checkbox'
import { ConnectedField } from '@welcome-ui/connected-field'
import { DatePicker } from '@welcome-ui/date-picker'
import { DateTimePicker } from '@welcome-ui/date-time-picker'
import * as DropdownMenu from '@welcome-ui/dropdown-menu'
Expand Down Expand Up @@ -68,7 +66,6 @@ import * as Emoji from '@welcome-ui/emoji'

import * as constants from '../constants'

import { Form } from './Form'
import { HookForm } from './HookForm'
import { IconsList } from './IconsList'
import * as S from './Code.styled'
Expand Down Expand Up @@ -137,7 +134,6 @@ export function Code({ children, className, isCopyable = true, live = true, row
Checkbox,
CodeContent: S.CodeContent,
CodeContentRow: S.CodeContentRow,
ConnectedField,
constants,
Controller,
dateFR,
Expand All @@ -152,8 +148,6 @@ export function Code({ children, className, isCopyable = true, live = true, row
FileDrop,
...Files,
FileUpload,
FinalForm,
Form,
Group,
Hint,
HookForm,
Expand Down Expand Up @@ -199,7 +193,13 @@ export function Code({ children, className, isCopyable = true, live = true, row
if (live === true && language === 'jsx') {
return (
<LiveProvider {...liveProviderProps}>
<S.LivePreview className="codeEditor">
<Card
className="codeEditor"
display="flex"
flexDirection="column"
mb="md"
overflow="visible"
>
<Card.Body color="dark.900" padding="xl" paddingBottom="lg">
<LivePreview />
<S.ShowEditor>
Expand All @@ -209,7 +209,7 @@ export function Code({ children, className, isCopyable = true, live = true, row
</Button>
</S.ShowEditor>
</Card.Body>
</S.LivePreview>
</Card>
{editorOpen && (
<S.LiveEditor>
<S.LiveEditorContent onChange={handleChange} padding={20} style={liveEditorStyle} />
Expand Down
8 changes: 0 additions & 8 deletions docs/components/Code.styled.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import styled from '@xstyled/styled-components'
import { th } from '@xstyled/system'
import { LiveEditor as ReactLiveEditor, LiveError as ReactLiveError } from 'react-live'
import { Card } from '@welcome-ui/card'
import { Box } from '@welcome-ui/box'

export const LiveEditor = styled(Box)`
Expand Down Expand Up @@ -38,13 +37,6 @@ export const LiveError = styled(ReactLiveError)`
margin: xxs 0 lg;
`

export const LivePreview = styled(Card)`
display: flex;
flex-direction: column;
overflow: visible;
margin-bottom: md;
`

export const ShowEditor = styled.div`
padding-top: sm;
margin-top: xl;
Expand Down
29 changes: 0 additions & 29 deletions docs/components/Form.js

This file was deleted.

20 changes: 10 additions & 10 deletions docs/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { Navigation } from './Navigation'
import { SelectTheme } from './SelectTheme'
import * as S from './Header.styled'

export const Header = () => {
export function Header() {
const modal = useModalState()
const theme = useThemeContext()

Expand All @@ -26,7 +26,7 @@ export const Header = () => {
window.docsearch({
apiKey: '85801aa252bde17259c4a5a61c1e84db',
indexName: 'welcome-ui',
inputSelector: '#search-algolia'
inputSelector: '#search-algolia',
})
}
}, [])
Expand Down Expand Up @@ -75,14 +75,14 @@ export const Header = () => {
<SelectTheme id="navigation" />
</Box>
<Box display={{ xs: 'none', md: 'block' }} mt="md" w="100%">
<Field
component={InputText}
icon={<SearchIcon color="light.100" size="sm" />}
isClearable
name="search-algolia"
placeholder="Search"
size="sm"
/>
<Field size="sm">
<InputText
icon={<SearchIcon color="light.100" size="sm" />}
isClearable
name="search-algolia"
placeholder="Search"
/>
</Field>
</Box>
<Box
display={{ xs: 'none', md: 'block' }}
Expand Down
71 changes: 64 additions & 7 deletions docs/pages/components/checkbox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,70 @@ import {
## Usage

```jsx
<Form initialValues={{ vue: true }}>
<FieldGroup label="Check the frameworks you have already worked with">
<ConnectedField component={Checkbox} name="react" label="React" />
<ConnectedField component={Checkbox} label="Angular" name="angular" id="angular_custom_id" />
<ConnectedField component={Checkbox} name="vue" label="Vue" />
</FieldGroup>
</Form>
function() {
const FormChildren = ({ control, register }) => (
<FieldGroup label="Check the frameworks you have already worked with">
<Controller
name="react"
control={control}
render={({ onChange, value}) => (
<Field label="React">
<Checkbox
name="react"
onChange={e => onChange(!e.target.checked)}
checked={value}
/>
</Field>
)
}
/>
<Controller
name="angular"
control={control}
render={({ onChange, value}) => (
<Field label="Angular">
<Checkbox
name="angular"
onChange={e => onChange(!e.target.checked)}
checked={value}
/>
</Field>
)
}
/>
<Controller
name="vue"
control={control}
render={({ onChange, value}) => (
<Field label="Vue">
<Checkbox
name="vue"
onChange={e => onChange(!e.target.checked)}
checked={value}
/>
</Field>
)
}
/>
</FieldGroup>
)

return (
<HookForm
defaultValues={{ vue: true }}
schemaValidate={() =>
yup.object().shape({
react: yup.boolean().required().oneOf([true, false]),
angular: yup.boolean().required().oneOf([true, false]),
vue: yup.boolean().required().oneOf([true, false]),
})
}
>
<FormChildren />
</HookForm>
)
}

```

## Standalone
Expand Down
85 changes: 60 additions & 25 deletions docs/pages/components/date-picker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,46 +21,81 @@ It is based on the [react-datepicker](https://github.com/Hacker0x01/react-datepi
## Simple use case

```jsx
<Form initialValues={{ welcome: Date.now() }}>
<ConnectedField component={DatePicker} label="Date" name="welcome" />
</Form>
function () {
const [value, setValue] = useState(Date.now())

const handleChange = newValue => {
setValue(newValue)
}

return (
<Field label="Date">
<DatePicker name="welcome" onChange={handleChange} value={value} />
</Field>
)
}
```

## Pass props from the original library.

```jsx
<Form initialValues={{ welcome2: Date.now() }}>
<ConnectedField
component={DatePicker}
dateFormat="MMM dd yyyy"
label="Date"
maxDate={new Date()}
name="welcome2"
popperProps={{ zIndex: 50 }}
yearDropdownItemNumber={30}
/>
</Form>
function () {
const [value, setValue] = useState(Date.now())

const handleChange = newValue => {
setValue(newValue)
}

return (
<Field label="Date">
<DatePicker
dateFormat="MMM dd yyyy"
name="welcome2"
maxDate={new Date()}
popperProps={{ zIndex: 50 }}
yearDropdownItemNumber={30}
onChange={handleChange}
value={value}
/>
</Field>
)
}
```

## Give an Icon

```jsx
<Form initialValues={{ welcome3: Date.now() }}>
<ConnectedField
component={DatePicker}
icon={<DateIcon color="light.100" />}
label="Date"
name="welcome3"
/>
</Form>
function () {
const [value, setValue] = useState(Date.now())

const handleChange = newValue => {
setValue(newValue)
}

return (
<Field label="Date">
<DatePicker icon={<DateIcon color="light.100" />} name="welcome3" value={value} onChange={handleChange} />
</Field>
)
}
```

## fr locale

```jsx
<Form initialValues={{}}>
<ConnectedField component={DatePicker} label="Date" locale={dateFR} name="welcome4" />
</Form>
function () {
const [value, setValue] = useState(Date.now())

const handleChange = newValue => {
setValue(newValue)
}

return (
<Field label="Date">
<DatePicker locale={dateFR} name="welcome4" value={value} onChange={handleChange} />
</Field>
)
}
```

## Properties
Expand Down