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

feat(Dimmer): Add component #447

Merged
merged 14 commits into from
Oct 31, 2016
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Any other issue labeled [`help wanted`][4] is ready for a PR.
|-----------------|-----------------|-----------------|-----------------|--------------------|
| ✓ Button | ✓ Breadcrumb | Advertisement | ✓ Accordion | ✓ Form Validation |
| ✓ Container | ✓ Form | ✓ Card | ✓ Checkbox | *API (NA)* |
| ✓ Divider | ✓ Grid | ✓ Comment | Dimmer | *Visibility (NA)* |
| ✓ Divider | ✓ Grid | ✓ Comment | Dimmer | *Visibility (NA)* |
| ✓ Flag | ✓ Menu | ✓ Feed | ✓ Dropdown | |
| ✓ Header | ✓ Message | ✓ Item | Embed | |
| ✓ Icon | ✓ Table | ✓ Statistic | ✓ Modal | |
Expand Down
17 changes: 17 additions & 0 deletions docs/app/Examples/modules/Dimmer/States/DimmerExampleActive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'
import { Dimmer, Segment } from 'semantic-ui-react'

const DimmerExampleActive = () => (
<Segment>
<Dimmer active />

<p>
<img src='http://semantic-ui.com/images/wireframe/short-paragraph.png' />
</p>
<p>
<img src='http://semantic-ui.com/images/wireframe/short-paragraph.png' />
</p>
</Segment>
)

export default DimmerExampleActive
17 changes: 17 additions & 0 deletions docs/app/Examples/modules/Dimmer/States/DimmerExampleDisabled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'
import { Dimmer, Segment } from 'semantic-ui-react'

const DimmerExampleDisabled = () => (
<Segment>
<Dimmer disabled />
Copy link
Member

Choose a reason for hiding this comment

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

Hm, do you know what this is supposed to do? The dimmer still is made active when I add:

<Dimmer active disabled />

Though, the description says:

A disabled dimmer cannot be activated

Perhaps this is only applicable to the jQuery plugin in SUI core? Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can remove disabled prop, it's quite strange to use disabled when you have control of active.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, especially since it does not override the active prop. Let's remove it.


<p>
<img src='http://semantic-ui.com/images/wireframe/short-paragraph.png' />
</p>
<p>
<img src='http://semantic-ui.com/images/wireframe/short-paragraph.png' />
</p>
</Segment>
)

export default DimmerExampleDisabled
21 changes: 21 additions & 0 deletions docs/app/Examples/modules/Dimmer/States/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'

import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'

const DimmerStatesExamples = () => (
<ExampleSection title='States'>
<ComponentExample
title='Active'
description='An active dimmer will dim its parent container'
examplePath='modules/Dimmer/States/DimmerExampleActive'
/>
<ComponentExample
title='Disabled'
description='A disabled dimmer cannot be activated'
examplePath='modules/Dimmer/States/DimmerExampleDisabled'
/>
</ExampleSection>
)

export default DimmerStatesExamples
36 changes: 36 additions & 0 deletions docs/app/Examples/modules/Dimmer/Types/DimmerExamplePage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React, { Component } from 'react'
import { Button, Dimmer, Header, Icon } from 'semantic-ui-react'

export default class DimmerExamplePage extends Component {
state = {}

handleClick = () => this.setState({ active: true })
handleClose = () => this.setState({ active: false })

render() {
const { active } = this.state

return (
<div>
<Button
content='Show'
icon='plus'
labelPosition='left'
onClick={this.handleClick}
/>

<Dimmer
active={active}
onClose={this.handleClose}
page
>
<Header as='h2' icon inverted>
<Icon name='heart' />
Dimmed Message!
<Header.Subheader>Dimmer sub-header</Header.Subheader>
</Header>
</Dimmer>
</div>
)
}
}
16 changes: 16 additions & 0 deletions docs/app/Examples/modules/Dimmer/Types/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react'

import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'

const DimmerTypesExamples = () => (
<ExampleSection title='Types'>
<ComponentExample
title='Page'
description='A dimmer can be formatted to be fixed to the page'
examplePath='modules/Dimmer/Types/DimmerExamplePage'
/>
</ExampleSection>
)

export default DimmerTypesExamples
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React, { Component } from 'react'
import { Button, Dimmer, Segment } from 'semantic-ui-react'

export default class DimmerExampleBlurring extends Component {
state = {}

handleShow = () => this.setState({ active: true })
handleHide = () => this.setState({ active: false })

render() {
const { active } = this.state

return (
<div>
<Dimmer blurring dimmable={Segment} dimmed={active}>
Copy link
Member

Choose a reason for hiding this comment

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

This currently does not pass extra props to the Segment. Example, adding color='red' should pass color to the Segment. What if we went with this API, it does pass extra props:

<Dimmer.Dimmable as={Segment} blurring dimmed={active} color='red'>
  <Dimmer active={active} />

  <p>
    <img src='http://semantic-ui.com/images/wireframe/short-paragraph.png' />
  </p>
  <p>
    <img src='http://semantic-ui.com/images/wireframe/short-paragraph.png' />
  </p>
</Dimmer.Dimmable>

I tested the above with only these changes required:

  1. Expose Dimmer.Dimmable = DimmerDimmable
  2. Rename DimmmerDimmable prop Component to as and use our standard getElementType() util and render <ElementType /> instead.
  3. I did not do this, but we should then remove all dimmable prop reference and logic from the main Dimmer.

This might be more in line with our existing patterns.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, you said that I thinked 👍

<Dimmer active={active} />

<p>
<img src='http://semantic-ui.com/images/wireframe/short-paragraph.png' />
</p>
<p>
<img src='http://semantic-ui.com/images/wireframe/short-paragraph.png' />
</p>
</Dimmer>

<Button.Group>
<Button icon='plus' onClick={this.handleShow} />
<Button icon='minus' onClick={this.handleHide} />
</Button.Group>
</div>
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React, { Component } from 'react'
import { Button, Dimmer, Segment } from 'semantic-ui-react'

export default class DimmerExampleBlurringInverted extends Component {
state = {}

handleShow = () => this.setState({ active: true })
handleHide = () => this.setState({ active: false })

render() {
const { active } = this.state

return (
<div>
<Dimmer blurring dimmable={Segment} dimmed={active}>
<Dimmer active={active} inverted />

<p>
<img src='http://semantic-ui.com/images/wireframe/short-paragraph.png' />
</p>
<p>
<img src='http://semantic-ui.com/images/wireframe/short-paragraph.png' />
</p>
</Dimmer>

<Button.Group>
<Button icon='plus' onClick={this.handleShow} />
<Button icon='minus' onClick={this.handleHide} />
</Button.Group>
</div>
)
}
}
17 changes: 17 additions & 0 deletions docs/app/Examples/modules/Dimmer/Variations/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'

import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'

const DimmerVariationsExamples = () => (
<ExampleSection title='Variations'>
<ComponentExample
title='Blurring'
description='A dimmable element can blur its contents'
examplePath='modules/Dimmer/Variations/DimmerExampleBlurring'
/>
<ComponentExample examplePath='modules/Dimmer/Variations/DimmerExampleBlurringInverted' />
</ExampleSection>
)

export default DimmerVariationsExamples
15 changes: 15 additions & 0 deletions docs/app/Examples/modules/Dimmer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react'

import States from './States'
import Types from './Types'
import Variations from './Variations'

const DimmerExamples = () => (
<div>
<Types />
<States />
<Variations />
</div>
)

export default DimmerExamples
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export { default as AccordionTitle } from './modules/Accordion/AccordionTitle'

export { default as Checkbox } from './modules/Checkbox'

export { default as Dimmer } from './modules/Dimmer'

export { default as Dropdown } from './modules/Dropdown'
export { default as DropdownDivider } from './modules/Dropdown/DropdownDivider'
export { default as DropdownHeader } from './modules/Dropdown/DropdownHeader'
Expand Down
Loading