This repository has been archived by the owner on Oct 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
/
UIControlsWrapper.js
93 lines (84 loc) · 2.12 KB
/
UIControlsWrapper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import React from "react";
import styled from "styled-components";
import { Checkbox, Toggle } from "@yoast/components";
import { makeOutboundLink } from "@yoast/helpers";
const Container = styled.div`
max-width: 1024px;
margin: 0 auto;
padding: 24px 24px 50em;
box-sizing: border-box;
`;
const Separator = styled.hr`
margin: 1em 0;
`;
const CornerstoneLink = makeOutboundLink();
/**
* Renders the yoast-component UI Controls.
*
* @returns {ReactElement} The UI Controls container component.
*/
export default class UIControlsList extends React.Component {
/**
* Constructs the UI Controls container.
*
* @returns {void}
*/
constructor() {
super();
this.state = {
simpleToggleChecked: false,
};
this.toggleSimpleToggle = this.toggleSimpleToggle.bind( this );
}
/**
* Toggles the simple toggle state.
*
* @returns {void}
*/
toggleSimpleToggle() {
this.setState( {
simpleToggleChecked: ! this.state.simpleToggleChecked,
} );
}
/**
* Renders all the UI Controls.
*
* @returns {ReactElement} The rendered list of UI Controls.
*/
render() {
return (
<Container>
<h2>Checkbox</h2>
<Checkbox
id="example-checkbox"
label={ [
"This is a label that also accepts arrays, so you can pass links such as ",
<CornerstoneLink key="1" href="https://yoa.st/metabox-help-cornerstone">cornerstone content</CornerstoneLink>,
", for example.",
] }
// eslint-disable-next-line no-console
onChange={ event => console.log( event ) }
/>
<Separator />
<h2>Simple toggle</h2>
<Toggle
id="simple-toggle"
labelText="Test the Toggle"
isEnabled={ this.state.simpleToggleChecked }
onSetToggleState={ this.toggleSimpleToggle }
/>
<Separator />
<Toggle
id="disabled-toggle"
labelText="Disabled Toggle"
isEnabled={ false }
// eslint-disable-next-line no-console
onSetToggleState={ () => console.log( "onSetToggleState callback" ) }
// eslint-disable-next-line no-console
onToggleDisabled={ () => console.log( "onToggleDisabled callback" ) }
disable={ true }
/>
</Container>
);
}
}