Skip to content

Commit

Permalink
[canvas] Reduce bundle size by co-locating strings with components (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
clintandrewhall committed Jun 23, 2021
1 parent 1e7ef98 commit 0669895
Show file tree
Hide file tree
Showing 69 changed files with 1,546 additions and 1,780 deletions.
8 changes: 2 additions & 6 deletions x-pack/plugins/canvas/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ To keep the code terse, Canvas uses i18n "dictionaries": abstracted, static sing

```js

// i18n/components.ts
export const ComponentStrings = {
// asset_manager.tsx
const strings = {
// ...
AssetManager: {
getCopyAssetMessage: (id: string) =>
Expand All @@ -52,10 +52,6 @@ export const ComponentStrings = {
// ...
};

// asset_manager.tsx
import { ComponentStrings } from '../../../i18n';
const { AssetManager: strings } = ComponentStrings;

const text = (
<EuiText>
{strings.getSpaceUsedText(percentageUsed)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@
* 2.0.
*/

import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import PropTypes from 'prop-types';
import React, { FunctionComponent } from 'react';
import { ComponentStrings } from '../../../../../i18n';
import PropTypes from 'prop-types';
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

const { AdvancedFilter: strings } = ComponentStrings;
const strings = {
getApplyButtonLabel: () =>
i18n.translate('xpack.canvas.renderer.advancedFilter.applyButtonLabel', {
defaultMessage: 'Apply',
description: 'This refers to applying the filter to the Canvas workpad',
}),
getInputPlaceholder: () =>
i18n.translate('xpack.canvas.renderer.advancedFilter.inputPlaceholder', {
defaultMessage: 'Enter filter expression',
}),
};

export interface Props {
/** Optional value for the component */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
* 2.0.
*/

import { EuiIcon } from '@elastic/eui';
import PropTypes from 'prop-types';
import React, { ChangeEvent, FocusEvent, FunctionComponent } from 'react';
import { ComponentStrings } from '../../../../../i18n';
import PropTypes from 'prop-types';
import { EuiIcon } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

const { DropdownFilter: strings } = ComponentStrings;
const strings = {
getMatchAllOptionLabel: () =>
i18n.translate('xpack.canvas.renderer.dropdownFilter.matchAllOptionLabel', {
defaultMessage: 'ANY',
description: 'The dropdown filter option to match any value in the field.',
}),
};

export interface Props {
/**
Expand Down
Loading

0 comments on commit 0669895

Please sign in to comment.