Skip to content

Commit

Permalink
Fixes on contact picker (#1285)
Browse files Browse the repository at this point in the history
Fixes on contact picker
  • Loading branch information
drazik authored Dec 2, 2019
2 parents 0581b59 + 85ce48c commit 81ce2cf
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 29 deletions.
1 change: 1 addition & 0 deletions react/ContactPicker/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ initialState = { selectedContact: null };
<DemoProvider>
<ContactPicker
placeholder="Select a contact"
listPlaceholder="Search a contact"
onChange={selectedContact => setState({ selectedContact })}
value={state.selectedContact}
/>
Expand Down
3 changes: 2 additions & 1 deletion react/ContactPicker/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const SelectControl = props => {
}

const ContactPicker = props => {
const { placeholder, onChange, value, ...rest } = props
const { placeholder, listPlaceholder, onChange, value, ...rest } = props
const [showContactsList, setShowContactsList] = useState(false)

const handleChange = contact => {
Expand All @@ -35,6 +35,7 @@ const ContactPicker = props => {
<ContactsListModal
dismissAction={() => setShowContactsList(false)}
onItemClick={handleChange}
placeholder={listPlaceholder}
/>
)}
</>
Expand Down
10 changes: 7 additions & 3 deletions react/ContactsListModal/index.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React, { useState } from 'react'
import { Query, fetchPolicies } from 'cozy-client'
import ContactsList from '../ContactsList'
import Modal, { ModalHeader, ModalDescription, ModalBackButton } from '../Modal'
import Modal, { ModalHeader, ModalDescription } from '../Modal'
import Spinner from '../Spinner'
import styles from './styles.styl'
import Input from '../Input'
import PropTypes from 'prop-types'
import withBreakpoints from '../helpers/withBreakpoints'
import Button from '../Button'
import { Contact } from 'cozy-doctypes'

const thirtySeconds = 30000
Expand Down Expand Up @@ -60,9 +61,12 @@ const ContactsListModal = props => {
<Modal size="xxlarge" mobileFullscreen {...rest} closable={!isMobile}>
<ModalHeader className={styles.ContactsListModal__header}>
{isMobile && (
<ModalBackButton
<Button
onClick={rest.dismissAction}
style={{ color: 'var(--white)' }}
extension="narrow"
iconOnly
icon="previous"
theme="primary"
/>
)}
<Input
Expand Down
4 changes: 2 additions & 2 deletions react/ContactsListModal/styles.styl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@require 'settings/breakpoints'

.ContactsListModal__header
.ContactsListModal__header.ContactsListModal__header
+small-screen()
background-color var(--primaryColor)
padding rem(12) 0
Expand All @@ -21,5 +21,5 @@
&::placeholder
color inherit

.ContactsListModal__description
.ContactsListModal__description.ContactsListModal__description
padding 0
3 changes: 2 additions & 1 deletion react/Field/styles.styl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@require '../../stylus/components/forms'
@require 'settings/spaces.styl'

.o-field
@extend $field
Expand All @@ -11,7 +12,7 @@
flex-basis rem(128)
flex-shrink 0
flex-grow 0
padding 0.75rem 0
padding spacing_values.m 0

+small-screen()
flex-basis auto
Expand Down
46 changes: 24 additions & 22 deletions react/Labs/CollectionField/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,30 @@ const CollectionField = props => {
<FieldContainer {...rest}>
<Label>{label}</Label>
<Stack>
<Stack spacing="s">
{values.map((value, index) => {
return (
<div key={index} className={styles.CollectionField__row}>
<Component
value={value}
onChange={handleChange(index)}
placeholder={placeholder}
/>
<Button
type="button"
theme="secondary"
label={removeButtonLabel}
iconOnly
round
icon={<Icon icon="cross-small" color="var(--slateGrey)" />}
onClick={() => handleRemove(index)}
/>
</div>
)
})}
</Stack>
{values.length > 0 ? (
<Stack spacing="s">
{values.map((value, index) => {
return (
<div key={index} className={styles.CollectionField__row}>
<Component
value={value}
onChange={handleChange(index)}
placeholder={placeholder}
/>
<Button
type="button"
theme="secondary"
label={removeButtonLabel}
iconOnly
round
icon={<Icon icon="cross-small" color="var(--slateGrey)" />}
onClick={() => handleRemove(index)}
/>
</div>
)
})}
</Stack>
) : null}
<Button
label={addButtonLabel}
type="button"
Expand Down

0 comments on commit 81ce2cf

Please sign in to comment.