From 095db3b8506f24f2d1235ebcc82e6db47da62add Mon Sep 17 00:00:00 2001 From: Gergely Nemeth Date: Mon, 25 Feb 2019 13:53:26 -0800 Subject: [PATCH] feat(i18n): breadcrumb and accordion --- src/accordion/locale.js | 19 ++++++++++++ src/accordion/panel.js | 57 +++++++++++++++++++--------------- src/breadcrumbs/breadcrumbs.js | 11 +++++-- src/breadcrumbs/locale.js | 17 ++++++++++ src/locale/en_US.js | 4 +++ src/locale/types.js | 4 +++ 6 files changed, 84 insertions(+), 28 deletions(-) create mode 100644 src/accordion/locale.js create mode 100644 src/breadcrumbs/locale.js diff --git a/src/accordion/locale.js b/src/accordion/locale.js new file mode 100644 index 0000000000..036470aa7e --- /dev/null +++ b/src/accordion/locale.js @@ -0,0 +1,19 @@ +/* +Copyright (c) 2018 Uber Technologies, Inc. + +This source code is licensed under the MIT license found in the +LICENSE file in the root directory of this source tree. +*/ +// @flow + +export type AccordionLocaleT = {| + collapse: string, + expand: string, +|}; + +const locale = { + collapse: 'Collapse', + expand: 'Expand', +}; + +export default locale; diff --git a/src/accordion/panel.js b/src/accordion/panel.js index 5c5ae0af2c..15d5b2f835 100644 --- a/src/accordion/panel.js +++ b/src/accordion/panel.js @@ -6,6 +6,7 @@ LICENSE file in the root directory of this source tree. */ // @flow import * as React from 'react'; +import {LocaleContext} from '../locale/index.js'; import {getOverrides, mergeOverrides} from '../helpers/overrides.js'; import { Plus as PlusIcon, @@ -91,31 +92,37 @@ class Panel extends React.Component { ); const ToggleIconComponent = expanded ? CheckIndeterminateIcon : PlusIcon; return ( - -
- {title} - -
- - {children} - -
+ + {locale => ( + +
+ {title} + +
+ + {children} + +
+ )} +
); } } diff --git a/src/breadcrumbs/breadcrumbs.js b/src/breadcrumbs/breadcrumbs.js index 5af6951d08..f1323a64bf 100644 --- a/src/breadcrumbs/breadcrumbs.js +++ b/src/breadcrumbs/breadcrumbs.js @@ -9,6 +9,7 @@ LICENSE file in the root directory of this source tree. import React, {Children} from 'react'; +import {LocaleContext} from '../locale/index.js'; import type {BreadcrumbsPropsT} from './types.js'; import {StyledRoot, StyledSeparator, StyledIcon} from './styled-components.js'; import {getOverrides} from '../helpers/overrides.js'; @@ -37,9 +38,13 @@ function Breadcrumbs({children, overrides = {}}: BreadcrumbsPropsT) { }); return ( - - {childrenWithSeparators} - + + {locale => ( + + {childrenWithSeparators} + + )} + ); } diff --git a/src/breadcrumbs/locale.js b/src/breadcrumbs/locale.js new file mode 100644 index 0000000000..097dacf63d --- /dev/null +++ b/src/breadcrumbs/locale.js @@ -0,0 +1,17 @@ +/* +Copyright (c) 2018 Uber Technologies, Inc. + +This source code is licensed under the MIT license found in the +LICENSE file in the root directory of this source tree. +*/ +// @flow + +export type BreadcrumbLocaleT = {| + ariaLabel: string, +|}; + +const locale = { + ariaLabel: 'Breadcrumbs navigation', +}; + +export default locale; diff --git a/src/locale/en_US.js b/src/locale/en_US.js index b32e62ed23..e0a5a7f218 100644 --- a/src/locale/en_US.js +++ b/src/locale/en_US.js @@ -6,9 +6,13 @@ LICENSE file in the root directory of this source tree. */ // @flow +import accordion from '../accordion/locale.js'; +import breadcrumb from '../breadcrumb/locale.js'; import datepicker from '../datepicker/locale.js'; const en_US = { + accordion, + breadcrumb, datepicker, }; diff --git a/src/locale/types.js b/src/locale/types.js index 5171c2c2c8..53afaefead 100644 --- a/src/locale/types.js +++ b/src/locale/types.js @@ -6,8 +6,12 @@ LICENSE file in the root directory of this source tree. */ // @flow +import type {AccordionLocaleT} from '../accordion/locale.js'; +import type {BreadcrumbLocaleT} from '../breadcrumb/locale.js'; import type {DatepickerLocaleT} from '../datepicker/locale.js'; export type LocaleT = {| + accordion: AccordionLocaleT, + breadcrumb: BreadcrumbLocaleT, datepicker: DatepickerLocaleT, |};