Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Labs/Popover2] Ease Popover2 migration with prop shims (#1581)
- Loading branch information
Showing
4 changed files
with
242 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright 2015 Palantir Technologies, Inc. All rights reserved. | ||
* Licensed under the BSD-3 License as modified (the “License”); you may obtain a copy | ||
* of the license at https://github.com/palantir/blueprint/blob/master/LICENSE | ||
* and https://github.com/palantir/blueprint/blob/master/PATENTS | ||
*/ | ||
|
||
const ns = "[Blueprint]"; | ||
const deprec = `${ns} DEPRECATION:`; | ||
|
||
export const POPOVER2_WARN_DEPRECATED_IS_DISABLED = `${deprec} <Popover2> isDisabled is deprecated. Use disabled.`; | ||
export const POPOVER2_WARN_DEPRECATED_IS_MODAL = `${deprec} <Popover2> isModal is deprecated. Use hasBackdrop.`; | ||
export const POPOVER2_WARN_DEPRECATED_POSITION = `${deprec} <Popover2> position is deprecated. Use placement.`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/labs/src/components/popover/popoverMigrationUtils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2017 Palantir Technologies, Inc. All rights reserved. | ||
* Licensed under the BSD-3 License as modified (the “License”); you may obtain a copy | ||
* of the license at https://github.com/palantir/blueprint/blob/master/LICENSE | ||
* and https://github.com/palantir/blueprint/blob/master/PATENTS | ||
*/ | ||
|
||
import { Position } from "@blueprintjs/core"; | ||
import { Placement } from "./popover2"; | ||
|
||
/** | ||
* Convert a position to a placement. | ||
* @param position the position to convert | ||
*/ | ||
export function positionToPlacement(position: Position): Placement { | ||
switch (position) { | ||
case Position.TOP_LEFT: | ||
return "top-start"; | ||
case Position.TOP: | ||
return "top"; | ||
case Position.TOP_RIGHT: | ||
return "top-end"; | ||
case Position.RIGHT_TOP: | ||
return "right-start"; | ||
case Position.RIGHT: | ||
return "right"; | ||
case Position.RIGHT_BOTTOM: | ||
return "right-end"; | ||
case Position.BOTTOM_RIGHT: | ||
return "bottom-end"; | ||
case Position.BOTTOM: | ||
return "bottom"; | ||
case Position.BOTTOM_LEFT: | ||
return "bottom-start"; | ||
case Position.LEFT_BOTTOM: | ||
return "left-end"; | ||
case Position.LEFT: | ||
return "left"; | ||
case Position.LEFT_TOP: | ||
return "left-start"; | ||
default: | ||
return assertNever(position); | ||
} | ||
} | ||
|
||
function assertNever(x: never): never { | ||
throw new Error("Unexpected position: " + x); | ||
} |
Oops, something went wrong.
d90adf5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Labs/Popover2] Ease Popover2 migration with prop shims (#1581)
Preview: documentation
Coverage: core | datetime