Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

feat(rtl): add span element with dir: 'auto' for the strings used in the Stardust components #704

Merged
merged 35 commits into from
Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8e99c2f
-added factories for generating the content as a slot or as a react node
Jan 11, 2019
b744d84
-fix expression in Header component
Jan 11, 2019
03bd6c4
-changed some other components
Jan 11, 2019
88c5296
-reverted ChatMessage changes
Jan 11, 2019
87ebbe7
-reverted ChatItem changes
Jan 11, 2019
f0bafc6
-refactored Slot component to generate Text component is the content …
Jan 14, 2019
2271c05
-checking for children string in the Slot and Text components
Jan 14, 2019
12f1276
-checking for children string in the all components
Jan 14, 2019
30fe7ef
-reverted changes for children in MenuItem
Jan 14, 2019
d7866d7
-added rtlProps
Jan 14, 2019
3ee7e02
-added rtlProps in the Button component
Jan 14, 2019
5f11829
-added rtlProps in the ChatMessage component
Jan 14, 2019
02c0d48
-adding rtlProps to all other components
Jan 14, 2019
19f70c9
-added rtl props in the default behavior
Jan 15, 2019
175deb8
-changed generation of span with dir auto
Jan 16, 2019
f17f189
-refactored other components to use the rtlTransformedChildren|Content
Jan 18, 2019
bf12cc9
-fixed regarding the prev changes
Jan 18, 2019
2f53572
-added getRtlTransformedElement usages in some of the components
Jan 18, 2019
09715d3
-added addRtlSupport services and used it in all components
Jan 18, 2019
3f871a2
Merge branch 'master' into fix/text-component-usages
Jan 18, 2019
dbdcb0f
-updated changelog
Jan 18, 2019
3128be8
-added rtl attributes as part of the renderComponent
Jan 21, 2019
ac41dc8
-fixed imports
Jan 21, 2019
dc77a9d
-changed all components to use the rtlAttributes
Jan 21, 2019
04def06
-fixes
Jan 21, 2019
8e0e7c4
Merge branch 'master' into fix/text-component-usages
Jan 21, 2019
d903ed0
-removed unnecessary rtl attributes
Jan 21, 2019
08593ad
-add childrenExists logic in the children dependent rtl attributes
Jan 21, 2019
82723eb
Merge branch 'master' into fix/text-component-usages
Jan 21, 2019
a433173
-fix AccordionContent rtl issues
Jan 21, 2019
812dff1
-fix header
Jan 21, 2019
1442e18
-renamed RtlFunc to RtlAttributesProvider and exported it from the rt…
Jan 22, 2019
3fdfd3a
-refactored components to use rtlTextContainer service
Jan 22, 2019
c9d2e55
Merge branch 'master' into fix/text-component-usages
Jan 22, 2019
8581720
-refactored getAttributes method from rtlTextContainer
Jan 22, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Features
- Rename `Slot` component to `Box` and export it @Bugaa92 ([#713](https://github.com/stardust-ui/react/pull/713))
- Add rtl support for the strings used inside the components @mnajdova ([#704](https://github.com/stardust-ui/react/pull/704))
mnajdova marked this conversation as resolved.
Show resolved Hide resolved

<!--------------------------------[ v0.17.0 ]------------------------------- -->
## [v0.17.0](https://github.com/stardust-ui/react/tree/v0.17.0) (2019-01-17)
Expand Down
3 changes: 2 additions & 1 deletion src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
UIComponentProps,
ChildrenComponentProps,
commonPropTypes,
addRtlSupport,
} from '../../lib'
import AccordionTitle from './AccordionTitle'
import AccordionContent from './AccordionContent'
Expand Down Expand Up @@ -181,7 +182,7 @@ class Accordion extends AutoControlledComponent<ReactProps<AccordionProps>, any>

return (
<ElementType {...accessibility.attributes.root} {...unhandledProps} className={classes.root}>
{childrenExist(children) ? children : this.renderPanels()}
{childrenExist(children) ? addRtlSupport(children) : this.renderPanels()}
</ElementType>
)
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Accordion/AccordionContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ChildrenComponentProps,
ContentComponentProps,
commonPropTypes,
addRtlSupport,
} from '../../lib'
import { ReactProps, ComponentEventHandler } from '../../../types/utils'

Expand Down Expand Up @@ -49,7 +50,7 @@ class AccordionContent extends UIComponent<ReactProps<AccordionContentProps>, an

return (
<ElementType {...unhandledProps} className={classes.root}>
{childrenExist(children) ? children : content}
{addRtlSupport(childrenExist(children) ? children : content)}
</ElementType>
)
}
Expand Down
11 changes: 2 additions & 9 deletions src/components/Accordion/AccordionTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ContentComponentProps,
ChildrenComponentProps,
commonPropTypes,
addRtlSupport,
} from '../../lib'
import { ReactProps, ComponentEventHandler } from '../../../types/utils'

Expand Down Expand Up @@ -56,17 +57,9 @@ class AccordionTitle extends UIComponent<ReactProps<AccordionTitleProps>, any> {
renderComponent({ ElementType, classes, unhandledProps }) {
const { children, content } = this.props

if (childrenExist(children)) {
return (
<ElementType {...unhandledProps} className={classes.root} onClick={this.handleClick}>
{children}
</ElementType>
)
}

return (
<ElementType {...unhandledProps} className={classes.root} onClick={this.handleClick}>
{content}
{addRtlSupport(childrenExist(children) ? children : content)}
</ElementType>
)
}
Expand Down
7 changes: 4 additions & 3 deletions src/components/Box/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
ContentComponentProps,
ChildrenComponentProps,
commonPropTypes,
addRtlSupport,
} from '../../lib'
import createComponent, { CreateComponentReturnType } from '../../lib/createComponent'
import { ReactProps } from '../../../types/utils'
Expand All @@ -28,12 +29,12 @@ const Box: CreateComponentReturnType<ReactProps<BoxProps>> = createComponent<Box
},

render(config, props) {
const { ElementType, classes, unhandledProps } = config
const { ElementType, classes, unhandledProps, accessibility } = config
const { children, content } = props

return (
<ElementType {...unhandledProps} className={classes.root}>
{childrenExist(children) ? children : content}
<ElementType {...accessibility.attributes.root} {...unhandledProps} className={classes.root}>
{addRtlSupport(childrenExist(children) ? children : content)}
</ElementType>
)
},
Expand Down
5 changes: 3 additions & 2 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
ContentComponentProps,
ChildrenComponentProps,
commonPropTypes,
addRtlSupport,
} from '../../lib'
import Icon from '../Icon/Icon'
import Box from '../Box/Box'
Expand Down Expand Up @@ -139,10 +140,10 @@ class Button extends UIComponent<ReactProps<ButtonProps>, ButtonState> {
{...accessibility.attributes.root}
{...unhandledProps}
>
{hasChildren && children}
{hasChildren && addRtlSupport(children)}
{!hasChildren && iconPosition !== 'after' && this.renderIcon(variables, styles)}
{Box.create(!hasChildren && content, {
defaultProps: { as: 'span', className: classes.content },
defaultProps: { as: 'span', styles: styles.content },
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

})}
{!hasChildren && iconPosition === 'after' && this.renderIcon(variables, styles)}
</ElementType>
Expand Down
5 changes: 3 additions & 2 deletions src/components/Button/ButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
ChildrenComponentProps,
ContentComponentProps,
commonPropTypes,
addRtlSupport,
} from '../../lib'
import Button from './Button'

Expand Down Expand Up @@ -51,15 +52,15 @@ class ButtonGroup extends UIComponent<ReactProps<ButtonGroupProps>, any> {
styles,
unhandledProps,
}): React.ReactNode {
const { children, content, buttons, circular } = this.props
const { children, buttons, circular, content } = this.props
if (_.isNil(buttons)) {
return (
<ElementType
{...accessibility.attributes.root}
{...unhandledProps}
className={classes.root}
>
{childrenExist(children) ? children : content}
{addRtlSupport(childrenExist(children) ? children : content)}
</ElementType>
)
}
Expand Down
12 changes: 10 additions & 2 deletions src/components/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import * as _ from 'lodash'
import * as PropTypes from 'prop-types'
import * as React from 'react'

import { childrenExist, customPropTypes, UIComponent, commonPropTypes } from '../../lib'
import {
childrenExist,
customPropTypes,
UIComponent,
commonPropTypes,
addRtlSupport,
} from '../../lib'
import ChatItem from './ChatItem'
import ChatMessage from './ChatMessage'
import { ReactProps, ShorthandValue } from '../../../types/utils'
Expand Down Expand Up @@ -56,7 +62,9 @@ class Chat extends UIComponent<ReactProps<ChatProps>, any> {
{...accessibility.keyHandlers.root}
{...unhandledProps}
>
{childrenExist(children) ? children : _.map(items, item => ChatItem.create(item))}
{childrenExist(children)
? addRtlSupport(children)
: _.map(items, item => ChatItem.create(item))}
</ElementType>
)
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Chat/ChatItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
ChildrenComponentProps,
commonPropTypes,
customPropTypes,
addRtlSupport,
} from '../../lib'
import Box from '../Box/Box'
import { ComponentSlotStylesPrepared } from '../../themes/types'
Expand Down Expand Up @@ -56,7 +57,7 @@ class ChatItem extends UIComponent<ReactProps<ChatItemProps>, any> {

return (
<ElementType {...unhandledProps} className={classes.root}>
{childrenExist(children) ? children : this.renderChatItem(styles)}
{childrenExist(children) ? addRtlSupport(children) : this.renderChatItem(styles)}
</ElementType>
)
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Chat/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
ChildrenComponentProps,
ContentComponentProps,
commonPropTypes,
addRtlSupport,
isFromKeyboard,
} from '../../lib'
import { ReactProps, ShorthandValue, ComponentEventHandler } from '../../../types/utils'
Expand Down Expand Up @@ -114,7 +115,7 @@ class ChatMessage extends UIComponent<ReactProps<ChatMessageProps>, ChatMessageS
className={className}
>
{childrenPropExists ? (
children
addRtlSupport(children)
) : (
<>
{!mine &&
Expand Down
3 changes: 2 additions & 1 deletion src/components/Divider/Divider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ColorComponentProps,
ContentComponentProps,
commonPropTypes,
addRtlSupport,
} from '../../lib'
import { ReactProps } from '../../../types/utils'

Expand Down Expand Up @@ -54,7 +55,7 @@ class Divider extends UIComponent<ReactProps<DividerProps>, any> {

return (
<ElementType {...unhandledProps} className={classes.root}>
{childrenExist(children) ? children : content}
{addRtlSupport(childrenExist(children) ? children : content)}
</ElementType>
)
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
UIComponentProps,
ChildrenComponentProps,
commonPropTypes,
addRtlSupport,
} from '../../lib'
import { ComponentEventHandler, ReactProps, ShorthandValue } from '../../../types/utils'
import FormField from './FormField'
Expand Down Expand Up @@ -64,7 +65,7 @@ class Form extends UIComponent<ReactProps<FormProps>, any> {
onSubmit={this.handleSubmit}
{...unhandledProps}
>
{childrenExist(children) ? children : this.renderFields()}
{childrenExist(children) ? addRtlSupport(children) : this.renderFields()}
</ElementType>
)
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ChildrenComponentProps,
commonPropTypes,
ContentComponentProps,
addRtlSupport,
} from '../../lib'
import { ReactProps } from '../../../types/utils'
import { Accessibility } from '../../lib/accessibility/types'
Expand Down Expand Up @@ -73,7 +74,7 @@ class Grid extends UIComponent<ReactProps<GridProps>, any> {

return (
<ElementType className={classes.root} {...unhandledProps}>
{childrenExist(children) ? children : content}
{addRtlSupport(childrenExist(children) ? children : content)}
</ElementType>
)
}
Expand Down
26 changes: 11 additions & 15 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ContentComponentProps,
commonPropTypes,
ColorComponentProps,
addRtlSupport,
} from '../../lib'
import HeaderDescription from './HeaderDescription'
import { ReactProps, ShorthandValue } from '../../../types/utils'
Expand Down Expand Up @@ -54,26 +55,21 @@ class Header extends UIComponent<ReactProps<HeaderProps>, any> {
static Description = HeaderDescription

renderComponent({ ElementType, classes, variables: v, unhandledProps }) {
const { children, content, description } = this.props
const { children, description, content } = this.props

if (childrenExist(children)) {
return (
<ElementType {...unhandledProps} className={classes.root}>
{children}
</ElementType>
)
}
const hasChildren = childrenExist(children)

return (
<ElementType {...unhandledProps} className={classes.root}>
{content}
{HeaderDescription.create(description, {
defaultProps: {
variables: {
...(v.descriptionColor && { color: v.descriptionColor }),
{hasChildren ? addRtlSupport(children) : addRtlSupport(content)}
mnajdova marked this conversation as resolved.
Show resolved Hide resolved
{!hasChildren &&
HeaderDescription.create(description, {
defaultProps: {
variables: {
...(v.descriptionColor && { color: v.descriptionColor }),
},
},
},
})}
})}
</ElementType>
)
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Header/HeaderDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ContentComponentProps,
commonPropTypes,
ColorComponentProps,
addRtlSupport,
} from '../../lib'
import { ReactProps } from '../../../types/utils'

Expand Down Expand Up @@ -40,7 +41,7 @@ class HeaderDescription extends UIComponent<ReactProps<HeaderDescriptionProps>,
const { children, content } = this.props
return (
<ElementType {...unhandledProps} className={classes.root}>
{childrenExist(children) ? children : content}
{addRtlSupport(childrenExist(children) ? children : content)}
</ElementType>
)
}
Expand Down
13 changes: 7 additions & 6 deletions src/components/ItemLayout/ItemLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
UIComponentProps,
commonPropTypes,
ContentComponentProps,
addRtlSupport,
} from '../../lib'
import Layout from '../Layout/Layout'
import { ComponentSlotClasses, ICSSInJSStyle } from '../../themes/types'
Expand Down Expand Up @@ -126,12 +127,12 @@ class ItemLayout extends UIComponent<ReactProps<ItemLayoutProps>, any> {
gap={pxToRem(8)}
debug={debug}
truncateMain={truncateHeader}
main={header}
main={addRtlSupport(header)}
rootCSS={headerCSS}
end={
headerMedia && (
<span style={headerMediaCSS} className={mediaClasses}>
{headerMedia}
{addRtlSupport(headerMedia)}
</span>
)
}
Expand All @@ -153,11 +154,11 @@ class ItemLayout extends UIComponent<ReactProps<ItemLayoutProps>, any> {
debug={debug}
truncateMain={truncateContent}
rootCSS={contentCSS}
main={content}
main={addRtlSupport(content)}
end={
contentMedia && (
<span style={contentMediaCSS} className={mediaClasses}>
{contentMedia}
{addRtlSupport(contentMedia)}
</span>
)
}
Expand Down Expand Up @@ -190,15 +191,15 @@ class ItemLayout extends UIComponent<ReactProps<ItemLayoutProps>, any> {
start={
startArea && (
<span style={mediaCSS} className={mergedMediaClasses}>
{startArea}
{addRtlSupport(startArea)}
</span>
)
}
main={mainArea}
end={
endArea && (
<span style={endMediaCSS} className={mergedEndMediaClasses}>
{endArea}
{addRtlSupport(endArea)}
</span>
)
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/Label/Label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
ChildrenComponentProps,
ContentComponentProps,
commonPropTypes,
addRtlSupport,
ColorComponentProps,
} from '../../lib'

Expand Down Expand Up @@ -88,7 +89,7 @@ class Label extends UIComponent<ReactProps<LabelProps>, any> {
if (childrenExist(children)) {
return (
<ElementType {...unhandledProps} className={classes.root}>
{children}
{addRtlSupport(children)}
</ElementType>
)
}
Expand Down Expand Up @@ -126,7 +127,7 @@ class Label extends UIComponent<ReactProps<LabelProps>, any> {
</>
)
}
main={content}
main={addRtlSupport(content)}
end={
hasEndElement && (
<>
Expand Down
Loading