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

docs: add transparent button to examples #407

Merged
merged 2 commits into from
Oct 29, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Documentation
- Add `Provider` examples @levithomason ([#285](https://github.com/stardust-ui/react/pull/285))
- Add transparent button to examples @levithomason ([#407](https://github.com/stardust-ui/react/pull/407))

### Documentation
- Add component descriptions and fix accessibility errors @levithomason ([#387](https://github.com/stardust-ui/react/pull/387))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ComponentControlsShowCode from './ComponentControlsShowCode'
import ComponentControlsCopyLink from './ComponentControlsCopyLink'
import ComponentControlsShowVariables from './ComponentControlsShowVariables'
import ComponentControlsMaximize from './ComponentControlsMaximize'
import ComponentControlsShowTransparent from './ComponentControlsShowTransparent'
import ComponentControlsRtl from './ComponentControlsRtl'

const ComponentControls: any = props => {
Expand All @@ -15,17 +16,20 @@ const ComponentControls: any = props => {
examplePath,
showCode,
showRtl,
showTransparent,
showVariables,
onCopyLink,
onShowCode,
onShowRtl,
onShowTransparent,
onShowVariables,
} = props

return (
<Menu color="green" icon="labeled" size="tiny" compact text>
<ComponentControlsShowCode active={showCode} onClick={onShowCode} />
<ComponentControlsShowVariables active={showVariables} onClick={onShowVariables} />
<ComponentControlsShowTransparent active={showTransparent} onClick={onShowTransparent} />
<ComponentControlsRtl active={showRtl} onClick={onShowRtl} />
<ComponentControlsMaximize examplePath={examplePath} />
<ComponentControlsCopyLink anchorName={anchorName} onClick={onCopyLink} />
Expand All @@ -39,13 +43,20 @@ ComponentControls.propTypes = {
onCopyLink: PropTypes.func,
onShowCode: PropTypes.func,
onShowRtl: PropTypes.func,
onShowTransparent: PropTypes.func,
onShowVariables: PropTypes.func,
showCode: PropTypes.bool,
showRtl: PropTypes.bool,
showTransparent: PropTypes.bool,
showVariables: PropTypes.bool,
visible: PropTypes.bool,
}

export default updateForKeys(['examplePath', 'showRtl', 'showCode', 'showVariables', 'visible'])(
ComponentControls,
)
export default updateForKeys([
'examplePath',
'showRtl',
'showCode',
'showTransparent',
'showVariables',
'visible',
])(ComponentControls)
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const ComponentControlsMaximize: any = ({ examplePath }) => (
target="_blank"
rel="noopener noreferrer"
>
<Icon color="grey" fitted name="window maximize" size="large" />
Maximize
<Icon color="grey" fitted name="external alternate" size="large" />
Popout
</Menu.Item>
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import PropTypes from 'prop-types'
import * as React from 'react'
import { Icon, Menu } from 'semantic-ui-react'

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

const ComponentControlsShowTransparent: React.SFC = ({ active, onClick }: any) => (
<Menu.Item active={active} onClick={onClick}>
<Icon color={active ? 'green' : 'grey'} size="large" name="adjust" fitted />
Transparent
</Menu.Item>
)

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

export default updateForKeys(['active'])(ComponentControlsShowTransparent)
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ interface ComponentExampleState {
showCode: boolean
showHTML: boolean
showRtl: boolean
showTransparent: boolean
showVariables: boolean
isHovering: boolean
copiedCode: boolean
Expand Down Expand Up @@ -75,6 +76,7 @@ class ComponentExample extends React.Component<ComponentExampleProps, ComponentE
showCode: false,
showHTML: false,
showRtl: false,
showTransparent: false,
showVariables: false,
isHovering: false,
copiedCode: false,
Expand Down Expand Up @@ -239,6 +241,14 @@ class ComponentExample extends React.Component<ComponentExampleProps, ComponentE
this.setState({ showVariables: !showVariables }, this.updateHash)
}

private handleShowTransparentClick = e => {
e.preventDefault()

const { showTransparent } = this.state

this.setState({ showTransparent: !showTransparent })
}

private handlePass = () => {
const { title } = this.props

Expand Down Expand Up @@ -607,6 +617,7 @@ class ComponentExample extends React.Component<ComponentExampleProps, ComponentE
showCode,
showHTML,
showRtl,
showTransparent,
showVariables,
} = this.state

Expand Down Expand Up @@ -658,9 +669,11 @@ class ComponentExample extends React.Component<ComponentExampleProps, ComponentE
onCopyLink={this.handleDirectLinkClick}
onShowRtl={this.handleShowRtlClick}
onShowVariables={this.handleShowVariablesClick}
onShowTransparent={this.handleShowTransparentClick}
showCode={showCode}
showHTML={showHTML}
showRtl={showRtl}
showTransparent={showTransparent}
showVariables={showVariables}
visible
/>
Expand All @@ -684,8 +697,13 @@ class ComponentExample extends React.Component<ComponentExampleProps, ComponentE
className={`rendered-example ${this.getKebabExamplePath()}`}
style={{
padding: '2rem',
backgroundColor: siteVariables.bodyBackground,
color: siteVariables.bodyColor,
backgroundColor: siteVariables.bodyBackground,
...(showTransparent && {
backgroundImage:
'url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAKUlEQVQoU2NkYGAwZkAD////RxdiYBwKCv///4/hGUZGkNNRAeMQUAgAtxof+nLDzyUAAAAASUVORK5CYII=")',
backgroundRepeat: 'repeat',
}),
}}
>
{exampleElement}
Expand Down