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

feat(popover): add align functionality #2835

Merged
merged 1 commit into from
Jan 16, 2020

Conversation

bryceosterhaus
Copy link
Member

@bryceosterhaus bryceosterhaus commented Jan 7, 2020

fixes #2768

@coveralls
Copy link

coveralls commented Jan 7, 2020

Pull Request Test Coverage Report for Build 4195

  • 12 of 23 (52.17%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.4%) to 77.816%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/clay-popover/src/index.tsx 12 23 52.17%
Totals Coverage Status
Change from base Build 4194: -0.4%
Covered Lines: 2126
Relevant Lines: 2535

💛 - Coveralls

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 7, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit e3825ad:

Sandbox Source
dank-http-qepcn Configuration
elated-cache-w5ypo Configuration

bottom: ['tc', 'bc'],
'bottom-left': ['tl', 'bl'],
'bottom-right': ['tr', 'br'],
left: ['cr', 'cl'],
Copy link
Member

Choose a reason for hiding this comment

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

How come we mix and match the nomenclature of these attributes? Some have quotes and others don't. I understand that the ones that don't have them don't need them, but why not favor consistency?

Yeah, but your scientists were so preoccupied with whether or not they could, they didn't stop to think if they should.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the idea is "use it when it's needed don't when it's not".

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I think we would tend to follow juliens comment. Also we have an eslint rule in this project(quote-props) that auto formats it to not use quotes when it isn't necessary.

Here is an example eslint error
Screen Shot 2020-01-10 at 11 25 34 AM

Copy link
Contributor

Choose a reason for hiding this comment

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

The only reason we haven't changed it to "consistent-as-needed" yet:

liferay/eslint-config-liferay#39

is due to an open bug in Prettier:

prettier/prettier#6064

Once that is resolved this will become somewhat nicer:

const ALIGNMENTS_MAP = {
	'bottom': ['tc', 'bc'],
	'bottom-left': ['tl', 'bl'],
	'bottom-right': ['tr', 'br'],
	'left': ['cr', 'cl'],
        // etc...
};

ref = popoverRef as React.Ref<HTMLDivElement>;
}

React.useEffect(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Is the preferred practice to use React.useSomething instead of importing useSomething from React, as I see examples of both when searching through the source code (mostly of React.useSomething)?

Copy link
Member Author

Choose a reason for hiding this comment

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

TBH, it's not a huge issue if you go one way or the other, so long as its consistent for the component or file you are working in. Personally I would opt for React.* and I forget where this conversation had happened, but I think we decided to try an opt for React.* to avoid confusion with our other custom hooks use*.

Copy link
Contributor

Choose a reason for hiding this comment

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

(Not this repo, but...) In liferay-portal we mostly just use useState and friends directly, because the number of built-in hooks is small and nobody actually gets confused about them coming from React. Less clutter in the code too, less likely to have to awkwardly wrap lines etc.

/**
* React element that the popover will align to when clicked.
*/
alignNode?: React.ReactElement & {
Copy link
Member

Choose a reason for hiding this comment

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

It might be better to rename the prop to trigger, at first glance I thought I needed to just pass the element ref and will also create a consistency with DropDown that uses the same approach to alignment.

@bryceosterhaus
Copy link
Member Author

@matuzalemsteles updated

Copy link
Member

@matuzalemsteles matuzalemsteles left a comment

Choose a reason for hiding this comment

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

LGTM

@bryceosterhaus bryceosterhaus merged commit c8cb6d2 into liferay:master Jan 16, 2020
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.

Popover positioning
6 participants