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

Change Popover.Arrow and Tooltip.Arrow position according to parent position #100

Closed
diegohaz opened this issue Jun 23, 2018 · 1 comment

Comments

@diegohaz
Copy link
Member

diegohaz commented Jun 23, 2018

Currently, if we pass a different pos to Tooltip or Popover, we also need to change the pos prop on the Arrow component.

<Tooltip pos="bottom">
  <Tooltip.Arrow pos="top" />
  Tooltip
</Tooltip>

That's kind of annoying. Setting pos="bottom" on Tooltip should automatically and correctly position Tooltip.Arrow.

We can't reliably set props on Arrow from Tooltip. The best option we have, I guess, is to change the styles. Something like this:

import { ifProp } from "styled-tools";
import TooltipArrow from "./TooltipArrow";

const Tooltip = styled(Base)`
  position: absolute;
  ${TooltipArrow} {
    // styles based on Tooltip pos
    ${ifProp({ pos: "bottom" }, /* apply styles for pos top */)}
  }
`;

In order to get Perpendicular styles, we should use getStyle from styled-tools:

import { ifProp, getStyle } from "styled-tools";
import TooltipArrow from "./TooltipArrow";

const Tooltip = styled(Base)`
  position: absolute;
  ${TooltipArrow} {
    ${ifProp({ pos: "bottom" }, getStyle(TooltipArrow, { pos: "top" }))};
  }
`;
@diegohaz diegohaz assigned tcodes0 and unassigned tcodes0 Jun 23, 2018
@diegohaz diegohaz added wontfix and removed feature labels Jun 27, 2018
@diegohaz
Copy link
Member Author

diegohaz commented Jun 27, 2018

Besides being too hidden magic, it'll require a lot of work and ugly code to happen (with bugs, probably). Closing for now.

@diegohaz diegohaz reopened this Jul 29, 2018
@diegohaz diegohaz removed the wontfix label Jul 29, 2018
diegohaz added a commit that referenced this issue Jul 30, 2018
Closes #130
Closes #100 

BREAKING CHANGE: `Hidden` styles have been changed. Now it has a `transform` property by default.

This affects all the other components that use `Hidden`: `Backdrop`, `Overlay`, `Sidebar`, `Popover`, `Tooltip`, `Step` and `TabsPanel`.

BREAKING CHANGE: `Perpendicular` has been removed. `Popover` and `Tooltip` use [popper.js](https://github.com/FezVrasta/popper.js) instead. 

It affects also `PopoverArrow` and `TooltipArrow`, which don't accept `Perpendicular` props anymore.

BREAKING CHANGE: `pos` prop on `Popover` and `Tooltip` has been replaced by `placement` prop, which accepts all the `pos` values plus `-start` and `-end` versions.

Before:
```jsx
<Popover pos="top" align="start" />
```

After:
```jsx
<Popover placement="top-start" />
```

BREAKING CHANGE: `PopoverArrow` and `TooltipArrow` don't accept `pos` anymore. Their position and angle are now automatically set according to `Popover` and `Tooltip` `placement` prop.

Before:
```jsx
<Popover pos="top">
  <Popover.Arrow pos="bottom" />
</Popover>
```

After:
```jsx
<Popover placement="top">
  <Popover.Arrow />
</Popover>
```

BREAKING CHANGE: `popoverId` state on `PopoverContainer` is now set on `componentDidMount` instead of on initial state. 

This means that it'll be `undefined` on the first render, but will have a consistent behavior when using [`context`](https://github.com/diegohaz/constate#context) prop.

BREAKING CHANGE: `Tooltip` styles have been changed. Now it has a slightly larger `font-size` and opaque `background-color`.
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

No branches or pull requests

2 participants