-
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
theme function #73451
theme function #73451
Conversation
Pinging @elastic/kibana-app-arch (Team:AppArch) |
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.
Haven't tested this, but the general approach looks good to me.
src/plugins/expressions/common/expression_functions/specs/theme.ts
Outdated
Show resolved
Hide resolved
help: i18n.translate('expressions.functions.font.args.defaultHelpText', { | ||
defaultMessage: 'default value in case theming info is not available.', | ||
}), | ||
types: ['string', 'number'], |
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.
Can we just allow everything here? For palettes it might be nice at some point to return more than just a simple value at once - this would give us more flexibility in using theme variables.
An example would be the palette params - the shape can be different for different palettes, so we can't always flatten them out into separate args
Same for output type of course.
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.
@ppisljar you gave a plus 1 but didn't change the code - do you have concerns with this? I'm open for discussion, but I'm not seeing why we shouldn't allow all types here
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 did, for some reason clicking the link in above comment takes you to old code without this change. going to files to view all changes you can confirm that type limitation was removed.
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.
Missed that, sorry. It seems like the Output
typescript type is still more restrictive, but that's just a nit as it should only be relevant for the implementation of the function itself.
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.
Code here LGTM so far. Haven't tested locally yet, but would be nice if we could add a couple of basic unit tests for the theme
fn.
src/plugins/expressions/common/expression_functions/specs/theme.ts
Outdated
Show resolved
Hide resolved
…e.ts Co-authored-by: Luke Elmers <lukeelmers@gmail.com>
@elasticmachine merge upstream |
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.
Added 2 small notes, but overall code updates LGTM; tested out the font
function in Canvas locally and it seems to still be working as I'd expect.
export type ExpressionFunctionTheme = ExpressionFunctionDefinition< | ||
'theme', | ||
null, | ||
Arguments, | ||
Output | ||
>; |
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 also get added to the mapping of all function definitions provided by the expressions plugin in src/plugins/expressions/common/expression_functions/types.ts
(I'm wondering if we should just get rid of this mapping; it feels like something that will be easy to forget to update?)
it('defaults to 14px', () => { | ||
const result = fn(null); | ||
expect(result).toMatchObject({ | ||
spec: { | ||
fontSize: '14px', | ||
}, | ||
}); | ||
expect(result.css).toContain('font-size:14px'); | ||
}); |
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.
One nit here -- it would be cool to add an integration test for font
that actually validates the correct default value is applied via theme
, based on whether or not you have set the appropriate variable.
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.
that won't be possible due to the way interpreter works:
- before running any function (font in this case) it will check if any arguments are missing and if defaults are provided for them
- it will evaluate the default value (interpret and execute), so if default is expression it will run it
- it will provide the result of expression as an actual argument to our function (font)
here we are just testing the font function without interpreter and providing arguments in. to do integration test we would need interpreter service running (with the registries and everything) which i think is hard at the moment.
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.
Ready to merge from my side, just a small nit about the Output
type of the function.
@elasticmachine merge upstream |
* master: (106 commits) [Functional Tests] Adds a wait time between setting the index pattern and the time field on TSVB (elastic#74736) [Lens] Add styling options for x and y axes on the settings popover (elastic#71829) [Maps] add initial location option that fits to data bounds (elastic#74583) theme function (elastic#73451) [data.ui.query] Write filters to query log from default editor. (elastic#74474) [data.search.SearchSource] Move some SearchSource dependencies to the server. (elastic#74607) [Canvas][tech-debt] Convert renderers (elastic#74134) [security solutions][lists] Adds end to end tests (elastic#74473) pluralized for occurrences vs occurrence (elastic#74564) Update links that pointed to CONTRIBUTING.md (elastic#74757) [Ingest pipelines] Implement tabs in processor flyout (elastic#74469) [Event log] Use Alerts client & Actions client when fetching these types of SOs (elastic#73257) Bump chalk to 4.1.0 (elastic#73397) Index pattern field list - transition away from extending array - introduce and use getAll() (elastic#74718) [SECURITY] Bugs css/inspect (elastic#74711) [telemetry] update README to downplay ui_metrics (elastic#74635) Fixed grammar (elastic#74725) [Telemetry][API Integration] size_in_bytes to be a number (elastic#74664) [ILM] Convert node details flyout to TS (elastic#73707) [Ingest Node Pipelines] Sentence-case processor names (elastic#74645) ...
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
page load bundle size
History
To update your PR or re-run it, just comment with: |
…nes/processor-forms-a-d * 'master' of github.com:elastic/kibana: (25 commits) [ML] Removing full lodash library imports (elastic#74742) [Search] Server strategy example (elastic#71679) [Reporting] Fix and test for Listing of Reports (elastic#74453) [maps] fix drawing shapes (elastic#74689) [Resolver] Improve simulator. Add more click-through tests and panel tests. (elastic#74601) Deprecate schema-less specs in Vega (elastic#73805) [Security Solution] Rename Administration > Hosts subtab to Endpoints (elastic#74287) Timelion deprecation doc (elastic#74508) [Functional Tests] Adds a wait time between setting the index pattern and the time field on TSVB (elastic#74736) [Lens] Add styling options for x and y axes on the settings popover (elastic#71829) [Maps] add initial location option that fits to data bounds (elastic#74583) theme function (elastic#73451) [data.ui.query] Write filters to query log from default editor. (elastic#74474) [data.search.SearchSource] Move some SearchSource dependencies to the server. (elastic#74607) [Canvas][tech-debt] Convert renderers (elastic#74134) [security solutions][lists] Adds end to end tests (elastic#74473) pluralized for occurrences vs occurrence (elastic#74564) Update links that pointed to CONTRIBUTING.md (elastic#74757) [Ingest pipelines] Implement tabs in processor flyout (elastic#74469) [Event log] Use Alerts client & Actions client when fetching these types of SOs (elastic#73257) ... # Conflicts: # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/field_components/text_editor.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/manage_processor_form.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/append.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/bytes.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/circle.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/common_fields/field_name_field.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/common_fields/ignore_missing_field.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/convert.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/csv.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/date.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/date_index_name.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/dissect.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/dot_expander.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/drop.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/index.ts # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/shared.ts
Looks like this PR is missing the 7.{num} label, but it was backported. Can you add it @ppisljar for the release it went/is going into? |
Summary
Adds a
theme
function as proposed here #71064Currently theme information (variables) are part of expression variables under
theme
key. Preferably we introduce a service in the future to provide this information.How to test:
provide a
theme
variable to expressions and see your fonts change:theme
variable needs to be sent to executor with the following structure:font
function for any of its arguments where specificfont
function arguments have not been overridden will not start using the theme information providedlooking at example canvas workpads it seems canvas always sets size family color and alignment when adding a font property to element, which should probably be changed, so it only adds {font} and all the arguments are set only after user changes from whats set on theme.
also, all the example workpads have most of the font arguments set (which means that a theme won't apply).
followup:
Checklist
Delete any items that are not applicable to this PR.
For maintainers