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

Add Overlay predefined positions #14752

Open
NetanelBasal opened this issue Jan 8, 2019 · 2 comments
Open

Add Overlay predefined positions #14752

NetanelBasal opened this issue Jan 8, 2019 · 2 comments
Labels
area: cdk/overlay docs This issue is related to documentation P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@NetanelBasal
Copy link

Hey guys,

Just published a new article about creating components with the CDK overlay. I'm suggesting to add predefined overlay positions to the library. I find that people are struggling to figure out how it works.

Here is what I imagine:

// overlay-predefined-positions.ts

/**
 * Set of predefined overlay positions.
 * Don't use object as we want it to be treeshakable.
 *
 */
export const overlayPositionTop: ConnectionPositionPair = {
  originX: 'center',
  originY: 'top',
  overlayX: 'center',
  overlayY: 'bottom'
};

export const overlayPositionTopCenter: ConnectionPositionPair = {
  originX: 'center',
  originY: 'top',
  overlayX: 'center',
  overlayY: 'bottom'
};

export const overlayPositionTopLeft: ConnectionPositionPair = {
  originX: 'start',
  originY: 'top',
  overlayX: 'start',
  overlayY: 'bottom'
};

export const overlayPositionTopRight: ConnectionPositionPair = {
  originX: 'end',
  originY: 'top',
  overlayX: 'end',
  overlayY: 'bottom'
};

export const overlayPositionRight: ConnectionPositionPair = {
  originX: 'end',
  originY: 'center',
  overlayX: 'start',
  overlayY: 'center'
};

export const overlayPositionRightTop: ConnectionPositionPair = {
  originX: 'end',
  originY: 'top',
  overlayX: 'start',
  overlayY: 'top'
};

export const overlayPositionRightBottom: ConnectionPositionPair = {
  originX: 'end',
  originY: 'bottom',
  overlayX: 'start',
  overlayY: 'bottom'
};

export const overlayPositionBottom: ConnectionPositionPair = {
  originX: 'center',
  originY: 'bottom',
  overlayX: 'center',
  overlayY: 'top'
};

export const overlayPositionBottomCenter: ConnectionPositionPair = {
  originX: 'center',
  originY: 'bottom',
  overlayX: 'center',
  overlayY: 'top'
};

export const overlayPositionBottomLeft: ConnectionPositionPair = {
  originX: 'start',
  originY: 'bottom',
  overlayX: 'start',
  overlayY: 'top'
};

export const overlayPositionBottomRight: ConnectionPositionPair = {
  originX: 'end',
  originY: 'bottom',
  overlayX: 'end',
  overlayY: 'top'
};

export const overlayPositionLeft: ConnectionPositionPair = {
  originX: 'start',
  originY: 'center',
  overlayX: 'end',
  overlayY: 'center'
};

export const overlayPositionLeftTop: ConnectionPositionPair = {
  originX: 'start',
  originY: 'top',
  overlayX: 'end',
  overlayY: 'top'
};

export const overlayPositionLeftBottom: ConnectionPositionPair = {
  originX: 'start',
  originY: 'bottom',
  overlayX: 'end',
  overlayY: 'bottom'
};

Let me know what you think. Thanks.

@jelbourn jelbourn added feature This issue represents a new feature or feature request rather than a bug or bug fix discussion labels Jan 10, 2019
@jelbourn
Copy link
Member

I think that this would make things even more confusing by giving people too many options. I think a better solution to explaining the positioning would be to have a live example that lets you set the position parameters and see the result in real-time.

@NetanelBasal
Copy link
Author

Allow me to disagree with you. Take for example the most popular positioning tool - Popper.js.

Popper exposes a simple API, for example:

new Popper(referenceElement, onPopper, {
  placement: 'right'
});

The placement option is straightforward and readable; You don't need to know, learn or think how the positioning system works. It provides multiple options like top, right, left, right-start, top-end, etc. I think the whole purpose of the CDK is to make things easier for the consumers by exposing a convenient API.

@mmalerba mmalerba added needs: discussion Further discussion with the team is needed before proceeding and removed discussion labels Mar 3, 2020
@mmalerba mmalerba added the needs triage This issue needs to be triaged by the team label May 20, 2020
@mmalerba mmalerba added docs This issue is related to documentation P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed feature This issue represents a new feature or feature request rather than a bug or bug fix needs: discussion Further discussion with the team is needed before proceeding needs triage This issue needs to be triaged by the team labels Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cdk/overlay docs This issue is related to documentation P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

4 participants