Skip to content

Conversation

@dannify
Copy link
Member

@dannify dannify commented May 1, 2020

The Picker docs

@dannify dannify marked this pull request as ready for review May 1, 2020 00:25
@dannify dannify changed the title Picker docs and fixes [WIP] Picker docs and fixes May 1, 2020
@dannify dannify marked this pull request as draft May 1, 2020 00:25
@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

@dannify dannify marked this pull request as ready for review May 8, 2020 22:04
@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

@dannify dannify changed the title [WIP] Picker docs and fixes Picker docs and fixes May 12, 2020
@adobe-bot
Copy link

Build successful! 🎉


The dynamic method (shown below) would be better suited to use if the options came from a data object such as values returned from an API call. Providing the data in this way allows for Picker to automatically cache the rendering of each item, which dramatically improves performance.

As seen below, an iterable list of options is passed to the Picker using the `items` prop. The value to be passed to the `onSelectionChange` handler can be set via the `uniqueKey` prop. Alternatively, if the options dataset contains an `id` key, as shown in the example below, this can be used instead. See the <a href="#events" title="Events">events</a> section for more detail on selection.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value to be passed to the onSelectionChange handler can be set via the uniqueKey prop.

This is a bit confusing. I think I'd say something like "Each item accepts a uniqueKey prop, which is passed to the onSelectionChange handler to identify the selected item."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Alternatively, if the item objects contain an id property, as shown in the example below, then this is used automatically and a uniqueKey prop is not required.

];
let [animal, setAnimal] = React.useState("Bison");


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra whitespace

{item => <Item uniqueKey={item.name}>{item.name}</Item>}
</Picker>


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

### Static Items
```tsx example
<Picker label="Pick an animal">
<Section uniqueKey="Animals" title="Animals">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could remove the uniqueKey here, since it's static. React will assign a key automatically, and since it's not used for selection a manual key isn't needed.


### Static Items
```tsx example
<Picker label="Pick an animal">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These aren't all animals :P

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sometimes :)

}
```

When using Picker with dynamic items, selection works much the same way using `uniqueKey`. However, if your data already has an `id` key (as is common with many data sets), Picker can use that id without needing to specify a `uniqueKey` prop. The below example shows Picker using the id of each item from the `items` array as the selected value without the need for `uniqueKey`. Note that `uniqueKey` will always take precedence if set.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe say "id property" instead of "key"? I feel like key has an overloaded meaning

```

## Complex Items
Items within Picker also allow for additional content used to better communicate options. Icons, descriptions can be added to the `children` of `Item` as shown in the example below. If a description is added, the prop `slot="description"` must be used to distinguish the different `<Text>` elements.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Icons, and descriptions"

Items within Picker also allow for additional content used to better communicate options. Icons, descriptions can be added to the `children` of `Item` as shown in the example below. If a description is added, the prop `slot="description"` must be used to distinguish the different `<Text>` elements.

```tsx example
<Picker label="Options" >
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

@dannify dannify merged commit 547a655 into master May 12, 2020
@dannify dannify deleted the picker-docs branch May 12, 2020 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants