-
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.
refactor(Accordion): use title and content sub components
- Loading branch information
1 parent
7d330f5
commit 75f34ff
Showing
15 changed files
with
462 additions
and
164 deletions.
There are no files selected for viewing
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,42 @@ | ||
import faker from 'faker' | ||
import _ from 'lodash' | ||
import React, { Component } from 'react' | ||
import { Accordion } from 'stardust' | ||
|
||
const panels = _.times(3, () => ({ | ||
title: faker.lorem.sentence(), | ||
content: faker.lorem.paragraphs(), | ||
})) | ||
|
||
export default class AccordionActiveIndexExample extends Component { | ||
state = { activeIndex: 0 } | ||
|
||
handleSliderChange = (e) => this.setState({ | ||
activeIndex: Number(e.target.value), | ||
}) | ||
|
||
handleTitleClick = (e, i) => this.setState({ | ||
activeIndex: this.state.activeIndex === i ? -1 : i, | ||
}) | ||
|
||
render() { | ||
const { activeIndex } = this.state | ||
return ( | ||
<div> | ||
<div>activeIndex: {activeIndex}</div> | ||
<input | ||
type='range' | ||
min='-1' | ||
max={panels.length - 1} | ||
value={activeIndex} | ||
onChange={this.handleSliderChange} | ||
/> | ||
<Accordion | ||
activeIndex={activeIndex} | ||
panels={panels} | ||
onTitleClick={this.handleTitleClick} | ||
/> | ||
</div> | ||
) | ||
} | ||
} |
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,17 @@ | ||
import React, { Component } from 'react' | ||
import { Accordion } from 'stardust' | ||
import faker from 'faker' | ||
import _ from 'lodash' | ||
|
||
const panels = _.times(3, () => ({ | ||
title: faker.lorem.sentence(), | ||
content: faker.lorem.paragraphs(), | ||
})) | ||
|
||
export default class AccordionPanelsPropExample extends Component { | ||
render() { | ||
return ( | ||
<Accordion panels={panels} /> | ||
) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,30 +1,17 @@ | ||
import _ from 'lodash' | ||
import faker from 'faker' | ||
import React, { Component } from 'react' | ||
import { Accordion } from 'stardust' | ||
|
||
const panels = _.times(3, () => ({ | ||
title: faker.lorem.sentence(), | ||
content: faker.lorem.paragraphs(), | ||
})) | ||
|
||
export default class AccordionStyledExample extends Component { | ||
render() { | ||
return ( | ||
<Accordion styled> | ||
<Accordion.Panel title='What is a dog?'> | ||
A dog is a type of domesticated animal. Known for its loyalty and faithfulness, | ||
{' '}it can be found as a welcome guest in many households across the world. | ||
</Accordion.Panel> | ||
<Accordion.Panel title='What kinds of dogs are there?'> | ||
There are many breeds of dogs. Each breed varies in size and temperament. | ||
{' '}Owners often select a breed of dog that they find to be compatible | ||
with their own lifestyle and desires from a companion. | ||
</Accordion.Panel> | ||
<Accordion.Panel title='How do you acquire a dog?'> | ||
Three common ways for a prospective owner to acquire a dog is from pet shops, | ||
{' '}private owners, or shelters. | ||
<br /> | ||
<br /> | ||
A pet shop may be the most convenient way to buy a dog. | ||
{' '}Buying a dog from a private owner allows you to assess the pedigree and | ||
{' '}upbringing of your dog before choosing to take it home. Lastly, finding your dog | ||
{' '}from a shelter, helps give a good home to a dog who may not find one so readily. | ||
</Accordion.Panel> | ||
</Accordion> | ||
<Accordion panels={panels} styled /> | ||
) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,30 +1,17 @@ | ||
import _ from 'lodash' | ||
import faker from 'faker' | ||
import React, { Component } from 'react' | ||
import { Accordion } from 'stardust' | ||
|
||
const panels = _.times(3, () => ({ | ||
title: faker.lorem.sentence(), | ||
content: faker.lorem.paragraphs(), | ||
})) | ||
|
||
export default class AccordionFluidExample extends Component { | ||
render() { | ||
return ( | ||
<Accordion fluid> | ||
<Accordion.Panel title='What is a dog?'> | ||
A dog is a type of domesticated animal. Known for its loyalty and faithfulness, | ||
{' '}it can be found as a welcome guest in many households across the world. | ||
</Accordion.Panel> | ||
<Accordion.Panel title='What kinds of dogs are there?'> | ||
There are many breeds of dogs. Each breed varies in size and temperament. | ||
{' '}Owners often select a breed of dog that they find to be compatible | ||
with their own lifestyle and desires from a companion. | ||
</Accordion.Panel> | ||
<Accordion.Panel title='How do you acquire a dog?'> | ||
Three common ways for a prospective owner to acquire a dog is from pet shops, | ||
{' '}private owners, or shelters. | ||
<br /> | ||
<br /> | ||
A pet shop may be the most convenient way to buy a dog. | ||
{' '}Buying a dog from a private owner allows you to assess the pedigree and | ||
{' '}upbringing of your dog before choosing to take it home. Lastly, finding your dog | ||
{' '}from a shelter, helps give a good home to a dog who may not find one so readily. | ||
</Accordion.Panel> | ||
</Accordion> | ||
<Accordion panels={panels} fluid /> | ||
) | ||
} | ||
} |
33 changes: 11 additions & 22 deletions
33
docs/app/Examples/modules/Accordion/Variations/Inverted.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 |
---|---|---|
@@ -1,30 +1,19 @@ | ||
import _ from 'lodash' | ||
import faker from 'faker' | ||
import React, { Component } from 'react' | ||
import { Accordion } from 'stardust' | ||
import { Accordion, Segment } from 'stardust' | ||
|
||
const panels = _.times(3, () => ({ | ||
title: faker.lorem.sentence(), | ||
content: faker.lorem.paragraphs(), | ||
})) | ||
|
||
export default class AccordionInvertedExample extends Component { | ||
render() { | ||
return ( | ||
<Accordion inverted> | ||
<Accordion.Panel title='What is a dog?'> | ||
A dog is a type of domesticated animal. Known for its loyalty and faithfulness, | ||
{' '}it can be found as a welcome guest in many households across the world. | ||
</Accordion.Panel> | ||
<Accordion.Panel title='What kinds of dogs are there?'> | ||
There are many breeds of dogs. Each breed varies in size and temperament. | ||
{' '}Owners often select a breed of dog that they find to be compatible | ||
with their own lifestyle and desires from a companion. | ||
</Accordion.Panel> | ||
<Accordion.Panel title='How do you acquire a dog?'> | ||
Three common ways for a prospective owner to acquire a dog is from pet shops, | ||
{' '}private owners, or shelters. | ||
<br /> | ||
<br /> | ||
A pet shop may be the most convenient way to buy a dog. | ||
{' '}Buying a dog from a private owner allows you to assess the pedigree and | ||
{' '}upbringing of your dog before choosing to take it home. Lastly, finding your dog | ||
{' '}from a shelter, helps give a good home to a dog who may not find one so readily. | ||
</Accordion.Panel> | ||
</Accordion> | ||
<Segment className='inverted'> | ||
<Accordion panels={panels} inverted /> | ||
</Segment> | ||
) | ||
} | ||
} |
Oops, something went wrong.