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 2 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
9 changes: 5 additions & 4 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import {
commonPropTypes,
} from '../../lib'
import Icon from '../Icon/Icon'
import Slot from '../Slot/Slot'
import { buttonBehavior } from '../../lib/accessibility'
import { Accessibility } from '../../lib/accessibility/types'
import { ComponentEventHandler, ReactProps, ShorthandValue } from '../../../types/utils'
import ButtonGroup from './ButtonGroup'
import { generateContentSlot } from '../../lib/generateContent'

export interface ButtonProps
extends UIComponentProps,
Expand Down Expand Up @@ -141,9 +141,10 @@ class Button extends UIComponent<ReactProps<ButtonProps>, ButtonState> {
>
{hasChildren && children}
{!hasChildren && iconPosition !== 'after' && this.renderIcon(variables, styles)}
{Slot.create(!hasChildren && content, {
defaultProps: { as: 'span', className: classes.content },
})}
{!hasChildren &&
generateContentSlot(content, {
defaultProps: { as: 'span', className: classes.content },
})}
{!hasChildren && iconPosition === 'after' && this.renderIcon(variables, styles)}
</ElementType>
)
Expand Down
3 changes: 2 additions & 1 deletion src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '../../lib'
import HeaderDescription from './HeaderDescription'
import { ReactProps, ShorthandValue } from '../../../types/utils'
import { generateContentElement } from '../../lib/generateContent'

export interface HeaderProps
extends UIComponentProps,
Expand Down Expand Up @@ -66,7 +67,7 @@ class Header extends UIComponent<ReactProps<HeaderProps>, any> {

return (
<ElementType {...unhandledProps} className={classes.root}>
{content}
{generateContentElement(content)}
{HeaderDescription.create(description, {
defaultProps: {
variables: {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { mergeStyles } from './mergeThemes'
type HTMLTag = 'iframe' | 'img' | 'input'
type ShorthandProp = 'children' | 'src' | 'type'

interface CreateShorthandOptions {
export interface CreateShorthandOptions {
/** Default props object */
defaultProps?: Props

Expand Down
22 changes: 22 additions & 0 deletions src/lib/generateContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as React from 'react'
import { ShorthandValue, ShorthandRenderCallback } from '../../types/utils'
import { CreateShorthandOptions } from './factories'
import Slot from '../components/Slot/Slot'
import Text from '../components/Text/Text'

export const generateContentSlot = (
content: ShorthandValue | ShorthandRenderCallback,
options: CreateShorthandOptions,
) => {
if (typeof content === 'string') {
return Text.create(content, options)
}
return Slot.create(content, options)
}

export const generateContentElement = (content: React.ReactNode) => {
if (typeof content === 'string') {
return Text.create(content)
}
return content
}