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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-calendar] Change tooltip to use hooks 馃帲 and portals #813

Merged
merged 24 commits into from May 6, 2020

Conversation

ajwhatson
Copy link
Contributor

@ajwhatson ajwhatson commented Apr 30, 2020

This creates a tooltip that utilizes react portals in order to live outside of the calendar component in which is was made.

This is an example of a tooltip living outside of its parent component.
Screen Shot 2020-04-30 at 2 29 01 PM

Included:

  • installation of @popperjs/core (for the tooltip), moment (to assist in the format of time in tooltip), react-popper (so the tooltip can be rendered in the correct position)

  • creation of Tooltip and Hook which together manage the positioning of the tooltip. Tooltip replaces the event element which would otherwise be automatically rendered FullCalendar. It replaces it with the hook. Hook makes the connection between the replacement event element and the new EventCard. Hook also conceals the EventCard when someone clicks away from the element and does so with eventListeners.

  • creation of EventCard which renders rows of information about the release. Each row has a related icon to the left and information to the right. The release cards match the corresponding channels by displaying a thin top bar and transparent background of the channel color.

  • styling for eventCard

  • styling adjustments to calendar in order to overwrite the default button colors of FullCalendar. FullCalendar.io does not allow for customized styling other than full Bootstrap themes- that seemed like an overkill.

  • small adjustments to the calendar so that the tooltip will not be cut off when it's positioned very low on the screen

  • change of testData from the first release being named 1234567890123 to 2004252135000 which instead is a real release tag so as to test the link to the github release body. Link will create a new tab.

  • emojis for channel schedule

  • add getReleaseDates(requestedRelease: string) to client side that uses the already made getCurrentReleases() call on the server side. This will carry ReleaseDate[] which contains promotion channels and start dates so to populate the emoji schedule.

  • TODO: Add cherrypick attribute to releaseDates currently the code on EventCard is commented out

  • TODO: Place emojis in rtv square on ChannelTable

@ajwhatson ajwhatson self-assigned this Apr 30, 2020
@ajwhatson ajwhatson changed the title [release-calendar] Change tooltip to use hooks and portals [release-calendar] Change tooltip to use hooks 馃帲 and portals Apr 30, 2020
Copy link
Contributor

@estherkim estherkim left a comment

Choose a reason for hiding this comment

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

Nice use of 馃帲

release-calendar/src/client/components/EventCard.tsx Outdated Show resolved Hide resolved
release-calendar/src/client/components/EventCard.tsx Outdated Show resolved Hide resolved
release-calendar/src/client/components/EventCard.tsx Outdated Show resolved Hide resolved
<div className={'content-row'} key={row.icon}>
<div className={'icon'}>
<i
className='material-icons'
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to use emojis instead of icons? We usually use 馃殑 for release

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also do you have a better idea for a Github emoji? 馃枼is just sad

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And! for LTS, what's better 馃彊or 馃彴? or other?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I think 馃彊

Copy link
Contributor

Choose a reason for hiding this comment

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

For the GitHub release link, I'd put 馃敆

@ajwhatson ajwhatson added this to In progress in Release Calendar Apr 30, 2020
@ajwhatson ajwhatson requested a review from estherkim May 1, 2020 20:28
release-calendar/src/client/components/EventCard.tsx Outdated Show resolved Hide resolved
release-calendar/src/client/components/EventCard.tsx Outdated Show resolved Hide resolved
</span>
</div>
<div className={'text'}>
{match.text + moment(row.date).format('MMMM Do, hA')}
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of having a match.text field, this can serve as a template to remove duplication.

Copy link
Contributor Author

@ajwhatson ajwhatson May 2, 2020

Choose a reason for hiding this comment

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

I'm not sure what you mean. Hm, if you're thinking that there could be something like
Promoted to Opt-in Experimental, Opt-In Beta on April 20th, 11 am
Promoted to Opt-in Experimental, Opt-In Beta on April 20th, 11 am
one line which represents Channel.OPT_IN_EXPERIMENTAL and the other Channel.OPT_IN_BETA? That wont happen because Channel.OPT_IN_BETA doesn't exist in the schedule template. There is the possibility of duplication if there had been a rollback and a release is getting reinstated to a channel it was already in. Is that what you're referring to? If so, I can brainstorm about adding a rollback line to divide the two promotions?

Copy link
Contributor

Choose a reason for hiding this comment

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

By template I mean removing the match.text field and putting here:
{match.title} was promoted ...

You don't have to have a single line for experimental/beta, if it makes it easier. 1 channel per line is okay.

release-calendar/src/client/components/EventCard.tsx Outdated Show resolved Hide resolved
<div ref={node}>
<div
ref={setPopperElement}
style={{...{zIndex: 999}, ...styles.popper}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be moved to an SCSS file? Not sure what popper suggests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a couple of things I can do.

  1. Change the CSSProperty in styles.popper directly.
    styles.popper['zIndex'] = 999;
  2. Keep what I have above
    style={{...{zIndex: 999}, ...styles.popper}}
  3. Or declare zIndex: 999 in a different variable
    const bringForward: React.CSSProperties = {zIndex: 999};
    style={{...bringForward,...styles.popper}}

Popper doesn't have a suggestion for smaller changes to style like this. But when doing a full customized tooltip, they suggest the third (when I wouldn't use styles.popper at all).

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, okay. We can leave this as is.

release-calendar/src/client/index.html Outdated Show resolved Hide resolved
@ajwhatson ajwhatson requested a review from estherkim May 4, 2020 16:18
release-calendar/package.json Outdated Show resolved Hide resolved
release-calendar/src/client/components/EventCard.tsx Outdated Show resolved Hide resolved
release-calendar/src/client/components/EventCard.tsx Outdated Show resolved Hide resolved
release-calendar/src/client/components/TooltipHook.tsx Outdated Show resolved Hide resolved
release-calendar/src/client/components/TooltipHook.tsx Outdated Show resolved Hide resolved
release-calendar/webpack.client.dev.config.js Show resolved Hide resolved
<div ref={node}>
<div
ref={setPopperElement}
style={{...{zIndex: 999}, ...styles.popper}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, okay. We can leave this as is.

@ajwhatson ajwhatson requested a review from estherkim May 4, 2020 23:39
release-calendar/package.json Outdated Show resolved Hide resolved
release-calendar/src/client/models/view-models.ts Outdated Show resolved Hide resolved
},
];

getTitle(search: Channel): string {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if history was a dict with Channel as the key? Could be a lot cleaner here.

Copy link
Contributor Author

@ajwhatson ajwhatson May 5, 2020

Choose a reason for hiding this comment

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

The best solution I can think to debug the channels with "-" not being accessible within the dictionary is to create an interface where the key is typed as a string. This will push the enum into a string under the hood, but it allows for normal dictionary sets and gets. If you are okay with here, then I could also make the channelsTitles a dictionary, which is currently a {channel: Channel, title: string}[]. We had used this structure because of the same weird "-" enum behavior. If I switched it, then I'd again have direct access to the titles I want instead of doing the find() loop I do now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we revisit the dict idea? Hyphens should not be a problem. For example

const channelMap = {
    'lts': 'lts',
    'stable': 'stable',
    'opt-in-beta': 'opt in beta',
    'perc-beta': '1% beta',
};

console.log(channels['opt-in-beta']);
// opt in beta

console.log(channels['perc-beta']);
// 1% beta

Copy link
Contributor

Choose a reason for hiding this comment

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

Making channelsTitles a dictionary is a great idea :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Also I totally misread your comment! My "revisit the dict idea" was not helpful haha. Nice workaround.

release-calendar/src/client/components/ReleaseCard.tsx Outdated Show resolved Hide resolved
release-calendar/src/client/stylesheets/_base.scss Outdated Show resolved Hide resolved
@ajwhatson
Copy link
Contributor Author

ajwhatson commented May 5, 2020

getReleaseDates() will be renamed to getRelease() once the current getRelease is changed in a different pr

release-calendar/package.json Outdated Show resolved Hide resolved
@@ -61,4 +61,10 @@ export class ApiService {
);
return new CurrentReleases(currentReleases);
}

async getReleaseDates(requestedRelease: string): Promise<Release> {
Copy link
Contributor

Choose a reason for hiding this comment

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

rename getReleaseDates because it's not getting releaseDates anymore.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I just saw your comment. Okay.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:)

release-calendar/src/client/components/ReleaseCard.tsx Outdated Show resolved Hide resolved
release-calendar/src/client/components/ReleaseCard.tsx Outdated Show resolved Hide resolved
},
];

getTitle(search: Channel): string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we revisit the dict idea? Hyphens should not be a problem. For example

const channelMap = {
    'lts': 'lts',
    'stable': 'stable',
    'opt-in-beta': 'opt in beta',
    'perc-beta': '1% beta',
};

console.log(channels['opt-in-beta']);
// opt in beta

console.log(channels['perc-beta']);
// 1% beta

@ajwhatson ajwhatson requested a review from estherkim May 6, 2020 02:14
@ajwhatson ajwhatson merged commit a433d09 into ampproject:master May 6, 2020
Release Calendar automation moved this from In progress to Done May 6, 2020
@ajwhatson ajwhatson deleted the eventCard branch May 6, 2020 19:08
@ajwhatson ajwhatson linked an issue May 7, 2020 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

[release-calendar] add links from github
4 participants