Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export default () => (
- [style](#style)
- [visible (from Popover)](#visible)
- [wrapperStyle](#wrapperStyle)
- [caretStyle](#caretStyle)
Copy link
Owner

Choose a reason for hiding this comment

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

Could this be added alongside caret* props?

Below caretPosition for example!

Please make sure to also change the position of the caretStyle paragraph :)


#### Popable.children

Expand Down Expand Up @@ -163,6 +164,15 @@ Style the wrapping `View` component using any [`View` style property](https://re
<Popable wrapperStyle={{ flex: 1, display: 'flex' }}>@morning_cafe</Popable>
```

#### caretStyle

Style the caret component using any [`View` style property](https://reactnative.dev/docs/view-style-props).

```jsx
<Popable caretStyle={{ backgroundColor: "blue" }}>@morning_cafe</Popable>
```


### Popover

The UI component in `Popable` can also be used on its own.
Expand Down
3 changes: 3 additions & 0 deletions src/Popable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type PopableProps = {
style?: PopoverProps['style'];
visible?: boolean;
wrapperStyle?: ViewProps['style'];
caretStyle?: ViewProps['style'];
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
caretStyle?: ViewProps['style'];
caretStyle?: PopoverProps['caretStyle'];

};

const DEFAULT_LAYOUT = {
Expand All @@ -61,6 +62,7 @@ const Popable = forwardRef<PopableManager, PopableProps>(function Popable(
style,
visible,
wrapperStyle,
caretStyle,
},
ref
) {
Expand Down Expand Up @@ -223,6 +225,7 @@ const Popable = forwardRef<PopableManager, PopableProps>(function Popable(
<Popover
{...sharedPopoverProps}
forceInitialAnimation
caretStyle={caretStyle}
Comment on lines 226 to +228
Copy link
Owner

Choose a reason for hiding this comment

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

Could caretStyle be added to sharedPopoverProps instead?

const sharedPopoverProps = {
  animated,
  ...,
  caretPosition,
  caretStyle, // <<

If we don't, caretStyle won't be added to the other instance of Popover on web below :)

visible={isPopoverVisible}
style={[
{
Expand Down
4 changes: 3 additions & 1 deletion src/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type PopoverProps = {
forceInitialAnimation?: boolean;
numberOfLines?: number;
visible?: boolean;
caretStyle: ViewProps['style'];
Copy link
Owner

Choose a reason for hiding this comment

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

caretStyle should be optional :)

Suggested change
caretStyle: ViewProps['style'];
caretStyle?: ViewProps['style'];

position?: 'top' | 'right' | 'bottom' | 'left';
} & ViewProps;

Expand All @@ -35,6 +36,7 @@ const Popover = React.forwardRef<View, PopoverProps>(function Popover(
forceInitialAnimation = false,
numberOfLines,
visible = true,
caretStyle = null,
Copy link
Owner

Choose a reason for hiding this comment

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

No need to set a default value, undefined will work too:

Suggested change
caretStyle = null,
caretStyle,

position = 'bottom',
style,
...extraProps
Expand Down Expand Up @@ -84,7 +86,7 @@ const Popover = React.forwardRef<View, PopoverProps>(function Popover(
align={caretPosition}
position={position}
backgroundColor={backgroundColor}
style={styles.caret}
style={[styles.caret, caretStyle]}
/>
);

Expand Down