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

chore(Indicator): use predefined icon set #1120

Merged
merged 22 commits into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as _ from 'lodash'
import * as PropTypes from 'prop-types'
import * as React from 'react'
import { Indicator, Tree } from '@stardust-ui/react'
import { Icon, Tree } from '@stardust-ui/react'

import { examplePathToHash } from 'docs/src/utils'

Expand Down Expand Up @@ -98,7 +98,7 @@ export default class ComponentSidebarSection extends React.PureComponent<any, an
active={active}
>
<span>{content}</span>
{hasSubtree && <Indicator direction={open ? 'bottom' : 'start'} />}
{hasSubtree && <Icon direction={name ? 'arrow-down' : 'arrow-end'} />}
</Component>
)

Expand Down

This file was deleted.

12 changes: 0 additions & 12 deletions docs/src/examples/components/Indicator/Rtl/index.tsx

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

25 changes: 0 additions & 25 deletions docs/src/examples/components/Indicator/Types/index.tsx

This file was deleted.

13 changes: 0 additions & 13 deletions docs/src/examples/components/Indicator/index.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions packages/react/src/components/Accordion/AccordionTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
rtlTextContainer,
} from '../../lib'
import { ReactProps, ComponentEventHandler, ShorthandValue } from '../../types'
import Indicator from '../Indicator/Indicator'
import Icon from '../Icon/Icon'
import Layout from '../Layout/Layout'

export interface AccordionTitleProps
Expand Down Expand Up @@ -67,9 +67,9 @@ class AccordionTitle extends UIComponent<ReactProps<AccordionTitleProps>, any> {

const contentElement = (
<Layout
start={Indicator.create(indicatorWithDefaults, {
start={Icon.create(indicatorWithDefaults, {
defaultProps: {
direction: active ? 'bottom' : 'end',
name: active ? 'stardust-arrow-down' : 'stardust-arrow-end',
styles: styles.indicator,
},
})}
Expand Down
11 changes: 5 additions & 6 deletions packages/react/src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
handleRef,
UIComponentProps,
} from '../../lib'
import Indicator, { IndicatorProps } from '../Indicator/Indicator'
import List from '../List/List'
import Ref from '../Ref/Ref'
import DropdownItem from './DropdownItem'
Expand Down Expand Up @@ -275,7 +274,7 @@ class Dropdown extends AutoControlledComponent<Extendable<DropdownProps>, Dropdo

static defaultProps: DropdownProps = {
as: 'div',
clearIndicator: 'close',
clearIndicator: 'stardust-close',
itemToString: item => {
if (!item || React.isValidElement(item)) {
return ''
Expand Down Expand Up @@ -397,14 +396,14 @@ class Dropdown extends AutoControlledComponent<Extendable<DropdownProps>, Dropdo
},
}),
})
: Indicator.create(toggleIndicator, {
: Icon.create(toggleIndicator, {
defaultProps: {
className: Dropdown.slotClassNames.toggleIndicator,
direction: open ? 'top' : 'bottom',
name: open ? 'stardust-arrow-up' : 'stardust-arrow-down',
styles: styles.toggleIndicator,
},
overrideProps: (predefinedProps: IndicatorProps) => ({
onClick: (e, indicatorProps: IndicatorProps) => {
overrideProps: (predefinedProps: IconProps) => ({
onClick: (e, indicatorProps: IconProps) => {
_.invoke(predefinedProps, 'onClick', e, indicatorProps)
getToggleButtonProps().onClick(e)
},
Expand Down
88 changes: 0 additions & 88 deletions packages/react/src/components/Indicator/Indicator.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/react/src/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class Input extends AutoControlledComponent<ReactProps<InputProps>, InputState>
const { value } = this.state

if (clearable && (value as string).length !== 0) {
return 'close'
return 'stardust-close'
}

return icon || null
Expand Down
5 changes: 2 additions & 3 deletions packages/react/src/components/Menu/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { Accessibility, AccessibilityActionHandlers } from '../../lib/accessibil
import { ComponentEventHandler, ReactProps, ShorthandValue } from '../../types'
import { focusAsync } from '../../lib/accessibility/FocusZone'
import Ref from '../Ref/Ref'
import Indicator from '../Indicator/Indicator'

export interface MenuItemSlotClassNames {
wrapper: string
Expand Down Expand Up @@ -216,9 +215,9 @@ class MenuItem extends AutoControlledComponent<ReactProps<MenuItemProps>, MenuIt
})}
{rtlTextContainer.createFor({ element: content })}
{menu &&
Indicator.create(indicatorWithDefaults, {
Icon.create(indicatorWithDefaults, {
defaultProps: {
direction: vertical ? 'end' : 'bottom',
name: vertical ? 'arrow-end' : 'arrow-down',
styles: styles.indicator,
},
})}
Expand Down
2 changes: 0 additions & 2 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ export { default as Animation, AnimationProps } from './components/Animation/Ani

export { default as Tree } from './components/Tree'

export { default as Indicator, IndicatorProps } from './components/Indicator/Indicator'

export { default as Reaction, ReactionProps, ReactionState } from './components/Reaction/Reaction'
export { default as ReactionGroup, ReactionGroupProps } from './components/Reaction/ReactionGroup'

Expand Down
1 change: 1 addition & 0 deletions packages/react/src/themes/base/componentStyles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { default as Dialog } from './components/Dialog/dialogStyles'
export { default as Icon } from './components/Icon/iconStyles'
export { default as Loader } from './components/Loader/loaderStyles'
export { default as ProviderBox } from './components/Provider/providerBoxStyles'
export { default as Text } from './components/Text/textStyles'
1 change: 1 addition & 0 deletions packages/react/src/themes/base/componentVariables.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { default as Dialog } from './components/Dialog/dialogVariables'
export { default as Icon } from './components/Icon/iconVariables'
export { default as Loader } from './components/Loader/loaderVariables'
export { default as ProviderBox } from './components/Provider/providerBoxVariables'
export { default as Text } from './components/Text/textVariables'
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ThemeIcons, ThemeIconSpec } from '../../../types'

const fontIcon = (content: string, fontFamily: string): ThemeIconSpec => ({
icon: { content: `'\\${content}'`, fontFamily },
})

const normal = (content: string) => fontIcon(content, '"Font Awesome 5 Free"')

// Originally generated from:
// https://github.com/Semantic-Org/Semantic-UI-CSS/blob/master/components/icon.css
// Corrections were made to duplicate icon names and incorrectly mapped alternates
const fontAwesomeIcons: ThemeIcons = {
'stardust-close': normal('f00d'),
'stardust-arrow-down': normal('f0d7'),
'stardust-arrow-end': normal('f0da'),
'stardust-arrow-up': normal('f0d8'),
}

const emptyIcon = { icon: { content: '?', fontFamily: '' } }

export default (name: string): ThemeIconSpec => fontAwesomeIcons[name] || emptyIcon
Loading