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

moving canvas font function to OSS #37619

Merged
merged 1 commit into from
Jun 25, 2019
Merged

Conversation

ppisljar
Copy link
Member

@ppisljar ppisljar commented May 31, 2019

Summary

Moves canvas font function to OSS, along with:

  • function_wrapper test utility, that its tests require
  • lib/fonts.ts which is required
  • types/style.ts which is required
    all of the three are reexported in their original place

blocker for #34532

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@ppisljar ppisljar added the chore label May 31, 2019
@ppisljar ppisljar requested a review from a team as a code owner May 31, 2019 07:52
@ppisljar ppisljar requested a review from w33ble May 31, 2019 07:53
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@lukeelmers lukeelmers force-pushed the move/canvasFontFn branch from f5d75f0 to 7fdfc58 Compare June 3, 2019 03:46

return (context, args, handlers) =>
spec.fn(context, { ...defaultArgs, ...args }, handlers, mockReduxStore);
};
Copy link
Member

Choose a reason for hiding this comment

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

Just FYI I think I already copied a (slightly modified) version of this to interpreter awhile back: src/legacy/core_plugins/interpreter/test_helpers.js

@elasticmachine
Copy link
Contributor

💔 Build Failed

@ppisljar ppisljar force-pushed the move/canvasFontFn branch from 7fdfc58 to cd9c607 Compare June 4, 2019 05:55
@elasticmachine
Copy link
Contributor

💔 Build Failed

@ppisljar
Copy link
Member Author

ppisljar commented Jun 6, 2019

retest

@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Contributor

@clintandrewhall clintandrewhall left a comment

Choose a reason for hiding this comment

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

You can test all of these changes easily in Storybook:

canvas: yarn storybook -> FontPicker

There's a bug currently fixed in #38222 that allows SVGs to load, but that shouldn't prevent you from testing easily.

import { i18n } from '@kbn/i18n';
import { FontWeight } from '../../types';

export const help: any = {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should always include a comment explaining why we're putting an any in TS. In this case, it's because the help introspection types haven't been moved up into OSS (yet).

I would add a TODO comment here with a link to an issue (if one exists, otherwise create one) explaining this should be converted to use a similar structure to what exists in Canvas.

This is important. It ensures Expressions are and remain translated.

Copy link
Member Author

Choose a reason for hiding this comment

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

i moved the translations into the function as we have with the rest of the functions in OSS for now, we'll move them back when/if we add the help introspection to OSS

/**
* Collection of text alignments.
*/
export const TEXT_ALIGNMENTS: TextAlignment[] = ['center', 'left', 'right', 'justify'];
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be deleted and callsites converted to TextAlignment.values()... no need to repeat. This was a chore I never cleaned up.

Copy link
Member Author

Choose a reason for hiding this comment

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

is there a way to convert string literal union to js array ?

Copy link
Member

Choose a reason for hiding this comment

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

is there a way to convert string literal union to js array ?

Yeah IDK if you can do this. I think you can do it the other way though (define a js array and convert it to a string literal union). But I'm not aware of any way to go union > array.

I'm also not sure TextAlignment.values() would work in this case, but @clintandrewhall probably knows of some magic I haven't heard of here

backgroundColor: string | null;
backgroundImage: string | null;
backgroundSize: 'contain' | 'cover' | 'auto';
backgroundRepeat: 'repeat-x' | 'repeat' | 'space' | 'round' | 'no-repeat' | 'space';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd love to see all of these as types, personally.

@clintandrewhall
Copy link
Contributor

clintandrewhall commented Jun 6, 2019

@lukeelmers Where do we stand on bringing the i18n help and error introspection into OSS? If we're not going to move that upward, that's ok... but I'd insist the font help have a copy or facsimile before being checked in.

@ppisljar ppisljar force-pushed the move/canvasFontFn branch from cd9c607 to 9fcc72c Compare June 6, 2019 08:59
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@ppisljar ppisljar force-pushed the move/canvasFontFn branch from 11f2fef to b28e258 Compare June 6, 2019 11:45
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Member

@lukeelmers lukeelmers left a comment

Choose a reason for hiding this comment

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

LGTM! Added 2 notes, but they shouldn't block merging this PR; they're intended more for future discussion.

/**
* Collection of text alignments.
*/
export const TEXT_ALIGNMENTS: TextAlignment[] = ['center', 'left', 'right', 'justify'];
Copy link
Member

Choose a reason for hiding this comment

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

is there a way to convert string literal union to js array ?

Yeah IDK if you can do this. I think you can do it the other way though (define a js array and convert it to a string literal union). But I'm not aware of any way to go union > array.

I'm also not sure TextAlignment.values() would work in this case, but @clintandrewhall probably knows of some magic I haven't heard of here

import { i18n } from '@kbn/i18n';
import { openSans } from '../../common/lib/fonts';
import { ExpressionFunction } from '../../types';
import { CSSStyle, FontFamily, FontWeight, Style, TextAlignment, TEXT_ALIGNMENTS } from '../types';
Copy link
Member

Choose a reason for hiding this comment

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

Question on the location (not sure if I know the right answer, just thinking aloud):

Since we know types for fonts are only going to be in /public (not /server), it makes sense that we would export them here. But would it make more sense to colocate them with the other types in interpreter/types, and then simply re-export them from interpreter/public?

It's the first time we've run into this situation, but I suppose it's a question of conventions. Do we want to centralize all types that we know are shared at a top-level (alongside /server and /public), and then export them as needed to either server or public or both? Or do we take items that we know are only ever one or the other and create another types directory inside of public?

Regardless I don't think this is important to solve now -- since this will all be moving to plugins/data eventually we can sort this out at that time. Just thought I'd raise the question to see if you had strong feelings on it.

@lukeelmers
Copy link
Member

Where do we stand on bringing the i18n help and error introspection into OSS? If we're not going to move that upward, that's ok... but I'd insist the font help have a copy or facsimile before being checked in.

@clintandrewhall For whatever reason I'm having trouble grokking exactly how the help types are working in Canvas, even after looking through the code a couple times. I could probably benefit from a quick sync if you have some time... I think it would be clearer for me to hear someone explain in person, and then would make it easier for us to sort out the best way to apply them here.

@clintandrewhall
Copy link
Contributor

@lukeelmers and I chatted today, and I'm going to provide more documentation and a few tweaks to font that will be helpful in a PR. Let's circle back Monday, as well. Thanks!

@clintandrewhall
Copy link
Contributor

I created #38554 to help... let me know if I can further clarify!

@ppisljar
Copy link
Member Author

thanks @clintandrewhall
regarding the i18n help and error introspection in OSS, i would keep it out of this PR to unblock the effort on improving semantics of OSS functions, and i suggest to tackle this all-at-once for all OSS functions.

@ppisljar ppisljar added the release_note:skip Skip the PR/issue when compiling release notes label Jun 14, 2019
@ppisljar ppisljar force-pushed the move/canvasFontFn branch from b28e258 to cbb7e8d Compare June 14, 2019 08:39
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@ppisljar
Copy link
Member Author

retest

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@clintandrewhall clintandrewhall removed the request for review from w33ble June 24, 2019 18:01
@ppisljar ppisljar force-pushed the move/canvasFontFn branch from 3937b98 to 201a510 Compare June 25, 2019 06:05
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@ppisljar ppisljar merged commit 01610b1 into elastic:master Jun 25, 2019
ppisljar added a commit that referenced this pull request Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore release_note:skip Skip the PR/issue when compiling release notes v7.3.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants