-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: convert examples to be functional components
- Loading branch information
1 parent
5646905
commit 6b54e0b
Showing
6 changed files
with
107 additions
and
118 deletions.
There are no files selected for viewing
47 changes: 24 additions & 23 deletions
47
docs/src/examples/addons/Confirm/Types/ConfirmExampleCallbacks.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,31 +1,32 @@ | ||
import React, { Component } from 'react' | ||
import React from 'react' | ||
import { Button, Confirm } from 'semantic-ui-react' | ||
|
||
class ConfirmExampleCallbacks extends Component { | ||
state = { open: false, result: 'show the modal to capture a result' } | ||
function ConfirmExampleCallbacks() { | ||
const [open, setOpen] = React.useState(false) | ||
const [result, setResult] = React.useState( | ||
'show the modal to capture a result', | ||
) | ||
|
||
show = () => this.setState({ open: true }) | ||
handleConfirm = () => this.setState({ result: 'confirmed', open: false }) | ||
handleCancel = () => this.setState({ result: 'cancelled', open: false }) | ||
|
||
render() { | ||
const { open, result } = this.state | ||
const show = () => setOpen(true) | ||
const handleConfirm = () => { | ||
setResult('confirmed') | ||
setOpen(false) | ||
} | ||
const handleCancel = () => { | ||
setResult('cancelled') | ||
setOpen(false) | ||
} | ||
|
||
return ( | ||
<div> | ||
<p> | ||
Result: <em>{result}</em> | ||
</p> | ||
return ( | ||
<div> | ||
<p> | ||
Result: <em>{result}</em> | ||
</p> | ||
|
||
<Button onClick={this.show}>Show</Button> | ||
<Confirm | ||
open={open} | ||
onCancel={this.handleCancel} | ||
onConfirm={this.handleConfirm} | ||
/> | ||
</div> | ||
) | ||
} | ||
<Button onClick={show}>Show</Button> | ||
<Confirm open={open} onCancel={handleCancel} onConfirm={handleConfirm} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default ConfirmExampleCallbacks |
28 changes: 11 additions & 17 deletions
28
docs/src/examples/addons/Confirm/Types/ConfirmExampleConfirm.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,24 +1,18 @@ | ||
import React, { Component } from 'react' | ||
import React from 'react' | ||
import { Button, Confirm } from 'semantic-ui-react' | ||
|
||
class ConfirmExampleConfirm extends Component { | ||
state = { open: false } | ||
function ConfirmExampleConfirm() { | ||
const [open, setOpen] = React.useState(false) | ||
|
||
open = () => this.setState({ open: true }) | ||
close = () => this.setState({ open: false }) | ||
const show = () => setOpen(true) | ||
const close = () => setOpen(false) | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<Button onClick={this.open}>Show</Button> | ||
<Confirm | ||
open={this.state.open} | ||
onCancel={this.close} | ||
onConfirm={this.close} | ||
/> | ||
</div> | ||
) | ||
} | ||
return ( | ||
<div> | ||
<Button onClick={show}>Show</Button> | ||
<Confirm open={open} onCancel={close} onConfirm={close} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default ConfirmExampleConfirm |
38 changes: 18 additions & 20 deletions
38
docs/src/examples/addons/Confirm/Variations/ConfirmExampleButtons.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,27 +1,25 @@ | ||
import React, { Component } from 'react' | ||
import React from 'react' | ||
import { Button, Confirm } from 'semantic-ui-react' | ||
|
||
class ConfirmExampleHeader extends Component { | ||
state = { open: false } | ||
function ConfirmExampleHeader() { | ||
const [open, setOpen] = React.useState(false) | ||
|
||
show = () => this.setState({ open: true }) | ||
handleConfirm = () => this.setState({ open: false }) | ||
handleCancel = () => this.setState({ open: false }) | ||
const show = () => setOpen(true) | ||
const handleConfirm = () => setOpen(false) | ||
const handleCancel = () => setOpen(false) | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<Button onClick={this.show}>Show</Button> | ||
<Confirm | ||
open={this.state.open} | ||
cancelButton='Never mind' | ||
confirmButton="Let's do it" | ||
onCancel={this.handleCancel} | ||
onConfirm={this.handleConfirm} | ||
/> | ||
</div> | ||
) | ||
} | ||
return ( | ||
<div> | ||
<Button onClick={show}>Show</Button> | ||
<Confirm | ||
open={open} | ||
cancelButton='Never mind' | ||
confirmButton="Let's do it" | ||
onCancel={handleCancel} | ||
onConfirm={handleConfirm} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export default ConfirmExampleHeader |
36 changes: 17 additions & 19 deletions
36
docs/src/examples/addons/Confirm/Variations/ConfirmExampleContent.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,26 +1,24 @@ | ||
import React, { Component } from 'react' | ||
import React from 'react' | ||
import { Button, Confirm } from 'semantic-ui-react' | ||
|
||
class ConfirmExampleContent extends Component { | ||
state = { open: false } | ||
function ConfirmExampleContent() { | ||
const [open, setOpen] = React.useState(false) | ||
|
||
show = () => this.setState({ open: true }) | ||
handleConfirm = () => this.setState({ open: false }) | ||
handleCancel = () => this.setState({ open: false }) | ||
const show = () => setOpen(true) | ||
const handleConfirm = () => setOpen(false) | ||
const handleCancel = () => setOpen(false) | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<Button onClick={this.show}>Show</Button> | ||
<Confirm | ||
open={this.state.open} | ||
content='This is a custom message' | ||
onCancel={this.handleCancel} | ||
onConfirm={this.handleConfirm} | ||
/> | ||
</div> | ||
) | ||
} | ||
return ( | ||
<div> | ||
<Button onClick={show}>Show</Button> | ||
<Confirm | ||
open={open} | ||
content='This is a custom message' | ||
onCancel={handleCancel} | ||
onConfirm={handleConfirm} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export default ConfirmExampleContent |
36 changes: 17 additions & 19 deletions
36
docs/src/examples/addons/Confirm/Variations/ConfirmExampleHeader.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,26 +1,24 @@ | ||
import React, { Component } from 'react' | ||
import React from 'react' | ||
import { Button, Confirm } from 'semantic-ui-react' | ||
|
||
class ConfirmExampleHeader extends Component { | ||
state = { open: false } | ||
function ConfirmExampleHeader() { | ||
const [open, setOpen] = React.useState(false) | ||
|
||
show = () => this.setState({ open: true }) | ||
handleConfirm = () => this.setState({ open: false }) | ||
handleCancel = () => this.setState({ open: false }) | ||
const show = () => setOpen(true) | ||
const handleConfirm = () => setOpen(false) | ||
const handleCancel = () => setOpen(false) | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<Button onClick={this.show}>Show</Button> | ||
<Confirm | ||
open={this.state.open} | ||
header='This is a custom header' | ||
onCancel={this.handleCancel} | ||
onConfirm={this.handleConfirm} | ||
/> | ||
</div> | ||
) | ||
} | ||
return ( | ||
<div> | ||
<Button onClick={show}>Show</Button> | ||
<Confirm | ||
open={open} | ||
header='This is a custom header' | ||
onCancel={handleCancel} | ||
onConfirm={handleConfirm} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export default ConfirmExampleHeader |
40 changes: 20 additions & 20 deletions
40
docs/src/examples/addons/Confirm/Variations/ConfirmExampleSize.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,25 +1,25 @@ | ||
import React, { Component } from 'react' | ||
import React from 'react' | ||
import { Button, Confirm } from 'semantic-ui-react' | ||
|
||
export default class ConfirmExampleSize extends Component { | ||
state = { open: false } | ||
function ConfirmExampleSize() { | ||
const [open, setOpen] = React.useState(false) | ||
|
||
handleButtonClick = () => this.setState({ open: true }) | ||
handleConfirm = () => this.setState({ open: false }) | ||
handleCancel = () => this.setState({ open: false }) | ||
const show = () => setOpen(true) | ||
const handleConfirm = () => setOpen(false) | ||
const handleCancel = () => setOpen(false) | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<Button onClick={this.handleButtonClick}>Show Large</Button> | ||
<Confirm | ||
header='This is a large confirm' | ||
open={this.state.open} | ||
onCancel={this.handleCancel} | ||
onConfirm={this.handleConfirm} | ||
size='large' | ||
/> | ||
</div> | ||
) | ||
} | ||
return ( | ||
<div> | ||
<Button onClick={show}>Show Large</Button> | ||
<Confirm | ||
header='This is a large confirm' | ||
open={open} | ||
onCancel={handleCancel} | ||
onConfirm={handleConfirm} | ||
size='large' | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export default ConfirmExampleSize |