Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(perf): refactor ComponentControls #3069

Merged
merged 1 commit into from
Aug 7, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
Expand Up @@ -12,7 +12,7 @@ const ComponentControls = (props) => {
const { anchorName, examplePath, showHTML, showCode, onCopyLink, onShowHTML, onShowCode } = props

return (
<Menu color='green' compact icon size='small' text>
<Menu color='green' compact icon='labeled' size='tiny' text>
<ComponentControlsCopyLink anchorName={anchorName} onClick={onCopyLink} />
<ComponentControlsMaximize examplePath={examplePath} />
<ComponentControlsShowHtml active={showHTML} onClick={onShowHTML} />
Expand All @@ -29,7 +29,6 @@ ComponentControls.propTypes = {
onShowHTML: PropTypes.func,
showCode: PropTypes.bool,
showHTML: PropTypes.bool,
visible: PropTypes.bool,
}

export default updateForKeys(['showCode', 'showHTML', 'visible'])(ComponentControls)
export default updateForKeys(['showCode', 'showHTML'])(ComponentControls)
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import PropTypes from 'prop-types'
import React, { Component } from 'react'
import { Icon, Menu } from 'semantic-ui-react'

import ComponentControlsToolTip from './ComponentControlsToolTip'

export default class ComponentControlsCopyLink extends Component {
state = {}

Expand Down Expand Up @@ -41,11 +39,10 @@ export default class ComponentControlsCopyLink extends Component {
const { active } = this.state

return (
<ComponentControlsToolTip content={active ? ' Copied Link!' : 'Direct link'}>
<Menu.Item href={`#${anchorName}`} onClick={this.handleClick}>
<Icon color={active ? 'green' : 'grey'} fitted name='linkify' size='large' />
</Menu.Item>
</ComponentControlsToolTip>
<Menu.Item href={`#${anchorName}`} onClick={this.handleClick}>
<Icon color={active ? 'green' : 'grey'} fitted name='linkify' size='large' />
{active ? ' Copied Link!' : 'Direct link'}
</Menu.Item>
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@ import PropTypes from 'prop-types'
import React from 'react'
import { Icon, Menu } from 'semantic-ui-react'

import { updateForKeys } from 'docs/src/hoc'
import ComponentControlsToolTip from './ComponentControlsToolTip'

const ComponentControlsEditCode = ({ active, onClick }) => (
<ComponentControlsToolTip content='Edit Code'>
<Menu.Item active={active} onClick={onClick}>
<Icon color={active ? 'green' : 'grey'} fitted name='code' size='large' />
</Menu.Item>
</ComponentControlsToolTip>
<Menu.Item active={active} onClick={onClick}>
<Icon color={active ? 'green' : 'grey'} fitted name='code' size='large' />
Try it
</Menu.Item>
)

ComponentControlsEditCode.propTypes = {
active: PropTypes.bool,
onClick: PropTypes.func,
}

export default updateForKeys(['active'])(ComponentControlsEditCode)
export default ComponentControlsEditCode
Copy link
Member Author

Choose a reason for hiding this comment

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

Now, there is no sence in this HOCs.

Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,18 @@ import PropTypes from 'prop-types'
import React from 'react'
import { Icon, Menu } from 'semantic-ui-react'

import { neverUpdate } from 'docs/src/hoc'
import ComponentControlsToolTip from './ComponentControlsToolTip'

const ComponentControlsMaximize = ({ examplePath }) => {
const href = `/maximize/${_.kebabCase(examplePath.split('/').slice(-1))}`

return (
<ComponentControlsToolTip content='Full Screen'>
<Menu.Item href={href} target='_blank'>
<Icon color='grey' fitted name='window maximize' size='large' />
</Menu.Item>
</ComponentControlsToolTip>
<Menu.Item href={href} target='_blank'>
<Icon color='grey' fitted name='window maximize' size='large' />
Maximize
</Menu.Item>
)
}
ComponentControlsMaximize.propTypes = {
examplePath: PropTypes.string.isRequired,
}

export default neverUpdate(ComponentControlsMaximize)
export default ComponentControlsMaximize
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@ import PropTypes from 'prop-types'
import React from 'react'
import { Icon, Menu } from 'semantic-ui-react'

import { updateForKeys } from 'docs/src/hoc'
import ComponentControlsToolTip from './ComponentControlsToolTip'

const ComponentControlsShowHtml = ({ active, onClick }) => (
<ComponentControlsToolTip content='Show HTML'>
<Menu.Item active={active} onClick={onClick}>
<Icon color={active ? 'green' : 'grey'} size='large' name='html5' fitted />
</Menu.Item>
</ComponentControlsToolTip>
<Menu.Item active={active} onClick={onClick}>
<Icon color={active ? 'green' : 'grey'} size='large' name='html5' fitted />
Show HTML
</Menu.Item>
)

ComponentControlsShowHtml.propTypes = {
active: PropTypes.bool,
onClick: PropTypes.func,
}

export default updateForKeys(['active'])(ComponentControlsShowHtml)
export default ComponentControlsShowHtml

This file was deleted.