-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f36ccd
commit 7fc77df
Showing
23 changed files
with
436 additions
and
122 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
docs/app/Components/ComponentDoc/ComponentControls/ComponentControls.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import PropTypes from 'prop-types' | ||
import React from 'react' | ||
import { Menu, Transition } from 'semantic-ui-react' | ||
|
||
import { updateForKeys } from 'docs/app/HOC' | ||
import ComponentControlsCopyLink from './ComponentControlsCopyLink' | ||
import ComponentControlsEditCode from './ComponentControlsEditCode' | ||
import ComponentControlsMaximize from './ComponentControlsMaximize' | ||
import ComponentControlsShowHtml from './ComponentControlsShowHtml' | ||
|
||
const ComponentControls = (props) => { | ||
const { | ||
anchorName, showHTML, showCode, | ||
onCopyLink, onShowHTML, onShowCode, | ||
visible, | ||
} = props | ||
|
||
return ( | ||
<Transition | ||
transitionOnMount | ||
visible={!!visible} | ||
unmountOnHide | ||
> | ||
{/* Heads up! Don't remove this `div`, visible Transition applies `display: block`, | ||
while Menu should have `display: inline-flex` | ||
*/} | ||
<div> | ||
<Menu | ||
color='green' | ||
compact | ||
icon | ||
size='small' | ||
text | ||
> | ||
<ComponentControlsCopyLink | ||
anchorName={anchorName} | ||
onClick={onCopyLink} | ||
/> | ||
<ComponentControlsMaximize anchorName={anchorName} /> | ||
<ComponentControlsShowHtml | ||
active={showHTML} | ||
onClick={onShowHTML} | ||
/> | ||
<ComponentControlsEditCode | ||
active={showCode} | ||
onClick={onShowCode} | ||
/> | ||
</Menu> | ||
</div> | ||
</Transition> | ||
) | ||
} | ||
|
||
ComponentControls.propTypes = { | ||
anchorName: PropTypes.string, | ||
onCopyLink: PropTypes.func, | ||
onShowCode: PropTypes.func, | ||
onShowHTML: PropTypes.func, | ||
showCode: PropTypes.bool, | ||
showHTML: PropTypes.bool, | ||
visible: PropTypes.bool, | ||
} | ||
|
||
export default updateForKeys(['showCode', 'showHTML', 'visible'])(ComponentControls) |
56 changes: 56 additions & 0 deletions
56
docs/app/Components/ComponentDoc/ComponentControls/ComponentControlsCopyLink.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
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 = {} | ||
|
||
static propTypes = { | ||
anchorName: PropTypes.string, | ||
onClick: PropTypes.func, | ||
} | ||
|
||
shouldComponentUpdate(nextProps, nextState) { | ||
return this.state.active !== nextState.active | ||
} | ||
|
||
componentDidMount() { | ||
this.mounted = true | ||
} | ||
|
||
componentWillUnmount() { | ||
this.mounted = false | ||
} | ||
|
||
handleClick = (e) => { | ||
const { onClick } = this.props | ||
|
||
e.preventDefault() | ||
onClick() | ||
|
||
this.setState({ active: true }) | ||
setTimeout(this.resetActive, 3000) | ||
} | ||
|
||
resetActive = () => this.mounted && this.setState({ active: false }) | ||
|
||
render() { | ||
const { anchorName } = this.props | ||
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> | ||
) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
docs/app/Components/ComponentDoc/ComponentControls/ComponentControlsEditCode.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import PropTypes from 'prop-types' | ||
import React from 'react' | ||
import { Icon, Menu } from 'semantic-ui-react' | ||
|
||
import { updateForKeys } from 'docs/app/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> | ||
) | ||
|
||
ComponentControlsEditCode.propTypes = { | ||
active: PropTypes.bool, | ||
onClick: PropTypes.func, | ||
} | ||
|
||
export default updateForKeys(['active'])(ComponentControlsEditCode) |
25 changes: 25 additions & 0 deletions
25
docs/app/Components/ComponentDoc/ComponentControls/ComponentControlsMaximize.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import PropTypes from 'prop-types' | ||
import React from 'react' | ||
import { Icon, Menu } from 'semantic-ui-react' | ||
|
||
import { neverUpdate } from 'docs/app/HOC' | ||
import ComponentControlsToolTip from './ComponentControlsToolTip' | ||
|
||
const ComponentControlsMaximize = ({ anchorName }) => ( | ||
<ComponentControlsToolTip content='Full Screen'> | ||
<Menu.Item href={`/maximize/${anchorName}`} target='_blank'> | ||
<Icon | ||
color='grey' | ||
fitted | ||
name='window maximize' | ||
size='large' | ||
/> | ||
</Menu.Item> | ||
</ComponentControlsToolTip> | ||
) | ||
|
||
ComponentControlsMaximize.propTypes = { | ||
anchorName: PropTypes.string, | ||
} | ||
|
||
export default neverUpdate(ComponentControlsMaximize) |
26 changes: 26 additions & 0 deletions
26
docs/app/Components/ComponentDoc/ComponentControls/ComponentControlsShowHtml.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import PropTypes from 'prop-types' | ||
import React from 'react' | ||
import { Icon, Menu } from 'semantic-ui-react' | ||
|
||
import { updateForKeys } from 'docs/app/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> | ||
) | ||
|
||
ComponentControlsShowHtml.propTypes = { | ||
active: PropTypes.bool, | ||
onClick: PropTypes.func, | ||
} | ||
|
||
export default updateForKeys(['active'])(ComponentControlsShowHtml) |
28 changes: 28 additions & 0 deletions
28
docs/app/Components/ComponentDoc/ComponentControls/ComponentControlsToolTip.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import PropTypes from 'prop-types' | ||
import React from 'react' | ||
import { Popup } from 'semantic-ui-react' | ||
|
||
const toolTipStyle = { | ||
padding: '0.5em', | ||
textAlign: 'center', | ||
width: 100, | ||
} | ||
|
||
const ComponentControlsToolTip = ({ children, content }) => ( | ||
<Popup | ||
content={content} | ||
inverted | ||
mouseEnterDelay={800} | ||
position='top center' | ||
size='tiny' | ||
style={toolTipStyle} | ||
trigger={children} | ||
/> | ||
) | ||
|
||
ComponentControlsToolTip.propTypes = { | ||
children: PropTypes.node, | ||
content: PropTypes.node, | ||
} | ||
|
||
export default ComponentControlsToolTip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default from './ComponentControls' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default from './ComponentExample' |
Oops, something went wrong.