-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Conversation
Pinging @elastic/kibana-app-arch |
💔 Build Failed |
💔 Build Failed |
f5d75f0
to
7fdfc58
Compare
|
||
return (context, args, handlers) => | ||
spec.fn(context, { ...defaultArgs, ...args }, handlers, mockReduxStore); | ||
}; |
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.
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
💔 Build Failed |
7fdfc58
to
cd9c607
Compare
💔 Build Failed |
retest |
💔 Build Failed |
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.
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 = { |
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.
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.
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.
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']; |
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.
This should be deleted and callsites converted to TextAlignment.values()
... no need to repeat. This was a chore I never cleaned up.
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.
is there a way to convert string literal union to js array ?
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.
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'; |
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.
nit: I'd love to see all of these as types, personally.
@lukeelmers Where do we stand on bringing the |
cd9c607
to
9fcc72c
Compare
💔 Build Failed |
💔 Build Failed |
11f2fef
to
b28e258
Compare
💔 Build Failed |
💚 Build Succeeded |
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.
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']; |
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.
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'; |
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.
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.
@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. |
@lukeelmers and I chatted today, and I'm going to provide more documentation and a few tweaks to |
I created #38554 to help... let me know if I can further clarify! |
thanks @clintandrewhall |
b28e258
to
cbb7e8d
Compare
💔 Build Failed |
💔 Build Failed |
retest |
💚 Build Succeeded |
3937b98
to
201a510
Compare
💚 Build Succeeded |
Summary
Moves canvas
font
function to OSS, along with:all of the three are reexported in their original place
blocker for #34532
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.[ ] This was checked for cross-browser compatibility, including a check against IE11[ ] Documentation was added for features that require explanation or tutorials[ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers
[ ] This was checked for breaking API changes and was labeled appropriately[ ] This includes a feature addition or change that requires a release note and was labeled appropriately